Crossfire Server, Branches 1.12  R18729
win32.h
Go to the documentation of this file.
1 #ifndef WIN32_H
2 #define WIN32_H
3 
12 #if !defined(AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_)
13 #define AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_
14 
15 /* Define the version here. In Unixland, it's defined on the command line now. */
16 #define VERSION "1.9.1 (trunk) snapshot 20061229"
17 
18 #pragma warning(disable: 4761) /* integral size mismatch in argument; conversion supplied */
19 
20 #if _MSC_VER > 1000
21 #pragma once
22 #endif /* _MSC_VER > 1000 */
23 
24 #endif /* !defined(AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_) */
25 
26 #define WIN32_LEAN_AND_MEAN
27 #include <windows.h>
28 #include <windowsx.h>
29 #include <mmsystem.h>
30 #include <winsock2.h>
31 #include <time.h>
32 #include <direct.h>
33 #include <math.h>
34 
35 #include <sys/stat.h> /* somewhat odd, but you don't get stat here with __STDC__ */
36 
37 #include <io.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <sys/types.h>
41 #include <process.h>
42 
43 #define __STDC__ 1 /* something odd, CF want this, but don'T include it */
44  /* before the standard includes */
45 
46 #ifndef HAVE_SNPRINTF
47 #define HAVE_SNPRINTF 1
48 #endif
49 #define snprintf _snprintf
50 
51 /* include all needed autoconfig.h defines */
52 #define CS_LOGSTATS
53 #define HAVE_SRAND
54 #ifndef HAVE_FCNTL_H
55  #define HAVE_FCNTL_H
56 #endif
57 #ifndef HAVE_STDDEF_H
58  #define HAVE_STDDEF_H
59 #endif
60 #define GETTIMEOFDAY_TWO_ARGS
61 #define MAXPATHLEN 256
62 #define HAVE_STRTOL
63 #define HAVE_STRERROR
64 
65 /* Many defines to redirect unix functions or fake standard unix values */
66 #define inline __inline
67 #define unlink(__a) _unlink(__a)
68 #define mkdir(__a, __b) mkdir(__a)
69 #define getpid() _getpid()
70 #define popen(__a, __b) _popen(__a, __b)
71 #define pclose(__a) _pclose(__a)
72 #define vsnprintf _vsnprintf
73 #define strtok_r(x, y, z) strtok(x, y)
74 
75 #define R_OK 6 /* for __access() */
76 #define F_OK 6
77 
78 #define PREFIXDIR ""
79 
80 #define S_ISDIR(x) (((x)&S_IFMT) == S_IFDIR)
81 #define S_ISREG(x) (((x)&S_IFMT) == S_IFREG)
82 
83 #ifndef S_ISGID
84 #define S_ISGID 0002000
85 #endif
86 #ifndef S_IWOTH
87 #define S_IWOTH 0000200
88 #endif
89 #ifndef S_IWGRP
90 #define S_IWGRP 0000020
91 #endif
92 #ifndef S_IWUSR
93 #define S_IWUSR 0000002
94 #endif
95 #ifndef S_IROTH
96 #define S_IROTH 0000400
97 #endif
98 #ifndef S_IRGRP
99 #define S_IRGRP 0000040
100 #endif
101 #ifndef S_IRUSR
102 #define S_IRUSR 0000004
103 #endif
104 
105 #define WIFEXITED(x) 1
106 #define WEXITSTATUS(x) x
107 
108 /* Location of read-only machine independent data */
109 #define DATADIR "share"
110 #define LIBDIR "share"
111 #define CONFDIR "share"
112 
113 /* Location of changeable single system data (temp maps, hiscore, etc) */
114 #define LOCALDIR "var"
115 
116 #define COMPRESS "/usr/bin/compress"
117 #define UNCOMPRESS "/usr/bin/uncompress"
118 #define GZIP "/bin/gzip"
119 #define GUNZIP "/bin/gunzip"
120 #define BZIP "/usr/bin/bzip2"
121 #define BUNZIP "/usr/bin/bunzip2"
122 
123 /* Suffix for libraries */
124 #define PLUGIN_SUFFIX ".dll"
125 
126 /* struct dirent - same as Unix */
127 
128 typedef struct dirent {
129  long d_ino; /* inode (always 1 in WIN32) */
130  off_t d_off; /* offset to this dirent */
131  unsigned short d_reclen; /* length of d_name */
132  char d_name[_MAX_FNAME+1]; /* filename (null terminated) */
133 }dirent;
134 
135 #define NAMLEN(dirent) strlen((dirent)->d_name)
136 
137 /* typedef DIR - not the same as Unix */
138 typedef struct {
139  long handle; /* _findfirst/_findnext handle */
140  short offset; /* offset into directory */
141  short finished; /* 1 if there are not more files */
142  struct _finddata_t fileinfo; /* from _findfirst/_findnext */
143  char *dir; /* the dir we are reading */
144  struct dirent dent; /* the dirent to return */
145 } DIR;
146 
147 #ifndef socklen_t
148 #define socklen_t int /* Doesn't exist, just a plain int */
149 #endif
150 
151 /* Function prototypes */
152 extern int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info);
153 extern DIR *opendir(const char *);
154 extern struct dirent *readdir(DIR *);
155 extern int closedir(DIR *);
156 extern void rewinddir(DIR *);
157 extern int strncasecmp(const char *s1, const char *s2, int n);
158 extern int strcasecmp(const char *s1, const char *s2);
159 extern void service_register();
160 extern void service_unregister();
161 extern void service_handle();
162 
163 /* For Win32 service */
164 extern int bRunning;
165 
166 /* Win32's Sleep takes milliseconds, not seconds. */
167 #define sleep(x) Sleep(x*1000)
168 
169 #endif /* WIN32_H */
unsigned short d_reclen
Definition: win32.h:131
short finished
Definition: win32.h:141
int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info)
Definition: win32.c:54
char * dir
Definition: win32.h:143
DIR * opendir(const char *)
Definition: win32.c:78
long handle
Definition: win32.h:139
Definition: win32.h:128
short offset
Definition: win32.h:140
Definition: win32.h:138
void service_unregister()
Definition: win32.c:266
int strcasecmp(const char *s1, const char *s2)
Definition: porting.c:434
long d_ino
Definition: win32.h:129
void rewinddir(DIR *)
Definition: win32.c:167
int bRunning
Definition: win32.c:202
char d_name[_MAX_FNAME+1]
Definition: win32.h:132
int strncasecmp(const char *s1, const char *s2, int n)
Definition: porting.c:402
struct dirent dirent
void service_handle()
Definition: win32.c:384
struct dirent * readdir(DIR *)
Definition: win32.c:116
void service_register()
Definition: win32.c:221
int closedir(DIR *)
Definition: win32.c:149
off_t d_off
Definition: win32.h:130
Definition: win32.c:39