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.

126 lines
2.1 KiB

  1. /*****************************************************************************
  2. S T R T O K
  3. Name: strtok.c
  4. Date: 21-Jan-1994
  5. Creator: Unknown
  6. Description:
  7. This file contains functions for string manipulations.
  8. History:
  9. 21-Jan-1994 John Fu, cleanup and reformat
  10. *****************************************************************************/
  11. #include <windows.h>
  12. #include "clipbook.h"
  13. #include "strtok.h"
  14. static LPCSTR lpchAlphaDelimiters;
  15. /*
  16. * IsInAlphaA
  17. */
  18. BOOL IsInAlphaA(
  19. char ch)
  20. {
  21. LPCSTR lpchDel = lpchAlphaDelimiters;
  22. if (ch)
  23. {
  24. while (*lpchDel)
  25. {
  26. if (ch == *lpchDel++)
  27. {
  28. return TRUE;
  29. }
  30. }
  31. }
  32. else
  33. {
  34. return TRUE;
  35. }
  36. return FALSE;
  37. }
  38. /*
  39. * strtokA
  40. */
  41. LPSTR strtokA(
  42. LPSTR lpchStart,
  43. LPCSTR lpchDelimiters)
  44. {
  45. static LPSTR lpchEnd;
  46. // PINFO("sTRTOK\r\n");
  47. if (NULL == lpchStart)
  48. {
  49. if (lpchEnd)
  50. {
  51. lpchStart = lpchEnd + 1;
  52. }
  53. else
  54. {
  55. return NULL;
  56. }
  57. }
  58. // PINFO("sTRING: %s\r\n", lpchStart);
  59. lpchAlphaDelimiters = lpchDelimiters;
  60. if (*lpchStart)
  61. {
  62. while (IsInAlphaA(*lpchStart))
  63. {
  64. lpchStart++;
  65. }
  66. // PINFO("Token: %s\r\n", lpchStart);
  67. lpchEnd = lpchStart;
  68. while (*lpchEnd && !IsInAlphaA(*lpchEnd))
  69. {
  70. lpchEnd++;
  71. }
  72. if (*lpchEnd)
  73. {
  74. // PINFO("Found tab\r\n");
  75. *lpchEnd = '\0';
  76. }
  77. else
  78. {
  79. // PINFO("Found null\r\n");
  80. lpchEnd = NULL;
  81. }
  82. }
  83. else
  84. {
  85. lpchEnd = NULL;
  86. return NULL;
  87. }
  88. // PINFO("Returning %s\r\n", lpchStart);
  89. return lpchStart;
  90. }