diff options
Diffstat (limited to 'dep/CascLib/src/CascPort.h')
-rw-r--r-- | dep/CascLib/src/CascPort.h | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/dep/CascLib/src/CascPort.h b/dep/CascLib/src/CascPort.h index 5d9a7104f7b..87a2f2fddbd 100644 --- a/dep/CascLib/src/CascPort.h +++ b/dep/CascLib/src/CascPort.h @@ -37,12 +37,20 @@ #define WIN32_LEAN_AND_MEAN #endif +//#pragma warning(disable:4995) // warning C4995: 'sprintf': name was marked as #pragma deprecated + #include <tchar.h> #include <assert.h> + #include <intrin.h> // Support for intrinsic functions #include <ctype.h> + #include <io.h> #include <stdio.h> + #include <stdlib.h> + #include <direct.h> + #include <malloc.h> #include <windows.h> #include <wininet.h> + #include <strsafe.h> #include <sys/types.h> #define PLATFORM_LITTLE_ENDIAN @@ -52,8 +60,10 @@ #define PLATFORM_32BIT #endif - #define PATH_SEPARATOR '\\' - #define CREATE_DIRECTORY(name) CreateDirectory(name, NULL); + #define PATH_SEP_CHAR '\\' + #define PATH_SEP_STRING "\\" + + #pragma intrinsic(memcmp, memcpy) #define PLATFORM_WINDOWS #define PLATFORM_DEFINED // The platform is known now @@ -75,6 +85,8 @@ #include <dirent.h> #include <errno.h> #include <stddef.h> + #include <string.h> + #include <cassert> // Support for PowerPC on Max OS X #if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1) @@ -90,9 +102,9 @@ #define PLATFORM_LITTLE_ENDIAN #endif - #define PATH_SEPARATOR '/' - #define CREATE_DIRECTORY(name) mkdir(name, 0755) - + #define PATH_SEP_CHAR '/' + #define PATH_SEP_STRING "/" + #define PLATFORM_MAC #define PLATFORM_DEFINED // The platform is known now @@ -103,7 +115,6 @@ // Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* #if !defined(PLATFORM_DEFINED) - #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> @@ -117,12 +128,13 @@ #include <stdarg.h> #include <string.h> #include <ctype.h> + #include <wchar.h> #include <assert.h> #include <errno.h> - #define PATH_SEPARATOR '/' - #define CREATE_DIRECTORY(name) mkdir(name, 0755) - + #define PATH_SEP_CHAR '/' + #define PATH_SEP_STRING "/" + #define PLATFORM_LITTLE_ENDIAN #define PLATFORM_LINUX #define PLATFORM_DEFINED @@ -145,20 +157,19 @@ typedef unsigned short USHORT; typedef int LONG; typedef unsigned int DWORD; - typedef unsigned long DWORD_PTR; - typedef long LONG_PTR; - typedef long INT_PTR; typedef long long LONGLONG; typedef unsigned long long ULONGLONG; typedef unsigned long long *PULONGLONG; typedef void * HANDLE; - typedef void * LPOVERLAPPED; // Unsupported on Linux and Mac typedef char TCHAR; typedef unsigned int LCID; typedef LONG * PLONG; typedef DWORD * PDWORD; typedef BYTE * LPBYTE; typedef char * LPSTR; + typedef const char * LPCSTR; + typedef TCHAR * LPTSTR; + typedef const TCHAR * LPCTSTR; #ifdef PLATFORM_32BIT #define _LZMA_UINT32_IS_ULONG @@ -179,7 +190,6 @@ #define _T(x) x #define _tcslen strlen - #define _tcscpy strcpy #define _tcscat strcat #define _tcschr strchr #define _tcsrchr strrchr @@ -187,9 +197,9 @@ #define _tcsspn strspn #define _tcsncmp strncmp #define _tprintf printf - #define _stprintf sprintf #define _tremove remove - #define _tmkdir mkdir + #define _taccess access + #define _access access #define _stricmp strcasecmp #define _strnicmp strncasecmp @@ -212,6 +222,7 @@ #if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) #define ERROR_SUCCESS 0 #define ERROR_FILE_NOT_FOUND ENOENT + #define ERROR_PATH_NOT_FOUND ENOENT #define ERROR_ACCESS_DENIED EPERM #define ERROR_INVALID_HANDLE EBADF #define ERROR_NOT_ENOUGH_MEMORY ENOMEM @@ -220,18 +231,34 @@ #define ERROR_DISK_FULL ENOSPC #define ERROR_ALREADY_EXISTS EEXIST #define ERROR_INSUFFICIENT_BUFFER ENOBUFS - #define ERROR_BAD_FORMAT 1000 // No such error code under Linux - #define ERROR_NO_MORE_FILES 1001 // No such error code under Linux - #define ERROR_HANDLE_EOF 1002 // No such error code under Linux - #define ERROR_CAN_NOT_COMPLETE 1003 // No such error code under Linux - #define ERROR_FILE_CORRUPT 1004 // No such error code under Linux - #define ERROR_FILE_ENCRYPTED 1005 // Returned by encrypted stream when can't find file key + #define ERROR_BAD_FORMAT 1000 // No such error code under Linux + #define ERROR_NO_MORE_FILES 1001 // No such error code under Linux + #define ERROR_HANDLE_EOF 1002 // No such error code under Linux + #define ERROR_CAN_NOT_COMPLETE 1003 // No such error code under Linux + #define ERROR_FILE_CORRUPT 1004 // No such error code under Linux + #define ERROR_FILE_ENCRYPTED 1005 // Returned by encrypted stream when can't find file key #endif #ifndef ERROR_FILE_INCOMPLETE -#define ERROR_FILE_INCOMPLETE 1006 // The required file part is missing +#define ERROR_FILE_INCOMPLETE 1006 // The required file part is missing +#endif + +#ifndef ERROR_FILE_OFFLINE +#define ERROR_FILE_OFFLINE 1007 // The file is not available in the local storage #endif +#ifndef ERROR_BUFFER_OVERFLOW +#define ERROR_BUFFER_OVERFLOW 1008 +#endif + +#ifndef ERROR_CANCELLED +#define ERROR_CANCELLED 1009 +#endif + +#ifndef _countof +#define _countof(x) (sizeof(x) / sizeof(x[0])) +#endif + //----------------------------------------------------------------------------- // Swapping functions @@ -273,4 +300,13 @@ #define BSWAP_ARRAY64_UNSIGNED(a,b) ConvertUInt64Buffer((a),(b)) #endif +//----------------------------------------------------------------------------- +// Forbidden functions, do not use + +#ifdef __CASCLIB_SELF__ +#define strcpy UNSAFE_DO_NOT_USE_STRCPY +#define strcat UNSAFE_DO_NOT_USE_STRCAT +#define sprintf UNSAFE_DO_NOT_USE_SPRINTF +#endif + #endif // __CASCPORT_H__ |