Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef UPDATEDEFINES_H |
michael@0 | 6 | #define UPDATEDEFINES_H |
michael@0 | 7 | |
michael@0 | 8 | #include "readstrings.h" |
michael@0 | 9 | |
michael@0 | 10 | #ifndef MAXPATHLEN |
michael@0 | 11 | # ifdef PATH_MAX |
michael@0 | 12 | # define MAXPATHLEN PATH_MAX |
michael@0 | 13 | # elif defined(MAX_PATH) |
michael@0 | 14 | # define MAXPATHLEN MAX_PATH |
michael@0 | 15 | # elif defined(_MAX_PATH) |
michael@0 | 16 | # define MAXPATHLEN _MAX_PATH |
michael@0 | 17 | # elif defined(CCHMAXPATH) |
michael@0 | 18 | # define MAXPATHLEN CCHMAXPATH |
michael@0 | 19 | # else |
michael@0 | 20 | # define MAXPATHLEN 1024 |
michael@0 | 21 | # endif |
michael@0 | 22 | #endif |
michael@0 | 23 | |
michael@0 | 24 | #if defined(XP_WIN) |
michael@0 | 25 | # include <windows.h> |
michael@0 | 26 | # include <shlwapi.h> |
michael@0 | 27 | # include <direct.h> |
michael@0 | 28 | # include <io.h> |
michael@0 | 29 | # include <stdio.h> |
michael@0 | 30 | # include <stdarg.h> |
michael@0 | 31 | |
michael@0 | 32 | # define F_OK 00 |
michael@0 | 33 | # define W_OK 02 |
michael@0 | 34 | # define R_OK 04 |
michael@0 | 35 | # define S_ISDIR(s) (((s) & _S_IFMT) == _S_IFDIR) |
michael@0 | 36 | # define S_ISREG(s) (((s) & _S_IFMT) == _S_IFREG) |
michael@0 | 37 | |
michael@0 | 38 | # define access _access |
michael@0 | 39 | |
michael@0 | 40 | # define putenv _putenv |
michael@0 | 41 | # define stat _stat |
michael@0 | 42 | # define DELETE_DIR L"tobedeleted" |
michael@0 | 43 | # define CALLBACK_BACKUP_EXT L".moz-callback" |
michael@0 | 44 | |
michael@0 | 45 | # define LOG_S "%S" |
michael@0 | 46 | # define NS_T(str) L ## str |
michael@0 | 47 | # define NS_SLASH NS_T('\\') |
michael@0 | 48 | // On Windows, _snprintf and _snwprintf don't guarantee null termination. These |
michael@0 | 49 | // macros always leave room in the buffer for null termination and set the end |
michael@0 | 50 | // of the buffer to null in case the string is larger than the buffer. Having |
michael@0 | 51 | // multiple nulls in a string is fine and this approach is simpler (possibly |
michael@0 | 52 | // faster) than calculating the string length to place the null terminator and |
michael@0 | 53 | // truncates the string as _snprintf and _snwprintf do on other platforms. |
michael@0 | 54 | static int mysnprintf(char* dest, size_t count, const char* fmt, ...) |
michael@0 | 55 | { |
michael@0 | 56 | size_t _count = count - 1; |
michael@0 | 57 | va_list varargs; |
michael@0 | 58 | va_start(varargs, fmt); |
michael@0 | 59 | int result = _vsnprintf(dest, count - 1, fmt, varargs); |
michael@0 | 60 | va_end(varargs); |
michael@0 | 61 | dest[_count] = '\0'; |
michael@0 | 62 | return result; |
michael@0 | 63 | } |
michael@0 | 64 | #define snprintf mysnprintf |
michael@0 | 65 | static int mywcsprintf(WCHAR* dest, size_t count, const WCHAR* fmt, ...) |
michael@0 | 66 | { |
michael@0 | 67 | size_t _count = count - 1; |
michael@0 | 68 | va_list varargs; |
michael@0 | 69 | va_start(varargs, fmt); |
michael@0 | 70 | int result = _vsnwprintf(dest, count - 1, fmt, varargs); |
michael@0 | 71 | va_end(varargs); |
michael@0 | 72 | dest[_count] = L'\0'; |
michael@0 | 73 | return result; |
michael@0 | 74 | } |
michael@0 | 75 | #define NS_tsnprintf mywcsprintf |
michael@0 | 76 | # define NS_taccess _waccess |
michael@0 | 77 | # define NS_tchdir _wchdir |
michael@0 | 78 | # define NS_tchmod _wchmod |
michael@0 | 79 | # define NS_tfopen _wfopen |
michael@0 | 80 | # define NS_tmkdir(path, perms) _wmkdir(path) |
michael@0 | 81 | # define NS_tremove _wremove |
michael@0 | 82 | // _wrename is used to avoid the link tracking service. |
michael@0 | 83 | # define NS_trename _wrename |
michael@0 | 84 | # define NS_trmdir _wrmdir |
michael@0 | 85 | # define NS_tstat _wstat |
michael@0 | 86 | # define NS_tlstat _wstat // No symlinks on Windows |
michael@0 | 87 | # define NS_tstrcat wcscat |
michael@0 | 88 | # define NS_tstrcmp wcscmp |
michael@0 | 89 | # define NS_tstricmp wcsicmp |
michael@0 | 90 | # define NS_tstrcpy wcscpy |
michael@0 | 91 | # define NS_tstrncpy wcsncpy |
michael@0 | 92 | # define NS_tstrlen wcslen |
michael@0 | 93 | # define NS_tstrchr wcschr |
michael@0 | 94 | # define NS_tstrrchr wcsrchr |
michael@0 | 95 | # define NS_tstrstr wcsstr |
michael@0 | 96 | # include "win_dirent.h" |
michael@0 | 97 | # define NS_tDIR DIR |
michael@0 | 98 | # define NS_tdirent dirent |
michael@0 | 99 | # define NS_topendir opendir |
michael@0 | 100 | # define NS_tclosedir closedir |
michael@0 | 101 | # define NS_treaddir readdir |
michael@0 | 102 | #else |
michael@0 | 103 | # include <sys/wait.h> |
michael@0 | 104 | # include <unistd.h> |
michael@0 | 105 | |
michael@0 | 106 | #ifdef SOLARIS |
michael@0 | 107 | # include <sys/stat.h> |
michael@0 | 108 | #else |
michael@0 | 109 | # include <fts.h> |
michael@0 | 110 | #endif |
michael@0 | 111 | # include <dirent.h> |
michael@0 | 112 | |
michael@0 | 113 | #ifdef XP_MACOSX |
michael@0 | 114 | # include <sys/time.h> |
michael@0 | 115 | #endif |
michael@0 | 116 | |
michael@0 | 117 | # define LOG_S "%s" |
michael@0 | 118 | # define NS_T(str) str |
michael@0 | 119 | # define NS_SLASH NS_T('/') |
michael@0 | 120 | # define NS_tsnprintf snprintf |
michael@0 | 121 | # define NS_taccess access |
michael@0 | 122 | # define NS_tchdir chdir |
michael@0 | 123 | # define NS_tchmod chmod |
michael@0 | 124 | # define NS_tfopen fopen |
michael@0 | 125 | # define NS_tmkdir mkdir |
michael@0 | 126 | # define NS_tremove remove |
michael@0 | 127 | # define NS_trename rename |
michael@0 | 128 | # define NS_trmdir rmdir |
michael@0 | 129 | # define NS_tstat stat |
michael@0 | 130 | # define NS_tlstat lstat |
michael@0 | 131 | # define NS_tstrcat strcat |
michael@0 | 132 | # define NS_tstrcmp strcmp |
michael@0 | 133 | # define NS_tstricmp strcasecmp |
michael@0 | 134 | # define NS_tstrcpy strcpy |
michael@0 | 135 | # define NS_tstrncpy strncpy |
michael@0 | 136 | # define NS_tstrlen strlen |
michael@0 | 137 | # define NS_tstrrchr strrchr |
michael@0 | 138 | # define NS_tstrstr strstr |
michael@0 | 139 | # define NS_tDIR DIR |
michael@0 | 140 | # define NS_tdirent dirent |
michael@0 | 141 | # define NS_topendir opendir |
michael@0 | 142 | # define NS_tclosedir closedir |
michael@0 | 143 | # define NS_treaddir readdir |
michael@0 | 144 | #endif |
michael@0 | 145 | |
michael@0 | 146 | #define BACKUP_EXT NS_T(".moz-backup") |
michael@0 | 147 | |
michael@0 | 148 | #endif |