1 /***
2 *tchar.h - definitions for generic international text functions
3 *
4 *           Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 *Purpose:
7 *           Definitions for generic international functions, mostly defines
8 *           which map string/formatted-io/ctype functions to char, wchar_t, or
9 *           MBCS versions.  To be used for compatibility between single-byte,
10 *           multi-byte and Unicode text models.
11 *
12 *           [Public]
13 *
14 ****/
15
16 #if        _MSC_VER > 1000
17 #pragma once
18 #endif
19
20 #include <crtdefs.h>
21
22 #ifndef _INC_TCHAR
23 #define _INC_TCHAR
24
25 #ifdef _STRSAFE_H_INCLUDED_
26 #error Need to include strsafe.h after tchar.h
27 #endif
28
29 #ifdef  _MSC_VER
30 #pragma warning(disable:4514)           /* disable unwanted C++ /W4 warning */
31 /* #pragma warning(default:4514) */ /* use this to reenable, if necessary */
32 #endif  /* _MSC_VER */
33
34 /* Notes */
35
36 /* There is no:
37  *          _tcscat_l
38  *          _tcscpy_l
39  * because mbscat and mbscpy just behave like strcat and strcpy,
40  * so no special locale-specific behavior is needed.
41  */
42
43 /* Functions like:
44  *          _strncat_l
45  *          _strncat_s_l
46  * are only available if ANSI is defined (i.e. no _UNICODE nor _MBCS),
47  * because these functions are only accessible through the _tcs macros.
48  */
49
50 #ifdef  __cplusplus
51 extern "C" {
52 #endif
53
54 #ifndef _CRT_FAR_MAPPINGS_NO_DEPRECATE
55 /*
56 Long ago, these f prefix text functions referred to handling of text in segmented architectures. Ever since the move
57 to Win32 they have been obsolete names, but we kept them around as aliases. Now that we have a deprecation 
58 mechanism we can warn about them. You should switch to the identical function without the f prefix.
59 */
60 #pragma deprecated("_ftcscat")
61 #pragma deprecated("_ftcschr")
62 #pragma deprecated("_ftcscpy")
63 #pragma deprecated("_ftcscspn")
64 #pragma deprecated("_ftcslen")
65 #pragma deprecated("_ftcsncat")
66 #pragma deprecated("_ftcsncpy")
67 #pragma deprecated("_ftcspbrk")
68 #pragma deprecated("_ftcsrchr")
69 #pragma deprecated("_ftcsspn")
70 #pragma deprecated("_ftcsstr")
71 #pragma deprecated("_ftcstok")
72 #pragma deprecated("_ftcsdup")
73 #pragma deprecated("_ftcsnset")
74 #pragma deprecated("_ftcsrev")
75 #pragma deprecated("_ftcsset")
76 #pragma deprecated("_ftcscmp")
77 #pragma deprecated("_ftcsicmp")
78 #pragma deprecated("_ftcsnccmp")
79 #pragma deprecated("_ftcsncmp")
80 #pragma deprecated("_ftcsncicmp")
81 #pragma deprecated("_ftcsnicmp")
82 #pragma deprecated("_ftcscoll")
83 #pragma deprecated("_ftcsicoll")
84 #pragma deprecated("_ftcsnccoll")
85 #pragma deprecated("_ftcsncoll")
86 #pragma deprecated("_ftcsncicoll")
87 #pragma deprecated("_ftcsnicoll")
88 #pragma deprecated("_ftcsclen")
89 #pragma deprecated("_ftcsnccat")
90 #pragma deprecated("_ftcsnccpy")
91 #pragma deprecated("_ftcsncset")
92 #pragma deprecated("_ftcsdec")
93 #pragma deprecated("_ftcsinc")
94 #pragma deprecated("_ftcsnbcnt")
95 #pragma deprecated("_ftcsnccnt")
96 #pragma deprecated("_ftcsnextc")
97 #pragma deprecated("_ftcsninc")
98 #pragma deprecated("_ftcsspnp")
99 #pragma deprecated("_ftcslwr")
100 #pragma deprecated("_ftcsupr")
101 #pragma deprecated("_ftclen")
102 #pragma deprecated("_ftccpy")
103 #pragma deprecated("_ftccmp")
104 #endif /* ndef _CRT_FAR_MAPPINGS_NO_DEPRECATE */
105
106 #define _ftcscat      _tcscat
107 #define _ftcschr      _tcschr
108 #define _ftcscpy      _tcscpy
109 #define _ftcscspn     _tcscspn
110 #define _ftcslen      _tcslen
111 #define _ftcsncat     _tcsncat
112 #define _ftcsncpy     _tcsncpy
113 #define _ftcspbrk     _tcspbrk
114 #define _ftcsrchr     _tcsrchr
115 #define _ftcsspn      _tcsspn
116 #define _ftcsstr      _tcsstr
117 #define _ftcstok      _tcstok
118
119 #define _ftcsdup      _tcsdup
120 #define _ftcsnset     _tcsnset
121 #define _ftcsrev      _tcsrev
122 #define _ftcsset      _tcsset
123
124 #define _ftcscmp          _tcscmp
125 #define _ftcsicmp        _tcsicmp
126 #define _ftcsnccmp      _tcsnccmp
127 #define _ftcsncmp        _tcsncmp
128 #define _ftcsncicmp     _tcsncicmp
129 #define _ftcsnicmp      _tcsnicmp
130
131 #define _ftcscoll        _tcscoll
132 #define _ftcsicoll      _tcsicoll
133 #define _ftcsnccoll     _tcsnccoll
134 #define _ftcsncoll      _tcsncoll
135 #define _ftcsncicoll  _tcsncicoll
136 #define _ftcsnicoll     _tcsnicoll
137
138 /* Redundant "logical-character" mappings */
139
140 #define _ftcsclen     _tcsclen
141 #define _ftcsnccat  _tcsnccat
142 #define _ftcsnccpy  _tcsnccpy
143 #define _ftcsncset  _tcsncset
144
145 #define _ftcsdec      _tcsdec
146 #define _ftcsinc      _tcsinc
147 #define _ftcsnbcnt  _tcsnbcnt
148 #define _ftcsnccnt  _tcsnccnt
149 #define _ftcsnextc  _tcsnextc
150 #define _ftcsninc     _tcsninc
151 #define _ftcsspnp     _tcsspnp
152
153 #define _ftcslwr      _tcslwr
154 #define _ftcsupr      _tcsupr
155
156 #define _ftclen        _tclen
157 #define _ftccpy        _tccpy
158 #define _ftccmp        _tccmp
159
160 #ifndef _CONST_RETURN
161 #ifdef  __cplusplus
162 #define _CONST_RETURN  const
163 #define _CRT_CONST_CORRECT_OVERLOADS
164 #else
165 #define _CONST_RETURN
166 #endif
167 #endif
168
169 /* For backwards compatibility */
170 #define _WConst_return _CONST_RETURN
171
172 #ifdef  _UNICODE
173
174 #ifdef  __cplusplus
175 }     /* ... extern "C" */
176 #endif
177
178 /* ++++++++++++++++++++ UNICODE ++++++++++++++++++++ */
179
180 #include <wchar.h>
181
182 #ifdef  __cplusplus
183 extern "C" {
184 #endif
185
186 #ifndef _WCTYPE_T_DEFINED
187 typedef unsigned short wint_t;
188 typedef unsigned short wctype_t;
189 #define _WCTYPE_T_DEFINED
190 #endif
191
192 #ifndef __TCHAR_DEFINED
193 typedef wchar_t        _TCHAR;
194 typedef wchar_t        _TSCHAR;
195 typedef wchar_t        _TUCHAR;
196 typedef wchar_t        _TXCHAR;
197 typedef wint_t          _TINT;
198 #define __TCHAR_DEFINED
199 #endif
200
201 #ifndef _TCHAR_DEFINED
202 #if        !__STDC__
203 typedef wchar_t        TCHAR;
204 #endif
205 #define _TCHAR_DEFINED
206 #endif
207
208 #define _TEOF           WEOF
209
210 #define __T(x)          L ## x
211
212
213 /* Program */
214
215 #define _tmain          wmain
216 #define _tWinMain     wWinMain
217 #define _tenviron     _wenviron
218 #define __targv        __wargv
219
220 /* Formatted i/o */
221
222 #define _tprintf             wprintf
223 #define _tprintf_l          _wprintf_l
224 #define _tprintf_s          wprintf_s
225 #define _tprintf_s_l      _wprintf_s_l
226 #define _tprintf_p          _wprintf_p
227 #define _tprintf_p_l      _wprintf_p_l
228 #define _tcprintf           _cwprintf
229 #define _tcprintf_l        _cwprintf_l
230 #define _tcprintf_s        _cwprintf_s
231 #define _tcprintf_s_l     _cwprintf_s_l
232 #define _tcprintf_p        _cwprintf_p
233 #define _tcprintf_p_l     _cwprintf_p_l
234 #define _vtcprintf          _vcwprintf
235 #define _vtcprintf_l      _vcwprintf_l
236 #define _vtcprintf_s      _vcwprintf_s
237 #define _vtcprintf_s_l  _vcwprintf_s_l
238 #define _vtcprintf_p      _vcwprintf_p
239 #define _vtcprintf_p_l  _vcwprintf_p_l
240 #define _ftprintf           fwprintf
241 #define _ftprintf_l        _fwprintf_l
242 #define _ftprintf_s        fwprintf_s
243 #define _ftprintf_s_l     _fwprintf_s_l
244 #define _ftprintf_p        _fwprintf_p
245 #define _ftprintf_p_l     _fwprintf_p_l
246 #define _stprintf           _swprintf
247 #define _stprintf_l        __swprintf_l
248 #define _stprintf_s        swprintf_s
249 #define _stprintf_s_l     _swprintf_s_l
250 #define _stprintf_p        _swprintf_p
251 #define _stprintf_p_l     _swprintf_p_l
252 #define _sctprintf          _scwprintf
253 #define _sctprintf_l      _scwprintf_l
254 #define _sctprintf_p      _scwprintf_p
255 #define _sctprintf_p_l  _scwprintf_p_l
256 #define _sntprintf          _snwprintf
257 #define _sntprintf_l      _snwprintf_l
258 #define _sntprintf_s      _snwprintf_s
259 #define _sntprintf_s_l  _snwprintf_s_l
260 #define _vtprintf           vwprintf
261 #define _vtprintf_l        _vwprintf_l
262 #define _vtprintf_s        vwprintf_s
263 #define _vtprintf_s_l     _vwprintf_s_l
264 #define _vtprintf_p        _vwprintf_p
265 #define _vtprintf_p_l     _vwprintf_p_l
266 #define _vftprintf          vfwprintf
267 #define _vftprintf_l      _vfwprintf_l
268 #define _vftprintf_s      vfwprintf_s
269 #define _vftprintf_s_l  _vfwprintf_s_l
270 #define _vftprintf_p      _vfwprintf_p
271 #define _vftprintf_p_l  _vfwprintf_p_l
272 #define _vstprintf          _vswprintf
273 #define _vstprintf_l      _vswprintf_l
274 #define _vstprintf_s      vswprintf_s
275 #define _vstprintf_s_l  _vswprintf_s_l
276 #define _vstprintf_p      _vswprintf_p
277 #define _vstprintf_p_l  _vswprintf_p_l
278 #define _vsctprintf        _vscwprintf
279 #define _vsctprintf_l     _vscwprintf_l
280 #define _vsctprintf_p     _vscwprintf_p
281 #define _vsctprintf_p_l _vscwprintf_p_l
282 #define _vsntprintf        _vsnwprintf
283 #define _vsntprintf_l     _vsnwprintf_l
284 #define _vsntprintf_s     _vsnwprintf_s
285 #define _vsntprintf_s_l _vsnwprintf_s_l
286
287 #define _tscanf               wscanf
288 #define _tscanf_l           _wscanf_l
289 #define _tscanf_s           wscanf_s
290 #define _tscanf_s_l        _wscanf_s_l
291 #define _tcscanf             _cwscanf
292 #define _tcscanf_l          _cwscanf_l
293 #define _tcscanf_s          _cwscanf_s
294 #define _tcscanf_s_l      _cwscanf_s_l
295 #define _ftscanf             fwscanf
296 #define _ftscanf_l          _fwscanf_l
297 #define _ftscanf_s          fwscanf_s
298 #define _ftscanf_s_l      _fwscanf_s_l
299 #define _stscanf             swscanf
300 #define _stscanf_l          _swscanf_l
301 #define _stscanf_s          swscanf_s
302 #define _stscanf_s_l      _swscanf_s_l
303 #define _sntscanf           _snwscanf
304 #define _sntscanf_l        _snwscanf_l
305 #define _sntscanf_s        _snwscanf_s
306 #define _sntscanf_s_l     _snwscanf_s_l
307
308
309 /* Unformatted i/o */
310
311 #define _fgettc               fgetwc
312 #define _fgettc_nolock  _fgetwc_nolock
313 #define _fgettchar          _fgetwchar
314 #define _fgetts               fgetws
315 #define _fputtc               fputwc
316 #define _fputtc_nolock  _fputwc_nolock
317 #define _fputtchar          _fputwchar
318 #define _fputts               fputws
319 #define _cputts               _cputws
320 #define _cgetts               _cgetws
321 #define _cgetts_s           _cgetws_s
322 #define _gettc                getwc
323 #define _gettc_nolock     _getwc_nolock
324 #define _gettch               _getwch
325 #define _gettch_nolock  _getwch_nolock
326 #define _gettche             _getwche
327 #define _gettche_nolock _getwche_nolock
328 #define _gettchar           getwchar
329 #define _gettchar_nolock _getwchar_nolock
330 #define _getts                _getws
331 #define _getts_s             _getws_s
332 #define _puttc                putwc
333 #define _puttc_nolock     _putwc_nolock
334 #define _puttchar           putwchar
335 #define _puttchar_nolock _putwchar_nolock
336 #define _puttch               _putwch
337 #define _puttch_nolock  _putwch_nolock
338 #define _putts                _putws
339 #define _ungettc             ungetwc
340 #define _ungettc_nolock _ungetwc_nolock
341 #define _ungettch           _ungetwch
342 #define _ungettch_nolock _ungetwch_nolock
343
344
345 /* String conversion functions */
346
347 #define _tcstod        wcstod
348 #define _tcstol        wcstol
349 #define _tcstoul      wcstoul
350 #define _tcstoi64     _wcstoi64
351 #define _tcstoui64  _wcstoui64
352 #define _tstof          _wtof
353 #define _tstol          _wtol
354 #define _tstoi          _wtoi
355 #define _tstoi64      _wtoi64
356 #define _tcstod_l        _wcstod_l
357 #define _tcstol_l        _wcstol_l
358 #define _tcstoul_l      _wcstoul_l
359 #define _tcstoi64_l     _wcstoi64_l
360 #define _tcstoui64_l  _wcstoui64_l
361 #define _tstof_l          _wtof_l
362 #define _tstol_l          _wtol_l
363 #define _tstoi_l          _wtoi_l
364 #define _tstoi64_l      _wtoi64_l
365
366 #define _itot_s        _itow_s
367 #define _ltot_s        _ltow_s
368 #define _ultot_s      _ultow_s
369 #define _itot           _itow
370 #define _ltot           _ltow
371 #define _ultot          _ultow
372 #define _ttoi           _wtoi
373 #define _ttol           _wtol
374
375 #define _ttoi64        _wtoi64
376 #define _i64tot_s     _i64tow_s
377 #define _ui64tot_s  _ui64tow_s
378 #define _i64tot        _i64tow
379 #define _ui64tot      _ui64tow
380
381 /* String functions */
382
383 #define _tcscat               wcscat
384 #define _tcscat_s           wcscat_s
385 #define _tcschr               wcschr
386 #define _tcscpy               wcscpy
387 #define _tcscpy_s           wcscpy_s
388 #define _tcscspn             wcscspn
389 #define _tcslen               wcslen
390 #define _tcsnlen             wcsnlen
391 #define _tcsncat             wcsncat
392 #define _tcsncat_s          wcsncat_s
393 #define _tcsncat_l          _wcsncat_l
394 #define _tcsncat_s_l      _wcsncat_s_l
395 #define _tcsncpy             wcsncpy
396 #define _tcsncpy_s          wcsncpy_s
397 #define _tcsncpy_l          _wcsncpy_l
398 #define _tcsncpy_s_l      _wcsncpy_s_l
399 #define _tcspbrk             wcspbrk
400 #define _tcsrchr             wcsrchr
401 #define _tcsspn               wcsspn
402 #define _tcsstr               wcsstr
403 #define _tcstok               wcstok
404 #define _tcstok_s           wcstok_s
405 #define _tcstok_l           _wcstok_l
406 #define _tcstok_s_l        _wcstok_s_l
407 #define _tcserror           _wcserror
408 #define _tcserror_s        _wcserror_s
409 #define __tcserror          __wcserror
410 #define __tcserror_s      __wcserror_s
411
412 #define _tcsdup               _wcsdup
413 #define _tcsnset             _wcsnset
414 #define _tcsnset_s          _wcsnset_s
415 #define _tcsnset_l          _wcsnset_l
416 #define _tcsnset_s_l      _wcsnset_s_l
417 #define _tcsrev               _wcsrev
418 #define _tcsset               _wcsset
419 #define _tcsset_s           _wcsset_s
420 #define _tcsset_l           _wcsset_l
421 #define _tcsset_s_l        _wcsset_s_l
422
423 #define _tcscmp               wcscmp
424 #define _tcsicmp             _wcsicmp
425 #define _tcsicmp_l          _wcsicmp_l
426 #define _tcsnccmp           wcsncmp
427 #define _tcsncmp             wcsncmp
428 #define _tcsncicmp          _wcsnicmp
429 #define _tcsncicmp_l      _wcsnicmp_l
430 #define _tcsnicmp           _wcsnicmp
431 #define _tcsnicmp_l        _wcsnicmp_l
432
433 #define _tcscoll             wcscoll
434 #define _tcscoll_l          _wcscoll_l
435 #define _tcsicoll           _wcsicoll
436 #define _tcsicoll_l        _wcsicoll_l
437 #define _tcsnccoll          _wcsncoll
438 #define _tcsnccoll_l      _wcsncoll_l
439 #define _tcsncoll           _wcsncoll
440 #define _tcsncoll_l        _wcsncoll_l
441 #define _tcsncicoll        _wcsnicoll
442 #define _tcsncicoll_l     _wcsnicoll_l
443 #define _tcsnicoll          _wcsnicoll
444 #define _tcsnicoll_l      _wcsnicoll_l
445
446 #ifdef _DEBUG
447 #define _tcsdup_dbg _wcsdup_dbg
448 #endif
449
450 /* Execute functions */
451
452 #define _texecl        _wexecl
453 #define _texecle      _wexecle
454 #define _texeclp      _wexeclp
455 #define _texeclpe     _wexeclpe
456 #define _texecv        _wexecv
457 #define _texecve      _wexecve
458 #define _texecvp      _wexecvp
459 #define _texecvpe     _wexecvpe
460
461 #define _tspawnl      _wspawnl
462 #define _tspawnle     _wspawnle
463 #define _tspawnlp     _wspawnlp
464 #define _tspawnlpe  _wspawnlpe
465 #define _tspawnv      _wspawnv
466 #define _tspawnve     _wspawnve
467 #define _tspawnvp     _wspawnvp
468 #define _tspawnvp     _wspawnvp
469 #define _tspawnvpe  _wspawnvpe
470
471 #define _tsystem      _wsystem
472
473
474 /* Time functions */
475
476 #define _tasctime     _wasctime
477 #define _tctime        _wctime
478 #define _tctime32     _wctime32
479 #define _tctime64     _wctime64
480 #define _tstrdate     _wstrdate
481 #define _tstrtime     _wstrtime
482 #define _tutime        _wutime
483 #define _tutime32     _wutime32
484 #define _tutime64     _wutime64
485 #define _tcsftime     wcsftime
486 #define _tcsftime_l _wcsftime_l
487
488 #define _tasctime_s     _wasctime_s
489 #define _tctime_s        _wctime_s
490 #define _tctime32_s     _wctime32_s
491 #define _tctime64_s     _wctime64_s
492 #define _tstrdate_s     _wstrdate_s
493 #define _tstrtime_s     _wstrtime_s
494
495 /* Directory functions */
496
497 #define _tchdir                     _wchdir
498 #define _tgetcwd                    _wgetcwd
499 #define _tgetdcwd                  _wgetdcwd
500 #define _tgetdcwd_nolock      _wgetdcwd_nolock
501 #define _tmkdir                     _wmkdir
502 #define _trmdir                     _wrmdir
503
504 #ifdef _DEBUG
505 #define _tgetcwd_dbg             _wgetcwd_dbg
506 #define _tgetdcwd_dbg           _wgetdcwd_dbg
507 #define _tgetdcwd_lk_dbg      _wgetdcwd_lk_dbg
508 #endif
509
510 /* Environment/Path functions */
511
512 #define _tfullpath          _wfullpath
513 #define _tgetenv             _wgetenv
514 #define _tgetenv_s          _wgetenv_s
515 #define _tdupenv_s          _wdupenv_s
516 #define _tmakepath          _wmakepath
517 #define _tmakepath_s      _wmakepath_s
518 #define _tpgmptr             _wpgmptr
519 #define _get_tpgmptr      _get_wpgmptr
520 #define _tputenv             _wputenv
521 #define _tputenv_s          _wputenv_s
522 #define _tsearchenv        _wsearchenv
523 #define _tsearchenv_s     _wsearchenv_s
524 #define _tsplitpath        _wsplitpath
525 #define _tsplitpath_s     _wsplitpath_s
526
527 #ifdef _DEBUG
528 #define _tfullpath_dbg  _wfullpath_dbg
529 #define _tdupenv_s_dbg  _wdupenv_s_dbg
530 #endif
531
532 /* Stdio functions */
533
534 #define _tfdopen      _wfdopen
535 #define _tfsopen      _wfsopen
536 #define _tfopen        _wfopen
537 #define _tfopen_s     _wfopen_s
538 #define _tfreopen     _wfreopen
539 #define _tfreopen_s _wfreopen_s
540 #define _tperror      _wperror
541 #define _tpopen        _wpopen
542 #define _ttempnam     _wtempnam
543 #define _ttmpnam      _wtmpnam
544 #define _ttmpnam_s  _wtmpnam_s
545
546 #ifdef _DEBUG
547 #define _ttempnam_dbg     _wtempnam_dbg
548 #endif
549
550
551 /* Io functions */
552
553 #define _taccess      _waccess
554 #define _taccess_s  _waccess_s
555 #define _tchmod        _wchmod
556 #define _tcreat        _wcreat
557 #define _tfindfirst           _wfindfirst
558 #define _tfindfirst32        _wfindfirst32
559 #define _tfindfirst64        _wfindfirst64
560 #define _tfindfirsti64      _wfindfirsti64
561 #define _tfindfirst32i64  _wfindfirst32i64
562 #define _tfindfirst64i32  _wfindfirst64i32
563 #define _tfindnext             _wfindnext
564 #define _tfindnext32          _wfindnext32
565 #define _tfindnext64          _wfindnext64
566 #define _tfindnexti64        _wfindnexti64
567 #define _tfindnext32i64     _wfindnext32i64
568 #define _tfindnext64i32     _wfindnext64i32
569 #define _tmktemp      _wmktemp
570 #define _tmktemp_s  _wmktemp_s
571 #define _topen          _wopen
572 #define _tremove      _wremove
573 #define _trename      _wrename
574 #define _tsopen        _wsopen
575 #define _tsopen_s     _wsopen_s
576 #define _tunlink      _wunlink
577
578 #define _tfinddata_t          _wfinddata_t
579 #define _tfinddata32_t      _wfinddata32_t
580 #define _tfinddata64_t      _wfinddata64_t
581 #define _tfinddatai64_t     _wfinddatai64_t
582 #define _tfinddata32i64_t _wfinddata32i64_t
583 #define _tfinddata64i32_t _wfinddata64i32_t
584
585
586 /* Stat functions */
587
588 #define _tstat          _wstat
589 #define _tstat32      _wstat32
590 #define _tstat32i64 _wstat32i64
591 #define _tstat64      _wstat64
592 #define _tstat64i32 _wstat64i32
593 #define _tstati64     _wstati64
594
595
596 /* Setlocale functions */
597
598 #define _tsetlocale _wsetlocale
599
600
601 /* Redundant "logical-character" mappings */
602
603 #define _tcsclen             wcslen
604 #define _tcscnlen           wcsnlen
605 #define _tcsclen_l(_String, _Locale) wcslen(_String)
606 #define _tcscnlen_l(_String, _Max_count, _Locale) wcsnlen((_String), (_Max_count))
607 #define _tcsnccat           wcsncat
608 #define _tcsnccat_s        wcsncat_s
609 #define _tcsnccat_l        _wcsncat_l
610 #define _tcsnccat_s_l     _wcsncat_s_l
611 #define _tcsnccpy           wcsncpy
612 #define _tcsnccpy_s        wcsncpy_s
613 #define _tcsnccpy_l        _wcsncpy_l
614 #define _tcsnccpy_s_l     _wcsncpy_s_l
615 #define _tcsncset           _wcsnset
616 #define _tcsncset_s        _wcsnset_s
617 #define _tcsncset_l        _wcsnset_l
618 #define _tcsncset_s_l     _wcsnset_s_l
619
620 #define _tcsdec        _wcsdec
621 #define _tcsinc        _wcsinc
622 #define _tcsnbcnt     _wcsncnt
623 #define _tcsnccnt     _wcsncnt
624 #define _tcsnextc     _wcsnextc
625 #define _tcsninc      _wcsninc
626 #define _tcsspnp      _wcsspnp
627
628 #define _tcslwr        _wcslwr
629 #define _tcslwr_l     _wcslwr_l
630 #define _tcslwr_s     _wcslwr_s
631 #define _tcslwr_s_l _wcslwr_s_l
632 #define _tcsupr        _wcsupr
633 #define _tcsupr_l     _wcsupr_l
634 #define _tcsupr_s     _wcsupr_s
635 #define _tcsupr_s_l _wcsupr_s_l
636 #define _tcsxfrm      wcsxfrm
637 #define _tcsxfrm_l  _wcsxfrm_l
638
639
640 #if        __STDC__ || defined(_NO_INLINING)
641 #define _tclen(_pc) (1)
642 #define _tccpy(_pc1,_cpc2) ((*(_pc1) = *(_cpc2)))
643 #define _tccpy_l(_pc1,_cpc2,_locale) _tccpy((_pc1),(_cpc2))
644 #define _tccmp(_cpc1,_cpc2) ((*(_cpc1))-(*(_cpc2)))
645 #else     /* __STDC__ */
646 _Check_return_ __inline size_t __CRTDECL _tclen(_In_z_ const wchar_t *_Cpc)
647 { 
648       /* avoid compiler warning */
649       (void *)_Cpc;
650       return 1;
651 }
652 __inline void __CRTDECL _tccpy(_Out_ wchar_t *_Pc1, _In_z_ const wchar_t *_Cpc2) { *_Pc1 = (wchar_t)*_Cpc2; }
653 __inline void __CRTDECL _tccpy_l(_Out_ wchar_t *_Pc1, _In_z_ const wchar_t *_Cpc2, _In_opt_ _locale_t _Locale)
654 {
655       _CRT_UNUSED(_Locale);
656       _tccpy(_Pc1, _Cpc2);
657 }
658 _Check_return_ __inline int __CRTDECL _tccmp(_In_z_ const wchar_t *_Cpc1, _In_z_ const wchar_t *_Cpc2) { return (int) ((*_Cpc1)-(*_Cpc2)); }
659 #endif  /* __STDC__ */
660
661 /* ctype functions */
662
663 #define _istalnum     iswalnum
664 #define _istalnum_l     _iswalnum_l
665 #define _istalpha     iswalpha
666 #define _istalpha_l     _iswalpha_l
667 #define _istascii     iswascii
668 #define _istcntrl     iswcntrl
669 #define _istcntrl_l     _iswcntrl_l
670 #define _istdigit     iswdigit
671 #define _istdigit_l     _iswdigit_l
672 #define _istgraph     iswgraph
673 #define _istgraph_l     _iswgraph_l
674 #define _istlower     iswlower
675 #define _istlower_l     _iswlower_l
676 #define _istprint     iswprint
677 #define _istprint_l     _iswprint_l
678 #define _istpunct     iswpunct
679 #define _istpunct_l     _iswpunct_l
680 #define _istspace     iswspace
681 #define _istspace_l     _iswspace_l
682 #define _istupper     iswupper
683 #define _istupper_l     _iswupper_l
684 #define _istxdigit  iswxdigit
685 #define _istxdigit_l  _iswxdigit_l
686
687 #define _totupper     towupper
688 #define _totupper_l     _towupper_l
689 #define _totlower     towlower
690 #define _totlower_l     _towlower_l
691
692 #define _istlegal(_Char)                          (1)
693 #define _istlead(_Char)                            (0)
694 #define _istleadbyte(_Char)                     (0)
695 #define _istleadbyte_l(_Char, _Locale)  (0)
696
697
698 #if        __STDC__ || defined(_NO_INLINING)
699 #define _wcsdec(_cpc1, _cpc2) ((_cpc1)>=(_cpc2) ? NULL : (_cpc2)-1)
700 #define _wcsinc(_pc)      ((_pc)+1)
701 #define _wcsnextc(_cpc) ((unsigned int) *(_cpc))
702 #define _wcsninc(_pc, _sz) (((_pc)+(_sz)))
703 _Check_return_ _CRTIMP size_t __cdecl __wcsncnt(_In_count_(_MaxCount) _Pre_z_ const wchar_t * _Str, _In_ size_t _MaxCount);
704 #define _wcsncnt(_cpc, _sz) (__wcsncnt(_cpc,_sz))
705 #define _wcsspnp(_cpc1, _cpc2)                                                                                                (_cpc1==NULL ? NULL : ((*((_cpc1)+wcsspn(_cpc1,_cpc2))) ? ((_cpc1)+wcsspn(_cpc1,_cpc2)) : NULL))
706 #define _wcsncpy_l(_Destination, _Source, _Count, _Locale)                                                  (wcsncpy(_Destination, _Source, _Count))
707 #if __STDC_WANT_SECURE_LIB__
708 #define _wcsncpy_s_l(_Destination, _Destination_size_chars, _Source, _Count, _Locale)     (wcsncpy_s(_Destination, _Destination_size_chars, _Source, _Count))
709 #endif
710 #define _wcsncat_l(_Destination, _Source, _Count, _Locale)                                                  (wcsncat(_Destination, _Source, _Count))
711 #if __STDC_WANT_SECURE_LIB__
712 #define _wcsncat_s_l(_Destination, _Destination_size_chars, _Source, _Count, _Locale)     (wcsncat_s(_Destination, _Destination_size_chars, _Source, _Count))
713 #endif
714 #define _wcstok_l(_String, _Delimiters, _Locale)                                                                  (wcstok(_String, _Delimiters))
715 #define _wcstok_s_l(_String, _Delimiters, _Current_position, _Locale)                               (wcstok_s(_String, _Delimiters, _Current_position))
716 #define _wcsnset_l(_Destination, _Value, _Count, _Locale)                                                   (_wcsnset(_Destination, _Value, _Count))
717 #define _wcsnset_s_l(_Destination, _Destination_size_chars, _Value, _Count, _Locale)      (_wcsnset_s(_Destination, _Destination_size_chars, _Value, _Count))
718 #define _wcsset_l(_Destination, _Value, _Locale)                                                                  (_wcsset(_Destination, _Value))
719 #define _wcsset_s_l(_Destination, _Destination_size_chars, _Value, _Locale)                     (_wcsset_s(_Destination, _Destination_size_chars, _Value))
720 #else     /* __STDC__ */
721 _Check_return_ __inline wchar_t * __CRTDECL _wcsdec(_In_z_ const wchar_t * _Cpc1, _In_z_ const wchar_t * _Cpc2) { return (wchar_t *)((_Cpc1)>=(_Cpc2) ? NULL : ((_Cpc2)-1)); }
722 _Check_return_ __inline wchar_t * __CRTDECL _wcsinc(_In_z_ const wchar_t * _Pc) { return (wchar_t *)(_Pc+1); }
723 _Check_return_ __inline unsigned int __CRTDECL _wcsnextc(_In_z_ const wchar_t * _Cpc) { return (unsigned int)*_Cpc; }
724 _Check_return_ __inline wchar_t * __CRTDECL _wcsninc(_In_z_ const wchar_t * _Pc, _In_ size_t _Sz) { return (wchar_t *)(_Pc+_Sz); }
725 _Check_return_ __inline size_t __CRTDECL _wcsncnt( _In_count_(_Cnt) _Pre_z_ const wchar_t * _String, _In_ size_t _Cnt) 
726 { 
727              size_t n = _Cnt; 
728              wchar_t *cp = (wchar_t *)_String; 
729              while (n-- && *cp) 
730                           cp++; 
731              return _Cnt - n - 1; 
732 }
733 _Check_return_ __inline wchar_t * __CRTDECL _wcsspnp
734 ( 
735       _In_z_ const wchar_t * _Cpc1, 
736       _In_z_ const wchar_t * _Cpc2
737 )
738 {
739       return _Cpc1==NULL ? NULL : ((*(_Cpc1 += wcsspn(_Cpc1,_Cpc2))!='\0') ? (wchar_t*)_Cpc1 : NULL); 
740 }
741
742 #if __STDC_WANT_SECURE_LIB__
743 _Check_return_wat_ __inline errno_t __CRTDECL _wcsncpy_s_l(_Out_z_cap_(_Destination_size_chars) wchar_t *_Destination, _In_ size_t _Destination_size_chars, _In_z_ const wchar_t *_Source, _In_ size_t _Count, _In_opt_ _locale_t _Locale)
744 {
745       _CRT_UNUSED(_Locale);
746       return wcsncpy_s(_Destination, _Destination_size_chars, _Source, _Count);
747 }
748 #endif
749
750 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(errno_t, _wcsncpy_s_l, wchar_t, _Dest, _In_z_ const wchar_t *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
751
752 __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(wchar_t *, __RETURN_POLICY_DST, _wcsncpy_l, _wcsncpy_s_l, _Out_z_cap_(_Size) wchar_t, _Out_cap_(_Count) wchar_t, _Dst, _In_z_ const wchar_t *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
753 {
754       _CRT_UNUSED(_Locale);
755 #pragma warning( push )
756 #pragma warning( disable : 4996 6054)
757       return wcsncpy(_Dst, _Source, _Count);
758 #pragma warning( pop )
759 }
760
761 __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(wchar_t *, __RETURN_POLICY_DST, _wcsncpy_l, _wcsncpy_s_l, _Deref_out_z_cap_c_(_Size) wchar_t, _Out_cap_(_Count), wchar_t, _Dst, _In_z_ const wchar_t *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
762
763 #if __STDC_WANT_SECURE_LIB__
764 _Check_return_wat_ __inline errno_t __CRTDECL _wcsncat_s_l(_Inout_z_cap_(_Destination_size_chars) wchar_t *_Destination, _In_ size_t _Destination_size_chars, _In_z_ const wchar_t *_Source, _In_ size_t _Count, _In_opt_ _locale_t _Locale)
765 {
766       _CRT_UNUSED(_Locale);
767       return wcsncat_s(_Destination, _Destination_size_chars, _Source, _Count);
768 }
769 #endif
770
771 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(errno_t, _wcsncat_s_l, wchar_t, _Dest, _In_z_ const wchar_t *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
772
773 __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(wchar_t *, __RETURN_POLICY_DST, _wcsncat_l, _wcsncat_s_l, _Inout_z_cap_(_Size) wchar_t, _Inout_z_ wchar_t, _Dst, _In_z_ const wchar_t *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
774 {
775       _CRT_UNUSED(_Locale);
776 #pragma warning( push )
777 #pragma warning( disable : 4996 6054 6059)
778 /* prefast noise VSW 489802 */
779       return wcsncat(_Dst, _Source, _Count);
780 #pragma warning( pop )
781 }
782
783 __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(wchar_t *, __RETURN_POLICY_DST, _wcsncat_l, _wcsncat_s_l, _Deref_inout_z_cap_c_(_Size) wchar_t, _Inout_z_, wchar_t, _Dst, _In_z_ const wchar_t *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
784
785 _CRT_INSECURE_DEPRECATE(_wcstok_s_l) __inline wchar_t * _wcstok_l(_Inout_opt_z_ wchar_t * _String, _In_z_ const wchar_t * _Delimiters, _In_opt_ _locale_t _Locale) 
786 {
787       _CRT_UNUSED(_Locale);
788 #pragma warning(push)
789 #pragma warning(disable:4996)
790     return wcstok(_String,_Delimiters);
791 #pragma warning(pop)
792 }
793
794 __inline wchar_t * _wcstok_s_l(_Inout_opt_z_ wchar_t * _String, _In_z_ const wchar_t * _Delimiters, _Inout_ _Deref_prepost_opt_z_ wchar_t **_Current_position, _In_opt_ _locale_t _Locale) 
795 {
796       _CRT_UNUSED(_Locale);
797       return wcstok_s(_String, _Delimiters, _Current_position);
798 }
799
800 _Check_return_wat_ __inline errno_t _wcsnset_s_l(_Inout_z_cap_(_Destination_size_chars) wchar_t * _Destination, _In_ size_t _Destination_size_chars, _In_ wchar_t _Value, _In_ size_t _Count, _In_opt_ _locale_t _Locale)
801 {
802       _CRT_UNUSED(_Locale);
803       return _wcsnset_s(_Destination, _Destination_size_chars, _Value, _Count);
804 }
805
806 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(errno_t, _wcsnset_s_l, _Deref_prepost_z_ wchar_t, _Dest, _In_ wchar_t, _Value, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
807
808 __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(wchar_t *, __RETURN_POLICY_DST, _wcsnset_l, _wcsnset_s_l, _Inout_z_cap_(_Size) wchar_t, _Inout_z_cap_(_MaxCount) wchar_t, _Dst, _In_ wchar_t, _Value, _In_ size_t, _MaxCount, _In_opt_ _locale_t, _Locale)
809 {
810       _CRT_UNUSED(_Locale);
811 #pragma warning( push )
812 #pragma warning( disable : 4996 )
813       return _wcsnset(_Dst, _Value, _MaxCount);
814 #pragma warning( pop )
815 }
816
817 __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(wchar_t *, __RETURN_POLICY_DST, _wcsnset_l, _wcsnset_s_l, _Deref_inout_z_cap_c_(_Size) wchar_t, _Inout_z_cap_(_MaxCount), wchar_t, _Dst, _In_ wchar_t, _Value, _In_ size_t, _MaxCount, _In_opt_ _locale_t, _Locale)
818
819 _Check_return_wat_ __inline errno_t _wcsset_s_l(_Inout_z_cap_(_Destination_size_chars) wchar_t * _Destination, _In_ size_t _Destination_size_chars, _In_ wchar_t _Value, _In_opt_ _locale_t _Locale) 
820 {
821       _CRT_UNUSED(_Locale);
822       return _wcsset_s(_Destination, _Destination_size_chars, _Value);
823 }
824
825 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(errno_t, _wcsset_s_l, _Deref_prepost_z_ wchar_t, _Dest, _In_ wchar_t, _Value, _In_opt_ _locale_t, _Locale)
826
827 __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(wchar_t *, __RETURN_POLICY_DST, _wcsset_l, _wcsset_s_l, _Inout_z_cap_(_Size) wchar_t, _Inout_z_ wchar_t, _Dst, _In_ wchar_t, _Value, _In_opt_ _locale_t, _Locale)
828 {
829       _CRT_UNUSED(_Locale);
830 #pragma warning( push )
831 #pragma warning( disable : 4996 )
832       return _wcsset(_Dst, _Value);
833 #pragma warning( pop )
834 }
835
836 __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(wchar_t *, __RETURN_POLICY_DST, _wcsset_l, _wcsset_s_l, _Deref_inout_z_cap_c_(_Size) wchar_t, _Inout_z_, wchar_t, _Dst, _In_ wchar_t, _Value, _In_opt_ _locale_t, _Locale)
837
838 #endif  /* __STDC__ */
839
840
841 #else     /* ndef _UNICODE */
842
843 /* ++++++++++++++++++++ SBCS and MBCS ++++++++++++++++++++ */
844
845 #ifdef  __cplusplus
846 }     /* ... extern "C" */
847 #endif
848
849 #include <string.h>
850
851 #ifdef  __cplusplus
852 extern "C" {
853 #endif
854
855
856 #define _TEOF           EOF
857
858 #define __T(x)          x
859
860
861 /* Program */
862
863 #define _tmain          main
864 #define _tWinMain     WinMain
865 #ifdef  _POSIX_
866 #define _tenviron     environ
867 #else
868 #define _tenviron  _environ
869 #endif
870 #define __targv        __argv
871
872
873 /* Formatted i/o */
874
875 #define _tprintf             printf
876 #define _tprintf_l          _printf_l
877 #define _tprintf_s          printf_s
878 #define _tprintf_s_l      _printf_s_l
879 #define _tprintf_p          _printf_p
880 #define _tprintf_p_l      _printf_p_l
881 #define _tcprintf           _cprintf
882 #define _tcprintf_l        _cprintf_l
883 #define _tcprintf_s        _cprintf_s
884 #define _tcprintf_s_l     _cprintf_s_l
885 #define _tcprintf_p        _cprintf_p
886 #define _tcprintf_p_l     _cprintf_p_l
887 #define _vtcprintf          _vcprintf
888 #define _vtcprintf_l      _vcprintf_l
889 #define _vtcprintf_s      _vcprintf_s
890 #define _vtcprintf_s_l  _vcprintf_s_l
891 #define _vtcprintf_p      _vcprintf_p
892 #define _vtcprintf_p_l  _vcprintf_p_l
893 #define _ftprintf           fprintf
894 #define _ftprintf_l        _fprintf_l
895 #define _ftprintf_s        fprintf_s
896 #define _ftprintf_s_l     _fprintf_s_l
897 #define _ftprintf_p        _fprintf_p
898 #define _ftprintf_p_l     _fprintf_p_l
899 #define _stprintf           sprintf
900 #define _stprintf_l        _sprintf_l
901 #define _stprintf_s        sprintf_s
902 #define _stprintf_s_l     _sprintf_s_l
903 #define _stprintf_p        _sprintf_p
904 #define _stprintf_p_l     _sprintf_p_l
905 #define _sctprintf          _scprintf
906 #define _sctprintf_l      _scprintf_l
907 #define _sctprintf_p      _scprintf_p
908 #define _sctprintf_p_l  _scprintf_p_l
909 #define _sntprintf          _snprintf
910 #define _sntprintf_l      _snprintf_l
911 #define _sntprintf_s      _snprintf_s
912 #define _sntprintf_s_l  _snprintf_s_l
913 #define _vtprintf           vprintf
914 #define _vtprintf_l        _vprintf_l
915 #define _vtprintf_s        vprintf_s
916 #define _vtprintf_s_l     _vprintf_s_l
917 #define _vtprintf_p        _vprintf_p
918 #define _vtprintf_p_l     _vprintf_p_l
919 #define _vftprintf          vfprintf
920 #define _vftprintf_l      _vfprintf_l
921 #define _vftprintf_s      vfprintf_s
922 #define _vftprintf_s_l  _vfprintf_s_l
923 #define _vftprintf_p      _vfprintf_p
924 #define _vftprintf_p_l  _vfprintf_p_l
925 #define _vstprintf          vsprintf
926 #define _vstprintf_l      _vsprintf_l
927 #define _vstprintf_s      vsprintf_s
928 #define _vstprintf_s_l  _vsprintf_s_l
929 #define _vstprintf_p      _vsprintf_p
930 #define _vstprintf_p_l  _vsprintf_p_l
931 #define _vsctprintf        _vscprintf
932 #define _vsctprintf_l     _vscprintf_l
933 #define _vsctprintf_p     _vscprintf_p
934 #define _vsctprintf_p_l _vscprintf_p_l
935 #define _vsntprintf        _vsnprintf
936 #define _vsntprintf_l     _vsnprintf_l
937 #define _vsntprintf_s     _vsnprintf_s
938 #define _vsntprintf_s_l _vsnprintf_s_l
939
940 #define _tscanf               scanf
941 #define _tscanf_l           _scanf_l
942 #define _tscanf_s           scanf_s
943 #define _tscanf_s_l        _scanf_s_l
944 #define _tcscanf             _cscanf
945 #define _tcscanf_l          _cscanf_l
946 #define _tcscanf_s          _cscanf_s
947 #define _tcscanf_s_l      _cscanf_s_l
948 #define _ftscanf             fscanf
949 #define _ftscanf_l          _fscanf_l
950 #define _ftscanf_s          fscanf_s
951 #define _ftscanf_s_l      _fscanf_s_l
952 #define _stscanf             sscanf
953 #define _stscanf_l          _sscanf_l
954 #define _stscanf_s          sscanf_s
955 #define _stscanf_s_l      _sscanf_s_l
956 #define _sntscanf           _snscanf
957 #define _sntscanf_l        _snscanf_l
958 #define _sntscanf_s        _snscanf_s
959 #define _sntscanf_s_l     _snscanf_s_l
960
961
962 /* Unformatted i/o */
963
964 #define _fgettc               fgetc
965 #define _fgettc_nolock  _fgetc_nolock
966 #define _fgettchar          _fgetchar
967 #define _fgetts               fgets
968 #define _fputtc               fputc
969 #define _fputtc_nolock  _fputc_nolock
970 #define _fputtchar          _fputchar
971 #define _fputts               fputs
972 #define _cputts               _cputs
973 #define _gettc                getc
974 #define _gettc_nolock     _getc_nolock
975 #define _gettch               _getch
976 #define _gettch_nolock  _getch_nolock
977 #define _gettche             _getche
978 #define _gettche_nolock _getche_nolock
979 #define _gettchar           getchar
980 #define _gettchar_nolock _getchar_nolock
981 #define _getts                gets
982 #define _getts_s             gets_s
983 #define _cgetts               _cgets
984 #define _cgetts_s           _cgets_s
985 #define _puttc                putc
986 #define _puttc_nolock     _putc_nolock
987 #define _puttchar           putchar
988 #define _puttchar_nolock _putchar_nolock
989 #define _puttch               _putch
990 #define _puttch_nolock  _putch_nolock
991 #define _putts                puts
992 #define _ungettc             ungetc
993 #define _ungettc_nolock _ungetc_nolock
994 #define _ungettch           _ungetch
995 #define _ungettch_nolock _ungetch_nolock
996
997 /* String conversion functions */
998
999 #define _tcstod        strtod
1000 #define _tcstol        strtol
1001 #define _tcstoul      strtoul
1002 #define _tstof          atof
1003 #define _tstol          atol
1004 #define _tstoi          atoi
1005 #define _tstoi64      _atoi64
1006 #define _tcstod_l        _strtod_l
1007 #define _tcstol_l        _strtol_l
1008 #define _tcstoul_l      _strtoul_l
1009 #define _tstof_l          _atof_l
1010 #define _tstol_l          _atol_l
1011 #define _tstoi_l          _atoi_l
1012 #define _tstoi64_l      _atoi64_l
1013
1014 #define _itot_s        _itoa_s
1015 #define _ltot_s        _ltoa_s
1016 #define _ultot_s      _ultoa_s
1017 #define _itot           _itoa
1018 #define _ltot           _ltoa
1019 #define _ultot          _ultoa
1020 #define _ttoi           atoi
1021 #define _ttol           atol
1022
1023 #define _ttoi64        _atoi64
1024 #define _tcstoi64     _strtoi64
1025 #define _tcstoi64_l     _strtoi64_l
1026 #define _tcstoui64  _strtoui64
1027 #define _tcstoui64_l  _strtoui64_l
1028 #define _i64tot_s     _i64toa_s
1029 #define _ui64tot_s  _ui64toa_s
1030 #define _i64tot        _i64toa
1031 #define _ui64tot      _ui64toa
1032
1033 /* String functions */
1034
1035 /* Note that _mbscat, _mbscpy and _mbsdup are functionally equivalent to 
1036      strcat, strcpy and strdup, respectively. */
1037
1038 #define _tcscat        strcat
1039 #define _tcscat_s     strcat_s
1040 #define _tcscpy        strcpy
1041 #define _tcscpy_s     strcpy_s
1042 #define _tcsdup        _strdup
1043 #define _tcslen        strlen
1044 #define _tcsnlen      strnlen
1045 #define _tcsxfrm      strxfrm
1046 #define _tcsxfrm_l      _strxfrm_l
1047 #define _tcserror     strerror
1048 #define _tcserror_s     strerror_s
1049 #define __tcserror  _strerror
1050 #define __tcserror_s  _strerror_s
1051
1052 #ifdef _DEBUG
1053 #define _tcsdup_dbg _strdup_dbg
1054 #endif
1055
1056 /* Execute functions */
1057
1058 #define _texecl        _execl
1059 #define _texecle      _execle
1060 #define _texeclp      _execlp
1061 #define _texeclpe     _execlpe
1062 #define _texecv        _execv
1063 #define _texecve      _execve
1064 #define _texecvp      _execvp
1065 #define _texecvpe     _execvpe
1066
1067 #define _tspawnl      _spawnl
1068 #define _tspawnle     _spawnle
1069 #define _tspawnlp     _spawnlp
1070 #define _tspawnlpe  _spawnlpe
1071 #define _tspawnv      _spawnv
1072 #define _tspawnve     _spawnve
1073 #define _tspawnvp     _spawnvp
1074 #define _tspawnvpe  _spawnvpe
1075
1076 #define _tsystem      system
1077
1078
1079 /* Time functions */
1080
1081 #define _tasctime     asctime
1082 #define _tctime        ctime
1083 #define _tctime32     _ctime32
1084 #define _tctime64     _ctime64
1085 #define _tstrdate     _strdate
1086 #define _tstrtime     _strtime
1087 #define _tutime        _utime
1088 #define _tutime32     _utime32
1089 #define _tutime64     _utime64
1090 #define _tcsftime     strftime
1091 #define _tcsftime_l _strftime_l
1092
1093 #define _tasctime_s     asctime_s
1094 #define _tctime_s        ctime_s
1095 #define _tctime32_s     _ctime32_s
1096 #define _tctime64_s     _ctime64_s
1097 #define _tstrdate_s     _strdate_s
1098 #define _tstrtime_s     _strtime_s
1099
1100 /* Directory functions */
1101
1102 #define _tchdir                     _chdir
1103 #define _tgetcwd                    _getcwd
1104 #define _tgetdcwd                  _getdcwd
1105 #define _tgetdcwd_nolock      _getdcwd_nolock
1106 #define _tmkdir                     _mkdir
1107 #define _trmdir                     _rmdir
1108
1109 #ifdef _DEBUG
1110 #define _tgetcwd_dbg             _getcwd_dbg
1111 #define _tgetdcwd_dbg           _getdcwd_dbg
1112 #define _tgetdcwd_lk_dbg      _getdcwd_lk_dbg
1113 #endif
1114
1115 /* Environment/Path functions */
1116
1117 #define _tfullpath          _fullpath
1118 #define _tgetenv             getenv
1119 #define _tgetenv_s          getenv_s
1120 #define _tdupenv_s          _dupenv_s
1121 #define _tmakepath          _makepath
1122 #define _tmakepath_s      _makepath_s
1123 #define _tpgmptr             _pgmptr
1124 #define _get_tpgmptr      _get_pgmptr
1125 #define _tputenv             _putenv
1126 #define _tputenv_s          _putenv_s
1127 #define _tsearchenv        _searchenv
1128 #define _tsearchenv_s     _searchenv_s
1129 #define _tsplitpath        _splitpath
1130 #define _tsplitpath_s     _splitpath_s
1131
1132 #ifdef _DEBUG
1133 #define _tfullpath_dbg  _fullpath_dbg
1134 #define _tdupenv_s_dbg  _dupenv_s_dbg
1135 #endif
1136
1137 /* Stdio functions */
1138
1139 #ifdef  _POSIX_
1140 #define _tfdopen      fdopen
1141 #else
1142 #define _tfdopen      _fdopen
1143 #endif
1144 #define _tfsopen      _fsopen
1145 #define _tfopen        fopen
1146 #define _tfopen_s     fopen_s
1147 #define _tfreopen     freopen
1148 #define _tfreopen_s freopen_s
1149 #define _tperror      perror
1150 #define _tpopen        _popen
1151 #define _ttempnam     _tempnam
1152 #define _ttmpnam      tmpnam
1153 #define _ttmpnam_s  tmpnam_s
1154
1155 #ifdef _DEBUG
1156 #define _ttempnam_dbg     _tempnam_dbg
1157 #endif
1158
1159
1160 /* Io functions */
1161
1162 #define _tchmod        _chmod
1163 #define _tcreat        _creat
1164 #define _tfindfirst          _findfirst
1165 #define _tfindfirst32      _findfirst32
1166 #define _tfindfirst64      _findfirst64
1167 #define _tfindfirsti64     _findfirsti64
1168 #define _tfindfirst32i64 _findfirst32i64
1169 #define _tfindfirst64i32 _findfirst64i32
1170 #define _tfindnext           _findnext
1171 #define _tfindnext32        _findnext32
1172 #define _tfindnext64        _findnext64
1173 #define _tfindnexti64      _findnexti64
1174 #define _tfindnext32i64  _findnext32i64
1175 #define _tfindnext64i32  _findnext64i32
1176 #define _tmktemp                    _mktemp
1177 #define _tmktemp_s                _mktemp_s
1178
1179 #ifdef  _POSIX_
1180 #define _topen          open
1181 #define _taccess      access
1182 #else
1183 #define _topen          _open
1184 #define _taccess      _access
1185 #define _taccess_s  _access_s
1186 #endif
1187
1188 #define _tremove      remove
1189 #define _trename      rename
1190 #define _tsopen        _sopen
1191 #define _tsopen_s     _sopen_s
1192 #define _tunlink      _unlink
1193
1194 #define _tfinddata_t          _finddata_t
1195 #define _tfinddata32_t      _finddata32_t
1196 #define _tfinddata64_t      __finddata64_t
1197 #define _tfinddatai64_t     _finddatai64_t
1198 #define _tfinddata32i64_t _finddata32i64_t
1199 #define _tfinddata64i32_t _finddata64i32_t
1200
1201 /* ctype functions */
1202 #define _istascii           __isascii
1203 #define _istcntrl           iscntrl
1204 #define _istcntrl_l        _iscntrl_l
1205 #define _istxdigit          isxdigit
1206 #define _istxdigit_l      _isxdigit_l
1207
1208 /* Stat functions */
1209 #define _tstat          _stat
1210 #define _tstat32      _stat32
1211 #define _tstat32i64 _stat32i64
1212 #define _tstat64      _stat64
1213 #define _tstat64i32 _stat64i32
1214 #define _tstati64     _stati64
1215
1216
1217 /* Setlocale functions */
1218
1219 #define _tsetlocale setlocale
1220
1221
1222 #ifdef  _MBCS
1223
1224 /* ++++++++++++++++++++ MBCS ++++++++++++++++++++ */
1225
1226 #ifdef  __cplusplus
1227 }     /* ... extern "C" */
1228 #endif
1229
1230 #include <mbstring.h>
1231
1232 #ifdef  __cplusplus
1233 extern "C" {
1234 #endif
1235
1236
1237 #ifndef __TCHAR_DEFINED
1238 typedef char                    _TCHAR;
1239 typedef signed char        _TSCHAR;
1240 typedef unsigned char     _TUCHAR;
1241 typedef unsigned char     _TXCHAR;
1242 typedef unsigned int      _TINT;
1243 #define __TCHAR_DEFINED
1244 #endif
1245
1246 #ifndef _TCHAR_DEFINED
1247 #if        !__STDC__
1248 typedef char                    TCHAR;
1249 #endif
1250 #define _TCHAR_DEFINED
1251 #endif
1252
1253
1254 #ifdef  _MB_MAP_DIRECT
1255
1256 /* use mb functions directly - types must match */
1257
1258 /* String functions */
1259
1260 #define _tcschr               _mbschr
1261 #define _tcscspn             _mbscspn
1262 #define _tcsncat             _mbsnbcat
1263 #define _tcsncat_s          _mbsnbcat_s
1264 #define _tcsncat_l          _mbsnbcat_l
1265 #define _tcsncat_s_l      _mbsnbcat_s_l
1266 #define _tcsncpy             _mbsnbcpy
1267 #define _tcsncpy_s          _mbsnbcpy_s
1268 #define _tcsncpy_l          _mbsnbcpy_l
1269 #define _tcsncpy_s_l      _mbsnbcpy_s_l
1270 #define _tcspbrk             _mbspbrk
1271 #define _tcsrchr             _mbsrchr
1272 #define _tcsspn               _mbsspn
1273 #define _tcsstr               _mbsstr
1274 #define _tcstok               _mbstok
1275 #define _tcstok_s           _mbstok_s
1276 #define _tcstok_l           _mbstok_l
1277 #define _tcstok_s_l        _mbstok_s_l
1278
1279 #define _tcsnset             _mbsnbset
1280 #define _tcsnset_l          _mbsnbset_l
1281 #define _tcsnset_s          _mbsnbset_s
1282 #define _tcsnset_s_l      _mbsnbset_s_l
1283 #define _tcsrev               _mbsrev
1284 #define _tcsset               _mbsset
1285 #define _tcsset_s           _mbsset_s
1286 #define _tcsset_l           _mbsset_l
1287 #define _tcsset_s_l        _mbsset_s_l
1288
1289 #define _tcscmp               _mbscmp
1290 #define _tcsicmp             _mbsicmp
1291 #define _tcsicmp_l          _mbsicmp_l
1292 #define _tcsnccmp           _mbsncmp
1293 #define _tcsncmp             _mbsnbcmp
1294 #define _tcsncicmp          _mbsnicmp
1295 #define _tcsncicmp_l      _mbsnicmp_l
1296 #define _tcsnicmp           _mbsnbicmp
1297 #define _tcsnicmp_l        _mbsnbicmp_l
1298
1299 #define _tcscoll             _mbscoll
1300 #define _tcscoll_l          _mbscoll_l
1301 #define _tcsicoll           _mbsicoll
1302 #define _tcsicoll_l        _mbsicoll_l
1303 #define _tcsnccoll          _mbsncoll
1304 #define _tcsnccoll_l      _mbsncoll_l
1305 #define _tcsncoll           _mbsnbcoll
1306 #define _tcsncoll_l        _mbsnbcoll_l
1307 #define _tcsncicoll        _mbsnicoll
1308 #define _tcsncicoll_l     _mbsnicoll_l
1309 #define _tcsnicoll          _mbsnbicoll
1310 #define _tcsnicoll_l      _mbsnbicoll_l
1311
1312 /* "logical-character" mappings */
1313
1314 #define _tcsclen             _mbslen
1315 #define _tcscnlen           _mbsnlen
1316 #define _tcsclen_l          _mbslen_l
1317 #define _tcscnlen_l        _mbsnlen_l
1318 #define _tcsnccat           _mbsncat
1319 #define _tcsnccat_s        _mbsncat_s
1320 #define _tcsnccat_l        _mbsncat_l
1321 #define _tcsnccat_s_l     _mbsncat_s_l
1322 #define _tcsnccpy           _mbsncpy
1323 #define _tcsnccpy_s        _mbsncpy_s
1324 #define _tcsnccpy_l        _mbsncpy_l
1325 #define _tcsnccpy_s_l     _mbsncpy_s_l
1326 #define _tcsncset           _mbsnset
1327 #define _tcsncset_s        _mbsnset_s
1328 #define _tcsncset_l        _mbsnset_l
1329 #define _tcsncset_s_l     _mbsnset_s_l
1330
1331 /* MBCS-specific mappings */
1332
1333 #define _tcsdec        _mbsdec
1334 #define _tcsinc        _mbsinc
1335 #define _tcsnbcnt     _mbsnbcnt
1336 #define _tcsnccnt     _mbsnccnt
1337 #define _tcsnextc     _mbsnextc
1338 #define _tcsninc      _mbsninc
1339 #define _tcsspnp      _mbsspnp
1340
1341 #define _tcslwr        _mbslwr
1342 #define _tcslwr_l     _mbslwr_l
1343 #define _tcslwr_s     _mbslwr_s
1344 #define _tcslwr_s_l _mbslwr_s_l
1345 #define _tcsupr        _mbsupr
1346 #define _tcsupr_l     _mbsupr_l
1347 #define _tcsupr_s     _mbsupr_s
1348 #define _tcsupr_s_l _mbsupr_s_l
1349
1350 #define _tclen          _mbclen
1351 #define _tccpy          _mbccpy
1352 #define _tccpy_l      _mbccpy_l
1353 #define _tccpy_s      _mbccpy_s
1354 #define _tccpy_s_l  _mbccpy_s_l
1355
1356 #else /* _MB_MAP_DIRECT */
1357
1358 #if        __STDC__ || defined(_NO_INLINING)
1359
1360 /* use type-safe linked-in function thunks */
1361
1362 /* String functions */
1363
1364 _Check_return_ _CRTIMP _CONST_RETURN char * __cdecl _tcschr(_In_z_ const char * _Str, _In_ unsigned int _Val);
1365 _Check_return_ _CRTIMP size_t __cdecl _tcscspn(_In_z_ const char * _Str, _In_z_ const char * _Control);
1366 _CRT_INSECURE_DEPRECATE(_tcsncat_s) _CRTIMP char * __cdecl _tcsncat(_Inout_z_cap_(_MaxCount) char *_Dst, _In_z_ const char *_Src, _In_ size_t _MaxCount);
1367 _CRTIMP char * __cdecl _tcsncat_s(_Inout_z_cap_(_DstSizeInChars) char *_Dst, _In_ size_t _DstSizeInChars, _In_z_ const char *_Src, size_t _MaxCount);
1368 _CRT_INSECURE_DEPRECATE(_tcsncat_s_l) _CRTIMP char * __cdecl _tcsncat_l(_Inout_z_cap_(_MaxCount) char *_Dst, _In_z_ const char *_Src, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
1369 _CRTIMP char * __cdecl _tcsncat_s_l(_Inout_z_cap_(_DstSizeInChars) char *_Dst, _In_ size_t _DstSizeInChars, _In_z_ const char *_Src, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
1370 _CRT_INSECURE_DEPRECATE(_tcsncpy_s) _CRTIMP char * __cdecl _tcsncpy(_Out_cap_(_MaxCount) _Post_maybez_ char *_Dst, _In_z_ const char *_Src, size_t _MaxCount);
1371 _CRTIMP char * __cdecl _tcsncpy_s(_Out_cap_(_DstSizeInChars) char *_Dst, _In_ size_t _DstSizeInChars, _In_z_ const char *_Src, size_t _MaxCount);
1372 _CRT_INSECURE_DEPRECATE(_tcsncpy_s_l) _CRTIMP char * __cdecl _tcsncpy_l(_Out_cap_(_MaxCount) _Post_maybez_ char *_Dst, _In_z_ const char *_Src, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
1373 _CRTIMP char * __cdecl _tcsncpy_s_l(_Out_cap_(_DstSizeInChars) char *_Dst, _In_ size_t _DstSizeInChars, _In_z_ const char *_Src, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
1374 _Check_return_ _CRTIMP _CONST_RETURN char * __cdecl _tcspbrk(_In_z_ const char * _Str, _In_z_ const char * _Control);
1375 _Check_return_ _CRTIMP _CONST_RETURN char * __cdecl _tcsrchr(_In_z_ const char * _Str, _In_ unsigned int _Ch);
1376 _Check_return_ _CRTIMP size_t __cdecl _tcsspn(_In_z_ const char * _Str, _In_z_ const char * _Control);
1377 _Check_return_ _CRTIMP _CONST_RETURN char * __cdecl _tcsstr(_In_z_ const char * _Str, _In_z_ const char * _Substr);
1378 _Check_return_ _CRT_INSECURE_DEPRECATE(_tcstok_s) _CRTIMP char * __cdecl _tcstok(_Inout_opt_ char *_Str, _In_z_ const char *_Delim);
1379 _Check_return_ _CRTIMP char * __cdecl _tcstok_s(_Inout_opt_ char *_Str, _In_z_ const char *_Delim, _Inout_ _Deref_prepost_opt_z_ char **_Context);
1380 _Check_return_ _CRT_INSECURE_DEPRECATE(_tcstok_s_l) _CRTIMP char * __cdecl _tcstok_l(_Inout_opt_ char *_Str, _In_z_ const char *_Delim, _In_opt_ _locale_t _Locale);
1381 _Check_return_ _CRTIMP char * __cdecl _tcstok_s_l(_Inout_opt_ char *_Str, _In_z_ const char *_Delim, _Inout_ _Deref_prepost_opt_z_ char **_Context, _In_opt_ _locale_t _Locale);
1382
1383 _CRT_INSECURE_DEPRECATE(_tcsnset_s) _CRTIMP char * __cdecl _tcsnset(_Inout_z_ char * _Str, _In_ unsigned int _Val, _In_ size_t _MaxCount);
1384 _Check_return_wat_ _CRTIMP errno_t __cdecl _tcsnset_s(_Inout_z_bytecap_(_SizeInChars) char * _Str, _In_ size_t _SizeInChars, _In_ unsigned int _Val , _In_ size_t _MaxCount);
1385 _CRT_INSECURE_DEPRECATE(_tcsnset_s_l) _CRTIMP char * __cdecl _tcsnset_l(_Inout_z_ char * _Str, _In_ unsigned int _Val, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
1386 _Check_return_wat_ _CRTIMP errno_t __cdecl _tcsnset_s_l(_Inout_z_bytecap_(_SizeInChars) char * _Str, _In_ size_t _SizeInChars, _In_ unsigned int _Val , _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
1387 _CRTIMP char * __cdecl _tcsrev(_Inout_z_ char * _Str);
1388 _CRT_INSECURE_DEPRECATE(_tcsset_s) _CRTIMP char * __cdecl _tcsset(_Inout_z_ char * _Str, _In_ unsigned int _Val);
1389 _CRT_INSECURE_DEPRECATE(_tcsset_s_l) _CRTIMP char * __cdecl _tcsset_l(_Inout_z_ char * _Str, _In_ unsigned int _Val, _In_opt_ _locale_t _Locale);
1390 _Check_return_wat_ _CRTIMP errno_t __cdecl _tcsset_s(_Inout_z_cap_(_SizeInChars) char * _Str, _In_ size_t _SizeInChars, _In_ unsigned int _Val);
1391 _Check_return_wat_ _CRTIMP errno_t __cdecl _tcsset_s_l(_Inout_z_cap_(_SizeInChars) char * _Str, _In_ size_t _SizeInChars, _In_ unsigned int, _In_opt_ _locale_t _Locale);
1392
1393 _Check_return_ _CRTIMP int __cdecl _tcscmp(_In_z_ const char *_Str1, _In_z_ const char * _Str);
1394 _Check_return_ _CRTIMP int __cdecl _tcsicmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2);
1395 _Check_return_ _CRTIMP int __cdecl _tcsicmp_l(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_opt_ _locale_t _Locale);
1396 _Check_return_ _CRTIMP int __cdecl _tcsnccmp(_In_z_ const char * _Str1, _In_z_ const char * _Str2, _In_ size_t _MaxCount);
1397 _Check_return_ _CRTIMP int __cdecl _tcsncmp(_In_z_ const char * _Str1, _In_z_ const char * _Str2, _In_ size_t _MaxCount);
1398 _Check_return_ _CRTIMP int __cdecl _tcsncicmp(_In_z_ const char * _Str1, _In_z_ const char * _Str2, _In_ size_t _MaxCount);
1399 _Check_return_ _CRTIMP int __cdecl _tcsncicmp_l(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
1400 _Check_return_ _CRTIMP int __cdecl _tcsnicmp(_In_z_ const char * _Str1, _In_z_ const char * _Str2, _In_ size_t _MaxCount);
1401 _Check_return_ _CRTIMP int __cdecl _tcsnicmp_l(_In_z_ const char *_Str1, _In_z_ const char *_Str2, size_t _MaxCount, _In_opt_ _locale_t _Locale);
1402
1403 _Check_return_ _CRTIMP int __cdecl _tcscoll(_In_z_ const char * _Str1, _In_z_ const char * _Str2);
1404 _Check_return_ _CRTIMP int __cdecl _tcscoll_l(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_opt_ _locale_t _Locale);
1405 _Check_return_ _CRTIMP int __cdecl _tcsicoll(_In_z_ const char * _Str1, _In_z_ const char * _Str2);
1406 _Check_return_ _CRTIMP int __cdecl _tcsicoll_l(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_opt_ _locale_t _Locale);
1407 _Check_return_ _CRTIMP int __cdecl _tcsnccoll(_In_z_ const char * _Str1, _In_z_ const char * _Str2, _In_ size_t _MaxCount);
1408 _Check_return_ _CRTIMP int __cdecl _tcsnccoll_l(_In_z_ const char *_Str1, _In_z_ const char *_Str2, _In_ size_t _MaxCount, _In_opt_ _locale_t _Locale);
Lines 1409 ... 1945 are skipped.
1946 }
1947
1948 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(errno_t, _tccpy_s, _Deref_post_z_ char, _Dest, _Out_opt_  int *, _PCopied, _In_z_ const char *, _Source)
1949
1950 _CRT_INSECURE_DEPRECATE(_tccpy_s) __inline void _tccpy(_Out_z_bytecap_c_(2) char * _Destination, _In_z_ const char * _Source) 
1951 {
1952 #pragma warning(push)
1953 #pragma warning(disable:4996)
1954       _mbccpy((unsigned char *)_Destination, (const unsigned char *)_Source);
1955 #pragma warning(pop)
1956 }
1957
1958 _Check_return_wat_ __inline errno_t _tccpy_s_l(_Out_z_bytecap_(_SizeInBytes) char * _Destination, _In_ size_t _SizeInBytes, _Out_opt_ int *_PCopied, _In_z_ const char * _Source, _In_opt_ _locale_t _Locale) 
1959 {
1960       return _mbccpy_s_l((unsigned char *)_Destination, _SizeInBytes, _PCopied, (const unsigned char *)_Source, _Locale);
1961 }
1962
1963 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(errno_t, _tccpy_s_l, _Deref_post_z_ char, _Dest, _Out_opt_ int *, _PCopied, _In_z_ const char *, _Source, _In_opt_ _locale_t, _Locale)
1964
1965 _CRT_INSECURE_DEPRECATE(_tccpy_s_l) __inline void _tccpy_l(_Out_z_bytecap_c_(2) char * _Destination, _In_z_ const char * _Source, _In_opt_ _locale_t _Locale) 
1966 {
1967 #pragma warning(push)
1968 #pragma warning(disable:4996)
1969       _mbccpy_l((unsigned char *)_Destination,( const unsigned char *)_Source, _Locale);
1970 #pragma warning(pop)
1971 }
1972
1973 /* inline helper */
1974 _Check_return_ __inline _UI _tcsnextc(_In_z_ _CPC _s1)
1975 {
1976       _UI _n=0; 
1977       if (_ismbblead((_UI)*(_PUC)_s1)) 
1978       {
1979              /*  for a dud MBCS string (leadbyte, EOS), we don't move forward 2
1980                     We do not assert here because this routine is too low-level
1981              */
1982              if(_s1[1]!='\0')
1983              {
1984                     _n=((_UI)*(_PUC)_s1)<<8; 
1985                     _s1++;
1986              }
1987       } 
1988       _n+=(_UI)*(_PUC)_s1; 
1989       
1990       return(_n);
1991 }
1992
1993 #endif  /* __STDC__ */
1994
1995 #ifdef  __cplusplus
1996 #ifndef _CPP_TCHAR_INLINES_DEFINED
1997 #define _CPP_TCHAR_INLINES_DEFINED
1998 extern "C++" {
1999 _Check_return_ inline char * __CRTDECL _tcschr(_In_z_ char *_S, _In_ unsigned int _C)
2000              {return ((char *)_tcschr((const char *)_S, _C)); }
2001 _Check_return_ inline char * __CRTDECL _tcspbrk(_In_z_ char *_S, _In_z_ const char *_P)
2002              {return ((char *)_tcspbrk((const char *)_S, _P)); }
2003 _Check_return_ inline char * __CRTDECL _tcsrchr(_In_z_ char *_S, _In_ unsigned int _C)
2004              {return ((char *)_tcsrchr((const char *)_S, _C)); }
2005 _Check_return_ inline char * __CRTDECL _tcsstr(_In_z_ char *_S, _In_z_ const char *_P)
2006              {return ((char *)_tcsstr((const char *)_S, _P)); }
2007 }
2008 #endif
2009 #endif  /* __cplusplus */
2010
2011 #endif  /* _MB_MAP_DIRECT */
2012
2013
2014 /* MBCS-specific mappings */
2015
2016 #define _tccmp(_cp1,_cp2)     _tcsnccmp(_cp1,_cp2,1)
2017
2018
2019 /* ctype functions */
2020
2021 #define _istalnum           _ismbcalnum
2022 #define _istalnum_l        _ismbcalnum_l
2023 #define _istalpha           _ismbcalpha
2024 #define _istalpha_l        _ismbcalpha_l
2025 #define _istdigit           _ismbcdigit
2026 #define _istdigit_l        _ismbcdigit_l
2027 #define _istgraph           _ismbcgraph
2028 #define _istgraph_l        _ismbcgraph_l
2029 #define _istlegal           _ismbclegal
2030 #define _istlegal_l        _ismbclegal_l
2031 #define _istlower           _ismbclower
2032 #define _istlower_l        _ismbclower_l
2033 #define _istprint           _ismbcprint
2034 #define _istprint_l        _ismbcprint_l
2035 #define _istpunct           _ismbcpunct
2036 #define _istpunct_l        _ismbcpunct_l
2037 #define _istspace           _ismbcspace
2038 #define _istspace_l        _ismbcspace_l
2039 #define _istupper           _ismbcupper
2040 #define _istupper_l        _ismbcupper_l
2041
2042 #define _totupper           _mbctoupper
2043 #define _totupper_l        _mbctoupper_l
2044 #define _totlower           _mbctolower
2045 #define _totlower_l        _mbctolower_l
2046
2047 #define _istlead             _ismbblead
2048 #define _istleadbyte      isleadbyte
2049 #define _istleadbyte_l  _isleadbyte_l
2050
2051 #else     /* !_MBCS */
2052
2053 /* ++++++++++++++++++++ SBCS ++++++++++++++++++++ */
2054
2055
2056 #ifndef __TCHAR_DEFINED
2057 typedef char                    _TCHAR;
2058 typedef signed char        _TSCHAR;
2059 typedef unsigned char     _TUCHAR;
2060 typedef char                    _TXCHAR;
2061 typedef int                     _TINT;
2062 #define __TCHAR_DEFINED
2063 #endif
2064
2065 #ifndef _TCHAR_DEFINED
2066 #if        !__STDC__
2067 typedef char                    TCHAR;
2068 #endif
2069 #define _TCHAR_DEFINED
2070 #endif
2071
2072
2073 /* String functions */
2074
2075 #define _tcschr               strchr
2076 #define _tcscspn             strcspn
2077 #define _tcsncat             strncat
2078 #define _tcsncat_s          strncat_s
2079 #define _tcsncat_l          _strncat_l
2080 #define _tcsncat_s_l      _strncat_s_l
2081 #define _tcsncpy             strncpy
2082 #define _tcsncpy_s          strncpy_s
2083 #define _tcsncpy_l          _strncpy_l
2084 #define _tcsncpy_s_l      _strncpy_s_l
2085 #define _tcspbrk             strpbrk
2086 #define _tcsrchr             strrchr
2087 #define _tcsspn               strspn
2088 #define _tcsstr               strstr
2089 #define _tcstok               strtok
2090 #define _tcstok_s           strtok_s
2091 #define _tcstok_l           _strtok_l
2092 #define _tcstok_s_l        _strtok_s_l
2093
2094 #define _tcsnset             _strnset
2095 #define _tcsnset_s          _strnset_s
2096 #define _tcsnset_l          _strnset_l
2097 #define _tcsnset_s_l      _strnset_s_l
2098 #define _tcsrev               _strrev
2099 #define _tcsset               _strset
2100 #define _tcsset_s           _strset_s
2101 #define _tcsset_l           _strset_l
2102 #define _tcsset_s_l        _strset_s_l
2103
2104 #define _tcscmp               strcmp
2105 #define _tcsicmp             _stricmp
2106 #define _tcsicmp_l          _stricmp_l
2107 #define _tcsnccmp           strncmp
2108 #define _tcsncmp             strncmp
2109 #define _tcsncicmp          _strnicmp
2110 #define _tcsncicmp_l      _strnicmp_l
2111 #define _tcsnicmp           _strnicmp
2112 #define _tcsnicmp_l        _strnicmp_l
2113
2114 #define _tcscoll             strcoll
2115 #define _tcscoll_l          _strcoll_l
2116 #define _tcsicoll           _stricoll
2117 #define _tcsicoll_l        _stricoll_l
2118 #define _tcsnccoll          _strncoll
2119 #define _tcsnccoll_l      _strncoll_l
2120 #define _tcsncoll           _strncoll
2121 #define _tcsncoll_l        _strncoll_l
2122 #define _tcsncicoll        _strnicoll
2123 #define _tcsncicoll_l     _strnicoll_l
2124 #define _tcsnicoll          _strnicoll
2125 #define _tcsnicoll_l      _strnicoll_l
2126
2127 /* "logical-character" mappings */
2128
2129 #define _tcsclen             strlen
2130 #define _tcscnlen           strnlen
2131 #define _tcsclen_l(_String, _Locale) strlen(_String)
2132 #define _tcscnlen_l(_String, _Max_count, _Locale) strnlen((_String), (_Max_count))
2133 #define _tcsnccat           strncat
2134 #define _tcsnccat_s        strncat_s  
2135 #define _tcsnccat_l        _strncat_l  
2136 #define _tcsnccat_s_l     _strncat_s_l
2137 #define _tcsnccpy           strncpy
2138 #define _tcsnccpy_s        strncpy_s  
2139 #define _tcsnccpy_l        _strncpy_l  
2140 #define _tcsnccpy_s_l     _strncpy_s_l
2141 #define _tcsncset           _strnset
2142 #define _tcsncset_s        _strnset_s
2143 #define _tcsncset_l        _strnset_l
2144 #define _tcsncset_s_l     _strnset_s_l
2145
2146 /* MBCS-specific functions */
2147
2148 #define _tcsdec        _strdec
2149 #define _tcsinc        _strinc
2150 #define _tcsnbcnt     _strncnt
2151 #define _tcsnccnt     _strncnt
2152 #define _tcsnextc     _strnextc
2153 #define _tcsninc      _strninc
2154 #define _tcsspnp      _strspnp
2155
2156 #define _tcslwr        _strlwr
2157 #define _tcslwr_l     _strlwr_l
2158 #define _tcslwr_s     _strlwr_s
2159 #define _tcslwr_s_l _strlwr_s_l
2160 #define _tcsupr        _strupr
2161 #define _tcsupr_l     _strupr_l
2162 #define _tcsupr_s     _strupr_s
2163 #define _tcsupr_s_l _strupr_s_l
2164 #define _tcsxfrm      strxfrm
2165 #define _tcsxfrm_l  _strxfrm_l
2166
2167 #define _istlead(_Char)                            (0)
2168 #define _istleadbyte(_Char)                     (0)
2169 #define _istleadbyte_l(_Char, _Locale)  (0)
2170
2171 #if        __STDC__ || defined(_NO_INLINING)
2172 #define _tclen(_pc) (1)
2173 #define _tccpy(_pc1,_cpc2) (*(_pc1) = *(_cpc2))
2174 #define _tccpy_l(_pc1,_cpc2,_locale) _tccpy((_pc1),(_cpc2))
2175 #define _tccmp(_cpc1,_cpc2) (((unsigned char)*(_cpc1))-((unsigned char)*(_cpc2)))
2176 #else     /* __STDC__ */
2177 _Check_return_ __inline size_t __CRTDECL _tclen(_In_z_ const char *_cpc)
2178 { 
2179       /* avoid compiler warning */
2180       (void *)_cpc;
2181       return 1;
2182 }
2183 __inline void __CRTDECL _tccpy(_Out_ char *_pc1, _In_z_ const char *_cpc2) { *_pc1 = *_cpc2; }
2184 __inline void __CRTDECL _tccpy_l(_Out_ char *_Pc1, _In_z_ const char *_Cpc2, _In_opt_ _locale_t _Locale)
2185 {
2186       _CRT_UNUSED(_Locale);
2187       _tccpy(_Pc1, _Cpc2);
2188 }
2189 _Check_return_ __inline int __CRTDECL _tccmp(_In_z_ const char *_cpc1, _In_z_ const char *_cpc2) { return (int) (((unsigned char)*_cpc1)-((unsigned char)*_cpc2)); }
2190 #endif  /* __STDC__ */
2191
2192
2193 /* ctype-functions */
2194
2195 #define _istalnum     isalnum
2196 #define _istalnum_l     _isalnum_l
2197 #define _istalpha     isalpha
2198 #define _istalpha_l     _isalpha_l
2199 #define _istdigit     isdigit
2200 #define _istdigit_l     _isdigit_l
2201 #define _istgraph     isgraph
2202 #define _istgraph_l     _isgraph_l
2203 #define _istlower     islower
2204 #define _istlower_l     _islower_l
2205 #define _istprint     isprint
2206 #define _istprint_l     _isprint_l
2207 #define _istpunct     ispunct
2208 #define _istpunct_l     _ispunct_l
2209 #define _istspace     isspace
2210 #define _istspace_l     _isspace_l
2211 #define _istupper     isupper
2212 #define _istupper_l     _isupper_l
2213
2214 #define _totupper     toupper
2215 #define _totupper_l     _toupper_l
2216 #define _totlower     tolower
2217 #define _totlower_l     _tolower_l
2218
2219 #define _istlegal(_c)     (1)
2220
2221
2222 /* the following is optional if functional versions are available */
2223
2224 /* define NULL pointer value */
2225 #ifndef NULL
2226 #ifdef __cplusplus
2227 #define NULL      0
2228 #else
2229 #define NULL      ((void *)0)
2230 #endif
2231 #endif
2232
2233
2234 #if        __STDC__ || defined(_NO_INLINING)
2235 #define _strdec(_cpc1, _cpc2) ((_cpc1)>=(_cpc2) ? NULL : (_cpc2)-1)
2236 #define _strinc(_pc)      ((_pc)+1)
2237 #define _strnextc(_cpc) ((unsigned int) *(const unsigned char *)(_cpc))
2238 #define _strninc(_pc, _sz) (((_pc)+(_sz)))
2239 _CRTIMP size_t    __cdecl    __strncnt(_In_count_(_Cnt) _Pre_z_ const char * _Str, _In_ size_t _Cnt);
2240 #define _strncnt(_cpc, _sz) (__strncnt(_cpc,_sz))
2241 #define _strspnp(_cpc1, _cpc2)                                                                                                (_cpc1==NULL ? NULL : ((*((_cpc1)+strspn(_cpc1,_cpc2))) ? ((_cpc1)+strspn(_cpc1,_cpc2)) : NULL))
2242
2243 #define _strncpy_l(_Destination, _Source, _Count, _Locale)                                                  (strncpy(_Destination, _Source, _Count))
2244 #if __STDC_WANT_SECURE_LIB__
2245 #define _strncpy_s_l(_Destination, _Destination_size_chars, _Source, _Count, _Locale)     (strncpy_s(_Destination, _Destination_size_chars, _Source, _Count))
2246 #endif
2247 #define _strncat_l(_Destination, _Source, _Count, _Locale)                                                  (strncat(_Destination, _Source, _Count))
2248 #if __STDC_WANT_SECURE_LIB__
2249 #define _strncat_s_l(_Destination, _Destination_size_chars, _Source, _Count, _Locale)     (strncat_s(_Destination, _Destination_size_chars, _Source, _Count))
2250 #endif
2251 #define _strtok_l(_String, _Delimiters, _Locale)                                                                  (strtok(_String, _Delimiters))
2252 #if __STDC_WANT_SECURE_LIB__
2253 #define _strtok_s_l(_String, _Delimiters, _Current_position, _Locale)                               (strtok_s(_String, _Delimiters, _Current_position))
2254 #endif
2255 #define _strnset_l(_Destination, _Value, _Count, _Locale)                                                   (_strnset(_Destination, _Value, _Count))
2256 #define _strnset_s_l(_Destination, _Destination_size_chars, _Value, _Count, _Locale)      (_strnset_s(_Destination, _Destination_size_chars, _Value, _Count))
2257 #define _strset_l(_Destination, _Value, _Locale)                                                                  (_strset(_Destination, _Value))
2258 #define _strset_s_l(_Destination, _Destination_size_chars, _Value, _Locale)                     (_strset_s(_Destination, _Destination_size_chars, _Value))
2259 #else     /* __STDC__ */
2260 _Check_return_ __inline char * __CRTDECL _strdec(_In_count_x_(_Cpc2 - _Cpc1) _Pre_z_ const char * _Cpc1, _In_z_ const char * _Cpc2) { return (char *)((_Cpc1)>=(_Cpc2) ? NULL : (_Cpc2-1)); }
2261 _Check_return_ __inline char * __CRTDECL _strinc(_In_z_ const char * _Pc) { return (char *)(_Pc+1); }
2262 _Check_return_ __inline unsigned int __CRTDECL _strnextc(_In_z_ const char * _Cpc) { return (unsigned int)*(const unsigned char *)_Cpc; }
2263 _Check_return_ __inline char * __CRTDECL _strninc(_In_count_(_Sz) _Pre_z_ const char * _Pc, _In_ size_t _Sz) { return (char *)(_Pc+_Sz); }
2264 _Check_return_ __inline size_t __CRTDECL _strncnt(_In_count_(_Cnt) _Pre_z_  const char * _String, _In_ size_t _Cnt) 
2265 { 
2266              size_t n = _Cnt; 
2267              char *cp = (char *)_String; 
2268              while (n-- && *cp) 
2269                           cp++; 
2270              return _Cnt - n - 1; 
2271 }
2272 _Check_return_ __inline char * __CRTDECL _strspnp
2273 ( 
2274       _In_z_ const char * _Cpc1, 
2275       _In_z_ const char * _Cpc2
2276 ) 
2277 { 
2278       return _Cpc1==NULL ? NULL : ((*(_Cpc1 += strspn(_Cpc1,_Cpc2))!='\0') ? (char*)_Cpc1 : NULL); 
2279 }
2280
2281 #if __STDC_WANT_SECURE_LIB__
2282 _Check_return_wat_ __inline errno_t __CRTDECL _strncpy_s_l(_Out_z_cap_(_Destination_size_chars) char *_Destination, _In_ size_t _Destination_size_chars, _In_z_ const char *_Source, _In_ size_t _Count, _In_opt_ _locale_t _Locale)
2283 {
2284       _CRT_UNUSED(_Locale);
2285       return strncpy_s(_Destination, _Destination_size_chars, _Source, _Count);
2286 }
2287 #endif
2288
2289 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(errno_t, _strncpy_s_l, _Deref_post_z_ char, _Dest, _In_z_ const char *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2290
2291 __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(char *, __RETURN_POLICY_DST, _strncpy_l, _strncpy_s_l, _Out_z_cap_(_Size) char, _Out_cap_(_Count) char, _Dst, _In_z_ const char *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2292 {
2293       _CRT_UNUSED(_Locale);
2294 #pragma warning( push )
2295 #pragma warning( disable : 4996 )
2296       return strncpy(_Dst, _Source, _Count);
2297 #pragma warning( pop )
2298 }
2299
2300 __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(char *, __RETURN_POLICY_DST, _strncpy_l, _strncpy_s_l, _Deref_out_z_cap_c_(_Size) char, _Out_cap_(_Count), char, _Dst, _In_z_ const char *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2301
2302 #if __STDC_WANT_SECURE_LIB__
2303 _Check_return_wat_ __inline errno_t __CRTDECL _strncat_s_l(_Inout_z_cap_(_Destination_size_chars) char *_Destination, _In_ size_t _Destination_size_chars, _In_z_ const char *_Source, _In_ size_t _Count, _In_opt_ _locale_t _Locale)
2304 {
2305       _CRT_UNUSED(_Locale);
2306       return strncat_s(_Destination, _Destination_size_chars, _Source, _Count);
2307 }
2308 #endif
2309
2310 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(errno_t, _strncat_s_l, _Deref_prepost_z_ char, _Dest, _In_z_ const char *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2311
2312 __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(char *, __RETURN_POLICY_DST, _strncat_l, _strncat_s_l, _Inout_z_cap_(_Size) char, _Inout_z_ char, _Dst, _In_z_ const char *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2313 {
2314       _CRT_UNUSED(_Locale);
2315 #pragma warning( push )
2316 #pragma warning( disable : 4996 6054 )
2317       return strncat(_Dst, _Source, _Count);
2318 #pragma warning( pop )
2319 }
2320
2321 __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(char *, __RETURN_POLICY_DST, _strncat_l, _strncat_s_l, _Deref_inout_z_cap_c_(_Size) char, _Inout_z_, char, _Dst, _In_z_ const char *, _Source, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2322
2323 _Check_return_ _CRT_INSECURE_DEPRECATE(_strtok_s_l) __inline char *  _strtok_l(_Inout_opt_z_ char * _String, _In_z_ const char * _Delimiters, _In_opt_ _locale_t _Locale) 
2324 {
2325       _CRT_UNUSED(_Locale);
2326 #pragma warning(push)
2327 #pragma warning(disable:4996)
2328       return strtok(_String,_Delimiters);
2329 #pragma warning(pop)
2330 }
2331
2332 #if __STDC_WANT_SECURE_LIB__
2333 _Check_return_ __inline char *  _strtok_s_l(_Inout_opt_z_ char * _String, _In_z_ const char * _Delimiters, _Inout_ _Deref_prepost_opt_z_ char **_Current_position, _In_opt_ _locale_t _Locale) 
2334 {
2335       _CRT_UNUSED(_Locale);
2336       return strtok_s(_String, _Delimiters, _Current_position);
2337 }
2338 #endif
2339
2340 __inline errno_t __CRTDECL _strnset_s_l(_Inout_z_cap_(_Destination_size_chars) char *_Destination, _In_ size_t _Destination_size_chars, _In_ int _Value, _In_ size_t _Count, _In_opt_ _locale_t _Locale)
2341 {
2342       _CRT_UNUSED(_Locale);
2343       return _strnset_s(_Destination, _Destination_size_chars, _Value, _Count);
2344 }
2345
2346 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(errno_t, _strnset_s_l, _Deref_prepost_z_ char, _Dest, _In_ int, _Value, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2347
2348 __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(char *, __RETURN_POLICY_DST, _strnset_l, _strnset_s_l, _Inout_z_cap_(_Size) char, _Inout_z_cap_(_MaxCount) char, _Dst, _In_ int, _Value, _In_ size_t, _MaxCount, _In_opt_ _locale_t, _Locale)
2349 {
2350       _CRT_UNUSED(_Locale);
2351 #pragma warning( push )
2352 #pragma warning( disable : 4996 6054 )
2353       return _strnset(_Dst, _Value, _MaxCount);
2354 #pragma warning( pop )
2355 }
2356
2357 __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(char *, __RETURN_POLICY_DST, _strnset_l, _strnset_s_l, _Deref_inout_z_cap_c_(_Size) char, _Inout_z_cap_(_MaxCount), char, _Dst, _In_ int, _Value, _In_ size_t, _Count, _In_opt_ _locale_t, _Locale)
2358
2359 __inline errno_t __CRTDECL _strset_s_l(_Inout_z_cap_(_Destination_size_chars) char *_Destination, _In_ size_t _Destination_size_chars, _In_ int _Value, _In_opt_ _locale_t _Locale)
2360 {
2361       _CRT_UNUSED(_Locale);
2362       return _strset_s(_Destination, _Destination_size_chars, _Value);
2363 }
2364
2365 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(errno_t, _strset_s_l, _Deref_prepost_z_ char, _Dest, _In_ int, _Value, _In_opt_ _locale_t, _Locale)
2366
2367 __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(char *, __RETURN_POLICY_DST, _strset_l, _strset_s_l, _Inout_z_cap_(_Size) char, _Inout_z_ char, _Dst, _In_ int, _Value, _In_opt_ _locale_t, _Locale)
2368 {
2369       _CRT_UNUSED(_Locale);
2370 #pragma warning( push )
2371 #pragma warning( disable : 4996 )
2372       return _strset(_Dst, _Value);
2373 #pragma warning( pop )
2374 }
2375
2376 __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(char *, __RETURN_POLICY_DST, _strset_l, _strset_s_l, _Deref_inout_z_cap_c_(_Size) char, _Inout_z_, char, _Dst, _In_ int, _Value, _In_opt_ _locale_t, _Locale)
2377
2378 #endif  /* __STDC__ */
2379
2380
2381 #endif  /* _MBCS */
2382
2383
2384 #endif  /* _UNICODE */
2385
2386
2387 /* Generic text macros to be used with string literals and character constants.
2388      Will also allow symbolic constants that resolve to same. */
2389
2390 #define _T(x)           __T(x)
2391 #define _TEXT(x)      __T(x)
2392
2393
2394 #ifdef  __cplusplus
2395 }     /* ... extern "C" */
2396 #endif
2397
2398 #endif  /* _INC_TCHAR */
2399
2400