1 /********************************************************************* 2 * 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * =================================================================== 15 * Revision History :: 16 * YYYY.MM.DD Change ID Developer 17 * Description 18 * ------------------------------------------------------------------- 19 * 2002.04.25 Vlad Skarzhevskyy 20 * Initial implementation. 21 * 22 * =================================================================== 23 * 24 * This file define map between Windows/DOS and Unix functions. 25 * As well missing in Windows/DOS functions defined in platform.c 26 * 27 ********************************************************************/ 28 29 30 #ifndef pure_sfv_platform_h_defined 31 #define pure_sfv_platform_h_defined 32 33 34 #define DIR_SEP_UNIX '/' 35 #define DIR_SEP_DOS '\\' 36 37 #ifdef __unix 38 39 /* Define new name for common functions just in case */ 40 41 #include <dirent.h> 42 #include <unistd.h> 43 /* #include <libgen.h> */ 44 45 #define DIR_SEP_PLATFORM DIR_SEP_UNIX 46 #define DOS_LINE_END "\r\n" 47 48 #define O_BINARY 0 49 50 /* End on Unix */ 51 #else 52 53 #ifdef _MSC_VER 54 55 /* MS VC++ Solution for this commmon functions */ 56 57 #include <io.h> 58 #include <direct.h> 59 60 #define DIR_SEP_PLATFORM DIR_SEP_DOS 61 #define DOS_LINE_END "\n" 62 63 #define open _open 64 #define read _read 65 #define close _close 66 #define stat _stat 67 #define S_ISDIR(mode) (((mode)&_S_IFDIR)) 68 69 #define strcasecmp _stricmp 70 71 #ifndef O_RDONLY 72 #define O_RDONLY _O_RDONLY 73 #endif 74 75 #ifndef O_BINARY 76 #define O_BINARY _O_BINARY 77 #endif 78 79 #define PATH_MAX _MAX_PATH 80 81 82 extern char* optarg; 83 extern int optind; 84 extern int getopt(int argc, char** argv, const char* pszValidOpts); 85 86 extern int chdir(const char *path); 87 extern char *getcwd(char *buf, int size); 88 89 typedef struct 90 { 91 char name[PATH_MAX]; 92 long dirp; 93 } DIR; 94 95 extern DIR *opendir(const char *dirname); 96 extern int closedir(DIR *dirp); 97 98 struct dirent 99 { 100 char d_name[PATH_MAX]; 101 }; 102 103 extern struct dirent *readdir(DIR *dirp); 104 105 /* ifdef _MSC_VER */ 106 #endif 107 108 /* ifdef __unix */ 109 #endif 110 111 #endif 112 /* EOF */ 113