nsis_tchar.h 4.7 KB

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