1 #ifndef _WIMLIB_TCHAR_H
2 #define _WIMLIB_TCHAR_H
4 /* Functions to act on "tchar" strings, which have a platform-dependent encoding
5 * and character size. */
9 /* For Windows builds, the "tchar" type will be 2 bytes and will be equivalent
10 * to "wchar_t" and "utf16lechar". All indicate one code unit of a UTF16-LE
12 typedef wchar_t tchar;
13 # define TCHAR_IS_UTF16LE 1
14 # define _T(text) L##text
15 # define T(text) _T(text) /* Make a string literal into a wide string */
16 # define TS "ls" /* Format a string of "tchar" */
17 # define TC "lc" /* Format a "tchar" */
19 /* For Windows builds, the following definitions replace the "tchar" functions
20 * with the "wide-character" functions. */
21 # define tmemchr wmemchr
22 # define tmemcpy wmemcpy
23 # define tmemmove wmemmove
24 # define tmempcpy wmempcpy
25 # define tstrcat wcscat
26 # define tstrcpy wcscpy
27 # define tprintf wprintf
28 # define tsprintf swprintf
29 # define tfprintf fwprintf
30 # define tvfprintf vfwprintf
31 # define istalpha(c) iswalpha((wchar_t)(c))
32 # define istspace(c) iswspace((wchar_t)(c))
33 # define totlower(c) towlower((wchar_t)(c))
34 # define tstrcmp wcscmp
35 # define tstrncmp wcsncmp
36 # define tstrchr wcschr
37 # define tstrpbrk wcspbrk
38 # define tstrrchr wcsrchr
39 # define tstrlen wcslen
40 # define tmemcmp wmemcmp
41 # define tstrcasecmp _wcsicmp
42 # define tstrftime wcsftime
43 # define tputchar putwchar
46 # define tfputs fputws
47 # define tfopen _wfopen
49 # define tstat _wstati64
50 # define tstrtol wcstol
51 # define tstrtod wcstod
52 # define tstrtoul wcstoul
53 # define tstrtoull wcstoull
54 # define tunlink _wunlink
55 # define tstrerror _wcserror
56 # define taccess _waccess
57 # define tstrdup wcsdup
58 # define ttempnam _wtempnam
59 # define tgetenv _wgetenv
60 /* The following "tchar" functions do not have exact wide-character equivalents
61 * on Windows so require parameter rearrangement or redirection to a replacement
62 * function defined ourselves. */
63 # define TSTRDUP WCSDUP
64 # define tmkdir(path, mode) _wmkdir(path)
65 # define tstrerror_r win32_strerror_r_replacement
66 # define trename win32_rename_replacement
67 # define tglob win32_wglob
69 /* For non-Windows builds, the "tchar" type will be one byte and will specify a
70 * string in the locale-dependent multibyte encoding. However, only UTF-8 is
71 * well supported in this library. */
73 # define TCHAR_IS_UTF16LE 0
74 # define T(text) text /* In this case, strings of "tchar" are simply strings of
76 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
78 # define TC "c" /* Print a single character */
79 /* For non-Windows builds, replace the "tchar" functions with the regular old
80 * string functions. */
81 # define tmemchr memchr
82 # define tmemcpy memcpy
83 # define tmemmove memmove
84 # define tmempcpy mempcpy
85 # define tstrcat strcat
86 # define tstrcpy strcpy
87 # define tprintf printf
88 # define tsprintf sprintf
89 # define tfprintf fprintf
90 # define tvfprintf vfprintf
91 # define istalpha(c) isalpha((unsigned char)(c))
92 # define istspace(c) isspace((unsigned char)(c))
93 # define totlower(c) tolower((unsigned char)(c))
94 # define tstrcmp strcmp
95 # define tstrncmp strncmp
96 # define tstrchr strchr
97 # define tstrpbrk strpbrk
98 # define tstrrchr strrchr
99 # define tstrlen strlen
100 # define tmemcmp memcmp
101 # define tstrcasecmp strcasecmp
102 # define tstrftime strftime
103 # define tputchar putchar
106 # define tfputs fputs
107 # define tfopen fopen
110 # define tunlink unlink
111 # define tstrerror strerror
112 # define tstrtol strtol
113 # define tstrtod strtod
114 # define tstrtoul strtoul
115 # define tstrtoull strtoull
116 # define tmkdir mkdir
117 # define tstrdup strdup
118 # define ttempnam tempnam
119 # define tgetenv getenv
120 # define TSTRDUP STRDUP
121 # define tstrerror_r strerror_r
122 # define trename rename
123 # define taccess access
125 #endif /* !__WIN32__ */
127 #endif /* _WIMLIB_TCHAR_H */