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
2.0 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. spstring.h
  5. Abstract:
  6. Header file for functions to manipulate strings.
  7. These functions would ordinarily be performed by C Runtime routines
  8. except that we want to avoid linking this device driver with
  9. the kernel crt.
  10. Author:
  11. Ted Miller (tedm) 15-Jan-1994
  12. Revision History:
  13. --*/
  14. //
  15. // Character types.
  16. //
  17. #define _SP_NONE 0x00
  18. #define _SP_SPACE 0x01
  19. #define _SP_DIGIT 0x02
  20. #define _SP_XDIGIT 0x04
  21. #define _SP_UPPER 0x08
  22. #define _SP_LOWER 0x10
  23. //
  24. // Optimize the size of the types array by noting that no characters
  25. // above 'z' have any attributes we care about.
  26. //
  27. #define CTSIZE ('z'+1)
  28. extern UCHAR _SpCharTypes[CTSIZE];
  29. //
  30. // Be careful using these as they evaluate their arguments more than once.
  31. //
  32. #define SpIsSpace(c) (((c) < CTSIZE) ? (_SpCharTypes[(c)] & _SP_SPACE) : FALSE)
  33. #define SpIsDigit(c) (((c) < CTSIZE) ? (_SpCharTypes[(c)] & _SP_DIGIT) : FALSE)
  34. #define SpIsXDigit(c) (((c) < CTSIZE) ? (_SpCharTypes[(c)] & _SP_XDIGIT) : FALSE)
  35. #define SpIsUpper(c) (((c) < CTSIZE) ? (_SpCharTypes[(c)] & _SP_UPPER) : FALSE)
  36. #define SpIsLower(c) (((c) < CTSIZE) ? (_SpCharTypes[(c)] & _SP_LOWER) : FALSE)
  37. #define SpIsAlpha(c) (SpIsUpper(c) || SpIsLower(c))
  38. #define SpToUpper(c) ((WCHAR)(SpIsLower(c) ? ((c)-(L'a'-L'A')) : (c)))
  39. #define SpToLower(c) ((WCHAR)(SpIsUpper(c) ? ((c)+(L'a'-L'A')) : (c)))
  40. VOID
  41. SpStringToUpper(
  42. IN PWSTR String
  43. );
  44. VOID
  45. SpStringToLower(
  46. IN PWSTR String
  47. );
  48. PWCHAR
  49. SpFindCharFromListInString(
  50. PWSTR String,
  51. PWSTR CharList
  52. );
  53. unsigned
  54. SpMultiByteStringToUnsigned(
  55. IN PUCHAR String,
  56. OUT PUCHAR *CharThatStoppedScan OPTIONAL
  57. );
  58. LONG
  59. SpStringToLong(
  60. IN PWSTR String,
  61. OUT PWCHAR *EndOfValue,
  62. IN unsigned Radix
  63. );
  64. PCHAR
  65. SpConvertMultiSzWstrToStr(
  66. IN PWCHAR Source,
  67. IN ULONG Length
  68. );
  69. PWCHAR
  70. SpConvertMultiSzStrToWstr(
  71. IN PCHAR Source,
  72. IN ULONG Length
  73. );