1 /*
2 * IceBreaker
3 * Copyright (c) 2000-2002 Matthew Miller <mattdm@mattdm.org> and
4 *   Enrico Tassi <gareuselesinge@infinito.it>
5 *
6 * <http://www.mattdm.org/icebreaker>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23 
24 /*
25 *  This file contains function prototypes, macros, etc. to aid in win32
26 *  cross-compiling using mingw32 (based on gcc version 2.95.2 19991024
27 *  (release))
28 *
29 *  This is Enrico Tassi's <gareuselesinge@infinito.it> domain. :)
30 */
31 
32 
33 #ifndef WIN32_COMPATIBILITY_H
34 #define WIN32_COMPATIBILITY_H
35 
36 // fix -- make this also work with cygwin
37 
38 #ifdef __MINGW32__
39 
40 #include <stdarg.h>
41 
42 /* mingw32 is missing snprintf. It has  _snprintf,
43    but unfortunately and stupidly, the size parameter has an off-by-one
44    error causing it to write one more char than requested. this is a
45    workaround.... */
46 #define snprintf snprintf_mingw32kludge
47 #define vsnprintf vsnprintf_mingw32kludge
48 int snprintf_mingw32kludge(char *str, size_t size, const  char  *format, ...);
49 int vsnprintf_mingw32kludge(char *str, size_t size, const  char  *format, va_list ap);
50 
51 /* mingw32 has no index() in string.h */
52 extern char *index(const char *s, int c);
53 
54 /* mingw32 has 'short' random functions */
55 #define srandom(A) srand(A)
56 #define random() rand()
57 
58 
59 /* No pwd.h in mingw32 */
60 #define uid_t int
61 #define gid_t int
62 
63 struct passwd{
64               char    *pw_name;       /* user name */
65               char    *pw_passwd;     /* user password */
66               uid_t   pw_uid;         /* user id */
67               gid_t   pw_gid;         /* group id */
68               char    *pw_gecos;      /* real name */
69               char    *pw_dir;        /* home directory */
70               char    *pw_shell;      /* shell program */
71       };
72 
73 
74 /* No pwd.h -> no getpw... */
75 #define getuid() 0
76 
77 extern struct passwd *getpwuid(int id);
78 
79 #else
80 
81 #error Please configure win32_compatibility.h / win32_compatibility.c for your compiler and send the results to <mattdm@mattdm.org>. Thank you!
82 
83 #endif // __MINGW__
84 
85 
86 #endif /* WIN32_COMPATIBILITY_H */
87