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.

191 lines
4.1 KiB

  1. /*
  2. * Module Name: WSTUNE.C
  3. *
  4. * Program: WSTUNE
  5. *
  6. *
  7. * Description:
  8. *
  9. * Shell to call former programs WSDUMP and WSREDUCE
  10. *
  11. *
  12. * Microsoft Confidential
  13. *
  14. * Copyright (c) Microsoft Corporation 1992-1998
  15. *
  16. * All Rights Reserved
  17. *
  18. * Modification History:
  19. *
  20. * 8-31-92: Made single exe from wspdump, wsreduce and wstune marklea
  21. * 4-13-98: QFE DerrickG (mdg):
  22. * - support for long file names (LFN) of input/output files
  23. * - based .TMI file name exclusively on .WSP name for consistency
  24. * - removed limit on symbol name lengths
  25. * - removed -F & -V flags for non-debug; made verbose global for WsRed...()
  26. * - made program name & version global; read version from ntverp.h
  27. *
  28. *
  29. */
  30. #include "wstune.h"
  31. #include <ntverp.h>
  32. #define COMMAND_LINE_LEN 128
  33. #define FILE_NAME_LEN 40
  34. #define FAKE_IT 1
  35. #define ERR fprintf(stderr
  36. VOID wsTuneUsage(VOID);
  37. CHAR *szProgName = "WSTUNE";
  38. CHAR *pszVersion = VER_PRODUCTVERSION_STR; // Current product version number
  39. INT nMode;
  40. #ifdef DEBUG
  41. BOOL fDbgVerbose = FALSE;
  42. #endif // DEBUG
  43. /* main()
  44. *
  45. * parses command line args
  46. */
  47. INT __cdecl main(INT argc,CHAR **argv)
  48. {
  49. CHAR *szBaseName = NULL;
  50. CHAR *szNull;
  51. BOOL fOutPut = FALSE;
  52. BOOL fNoReduce = FALSE;
  53. BOOL fNoDump = FALSE;
  54. INT cArgCnt = 0;
  55. ConvertAppToOem( argc, argv );
  56. nMode = 0; // default flags set
  57. while (--argc && (**(++argv) == '-' || **argv=='/'))
  58. {
  59. while(*(++(*argv))) switch (**argv)
  60. {
  61. case '?':
  62. wsTuneUsage();
  63. break;
  64. #ifdef DEBUG
  65. case 'f':
  66. case 'F':
  67. nMode |= FAKE_IT;
  68. break;
  69. #endif // DEBUG
  70. case 'O':
  71. case 'o':
  72. fOutPut = TRUE;
  73. break;
  74. case 'N':
  75. case 'n':
  76. fNoDump = TRUE;
  77. break;
  78. case 'D':
  79. case 'd':
  80. fNoReduce = TRUE;
  81. break;
  82. #ifdef DEBUG
  83. case 'V':
  84. case 'v':
  85. fDbgVerbose = TRUE;
  86. break;
  87. #endif // DEBUG
  88. case 'P':
  89. case 'p':
  90. fWsIndicator = TRUE;
  91. break;
  92. default: ERR,"%s: Unrecognized switch: %c\n",
  93. szProgName,**argv);
  94. return(-1);
  95. }
  96. }
  97. /* any files? */
  98. if (argc <1)
  99. {
  100. wsTuneUsage();
  101. return(-1);
  102. }
  103. /* now we go to work -- walk through the file names on the command line */
  104. while (argc--)
  105. {
  106. szBaseName = *(argv++);
  107. printf("%s: using \042%s\042\n",szProgName,szBaseName);
  108. if (szNull = strchr(szBaseName, '.'), szNull) {
  109. *szNull = '\0';
  110. }
  111. /* WSREDUCE file.WSP */
  112. if (!(nMode & FAKE_IT)){
  113. if (!fNoReduce){
  114. wsReduceMain( szBaseName );
  115. }
  116. }
  117. if (!fNoDump){
  118. /* WSPDUMP /V /Ffile.WSP /Tfile.TMI /Rfile.WSR > file.DT */
  119. if(!(nMode & FAKE_IT)){
  120. wspDumpMain( szBaseName, (fOutPut ? ".DT" : NULL), TRUE, TRUE );
  121. }
  122. /* wspdump /Ffile.wsp /Tfile.tmi > file.DN */
  123. if (!(nMode & FAKE_IT) && fOutPut){
  124. wspDumpMain( szBaseName, ".DN", FALSE, FALSE );
  125. }
  126. }
  127. }
  128. return 0; // mdg 98/4
  129. }
  130. /*
  131. *
  132. * VOID wsTuneUsage (VOID)
  133. *
  134. *
  135. * Effects:
  136. *
  137. * Prints out usage message, and exits with an error.
  138. *
  139. * Returns:
  140. *
  141. * Exits with ERROR.
  142. */
  143. VOID wsTuneUsage(VOID)
  144. {
  145. printf("\nUsage: %s [/O] [/D] [/N] [?] moduleName1[.WSP] [...]\n\n", szProgName);
  146. printf(
  147. " /O Dump analysis data to file (*.DT tuned, *.DN not tuned)\n"
  148. " /N Analyze bitstring data only, create .WSR and .PRF files (turns off /O)\n"
  149. " /D Dump analysis data only; use existing .WSR file (turns off /N)\n"
  150. #ifdef DEBUG
  151. " /F Fake run for command-line parser debugging\n"
  152. " /V Verbose mode for debugging\n"
  153. #endif // DEBUG
  154. " /P Display a progress indicator\n"
  155. " /? Display this usage message\n\n"
  156. " \"moduleNameX\" is the name(s) of the module file(s) to tune.\n\n"
  157. );
  158. printf("%s %s\n", szProgName, pszVersion);
  159. exit(ERROR);
  160. }