1 #ifndef __PORTABLE_H__ 2 #define __PORTABLE_H__ 3 4 extern int debugmode; 5 6 #ifndef WIN32 7 #define dbg_printf(fmt, args...) do{ if(debugmode) fprintf(stderr, fmt, ## args); } while(0) 8 #else 9 10 #ifdef DEBUG 11 #define dbg_printf(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__) 12 #else 13 #define dbg_printf(fmt, ...) /* Don't do anything in release builds */ 14 #endif 15 #endif 16 17 #ifndef _MSC_VER 18 #include <unistd.h> 19 #endif 20 #ifdef WIN32 21 #include <Windows.h> 22 #include <direct.h> 23 #include <io.h> 24 #endif 25 #ifdef __linux__ 26 #include <linux/limits.h> 27 #endif 28 #if defined(__FreeBSD__) || defined(__DragonFly__) 29 #include <sys/param.h> 30 #endif 31 32 #ifndef WIN32 33 #define PATH_SEPARATOR '/' 34 #define msleep(ms) usleep((ms) * 1000) 35 #else 36 #define PATH_MAX MAX_PATH 37 #define PATH_SEPARATOR '\\' 38 #define msleep(ms) Sleep(ms) 39 #endif 40 41 #ifdef _MSC_VER 42 #define R_OK 04 43 44 #define open(filename,oflag) _open(filename,oflag) 45 #define write(fd,buffer,count) _write(fd,buffer,count) 46 #define read(fd,buffer,count) _read(fd,buffer,count) 47 #define close(fd) _close(fd) 48 #define access(filename,oflag) _access(filename,oflag) 49 #define getcwd(buffer, maxlen) _getcwd(buffer, maxlen) 50 #endif 51 52 #endif /* __PORTABLE_H__ */ 53