Crossfire Server, Branch 1.12  R12190
win32.h
Go to the documentation of this file.
00001 #ifndef WIN32_H
00002 #define WIN32_H
00003 
00012 #if !defined(AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_)
00013 #define AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_
00014 
00015 /* Define the version here.  In Unixland, it's defined on the command line now. */
00016 #define VERSION "1.9.1 (trunk) snapshot 20061229"
00017 
00018 #pragma warning(disable: 4761) /* integral size mismatch in argument; conversion supplied */
00019 
00020 #if _MSC_VER > 1000
00021 #pragma once
00022 #endif /* _MSC_VER > 1000 */
00023 
00024 #endif /* !defined(AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_) */
00025 
00026 #define WIN32_LEAN_AND_MEAN
00027 #include <windows.h>
00028 #include <windowsx.h>
00029 #include <mmsystem.h>
00030 #include <winsock2.h>
00031 #include <time.h>
00032 #include <direct.h>
00033 #include <math.h>
00034 
00035 #include <sys/stat.h>   /* somewhat odd, but you don't get stat here with __STDC__ */
00036 
00037 #include <io.h>
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040 #include <sys/types.h>
00041 #include <process.h>
00042 
00043 #define __STDC__ 1      /* something odd, CF want this, but don'T include it */
00044                         /* before the standard includes */
00045 
00046 #ifndef HAVE_SNPRINTF
00047 #define HAVE_SNPRINTF 1
00048 #endif
00049 #define snprintf _snprintf
00050 
00051 /* include all needed autoconfig.h defines */
00052 #define CS_LOGSTATS
00053 #define HAVE_SRAND
00054 #ifndef HAVE_FCNTL_H
00055     #define HAVE_FCNTL_H
00056 #endif
00057 #ifndef HAVE_STDDEF_H
00058     #define HAVE_STDDEF_H
00059 #endif
00060 #define GETTIMEOFDAY_TWO_ARGS
00061 #define MAXPATHLEN 256
00062 #define HAVE_STRTOL
00063 #define HAVE_STRERROR
00064 
00065 /* Many defines to redirect unix functions or fake standard unix values */
00066 #define inline __inline
00067 #define unlink(__a) _unlink(__a)
00068 #define mkdir(__a, __b) mkdir(__a)
00069 #define getpid() _getpid()
00070 #define popen(__a, __b) _popen(__a, __b)
00071 #define pclose(__a) _pclose(__a)
00072 #define vsnprintf _vsnprintf
00073 #define strtok_r(x, y, z) strtok(x, y)
00074 
00075 #define R_OK 6          /* for __access() */
00076 #define F_OK 6
00077 
00078 #define PREFIXDIR ""
00079 
00080 #define S_ISDIR(x) (((x)&S_IFMT) == S_IFDIR)
00081 #define S_ISREG(x) (((x)&S_IFMT) == S_IFREG)
00082 
00083 #ifndef S_ISGID
00084 #define S_ISGID 0002000
00085 #endif
00086 #ifndef S_IWOTH
00087 #define S_IWOTH 0000200
00088 #endif
00089 #ifndef S_IWGRP
00090 #define S_IWGRP 0000020
00091 #endif
00092 #ifndef S_IWUSR
00093 #define S_IWUSR 0000002
00094 #endif
00095 #ifndef S_IROTH
00096 #define S_IROTH 0000400
00097 #endif
00098 #ifndef S_IRGRP
00099 #define S_IRGRP 0000040
00100 #endif
00101 #ifndef S_IRUSR
00102 #define S_IRUSR 0000004
00103 #endif
00104 
00105 #define WIFEXITED(x) 1
00106 #define WEXITSTATUS(x) x
00107 
00108 /* Location of read-only machine independent data */
00109 #define DATADIR "share"
00110 #define LIBDIR "share"
00111 #define CONFDIR "share"
00112 
00113 /* Location of changeable single system data (temp maps, hiscore, etc) */
00114 #define LOCALDIR "var"
00115 
00116 #define COMPRESS "/usr/bin/compress"
00117 #define UNCOMPRESS "/usr/bin/uncompress"
00118 #define GZIP "/bin/gzip"
00119 #define GUNZIP "/bin/gunzip"
00120 #define BZIP "/usr/bin/bzip2"
00121 #define BUNZIP "/usr/bin/bunzip2"
00122 
00123 /* Suffix for libraries */
00124 #define PLUGIN_SUFFIX ".dll"
00125 
00126 /* struct dirent - same as Unix */
00127 
00128 typedef struct dirent {
00129     long d_ino;                         /* inode (always 1 in WIN32) */
00130     off_t d_off;                        /* offset to this dirent */
00131     unsigned short d_reclen;            /* length of d_name */
00132     char d_name[_MAX_FNAME+1];          /* filename (null terminated) */
00133 }dirent;
00134 
00135 #define NAMLEN(dirent) strlen((dirent)->d_name)
00136 
00137 /* typedef DIR - not the same as Unix */
00138 typedef struct {
00139     long handle;                        /* _findfirst/_findnext handle */
00140     short offset;                       /* offset into directory */
00141     short finished;                     /* 1 if there are not more files */
00142     struct _finddata_t fileinfo;        /* from _findfirst/_findnext */
00143     char *dir;                          /* the dir we are reading */
00144     struct dirent dent;                 /* the dirent to return */
00145 } DIR;
00146 
00147 #ifndef socklen_t
00148 #define socklen_t int /* Doesn't exist, just a plain int */
00149 #endif
00150 
00151 /* Function prototypes */
00152 extern int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info);
00153 extern DIR *opendir(const char *);
00154 extern struct dirent *readdir(DIR *);
00155 extern int closedir(DIR *);
00156 extern void rewinddir(DIR *);
00157 extern int strncasecmp(const char *s1, const char *s2, int n);
00158 extern int strcasecmp(const char *s1, const char *s2);
00159 extern void service_register();
00160 extern void service_unregister();
00161 extern void service_handle();
00162 
00163 /* For Win32 service */
00164 extern int bRunning;
00165 
00166 /* Win32's Sleep takes milliseconds, not seconds. */
00167 #define sleep(x) Sleep(x*1000)
00168 
00169 #endif /* WIN32_H */