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.

194 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1991-1993 Microsoft Corporation
  3. Module Name:
  4. tstring.h
  5. Abstract:
  6. This include file contains manifests and macros to be used to integrate
  7. the TCHAR and LPTSTR definitions
  8. Note that our naming convention is that a "size" indicates a number of
  9. bytes whereas a "length" indicates a number of characters.
  10. Author:
  11. Richard Firth (rfirth) 02-Apr-1991
  12. Environment:
  13. Portable (Win/32).
  14. Requires ANSI C extensions: slash-slash comments, long external names,
  15. _ultoa() routine.
  16. Revision History:
  17. 22-May-1991 Danl
  18. Added STRSIZE macro
  19. 19-May-1991 JohnRo
  20. Changed some parm names to make things easier to read.
  21. 15-May-1991 rfirth
  22. Added TCHAR_SPACE and MAKE_TCHAR() macro
  23. 15-Jul-1991 RFirth
  24. Added STRING_SPACE_REQD() and DOWN_LEVEL_STRSIZE
  25. 05-Aug-1991 JohnRo
  26. Added MEMCPY macro.
  27. 19-Aug-1991 JohnRo
  28. Added character type stuff: ISDIGIT(), TOUPPER(), etc.
  29. 20-Aug-1991 JohnRo
  30. Changed strnicmp to _strnicmp to keep PC-LINT happy. Ditto stricmp.
  31. 13-Sep-1991 JohnRo
  32. Need UNICODE STRSIZE() too.
  33. 13-Sep-1991 JohnRo
  34. Added UNICODE STRCMP() and various others.
  35. 18-Oct-1991 JohnRo
  36. Added NetpCopy routines and WCSSIZE().
  37. 26-Nov-1991 JohnRo
  38. Added NetpNCopy routines (like strncpy but do conversions as well).
  39. 09-Dec-1991 rfirth
  40. Added STRREV
  41. 03-Jan-1992 JohnRo
  42. Added NetpAlloc{type}From{type} routines and macros.
  43. 09-Jan-1992 JohnRo
  44. Added ATOL() macro and wtol() routine.
  45. Ditto ULTOA() macro and ultow() routine.
  46. 13-Jan-1992 JohnRo
  47. Oops, I missed from NetpAlloc{type}From{type} macros
  48. Also added STRNCMPI as an alias for STRNICMP.
  49. 16-Jan-1992 Danl
  50. Moved the macros to \private\inc\tstr.h
  51. 23-Mar-1992 JohnRo
  52. Added NetpCopy{Str,TStr,WStr}ToUnalignedWStr().
  53. 27-Apr-1992 JohnRo
  54. Changed NetpNCopy{type}From{type} to return NET_API_STATUS.
  55. 03-Aug-1992 JohnRo
  56. RAID 1895: Net APIs and svcs should use OEM char set.
  57. 14-Apr-1993 JohnRo
  58. RAID 6113 ("PortUAS: dangerous handling of Unicode").
  59. Made changes suggested by PC-LINT 5.0
  60. --*/
  61. #ifndef _TSTRING_H_INCLUDED
  62. #define _TSTRING_H_INCLUDED
  63. #include <lmcons.h> // NET_API_STATUS.
  64. // Don't complain about "unneeded" includes of these files:
  65. /*lint -efile(764,tstr.h,winerror.h) */
  66. /*lint -efile(766,tstr.h,winerror.h) */
  67. #include <tstr.h> // tstring stuff, used in macros below.
  68. #include <winerror.h> // NO_ERROR.
  69. //
  70. // Eventually, most uses of non-UNICODE strings should refer to the default
  71. // codepage for the LAN. The NetpCopy functions support the default codepage.
  72. // The other STR macros may not.
  73. //
  74. VOID
  75. NetpCopyStrToWStr(
  76. OUT LPWSTR Dest,
  77. IN LPSTR Src // string in default LAN codepage
  78. );
  79. NET_API_STATUS
  80. NetpNCopyStrToWStr(
  81. OUT LPWSTR Dest,
  82. IN LPSTR Src, // string in default LAN codepage
  83. IN DWORD CharCount
  84. );
  85. VOID
  86. NetpCopyWStrToStr(
  87. OUT LPSTR Dest, // string in default LAN codepage
  88. IN LPWSTR Src
  89. );
  90. NET_API_STATUS
  91. NetpNCopyWStrToStr(
  92. OUT LPSTR Dest, // string in default LAN codepage
  93. IN LPWSTR Src,
  94. IN DWORD CharCount
  95. );
  96. VOID
  97. NetpCopyWStrToStrDBCS(
  98. OUT LPSTR Dest, // string in default LAN codepage
  99. IN LPWSTR Src
  100. );
  101. ULONG
  102. NetpUnicodeToDBCSLen(
  103. IN LPWSTR Src
  104. );
  105. #ifdef UNICODE
  106. #define NetpCopyStrToTStr(Dest,Src) NetpCopyStrToWStr((Dest),(Src))
  107. #define NetpCopyTStrToStr(Dest,Src) NetpCopyWStrToStr((LPSTR)(Dest),(LPWSTR)(Src))
  108. #define NetpCopyTStrToWStr(Dest,Src) (void) wcscpy((Dest),(Src))
  109. #define NetpNCopyTStrToWStr(Dest,Src,Len) \
  110. (wcsncpy((Dest),(Src),(Len)), NO_ERROR)
  111. #endif // UNICODE
  112. //
  113. // Define a set of allocate and copy functions. These all return NULL if
  114. // unable to allocate memory. The memory must be freed with NetApiBufferFree.
  115. //
  116. LPSTR
  117. NetpAllocStrFromWStr (
  118. IN LPWSTR Src
  119. );
  120. LPWSTR
  121. NetpAllocWStrFromStr (
  122. IN LPSTR Src
  123. );
  124. LPWSTR
  125. NetpAllocWStrFromWStr (
  126. IN LPWSTR Src
  127. );
  128. //
  129. // As of 03-Aug-1992, people are still arguing over whether there should
  130. // be an RtlInitOemString. So I'm inventing NetpInitOemString in the
  131. // meantime. --JR
  132. //
  133. #ifdef _NTDEF_ // POEM_STRING typedef visible?
  134. VOID
  135. NetpInitOemString(
  136. OUT POEM_STRING DestinationString,
  137. IN PCSZ SourceString
  138. );
  139. #endif // _NTDEF_
  140. //
  141. //
  142. // ANSI versions of the API.
  143. //
  144. LPWSTR
  145. NetpAllocWStrFromAStr (
  146. IN LPCSTR Src
  147. );
  148. LPSTR
  149. NetpAllocAStrFromWStr (
  150. IN LPCWSTR Src
  151. );
  152. #endif // _TSTRING_H_INCLUDED