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.

113 lines
2.7 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 stricmp
  35. #undef _stricmp
  36. #undef strlwr
  37. #undef _strlwr
  38. #undef strupr
  39. #undef tolower
  40. #undef toupper
  41. #undef wcslen
  42. #undef _strstr
  43. #undef strstr
  44. #undef _strchr
  45. #undef strchr
  46. #undef strrchr
  47. #undef __atoi
  48. #undef _atoi
  49. #undef atoi
  50. #undef _strncat
  51. #undef strncat
  52. #undef _strncpy
  53. #undef strncpy
  54. #undef _strnicmp
  55. #undef strnicmp
  56. #undef _strncmp
  57. #undef strncmp
  58. #undef StrChr
  59. #define free(ptr) FREE_MEMORY((HLOCAL) ptr)
  60. #define malloc(size) ((PVOID)ALLOCATE_MEMORY(LMEM_FIXED, size))
  61. #define memmove(m1,m2,n) RtlMoveMemory (m1,m2,n)
  62. #define strdup(s) NewString(s)
  63. #define stricmp(s1,s2) lstrcmpi(s1,s2)
  64. #define _stricmp(s1,s2) lstrcmpi(s1,s2)
  65. #define strlwr(s) CharLower(s)
  66. #define _strlwr(s) CharLower(s)
  67. #define strupr(s) CharUpper(s)
  68. #define tolower(c) ((BYTE) CharLower((LPSTR) ((DWORD_PTR)((BYTE)(c) & 0xff))))
  69. #define toupper(c) ((BYTE) CharUpper((LPSTR) ((DWORD_PTR)((BYTE)(c) & 0xff))))
  70. #define wcslen(s) lstrlenW(s)
  71. #define _strstr StrStr
  72. #define strstr StrStr
  73. #define StrChr PrivateStrChr
  74. #define _strchr StrChr
  75. #define strchr StrChr
  76. #define strrchr(s, c) StrRChr(s, NULL, c)
  77. #define __atoi StrToInt
  78. #define _atoi StrToInt
  79. #define atoi StrToInt
  80. #define strncat StrNCat
  81. #define _strncat StrNCat
  82. #define strncpy StrNCpy
  83. #define _strncpy StrNCpy
  84. #define strnicmp StrCmpNIC
  85. #define _strnicmp StrCmpNIC
  86. #define strncmp StrCmpNC
  87. #define _strncmp StrCmpNC
  88. #undef itoa
  89. #undef ultoa
  90. //#define itoa(val,s,n) _itoa(val,s,n)
  91. //#define ultoa(val,s,n) _ultoa(val,s,n)
  92. #endif /* unix */