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.

128 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name :
  4. tsvmap.cxx
  5. Abstract:
  6. This is a test module for the server variable map
  7. Author:
  8. Taylor Weiss ( TaylorW ) 19-Apr-1999
  9. Environment:
  10. User Mode - Win32
  11. Project:
  12. Internet Information Services
  13. Functions Exported:
  14. Revision History:
  15. --*/
  16. #include <windows.h>
  17. #include <dbgutil.h>
  18. #include <svmap.h>
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. DECLARE_DEBUG_PRINTS_OBJECT();
  22. #ifndef _NO_TRACING_
  23. #include <initguid.h>
  24. DEFINE_GUID(IisTSvMapGuid,
  25. 0x784d8939, 0xaa8c, 0x11d2, 0x92, 0x5e, 0x00, 0xc0, 0x4f, 0x72, 0xd9, 0x0e);
  26. #else
  27. DECLARE_DEBUG_VARIABLE();
  28. #endif
  29. #define DEFINE_SV( token ) #token,
  30. LPCSTR rgValidNames[] =
  31. {
  32. ALL_SERVER_VARIABLES()
  33. };
  34. #undef DEFINE_SV
  35. int cValidNames = sizeof(rgValidNames)/sizeof(rgValidNames[0]);
  36. LPCSTR rgInvalidNames[] =
  37. {
  38. "HTTP_BOGUS",
  39. "_HTTP_",
  40. "47",
  41. "",
  42. "Hello, There!",
  43. "0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
  44. };
  45. int cInvalidNames = sizeof(rgInvalidNames)/sizeof(rgInvalidNames[0]);
  46. int __cdecl
  47. main(int argc, char * argv[])
  48. {
  49. int argSeen = 1;
  50. #ifndef _NO_TRACING_
  51. CREATE_DEBUG_PRINT_OBJECT( argv[0], IisTSvMapGuid);
  52. CREATE_INITIALIZE_DEBUG();
  53. #else
  54. CREATE_DEBUG_PRINT_OBJECT( argv[0]);
  55. SET_DEBUG_FLAGS( DEBUG_ERROR | DEBUG_INIT_CLEAN);
  56. #endif
  57. SV_CACHE_MAP map;
  58. DBG_REQUIRE( map.Initialize() );
  59. // Dump the table
  60. // This should be more than enough space, see
  61. // SV_CACHE_MAP::Print if this asserts.
  62. CHAR pchBuffer[ 5000 ];
  63. DWORD cb = sizeof( pchBuffer );
  64. map.PrintToBuffer( pchBuffer, &cb );
  65. DBG_ASSERT( cb < sizeof(pchBuffer) );
  66. printf( pchBuffer );
  67. DWORD dwId = 0;
  68. // Do lookups for all valid names
  69. for( int i = 0; i < cValidNames; ++i )
  70. {
  71. DBG_REQUIRE( map.FindOrdinal( rgValidNames[i],
  72. strlen( rgValidNames[i] ),
  73. &dwId
  74. ) );
  75. DBG_REQUIRE( strcmp( rgValidNames[i], map.FindName( dwId ) ) == 0 );
  76. }
  77. // Do lookups for invalid names
  78. for( int j = 0; j < cInvalidNames; ++j )
  79. {
  80. DBG_REQUIRE( map.FindOrdinal( rgInvalidNames[j],
  81. strlen( rgInvalidNames[j] ),
  82. &dwId
  83. ) == FALSE );
  84. }
  85. DELETE_DEBUG_PRINT_OBJECT();
  86. return 1;
  87. } // main()