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