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.

184 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1995-2000 Microsoft Corporation
  3. Module Name:
  4. help.cxx
  5. Abstract:
  6. This module contains the help text for all commands supported by this
  7. NTSD debugger extension.
  8. Author:
  9. Keith Moore (keithmo) 12-Nov-1997
  10. Revision History:
  11. --*/
  12. #include "precomp.hxx"
  13. //
  14. // The following structure defines the text displayed in response
  15. // to the "!help" command. This text may also be displayed if invalid
  16. // arguments are passed to a command.
  17. //
  18. typedef struct _HELP_MAP {
  19. //
  20. // This is the name of the command.
  21. //
  22. PSTR Command;
  23. //
  24. // This is a "one-liner" displayed when the user executes "!help".
  25. //
  26. PSTR OneLiner;
  27. //
  28. // This is the full help text displayed when the user executes
  29. // "!help <cmd>".
  30. //
  31. PSTR FullHelp;
  32. } HELP_MAP, *PHELP_MAP;
  33. HELP_MAP HelpMaps[] =
  34. {
  35. {
  36. "help",
  37. "Dump this list or help for specific command",
  38. "help [<cmd>] - Dump help for command\n"
  39. " If no <cmd> is given, a list of all available commands is displayed\n"
  40. },
  41. {
  42. "lkrhash",
  43. "Dump LKRhash table structures",
  44. "!lkrhash [options] <addr> - Dump LKRhash table at <addr>\n"
  45. " -l[0-2] == verbosity level\n"
  46. " -v == very verbose\n"
  47. " -g[0-2] == dump global list of LKRhashes at verbosity level\n"
  48. },
  49. };
  50. #define NUM_HELP_MAPS ( sizeof(HelpMaps) / sizeof(HelpMaps[0]) )
  51. PSTR
  52. FindHelpForCommand(
  53. IN PSTR CommandName
  54. )
  55. {
  56. PHELP_MAP helpMap;
  57. ULONG i;
  58. for( i = NUM_HELP_MAPS, helpMap = HelpMaps ; i > 0 ; i--, helpMap++ ) {
  59. if( _stricmp( helpMap->Command, CommandName ) == 0 ) {
  60. return helpMap->FullHelp;
  61. }
  62. }
  63. return NULL;
  64. } // FindHelpForCommand
  65. VOID
  66. PrintUsage(
  67. IN PSTR CommandName
  68. )
  69. {
  70. PSTR cmdHelp;
  71. PHELP_MAP helpMap;
  72. ULONG i;
  73. ULONG maxLength;
  74. ULONG length;
  75. dprintf( "IIS debugging extension for IIS Version 5.0\n" );
  76. if( CommandName == NULL ) {
  77. //
  78. // We'll display the one-liners for each command. Start by
  79. // scanning the commands to find the longest length. This makes the
  80. // output much prettier without having to manually tweak the
  81. // columns.
  82. //
  83. maxLength = 0;
  84. for( i = NUM_HELP_MAPS, helpMap = HelpMaps ; i > 0 ; i--, helpMap++ ) {
  85. length = (ULONG)strlen( helpMap->Command );
  86. if( length > maxLength ) {
  87. maxLength = length;
  88. }
  89. }
  90. //
  91. // Now actually display the one-liners.
  92. //
  93. for( i = NUM_HELP_MAPS, helpMap = HelpMaps ; i > 0 ; i--, helpMap++ ) {
  94. dprintf(
  95. "!%-*s - %s\n",
  96. maxLength,
  97. helpMap->Command,
  98. helpMap->OneLiner
  99. );
  100. }
  101. } else {
  102. //
  103. // Find a specific command and display the full help.
  104. //
  105. cmdHelp = FindHelpForCommand( CommandName );
  106. if( cmdHelp == NULL ) {
  107. dprintf( "unrecognized command %s\n", CommandName );
  108. } else {
  109. dprintf( "%s", cmdHelp );
  110. }
  111. }
  112. } // PrintUsage()
  113. DECLARE_API( help )
  114. {
  115. INIT_API();
  116. //
  117. // Skip leading blanks.
  118. //
  119. while( *lpArgumentString == ' ' ||
  120. *lpArgumentString == '\t' ) {
  121. lpArgumentString++;
  122. }
  123. if( !strcmp( lpArgumentString, "?" ) ) {
  124. lpArgumentString = "help";
  125. }
  126. if( *lpArgumentString == '\0' ) {
  127. lpArgumentString = NULL;
  128. }
  129. PrintUsage( lpArgumentString );
  130. } // DECLARE_API( help )