pull up r24469, r24530, r24533, r24534, r24535, r24537 from trunk
[krb5.git] / src / include / win-mac.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * This file is now only used on Windows
4  */
5
6 /*
7  * type functions split out of here to make things look nicer in the
8  * various include files which need these definitions, as well as in
9  * the util/ directories.
10  */
11
12 #ifndef _KRB5_WIN_MAC_H
13 #define _KRB5_WIN_MAC_H
14
15 #ifdef _WIN32
16
17 #define ID_READ_PWD_DIALOG  10000
18 #define ID_READ_PWD_PROMPT  10001
19 #define ID_READ_PWD_PROMPT2 10002
20 #define ID_READ_PWD_PWD     10003
21
22 #ifdef RES_ONLY
23
24 #define APSTUDIO_HIDDEN_SYMBOLS
25 #include <windows.h>
26
27 #else /* ! RES_ONLY */
28
29 /* To ensure backward compatibility of the ABI use 32-bit time_t on
30  * 32-bit Windows.
31  */
32 #ifdef _KRB5_INT_H
33 #ifdef KRB5_GENERAL__
34 #error krb5.h included before k5-int.h
35 #endif /* KRB5_GENERAL__ */
36 #if _INTEGRAL_MAX_BITS >= 64 && _MSC_VER >= 1400 && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T)
37 #if defined(_TIME_T_DEFINED) || defined(_INC_IO) || defined(_INC_TIME) || defined(_INC_WCHAR)
38 #error time_t has been defined as a 64-bit integer which is incompatible with Kerberos on this platform.
39 #endif /* _TIME_T_DEFINED */
40 #define _USE_32BIT_TIME_T
41 #endif
42 #endif
43
44 #define SIZEOF_INT      4
45 #define SIZEOF_SHORT    2
46 #define SIZEOF_LONG     4
47
48 #include <windows.h>
49 #include <limits.h>
50
51 #ifndef SIZE_MAX    /* in case Microsoft defines max size of size_t */
52 #ifdef  MAX_SIZE    /* Microsoft defines MAX_SIZE as max size of size_t */
53 #define SIZE_MAX MAX_SIZE
54 #else
55 #define SIZE_MAX UINT_MAX
56 #endif
57 #endif
58
59 #ifndef KRB5_CALLCONV
60 #  define KRB5_CALLCONV __stdcall
61 #  define KRB5_CALLCONV_C __cdecl
62
63 /*
64  * Use this to mark an incorrect calling convention that has been
65  * "immortalized" because it was incorrectly exported in a previous
66  * release.
67  */
68
69 #  define KRB5_CALLCONV_WRONG KRB5_CALLCONV_C
70
71 #endif /* !KRB5_CALLCONV */
72
73 #ifndef KRB5_SYSTYPES__
74 #define KRB5_SYSTYPES__
75 #include <sys/types.h>
76 typedef unsigned long    u_long;      /* Not part of sys/types.h on the pc */
77 typedef unsigned int     u_int;
78 typedef unsigned short   u_short;
79 typedef unsigned char    u_char;
80 typedef unsigned int     uint32_t;
81 typedef int              int32_t;
82 #if _INTEGRAL_MAX_BITS >= 64
83 typedef unsigned __int64 uint64_t;
84 typedef __int64          int64_t;
85 #endif
86 #ifndef SSIZE_T_DEFINED
87 #ifdef ssize_t
88 #undef ssize_t
89 #endif
90 #ifdef _WIN64
91 typedef __int64          ssize_t;
92 #else
93 typedef _W64 int         ssize_t;
94 #endif
95 #define SSIZE_T_DEFINED
96 #endif
97 #endif /* KRB5_SYSTYPES__ */
98
99 #define MAXHOSTNAMELEN  512
100 #ifndef MAXPATHLEN
101 #define MAXPATHLEN      256            /* Also for Windows temp files */
102 #endif
103
104 #define HAVE_NETINET_IN_H
105 #define MSDOS_FILESYSTEM
106 #define HAVE_STRING_H
107 #define HAVE_SRAND
108 #define HAVE_ERRNO
109 #define HAVE_STRDUP
110 #define HAVE_GETADDRINFO
111 #define HAVE_GETNAMEINFO
112 #define NO_USERID
113 #define NO_PASSWORD
114 #define HAVE_STRERROR
115 #define SYS_ERRLIST_DECLARED
116 /* if __STDC_VERSION__ >= 199901L this shouldn't be needed */
117 #define inline __inline
118 #define KRB5_USE_INET6
119 #define NEED_INSIXADDR_ANY
120 #define ENABLE_THREADS
121
122 #define WM_KERBEROS5_CHANGED "Kerberos5 Changed"
123 #ifdef KRB4
124 #define WM_KERBEROS_CHANGED "Kerberos Changed"
125 #endif
126
127 /* Kerberos Windows initialization file */
128 #define KERBEROS_INI    "kerberos.ini"
129 #ifdef CYGNUS
130 #define KERBEROS_HLP    "kerbnet.hlp"
131 #else
132 #define KERBEROS_HLP    "krb5clnt.hlp"
133 #endif
134 #define INI_DEFAULTS    "Defaults"
135 #define   INI_USER        "User"          /* Default user */
136 #define   INI_INSTANCE    "Instance"      /* Default instance */
137 #define   INI_REALM       "Realm"         /* Default realm */
138 #define   INI_POSITION    "Position"
139 #define   INI_OPTIONS     "Options"
140 #define   INI_DURATION    "Duration"   /* Ticket duration in minutes */
141 #define INI_EXPIRATION  "Expiration" /* Action on expiration (alert or beep) */
142 #define   INI_ALERT       "Alert"
143 #define   INI_BEEP        "Beep"
144 #define   INI_FILES       "Files"
145 #ifdef KRB4
146 #define   INI_KRB_CONF    "krb.conf"     /* Location of krb.conf file */
147 #define   DEF_KRB_CONF    "krb.conf"      /* Default name for krb.conf file */
148 #else
149 #define INI_KRB5_CONF   "krb5.ini"      /* From k5-config.h */
150 #define INI_KRB_CONF    INI_KRB5_CONF   /* Location of krb.conf file */
151 #define DEF_KRB_CONF    INI_KRB5_CONF   /* Default name for krb.conf file */
152 #define INI_TICKETOPTS  "TicketOptions" /* Ticket options */
153 #define   INI_FORWARDABLE  "Forwardable" /* get forwardable tickets */
154 #define INI_KRB_CCACHE  "krb5cc"        /* From k5-config.h */
155 #endif
156 #define INI_KRB_REALMS  "krb.realms"    /* Location of krb.realms file */
157 #define DEF_KRB_REALMS  "krb.realms"    /* Default name for krb.realms file */
158 #define INI_RECENT_LOGINS "Recent Logins"
159 #define INI_LOGIN       "Login"
160
161 #define HAS_VOID_TYPE
162 #define HAVE_STDARG_H
163 #define HAVE_SYS_TYPES_H
164 #define HAVE_STDLIB_H
165
166 /* This controls which encryption routines libcrypto will provide */
167 #define PROVIDE_DES_CBC_MD5
168 #define PROVIDE_DES_CBC_CRC
169 #define PROVIDE_DES_CBC_RAW
170 #define PROVIDE_DES_CBC_CKSUM
171 #define PROVIDE_CRC32
172 #define PROVIDE_RSA_MD4
173 #define PROVIDE_RSA_MD5
174 /* #define PROVIDE_DES3_CBC_SHA */
175 /* #define PROVIDE_DES3_CBC_RAW */
176 /* #define PROVIDE_NIST_SHA */
177
178 /* Ugly. Microsoft, in stdc mode, doesn't support the low-level i/o
179  * routines directly. Rather, they only export the _<function> version.
180  * The following defines works around this problem.
181  */
182 #include <sys\types.h>
183 #include <sys\stat.h>
184 #include <fcntl.h>
185 #include <io.h>
186 #include <process.h>
187
188 #ifdef NEED_SYSERROR
189 /* Only needed by util/et/error_message.c but let's keep the source clean */
190 #define sys_nerr        _sys_nerr
191 #define sys_errlist     _sys_errlist
192 #endif
193
194 /*
195  * Functions with slightly different names on the PC
196  */
197 #ifndef strcasecmp
198 #define strcasecmp   _stricmp
199 #endif
200 #ifndef strncasecmp
201 #define strncasecmp  _strnicmp
202 #endif
203
204 /* VS2005 has deprecated strdup */
205 #ifndef strdup
206 #define strdup _strdup
207 #endif
208
209 /* Windows has its own name for reentrant strtok. */
210 #define strtok_r strtok_s
211
212 HINSTANCE get_lib_instance(void);
213
214 #define GETSOCKNAME_ARG2_TYPE   struct sockaddr
215 #define GETSOCKNAME_ARG3_TYPE   size_t
216 #define GETPEERNAME_ARG2_TYPE   GETSOCKNAME_ARG2_TYPE
217 #define GETPEERNAME_ARG3_TYPE   GETSOCKNAME_ARG3_TYPE
218
219 #endif /* !RES_ONLY */
220
221 #endif /* _WIN32 */
222
223 #define THREEPARAMOPEN(x,y,z) open(x,y,z)
224
225 #ifndef KRB5_CALLCONV
226 #define KRB5_CALLCONV
227 #endif
228
229 #ifndef KRB5_CALLCONV_C
230 #define KRB5_CALLCONV_C
231 #endif
232
233 #endif /* _KRB5_WIN_MAC_H */