1 #ifndef __FIXER_H__
2 #define __FIXER_H__
3 
4 #if defined(_MSC_VER)
5 
6 // just include the windows header to get everything.
7 #undef Yes // sigh
8 #undef No // sigh
9 #include <windows.h>
10 #include <tchar.h>
11 #include <mbstring.h>
12 #include <inttypes.h>
13 #define Yes 1 // sigh
14 #define No 0 // sigh
15 
16 #pragma warning( disable: 4996 ) // unsafe function (strcpy, fopen, etc.) used
17 
18 #include "files.h"
19 
20 #if !defined(PATH_MAX)
21 #define PATH_MAX MAX_PATH
22 #endif
23 
24 #define PACKED_PUSH  __pragma( pack(push, 1) );
25 #define PACKED_POP   __pragma( pack(pop) );
26 #define PACKED
27 
28 // not sure where this was originally defined.
29 #define RGBA_MAKE(r, g, b, a)   ((((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
30 
31 #else
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <limits.h>
37 #include <inttypes.h> /* int64_t */
38 
39 #include "files.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #define PACKED_PUSH
46 #define PACKED_POP
47 #define PACKED __attribute__((packed))
48 
49 /* windows junk */
50 #ifndef min
51 #define min(a, b) (((a) < (b)) ? (a) : (b))
52 #endif
53 
54 #ifndef max
55 #define max(a, b) (((a) > (b)) ? (a) : (b))
56 #endif
57 
58 #define __cdecl
59 
60 #define NO_ERROR	0
61 
62 #define TRUE    1
63 #define FALSE   0
64 
65 #define stricmp         strcasecmp
66 #define _stricmp        strcasecmp
67 
68 #define strnicmp	strncasecmp
69 #define _strnicmp	strncasecmp
70 
71 #define	lstrlen		strlen
72 #define lstrcat		strcat
73 
74 #define _tcslen		strlen
75 #define _tcscpy		strcpy
76 
77 #define _snprintf   snprintf
78 
79 #define __inline    inline
80 
81 size_t _mbclen(const unsigned char *s);
82 
83 #define RGBA_MAKE(r, g, b, a)   ((((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
84 
85 #define MAX_PATH	PATH_MAX
86 
87 typedef int GUID;
88 typedef int HINSTANCE;
89 typedef int WPARAM;
90 typedef int LPARAM;
91 typedef int HANDLE;
92 typedef int HRESULT;
93 
94 typedef int BOOL;
95 typedef unsigned char BYTE;
96 typedef unsigned short WORD;
97 typedef unsigned int DWORD;
98 typedef long LONG;
99 typedef char TCHAR;
100 typedef DWORD * LPDWORD;
101 typedef char * LPTSTR;
102 
103 #define TEXT(x) x
104 
105 typedef struct RECT
106 {
107 	int left;
108 	int top;
109 	int right;
110 	int bottom;
111 } RECT;
112 
113 typedef struct PALETTEENTRY
114 {
115 	BYTE peRed;
116 	BYTE peGreen;
117 	BYTE peBlue;
118 	BYTE peFlags;
119 } PALETTEENTRY;
120 
121 #if !defined(__INTEL_COMPILER)
122 typedef int64_t __int64;
123 #else
124 typedef __int64 int64_t;
125 typedef unsigned __int64 uint64_t;
126 #endif
127 
128 #define	VK_BACK				1
129 #define VK_END				2
130 #define VK_HOME				3
131 #define VK_LEFT				4
132 #define VK_UP				5
133 #define VK_RIGHT			6
134 #define VK_DOWN				7
135 #define VK_INSERT			8
136 #define VK_DELETE			9
137 #define VK_TAB				10
138 
139 #define INVALID_HANDLE_VALUE		-1
140 #define GENERIC_WRITE			0x0001
141 #define CREATE_ALWAYS			0x0002
142 #define FILE_FLAG_RANDOM_ACCESS		0x0004
143 #define GENERIC_READ			0x0008
144 #define OPEN_EXISTING			0x0010
145 #define FILE_CURRENT			0x0020
146 #define FILE_BEGIN			0x0040
147 #define FILE_END			0x0080
148 #define FILE_SHARE_READ			0x0100
149 #define FILE_SHARE_WRITE		0x0200
150 #define OPEN_ALWAYS			0x0400
151 #define FILE_ATTRIBUTE_READONLY		0x0800
152 #define FILE_ATTRIBUTE_DIRECTORY	0x1000
153 #define FILE_ATTRIBUTE_NORMAL		0x2000
154 
155 
156 HANDLE CreateFile(const char *file, int write, int x, int y, int flags, int flags2, int z);
157 HANDLE CreateFileA(const char *file, int write, int x, int y, int flags, int flags2, int z);
158 int WriteFile(HANDLE file, const void *data, int len, /* unsigned long */ void *byteswritten, int x);
159 int ReadFile(HANDLE file, void *data, int len, /* unsigned long */ void *bytesread, int x);
160 int GetFileSize(HANDLE file, int x);
161 int CloseHandle(HANDLE file);
162 int DeleteFile(const char *file);
163 int DeleteFileA(const char *file);
164 int GetDiskFreeSpace(int x, unsigned long *a, unsigned long *b, unsigned long *c, unsigned long *d);
165 int CreateDirectory(char *dir, int x);
166 int MoveFile(const char *newfile, const char *oldfile);
167 int MoveFileA(const char *newfile, const char *oldfile);
168 int CopyFile(const char *newfile, const char *oldfile, int x);
169 int GetFileAttributes(const char *file);
170 int GetFileAttributesA(const char *file);
171 unsigned int SetFilePointer(HANDLE file, int x, int y, int z);
172 int SetEndOfFile(HANDLE file);
173 
174 unsigned int timeGetTime();
175 unsigned int GetTickCount();
176 
177 #define JOYCAPS_HASR		1
178 
179 typedef struct JOYINFOEX
180 {
181 	DWORD dwXpos;
182 	DWORD dwYpos;
183 	DWORD dwRpos;
184 	DWORD dwUpos;
185 	DWORD dwVpos;
186 	DWORD dwPOV;
187 } JOYINFOEX;
188 
189 typedef struct JOYCAPS
190 {
191 	int wCaps;
192 } JOYCAPS;
193 
194 #ifdef __cplusplus
195 };
196 #endif
197 
198 #endif
199 
200 #ifdef __cplusplus
201 extern "C" {
202 #endif
203 // unused placeholder directplay code.
204 typedef int DPID;
205 
206 typedef struct DPNAME
207 {
208 	int dwSize;
209 
210 	char *lpszShortNameA;
211 	char *lpszLongNameA;
212 } DPNAME;
213 
214 #define DP_OK	0
215 
216 #define DPRECEIVE_ALL			1
217 #define DPSYS_ADDPLAYERTOGROUP		2
218 #define	DPSYS_CREATEPLAYERORGROUP	3
219 #define DPPLAYERTYPE_PLAYER		4
220 #define DPSYS_DELETEPLAYERFROMGROUP	5
221 #define DPSYS_HOST			6
222 #define DPSYS_SESSIONLOST		7
223 #define DPSYS_SETPLAYERORGROUPDATA	8
224 #define DPSYS_SETPLAYERORGROUPNAME	9
225 #define DPEXT_HEADER_SIZE		10
226 #define DPERR_BUSY			11
227 #define DPERR_CONNECTIONLOST		12
228 #define DPERR_INVALIDPARAMS		13
229 #define DPERR_INVALIDPLAYER		14
230 #define DPERR_NOTLOGGEDIN		15
231 #define DPERR_SENDTOOBIG		16
232 #define DPERR_BUFFERTOOSMALL		17
233 #define DPID_SYSMSG			18
234 #define DPSYS_DESTROYPLAYERORGROUP	19
235 #define DPID_ALLPLAYERS			20
236 
237 typedef struct DPMSG_GENERIC
238 {
239 	int dwType;
240 } DPMSG_GENERIC;
241 typedef DPMSG_GENERIC * LPDPMSG_GENERIC;
242 
243 typedef struct DPMSG_CREATEPLAYERORGROUP
244 {
245 	int dwType;
246 
247 	DPID dpId;
248 	int dwPlayerType;
249 
250 	DPNAME dpnName;
251 } DPMSG_CREATEPLAYERORGROUP;
252 typedef DPMSG_CREATEPLAYERORGROUP * LPDPMSG_CREATEPLAYERORGROUP;
253 
254 typedef struct DPMSG_DESTROYPLAYERORGROUP
255 {
256 	int dwType;
257 
258 	DPID dpId;
259 	int dwPlayerType;
260 } DPMSG_DESTROYPLAYERORGROUP;
261 typedef DPMSG_DESTROYPLAYERORGROUP * LPDPMSG_DESTROYPLAYERORGROUP;
262 #ifdef __cplusplus
263 };
264 #endif
265 
266 #endif
267