/* Mingw32 fake portability - the header file. Version 1.2. This file is provided 'as-is'. It comes with absolutely no warranty. Any and all usage of this file is at your own risk. I can in no case what-so-ever be held responsible for any damage cause by the direct or indirect use or misuse of this, or any accompanying, file. This file may be used and distributed freely and in any way. It has been released into public domain with the hope it might help people porting from Unix to Windows. For questions, additions or fixes to this file, please contact me at: oscar.sundbom@swipnet.se Oscar Sundbom, 2003 */ /* This file should be included AFTER all mingw system headers. */ /* This may seem like a long identifier, but it's to make (resonably) sure it doesn't interfere with "real" mingw32 defines */ #ifndef _MINGW32_FAKEPORT_H #define _MINGW32_FAKEPORT_H /* This may also seem wierd. This is to make sure no-one tries to include it when they don't intend to, since it changes function calls and so on. */ #ifndef WIN32 #error "WIN32 not defined, this is needed to use this header, to make sure you know what you're doing." #endif /* ---- DEFINES NOT IN MINGW32 FOR EASIER PORTABILITY ---- */ /* File permissions unused in Windows */ #define MGW32FP_NULLDEF 0 #define MGW32FP_FAKEDEF 1 /* Each subsystem has a flag define which sets how it's used. It can be set to: MGW32FP_NULLDEF will set all unused defines to NULL. MGW32FP_FAKEDEF will set all unused defines to the closest match. */ #define S_IRUSR _S_IREAD #define S_IWUSR _S_IWRITE #define S_IXUSR 0 #if MGW32FP_FD == MGW32FP_FAKEDEF #define S_IRWXG S_IRWXU #define S_IRGRP S_IRUSR #define S_IWGRP S_IWUSR #define S_IXGRP S_IXUSR #define S_IRWXO S_IRWXU #define S_IROTH S_IRUSR #define S_IWOTH S_IWUSR #define S_IXOTH S_IXUSR #elif MGW32FP_FD == MGW32FP_NULLDEF #define S_IRWXG 0 #define S_IRGRP 0 #define S_IWGRP 0 #define S_IXGRP 0 #define S_IRWXO 0 #define S_IROTH 0 #define S_IWOTH 0 #define S_IXOTH 0 #endif /* Function names will be renamed to win_function to allow them to be used if neccessary. These redefinitions will work even if _NO_OLDNAMES is defined, unless the compiler halts when trying to #undef something not defined. NOTE: When using this header, _NO_OLDNAMES must probably be undefined. If your GCC reports errors having to do with defines, check this first. */ /* ---- FUNCTION REDEFINITIONS THROUGH USE OF MACROS ---- */ #define win_open _open #undef open #define open(file, flags) win_open(file, flags | _O_BINARY) #define win_creat _creat #undef creat #define creat(file, mode) win_open(file, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, mode) #define win_mkdir mkdir #undef mkdir #define mkdir(x, y) win_mkdir(x) #define vsnprintf _vsnprintf #define snprintf _snprintf #define index strchr #define rindex strrchr #define strcasecmp strcmpi #endif