| 1 |
/* |
| 2 |
* nsis_tchar.h |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft and Contributors |
| 7 |
* |
| 8 |
* This software is provided 'as-is', without any express or implied |
| 9 |
* warranty. |
| 10 |
* |
| 11 |
* For Unicode support by Jim Park -- 08/30/2007 |
| 12 |
*/ |
| 13 |
|
| 14 |
// Jim Park: Only those we use are listed here. |
| 15 |
|
| 16 |
#pragma once |
| 17 |
|
| 18 |
#ifdef _UNICODE |
| 19 |
|
| 20 |
#ifndef _T |
| 21 |
#define __T(x) L ## x |
| 22 |
#define _T(x) __T(x) |
| 23 |
#define _TEXT(x) __T(x) |
| 24 |
#endif |
| 25 |
|
| 26 |
#ifndef _TCHAR_DEFINED |
| 27 |
#define _TCHAR_DEFINED |
| 28 |
#if !defined(_NATIVE_WCHAR_T_DEFINED) && !defined(_WCHAR_T_DEFINED) |
| 29 |
typedef unsigned short TCHAR; |
| 30 |
#else |
| 31 |
typedef wchar_t TCHAR; |
| 32 |
#endif |
| 33 |
#endif |
| 34 |
|
| 35 |
|
| 36 |
// program |
| 37 |
#define _tenviron _wenviron |
| 38 |
#define __targv __wargv |
| 39 |
|
| 40 |
// printfs |
| 41 |
#define _ftprintf fwprintf |
| 42 |
#define _sntprintf _snwprintf |
| 43 |
#if (defined(_MSC_VER) && (_MSC_VER<=1310||_MSC_FULL_VER<=140040310)) || defined(__MINGW32__) |
| 44 |
# define _stprintf swprintf |
| 45 |
#else |
| 46 |
# define _stprintf _swprintf |
| 47 |
#endif |
| 48 |
#define _tprintf wprintf |
| 49 |
#define _vftprintf vfwprintf |
| 50 |
#define _vsntprintf _vsnwprintf |
| 51 |
#if defined(_MSC_VER) && (_MSC_VER<=1310) |
| 52 |
# define _vstprintf vswprintf |
| 53 |
#else |
| 54 |
# define _vstprintf _vswprintf |
| 55 |
#endif |
| 56 |
|
| 57 |
// scanfs |
| 58 |
#define _tscanf wscanf |
| 59 |
#define _stscanf swscanf |
| 60 |
|
| 61 |
// string manipulations |
| 62 |
#define _tcscat wcscat |
| 63 |
#define _tcschr wcschr |
| 64 |
#define _tcsclen wcslen |
| 65 |
#define _tcscpy wcscpy |
| 66 |
#define _tcsdup _wcsdup |
| 67 |
#define _tcslen wcslen |
| 68 |
#define _tcsnccpy wcsncpy |
| 69 |
#define _tcsncpy wcsncpy |
| 70 |
#define _tcsrchr wcsrchr |
| 71 |
#define _tcsstr wcsstr |
| 72 |
#define _tcstok wcstok |
| 73 |
|
| 74 |
// string comparisons |
| 75 |
#define _tcscmp wcscmp |
| 76 |
#define _tcsicmp _wcsicmp |
| 77 |
#define _tcsncicmp _wcsnicmp |
| 78 |
#define _tcsncmp wcsncmp |
| 79 |
#define _tcsnicmp _wcsnicmp |
| 80 |
|
| 81 |
// upper / lower |
| 82 |
#define _tcslwr _wcslwr |
| 83 |
#define _tcsupr _wcsupr |
| 84 |
#define _totlower towlower |
| 85 |
#define _totupper towupper |
| 86 |
|
| 87 |
// conversions to numbers |
| 88 |
#define _tcstoi64 _wcstoi64 |
| 89 |
#define _tcstol wcstol |
| 90 |
#define _tcstoul wcstoul |
| 91 |
#define _tstof _wtof |
| 92 |
#define _tstoi _wtoi |
| 93 |
#define _tstoi64 _wtoi64 |
| 94 |
#define _ttoi _wtoi |
| 95 |
#define _ttoi64 _wtoi64 |
| 96 |
#define _ttol _wtol |
| 97 |
|
| 98 |
// conversion from numbers to strings |
| 99 |
#define _itot _itow |
| 100 |
#define _ltot _ltow |
| 101 |
#define _i64tot _i64tow |
| 102 |
#define _ui64tot _ui64tow |
| 103 |
|
| 104 |
// file manipulations |
| 105 |
#define _tfopen _wfopen |
| 106 |
#define _topen _wopen |
| 107 |
#define _tremove _wremove |
| 108 |
#define _tunlink _wunlink |
| 109 |
|
| 110 |
// reading and writing to i/o |
| 111 |
#define _fgettc fgetwc |
| 112 |
#define _fgetts fgetws |
| 113 |
#define _fputts fputws |
| 114 |
#define _gettchar getwchar |
| 115 |
|
| 116 |
// directory |
| 117 |
#define _tchdir _wchdir |
| 118 |
|
| 119 |
// environment |
| 120 |
#define _tgetenv _wgetenv |
| 121 |
#define _tsystem _wsystem |
| 122 |
|
| 123 |
// time |
| 124 |
#define _tcsftime wcsftime |
| 125 |
|
| 126 |
#else // ANSI |
| 127 |
|
| 128 |
#ifndef _T |
| 129 |
#define _T(x) x |
| 130 |
#define _TEXT(x) x |
| 131 |
#endif |
| 132 |
|
| 133 |
#ifndef _TCHAR_DEFINED |
| 134 |
#define _TCHAR_DEFINED |
| 135 |
typedef char TCHAR; |
| 136 |
#endif |
| 137 |
|
| 138 |
// program |
| 139 |
#define _tenviron environ |
| 140 |
#define __targv __argv |
| 141 |
|
| 142 |
// printfs |
| 143 |
#define _ftprintf fprintf |
| 144 |
#define _sntprintf _snprintf |
| 145 |
#define _stprintf sprintf |
| 146 |
#define _tprintf printf |
| 147 |
#define _vftprintf vfprintf |
| 148 |
#define _vsntprintf _vsnprintf |
| 149 |
#define _vstprintf vsprintf |
| 150 |
|
| 151 |
// scanfs |
| 152 |
#define _tscanf scanf |
| 153 |
#define _stscanf sscanf |
| 154 |
|
| 155 |
// string manipulations |
| 156 |
#define _tcscat strcat |
| 157 |
#define _tcschr strchr |
| 158 |
#define _tcsclen strlen |
| 159 |
#define _tcscnlen strnlen |
| 160 |
#define _tcscpy strcpy |
| 161 |
#define _tcsdup _strdup |
| 162 |
#define _tcslen strlen |
| 163 |
#define _tcsnccpy strncpy |
| 164 |
#define _tcsrchr strrchr |
| 165 |
#define _tcsstr strstr |
| 166 |
#define _tcstok strtok |
| 167 |
|
| 168 |
// string comparisons |
| 169 |
#define _tcscmp strcmp |
| 170 |
#define _tcsicmp _stricmp |
| 171 |
#define _tcsncmp strncmp |
| 172 |
#define _tcsncicmp _strnicmp |
| 173 |
#define _tcsnicmp _strnicmp |
| 174 |
|
| 175 |
// upper / lower |
| 176 |
#define _tcslwr _strlwr |
| 177 |
#define _tcsupr _strupr |
| 178 |
|
| 179 |
#define _totupper toupper |
| 180 |
#define _totlower tolower |
| 181 |
|
| 182 |
// conversions to numbers |
| 183 |
#define _tcstol strtol |
| 184 |
#define _tcstoul strtoul |
| 185 |
#define _tstof atof |
| 186 |
#define _tstoi atoi |
| 187 |
#define _tstoi64 _atoi64 |
| 188 |
#define _tstoi64 _atoi64 |
| 189 |
#define _ttoi atoi |
| 190 |
#define _ttoi64 _atoi64 |
| 191 |
#define _ttol atol |
| 192 |
|
| 193 |
// conversion from numbers to strings |
| 194 |
#define _i64tot _i64toa |
| 195 |
#define _itot _itoa |
| 196 |
#define _ltot _ltoa |
| 197 |
#define _ui64tot _ui64toa |
| 198 |
|
| 199 |
// file manipulations |
| 200 |
#define _tfopen fopen |
| 201 |
#define _topen _open |
| 202 |
#define _tremove remove |
| 203 |
#define _tunlink _unlink |
| 204 |
|
| 205 |
// reading and writing to i/o |
| 206 |
#define _fgettc fgetc |
| 207 |
#define _fgetts fgets |
| 208 |
#define _fputts fputs |
| 209 |
#define _gettchar getchar |
| 210 |
|
| 211 |
// directory |
| 212 |
#define _tchdir _chdir |
| 213 |
|
| 214 |
// environment |
| 215 |
#define _tgetenv getenv |
| 216 |
#define _tsystem system |
| 217 |
|
| 218 |
// time |
| 219 |
#define _tcsftime strftime |
| 220 |
|
| 221 |
#endif |
| 222 |
|
| 223 |
// is functions (the same in Unicode / ANSI) |
| 224 |
#define _istgraph isgraph |
| 225 |
#define _istascii __isascii |
| 226 |
|
| 227 |
#define __TFILE__ _T(__FILE__) |
| 228 |
#define __TDATE__ _T(__DATE__) |
| 229 |
#define __TTIME__ _T(__TIME__) |