Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
unix.h
Go to the documentation of this file.
1// Windows macros to compile on Unix machines.
2// Taken from MSDOS.H and from various wine headers.
3// Only the absolute minimum has been integrated.
4// 2007, CSH, University of Freiburg
5
6// Error return from SetFilePointer()
7#ifndef INVALID_SEEK_VALUE
8#define INVALID_SEEK_VALUE (0xFFFFFFFF)
9#endif
10#define FILE_NULL NULL
11#define IDS_ENOMESSAGESTR 4
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#if defined(_MSC_VER)
18 #include <windows.h>
19 #include <stdio.h>
20 typedef HANDLE FILEHANDLE;
21 #include "resource.h"
22 #define __LITTLE_ENDIAN__
23#else
24 #ifdef __APPLE__
25 #include <machine/endian.h>
26 #elif defined(__MINGW32__)
27 #define __LITTLE_ENDIAN__
28 #else
29 #include <endian.h>
30 #endif
31 #ifndef INVALID_HANDLE_VALUE
32 #define INVALID_HANDLE_VALUE ((HANDLE)0xFFFFFFFF)
33 #endif
34
36
37#include <stdio.h>
38 typedef FILE* FILEHANDLE;
39
40//
41// Commonly used typedefs & constants from windows.h.
42//
43typedef unsigned char BYTE;
44typedef unsigned short WORD;
45typedef unsigned ABFLONG DWORD;
46typedef unsigned ABFLONG *LPDWORD;
47typedef unsigned int UINT;
48typedef int INT;
49typedef int BOOL;
50typedef long *PLONG;
51typedef unsigned char *LPBYTE;
52typedef void *LPVOID;
53typedef const void *LPCVOID;
54
55//
56// Basics
57//
58
59#ifndef VOID
60#define VOID void
61typedef char CHAR;
62typedef short SHORT;
63typedef long LONG;
64#endif
65
66//
67// UNICODE (Wide Character) types
68//
69
70#ifndef _MAC
71typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
72#else
73// some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
74typedef unsigned short WCHAR; // wc, 16-bit UNICODE character
75#endif
76
77typedef WCHAR *PWCHAR;
78typedef WCHAR *LPWCH, *PWCH;
79typedef const WCHAR *LPCWCH, *PCWCH;
80typedef WCHAR *NWPSTR;
81typedef WCHAR *LPWSTR, *PWSTR;
82
83typedef const WCHAR *LPCWSTR, *PCWSTR;
84
85//
86// ANSI (Multi-byte Character) types
87//
88typedef CHAR *PCHAR;
89typedef CHAR *LPCH, *PCH;
90
91typedef const CHAR *LPCCH, *PCCH;
92typedef CHAR *NPSTR;
93typedef CHAR *LPSTR, *PSTR;
94typedef const CHAR *LPCSTR, *PCSTR;
95
96//
97// Neutral ANSI/UNICODE types and macros
98//
99
100#if defined(__MINGW32__)
101 #include <stdarg.h>
102 #include <windef.h>
103 #include <winbase.h>
104#else
105
106#if defined(UNICODE) // r_winnt
107
108#ifndef _TCHAR_DEFINED
109typedef WCHAR TCHAR, *PTCHAR;
110typedef WCHAR TBYTE , *PTBYTE ;
111#define _TCHAR_DEFINED
112#endif /* !_TCHAR_DEFINED */
113
114typedef LPWSTR LPTCH, PTCH;
115typedef LPWSTR PTSTR, LPTSTR;
116typedef LPCWSTR LPCTSTR;
117typedef LPWSTR LP;
118#define __TEXT(quote) L##quote // r_winnt
119
120#else /* UNICODE */ // r_winnt
121
122#ifndef _TCHAR_DEFINED
123typedef char TCHAR, *PTCHAR;
124typedef unsigned char TBYTE , *PTBYTE ;
125#define _TCHAR_DEFINED
126#endif /* !_TCHAR_DEFINED */
127
128typedef LPSTR LPTCH, PTCH;
131#define __TEXT(quote) quote // r_winnt
132
133#endif /* UNICODE */ // r_winnt
134
135// Handle declarations.
136typedef void *HANDLE;
139
140typedef void *LPOVERLAPPED;
142
143typedef long long LONGLONG;
144#if defined(_WIN64)
145typedef unsigned __int64 UINT_PTR;
146#else
147typedef unsigned int UINT_PTR;
148#endif
149#endif //
150
151#define DWORD_PTR UINT_PTR
152
153#define FILE_BEGIN 0
154#define FILE_CURRENT 1
155#define FILE_END 2
156#define FILE_ATTRIBUTE_NORMAL 0x00000080
157
158#define CREATE_NEW 1
159#define CREATE_ALWAYS 2
160#define OPEN_EXISTING 3
161
162#if !defined(__MINGW32__)
163#define GENERIC_READ 0x80000000
164#define GENERIC_WRITE 0x40000000
165
166#define FILE_SHARE_READ 0x00000001L
167
168#define NO_ERROR 0
169#define ERROR_HANDLE_EOF 38
170
171#define TRUE 1
172#define FALSE 0
173
174#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xFF))
175#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8))
176
177#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF))
178#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
179
180#define ERROR_TOO_MANY_OPEN_FILES 4
181#endif
182
183#ifndef _MAX_PATH
184#define _MAX_DRIVE 3
185#define _MAX_FNAME 256
186#define _MAX_DIR _MAX_FNAME
187#define _MAX_EXT _MAX_FNAME
188#define _MAX_PATH 260
189#endif
190
191
192 // #define __stdcall __attribute__((__stdcall__))
193#if !defined(__MINGW32__)
194#define __stdcall
195#endif
196// gcc uses cdecl as a standard:
197#define cdecl
198#define WINAPI __stdcall
199
200#ifndef GUID_DEFINED
201typedef struct _GUID
202{
203 // TODO: for WIN64 this need to be redefined
204 unsigned int Data1;
205 unsigned short Data2;
206 unsigned short Data3;
207 unsigned char Data4[ 8 ];
209#define GUID_DEFINED
210#endif
211
212#if !defined(__MINGW32__)
213void _splitpath(const char* inpath, char * drv, char * dir,
214 char* fname, char * ext );
215int _strnicmp( LPCSTR str1, LPCSTR str2, size_t n );
216void _makepath( char * path, const char * drive,
217 const char *directory, const char * filename,
218 const char * extension );
219
220/* 64 bit number of 100 nanoseconds intervals since January 1, 1601 */
221typedef struct _FILETIME
222{
223#ifdef __BIG_ENDIAN__
226#else
229#endif
231
242#endif // __MINGW32__
243
244#endif // _MSC_VER
245
247
248//
249// Function wrappers
250//
251
252int WINAPI AXODBG_printf(char *lpsz, ... );
253BOOL WINAPI c_WriteFile( FILEHANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
254 LPDWORD bytesWritten, LPOVERLAPPED overlapped );
255FILEHANDLE WINAPI c_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
256 LPSECURITY_ATTRIBUTES sa, DWORD creation,
257 DWORD attributes_, HANDLE templ);
258DWORD WINAPI c_SetFilePointer( FILEHANDLE hFile, LONG distance, LONG *highword, DWORD method );
259BOOL WINAPI c_ReadFile( FILEHANDLE hFile, LPVOID buffer, DWORD bytesToRead,
260 LPDWORD bytesRead, LPOVERLAPPED overlapped );
263INT WINAPI c_LoadString( HINSTANCE instance, UINT resource_id,
264 LPSTR buffer, INT buflen );
265
266#ifdef __cplusplus
267}
268#endif
#define ABFLONG
Definition AxAbffio32.h:21
WORD TpMarker int n
Definition Son.h:353
HINSTANCE g_hInstance
DWORD dwHighDateTime
Definition unix.h:228
DWORD dwLowDateTime
Definition unix.h:227
Definition unix.h:202
unsigned char Data4[8]
Definition unix.h:207
unsigned int Data1
Definition unix.h:204
unsigned short Data2
Definition unix.h:205
unsigned short Data3
Definition unix.h:206
WORD wYear
Definition unix.h:233
WORD wMilliseconds
Definition unix.h:240
WORD wMonth
Definition unix.h:234
WORD wHour
Definition unix.h:237
WORD wSecond
Definition unix.h:239
WORD wMinute
Definition unix.h:238
WORD wDay
Definition unix.h:236
WORD wDayOfWeek
Definition unix.h:235
BOOL WINAPI c_ReadFile(FILEHANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD bytesRead, LPOVERLAPPED overlapped)
char TCHAR
Definition unix.h:123
int BOOL
Definition unix.h:49
DWORD WINAPI c_GetFileSize(FILEHANDLE hFile, LPDWORD filesizehigh)
HANDLE HINSTANCE
Definition unix.h:137
WCHAR * LPWSTR
Definition unix.h:81
unsigned short WORD
Definition unix.h:44
WCHAR * NWPSTR
Definition unix.h:80
const WCHAR * LPCWCH
Definition unix.h:79
long LONG
Definition unix.h:63
const CHAR * LPCCH
Definition unix.h:91
void _splitpath(const char *inpath, char *drv, char *dir, char *fname, char *ext)
INT WINAPI c_LoadString(HINSTANCE instance, UINT resource_id, LPSTR buffer, INT buflen)
unsigned int UINT
Definition unix.h:47
int INT
Definition unix.h:48
const WCHAR * PCWSTR
Definition unix.h:83
WCHAR * PWCH
Definition unix.h:78
LPSTR PTSTR
Definition unix.h:129
struct _SYSTEMTIME * PSYSTEMTIME
unsigned char BYTE
Definition unix.h:43
BOOL WINAPI c_CloseHandle(FILEHANDLE handle)
unsigned int UINT_PTR
Definition unix.h:147
WCHAR * PWSTR
Definition unix.h:81
CHAR * PCH
Definition unix.h:89
FILE * FILEHANDLE
Definition unix.h:38
CHAR * PCHAR
Definition unix.h:88
LPSTR LPTSTR
Definition unix.h:129
int WINAPI AXODBG_printf(char *lpsz,...)
CHAR * PSTR
Definition unix.h:93
LPSTR LPTCH
Definition unix.h:128
const WCHAR * PCWCH
Definition unix.h:79
void _makepath(char *path, const char *drive, const char *directory, const char *filename, const char *extension)
struct _SYSTEMTIME * LPSYSTEMTIME
struct _SYSTEMTIME SYSTEMTIME
CHAR * NPSTR
Definition unix.h:92
BOOL WINAPI c_WriteFile(FILEHANDLE hFile, LPCVOID buffer, DWORD bytesToWrite, LPDWORD bytesWritten, LPOVERLAPPED overlapped)
WCHAR * LPWCH
Definition unix.h:78
struct _FILETIME * PFILETIME
void * LPSECURITY_ATTRIBUTES
Definition unix.h:141
const CHAR * PCCH
Definition unix.h:91
struct _FILETIME FILETIME
struct _FILETIME * LPFILETIME
unsigned ABFLONG * LPDWORD
Definition unix.h:46
const WCHAR * LPCWSTR
Definition unix.h:83
short SHORT
Definition unix.h:62
#define WINAPI
Definition unix.h:198
void * HANDLE
Definition unix.h:136
unsigned char * LPBYTE
Definition unix.h:51
wchar_t WCHAR
Definition unix.h:71
void * LPVOID
Definition unix.h:52
unsigned char TBYTE
Definition unix.h:124
char * PTCHAR
Definition unix.h:123
CHAR * LPSTR
Definition unix.h:93
long * PLONG
Definition unix.h:50
unsigned ABFLONG DWORD
Definition unix.h:45
const CHAR * LPCSTR
Definition unix.h:94
DWORD WINAPI c_SetFilePointer(FILEHANDLE hFile, LONG distance, LONG *highword, DWORD method)
FILEHANDLE WINAPI c_CreateFile(LPCSTR filename, DWORD access, DWORD sharing, LPSECURITY_ATTRIBUTES sa, DWORD creation, DWORD attributes_, HANDLE templ)
int _strnicmp(LPCSTR str1, LPCSTR str2, size_t n)
LPCSTR LPCTSTR
Definition unix.h:130
unsigned char * PTBYTE
Definition unix.h:124
const CHAR * PCSTR
Definition unix.h:94
struct _GUID GUID
void * LPOVERLAPPED
Definition unix.h:140
const void * LPCVOID
Definition unix.h:53
HINSTANCE HMODULE
Definition unix.h:138
char CHAR
Definition unix.h:61
long long LONGLONG
Definition unix.h:143
CHAR * LPCH
Definition unix.h:89
WCHAR * PWCHAR
Definition unix.h:77
LPSTR PTCH
Definition unix.h:128