Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. tcs.h
  5. Abstract:
  6. Overload the TCS routines to allow simultaneous use of bot char and WCHAR versions
  7. History:
  8. 02/22/2001 robkenny Created
  9. --*/
  10. #pragma once
  11. #ifdef TCHAR
  12. #pragma message( "TCHAR is defined. Do not include TCHAR.H" )
  13. #endif
  14. #include <stdio.h> // for _vsnwprintf
  15. #include "LegalStr.h"
  16. // Overload the _tcs routines to automatically handle Ansi/MBCS or UNICODE
  17. // Crystal clear replacement routines
  18. inline size_t _tcslenBytes(const char * s1) { return strlen(s1); }
  19. inline size_t _tcslenChars(const char * s1)
  20. {
  21. const char * send = s1;
  22. while (*send)
  23. {
  24. // Can't use CharNextA, since User32 might not be initialized
  25. if (IsDBCSLeadByte(*send))
  26. {
  27. ++send;
  28. }
  29. ++send;
  30. }
  31. return send - s1;
  32. }
  33. inline size_t _tcslenBytes(const WCHAR * s1) { return wcslen(s1) * sizeof(WCHAR); }
  34. inline size_t _tcslenChars(const WCHAR * s1) { return wcslen(s1); }
  35. // Allow these routines
  36. inline char * _tcscpy ( char *s1, const char *s2) { return strcpy(s1, s2); }
  37. inline char * _tcsncpy ( char *s1, const char *s2, size_t count ) { return strncpy(s1, s2, count); }
  38. inline int _tcsicmp (const char * s1, const char * s2) { return _stricmp(s1, s2); }
  39. inline int _tcscmp (const WCHAR * s1, const WCHAR * s2) { return wcscmp(s1, s2); }
  40. inline int _tcsncmp (const WCHAR * s1, const WCHAR * s2, size_t count ) { return wcsncmp(s1, s2, count); }
  41. inline int _tcsnicmp (const WCHAR * s1, const WCHAR * s2, size_t count ) { return _wcsnicmp(s1, s2, count); }
  42. inline int _tcsicmp (const WCHAR * s1, const WCHAR * s2) { return _wcsicmp(s1, s2); }
  43. inline int _tcscoll (const WCHAR * s1, const WCHAR * s2) { return wcscoll(s1, s2); }
  44. inline int _tcsicoll(const WCHAR * s1, const WCHAR * s2) { return _wcsicoll(s1, s2); }
  45. inline const WCHAR * _tcschr (const WCHAR * s1, WCHAR ch) { return wcschr(s1, ch); }
  46. inline WCHAR * _tcschr ( WCHAR * s1, WCHAR ch) { return wcschr(s1, ch); }
  47. inline const WCHAR * _tcspbrk (const WCHAR * s1, const WCHAR * s2) { return wcspbrk(s1, s2); }
  48. inline WCHAR * _tcspbrk ( WCHAR * s1, const WCHAR * s2) { return wcspbrk(s1, s2); }
  49. inline WCHAR * _tcsupr ( WCHAR * s1) { return _wcsupr(s1); }
  50. inline WCHAR * _tcslwr ( WCHAR * s1) { return _wcslwr(s1); }
  51. inline WCHAR * _tcsrev ( WCHAR * s1) { return _wcsrev(s1); }
  52. inline const WCHAR * _tcsinc (const WCHAR * s1) { return (s1) + 1; }
  53. inline WCHAR * _tcsinc ( WCHAR * s1) { return (s1) + 1; }
  54. inline const WCHAR * _tcsstr (const WCHAR * s1, const WCHAR * s2) { return wcsstr(s1, s2); }
  55. inline WCHAR * _tcsstr ( WCHAR * s1, const WCHAR * s2) { return wcsstr(s1, s2); }
  56. inline size_t _tcsspn (const WCHAR * s1, const WCHAR * s2) { return wcsspn(s1, s2); }
  57. inline size_t _tcscspn (const WCHAR * s1, const WCHAR * s2) { return wcscspn(s1, s2); }
  58. inline const WCHAR * _tcsrchr ( WCHAR * s1, WCHAR ch) { return wcsrchr(s1, ch); }
  59. inline WCHAR * _tcsrchr (const WCHAR * s1, WCHAR ch) { return wcsrchr(s1, ch); }
  60. inline size_t _tclen (const WCHAR * /*s1*/) { return 1; }
  61. inline size_t _tcslen (const WCHAR * s1) { return _tcslenChars(s1); }
  62. inline int _ttoi (const WCHAR * s1) { return _wtoi(s1); }
  63. inline int _istspace( WCHAR ch) { return iswspace(ch); }
  64. inline int _istdigit( WCHAR ch) { return iswdigit(ch); }
  65. inline WCHAR * _tcsncpy ( WCHAR *s1, const WCHAR *s2, size_t count ) { return wcsncpy(s1, s2, count); }
  66. inline WCHAR * _tcscpy ( WCHAR *s1, const WCHAR *s2) { return wcscpy(s1, s2); }
  67. inline int _tcsnprintf(WCHAR *buffer, size_t count, const WCHAR *format, va_list argptr) { return _vsnwprintf(buffer, count, format, argptr); }
  68. inline BOOL IsPathSep(WCHAR ch) { return ch == L'\\' || ch == L'/'; }
  69. #include "MakeIllegalStr.h"