Leaked source code of windows server 2003
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.

114 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. crtsubst.h
  5. Abstract:
  6. Maps some CRT functions to Win32 calls
  7. Author:
  8. Rajeev Dujari (rajeevd) 04-Apr-1996
  9. Revision History:
  10. 04-Apr-1996 rajeevd
  11. Created
  12. --*/
  13. #include "iert.h"
  14. #ifndef unix
  15. /*
  16. On NT, kernel32 forwards RtlMoveMemory to ntdll.
  17. On 95, kernel32 has RtlMoveMemory but ntdll doesn't.
  18. Override the NT headers forwarding at compile time.
  19. */
  20. #ifdef RtlMoveMemory
  21. #undef RtlMoveMemory
  22. extern "C" void RtlMoveMemory (void *, const void *, unsigned long);
  23. #endif
  24. /* WARNING: Be careful mapping CRT strncpy to Win32 lstrcpyn.
  25. strncpy (dst, "bar", 2); // dst will get 'b', 'a'
  26. lstrcpyn (dst, "bar" 2); // dst will get 'b', 0
  27. strncpy (dst, "bar", 6); // dst will get 'b', 'a', 'r', 0, 0, 0
  28. lstrcpyn (dst, "bar", 6); // dst will get 'b', 'a', 'r', 0
  29. */
  30. #undef free
  31. #undef malloc
  32. #undef memmove
  33. #undef strdup
  34. #undef wcsdup
  35. #undef stricmp
  36. #undef _stricmp
  37. #undef strlwr
  38. #undef _strlwr
  39. #undef strupr
  40. #undef tolower
  41. #undef toupper
  42. #undef wcslen
  43. #undef _strstr
  44. #undef strstr
  45. #undef _strchr
  46. #undef strchr
  47. #undef strrchr
  48. #undef __atoi
  49. #undef _atoi
  50. #undef atoi
  51. #undef _strncat
  52. #undef strncat
  53. #undef _strncpy
  54. #undef strncpy
  55. #undef _strnicmp
  56. #undef strnicmp
  57. #undef _strncmp
  58. #undef strncmp
  59. #undef StrChr
  60. #define free(ptr) FREE_MEMORY((HLOCAL) ptr)
  61. #define malloc(size) ((PVOID)ALLOCATE_MEMORY(LMEM_FIXED, size))
  62. #define memmove(m1,m2,n) RtlMoveMemory (m1,m2,n)
  63. #define strdup(s) NewString(s)
  64. #define wcsdup(s) NewStringW(s)
  65. #define stricmp(s1,s2) lstrcmpi(s1,s2)
  66. #define _stricmp(s1,s2) lstrcmpi(s1,s2)
  67. #define strlwr(s) CharLower(s)
  68. #define _strlwr(s) CharLower(s)
  69. #define strupr(s) CharUpper(s)
  70. #define tolower(c) ((BYTE) CharLower((LPSTR) ((DWORD_PTR)((BYTE)(c) & 0xff))))
  71. #define toupper(c) ((BYTE) CharUpper((LPSTR) ((DWORD_PTR)((BYTE)(c) & 0xff))))
  72. #define wcslen(s) lstrlenW(s)
  73. #define _strstr StrStr
  74. #define strstr StrStr
  75. #define StrChr PrivateStrChr
  76. #define _strchr StrChr
  77. #define strchr StrChr
  78. #define strrchr(s, c) StrRChr(s, NULL, c)
  79. #define __atoi StrToInt
  80. #define _atoi StrToInt
  81. #define atoi StrToInt
  82. #define strncat StrNCat
  83. #define _strncat StrNCat
  84. #define strncpy StrNCpy
  85. #define _strncpy StrNCpy
  86. #define strnicmp StrCmpNIC
  87. #define _strnicmp StrCmpNIC
  88. #define strncmp StrCmpNC
  89. #define _strncmp StrCmpNC
  90. #undef itoa
  91. #undef ultoa
  92. //#define itoa(val,s,n) _itoa(val,s,n)
  93. //#define ultoa(val,s,n) _ultoa(val,s,n)
  94. #endif /* unix */