Crossfire Server, Trunk
win32.h
Go to the documentation of this file.
1 #ifndef WIN32_H
2 #define WIN32_H
3 
4 #ifndef UNICODE
5 #define UNICODE
6 #endif
7 
8 #define WIN32_LEAN_AND_MEAN
9 #include <windows.h>
10 
11 #include <dirent.h>
12 #include <time.h>
13 #include <direct.h>
14 #include <sys/stat.h> /* somewhat odd, but you don't get stat here with __STDC__ */
15 
16 #ifndef socklen_t
17 #define socklen_t int /* Doesn't exist, just a plain int */
18 #endif
19 
20 #ifndef WIN32
21 #define WIN32
22 #endif
23 
24 #define NAMLEN(dirent) strlen((dirent)->d_name)
25 
26 /* Function prototypes */
27 extern DIR *opendir(const char *);
28 extern struct dirent *readdir(DIR *);
29 extern int closedir(DIR *);
30 extern void rewinddir(DIR *);
31 extern int strcasecmp(const char *s1, const char *s2);
32 extern const char *strcasestr(const char *s, const char *find);
33 extern void service_register();
34 extern void service_unregister();
35 extern void service_handle();
36 
37 #ifndef S_ISGID
38 #define S_ISGID 0002000
39 #endif
40 #ifndef S_IWOTH
41 #define S_IWOTH 0000200
42 #endif
43 #ifndef S_IWGRP
44 #define S_IWGRP 0000020
45 #endif
46 #ifndef S_IWUSR
47 #define S_IWUSR 0000002
48 #endif
49 #ifndef S_IROTH
50 #define S_IROTH 0000400
51 #endif
52 #ifndef S_IRGRP
53 #define S_IRGRP 0000040
54 #endif
55 #ifndef S_IRUSR
56 #define S_IRUSR 0000004
57 #endif
58 
59 /* For Win32 service */
60 extern int bRunning;
61 
62 #if 0
63 
72 #if !defined(AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_)
73 #define AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_
74 
75 /* Define the version here. In Unixland, it's defined on the command line now. */
76 #define VERSION "1.9.1 (trunk) snapshot 20061229"
77 
78 #pragma warning(disable: 4761) /* integral size mismatch in argument; conversion supplied */
79 
80 #if _MSC_VER > 1000
81 #pragma once
82 #endif /* _MSC_VER > 1000 */
83 
84 #endif /* !defined(AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_) */
85 
86 #define WIN32_LEAN_AND_MEAN
87 #include <windows.h>
88 #include <windowsx.h>
89 #include <mmsystem.h>
90 #include <winsock2.h>
91 #include <time.h>
92 #include <math.h>
93 
94 #include <io.h>
95 #include <stdio.h>
96 #include <stdlib.h>
97 #include <sys/types.h>
98 #include <process.h>
99 
100 #define __STDC__ 1 /* something odd, CF want this, but don'T include it */
101  /* before the standard includes */
102 
103 #define snprintf _snprintf
104 
105 /* include all needed autoconfig.h defines */
106 #define CS_LOGSTATS
107 #define MAXPATHLEN 256
108 #define HAVE_STRTOL
109 #define HAVE_STRERROR
110 
111 /* Many defines to redirect unix functions or fake standard unix values */
112 #define inline __inline
113 #define unlink(__a) _unlink(__a)
114 #define mkdir(__a, __b) mkdir(__a)
115 #define getpid() _getpid()
116 #define popen(__a, __b) _popen(__a, __b)
117 #define pclose(__a) _pclose(__a)
118 #define vsnprintf _vsnprintf
119 #define strtok_r(x, y, z) strtok(x, y)
120 
121 #define R_OK 6 /* for __access() */
122 #define F_OK 6
123 
124 #define PREFIXDIR ""
125 
126 #define S_ISDIR(x) (((x)&S_IFMT) == S_IFDIR)
127 #define S_ISREG(x) (((x)&S_IFMT) == S_IFREG)
128 
129 #define WIFEXITED(x) 1
130 #define WEXITSTATUS(x) x
131 
132 /* Location of read-only machine independent data */
133 #define DATADIR "share"
134 #define LIBDIR "share"
135 #define CONFDIR "share"
136 
137 /* Location of changeable single system data (temp maps, hiscore, etc) */
138 #define LOCALDIR "var"
139 
140 /* Suffix for libraries */
141 #define PLUGIN_SUFFIX ".dll"
142 
143 /* struct dirent - same as Unix */
144 
145 typedef struct dirent {
146  long d_ino; /* inode (always 1 in WIN32) */
147  off_t d_off; /* offset to this dirent */
148  unsigned short d_reclen; /* length of d_name */
149  char d_name[_MAX_FNAME+1]; /* filename (null terminated) */
150 }dirent;
151 
152 #define NAMLEN(dirent) strlen((dirent)->d_name)
153 
154 
155 #define HAVE_LIBCURL
156 
157 /* Win32's Sleep takes milliseconds, not seconds. */
158 #define sleep(x) Sleep(x*1000)
159 
166 typedef signed char int8_t;
167 typedef signed int int32_t;
168 typedef signed short int16_t;
169 typedef unsigned char uint8_t;
170 typedef unsigned int uint32_t;
171 typedef unsigned short uint16_t;
172 
173 /* Python plugin stuff defines SIZEOF_LONG_LONG as 8, and besides __int64 is a 64b type on MSVC...
174  * So let's force the typedef */
175 typedef unsigned __int64 uint64_t;
176 typedef signed __int64 int64_t;
177 /* Needed for experience */
178 #define atoll _atoi64
179 
180 #define FMT64 "I64d"
181 #define FMT64U "I64u"
182 
183 /* To reduce number of warnings */
184 #pragma warning(disable: 4244) /* conversion from 'xxx' to 'yyy', possible loss of data */
185 #pragma warning(disable: 4305) /* initializing float f = 0.05; instead of f = 0.05f; */
186 
187 #endif /* WIN32_H */
188 
189 #endif
service_handle
void service_handle()
service_register
void service_register()
opendir
DIR * opendir(const char *)
readdir
struct dirent * readdir(DIR *)
service_unregister
void service_unregister()
strcasestr
const char * strcasestr(const char *s, const char *find)
bRunning
int bRunning
strcasecmp
int strcasecmp(const char *s1, const char *s2)
rewinddir
void rewinddir(DIR *)
closedir
int closedir(DIR *)