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.

154 lines
2.9 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1993 **/
  4. /**********************************************************************/
  5. /*
  6. utility.cxx
  7. This module contains routines of general utility.
  8. FILE HISTORY:
  9. KeithMo 17-Mar-1993 Created.
  10. */
  11. #include "w3p.hxx"
  12. #include <time.h>
  13. //
  14. // Private constants.
  15. //
  16. //
  17. // The number of times to retry outputting a log item
  18. //
  19. #define LOG_FILE_RETRIES 2
  20. //
  21. // Private globals.
  22. //
  23. //
  24. // Private prototypes.
  25. //
  26. /*******************************************************************
  27. NAME: ::SkipNonWhite
  28. SYNOPSIS: Returns the first whitespace character starting
  29. from the passed position
  30. HISTORY:
  31. Johnl 21-Sep-1994 Created
  32. ********************************************************************/
  33. CHAR * SkipNonWhite( CHAR * pch )
  34. {
  35. while ( *pch && !ISWHITEA( *pch ) && *pch != '\n' )
  36. pch++;
  37. return pch;
  38. }
  39. CHAR * SkipTo( CHAR * pch, CHAR ch )
  40. {
  41. while ( *pch && *pch != '\n' && *pch != ch )
  42. pch++;
  43. return pch;
  44. }
  45. /*******************************************************************
  46. NAME: ::SkipWhite
  47. SYNOPSIS: Skips white space starting at the passed point in the string
  48. and returns the next non-white space character.
  49. HISTORY:
  50. Johnl 23-Aug-1994 Created
  51. ********************************************************************/
  52. CHAR * SkipWhite( CHAR * pch )
  53. {
  54. while ( ISWHITEA( *pch ) )
  55. {
  56. pch++;
  57. }
  58. return pch;
  59. }
  60. /*******************************************************************
  61. NAME: IsPointNine
  62. SYNOPSIS: Determines if the HTTP request is a 0.9 request (has no
  63. version number)
  64. ENTRY: pchReq - HTTP request to look in
  65. RETURNS: TRUE if this is a 0.9 request, FALSE if not
  66. HISTORY:
  67. Johnl 08-Sep-1994 Created
  68. ********************************************************************/
  69. BOOL IsPointNine( CHAR * pchReq )
  70. {
  71. //
  72. // If there's no '\n' then we don't have a complete request yet
  73. //
  74. if ( !strchr( pchReq, '\n' ))
  75. return FALSE;
  76. //
  77. // Skip white space at beginning of request.
  78. //
  79. pchReq = ::SkipWhite( pchReq );
  80. //
  81. // Should be at a 'GET' now.
  82. //
  83. if (*pchReq != 'G' && *pchReq != 'g')
  84. {
  85. return FALSE;
  86. }
  87. //
  88. // Skip the rest of the verb, whitespace, and the URL.
  89. // URL.
  90. pchReq = ::SkipNonWhite( pchReq );
  91. pchReq = ::SkipWhite( pchReq );
  92. pchReq = ::SkipNonWhite( pchReq );
  93. //
  94. // Skip white space after the URL
  95. //
  96. pchReq = ::SkipWhite( pchReq );
  97. if (*pchReq == '\n' || *pchReq == '\0')
  98. {
  99. return TRUE;
  100. }
  101. return FALSE;
  102. }
  103. //
  104. // Private functions.
  105. //
  106.