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.

115 lines
2.7 KiB

  1. #Copyright (c) 1992-2000 Microsoft Corporation
  2. #
  3. #Module Name:
  4. #
  5. # pooltags.pl
  6. #
  7. #Abstract:
  8. #
  9. # WinDbg Extension Api
  10. #
  11. #Environment:
  12. #
  13. # User Mode.
  14. #
  15. #Revision History:
  16. #
  17. # Kshitix K. Sharma (kksharma)
  18. #
  19. #
  20. # Parse pooltags.w file to eliminate owner info and generate public pooltag.txt
  21. #
  22. # PPPP - <One line description string>
  23. #
  24. # PPPP is a 4 character max pooltag
  25. #
  26. # Any line which doesn't fit this format is ignored
  27. #
  28. sub EmitFileHeader;
  29. sub NextLine;
  30. sub IsPoolTagDescription;
  31. #####################################################################################
  32. #
  33. # main
  34. #
  35. # Usage pooltags [-o <outfile>] [-i] <infile>
  36. #
  37. #####################################################################################
  38. $g_NumLine = 0;
  39. $PoolTagDesc = {
  40. TAG => 0,
  41. DESCRIPTION => "",
  42. };
  43. while ($arg = shift) {
  44. if ($arg eq "-o") {
  45. $OutFileName = shift;
  46. } elsif ($arg eq "-i") {
  47. $PoolTagTxtFile = shift;
  48. } else {
  49. $PoolTagTxtFile = $arg;
  50. }
  51. }
  52. die "Cannot open file $PoolTagTxtFile\n" if !open(POOLT_FILE, $PoolTagTxtFile);
  53. die "Cannot open file $OutFileName\n" if !open(OUT_FILE, ">" . $OutFileName);
  54. EmitFileHeader();
  55. while (IsPoolTagDescription() || NextLine ) {
  56. $LineToPrint = $g_line;
  57. if (($PoolTag,$Description) = $g_line =~ /^ ?(....) +-\s*(.*)$/) {
  58. ($T1,$T2,$T3,$T4) = $PoolTag =~ /^(.)(.)(.)(.)$/;
  59. if (($RestOfLine, $Owner) = $g_line =~ /(.*)- OWNER (.*)/) {
  60. # We have owner info here
  61. $LineToPrint = $RestOfLine . "\n";
  62. }
  63. }
  64. printf OUT_FILE ($LineToPrint);
  65. } continue {
  66. close POOLT_FILE if eof;
  67. }
  68. #####################################################################################
  69. #
  70. # Subroutines
  71. #
  72. #####################################################################################
  73. sub NextLine {
  74. $g_line = <POOLT_FILE>;
  75. $g_NumLine++;
  76. return $g_line;
  77. }
  78. sub IsPoolTagDescription {
  79. # Match PPPP - <Description>
  80. if ($g_line =~ /^ ?.... +- .*$/) {
  81. return 0;
  82. }
  83. if ($g_line =~ /^([A-Z][A-Z_0-9]+)\s*\((.*)\)$/) {
  84. return 1;
  85. }
  86. return 0;
  87. }
  88. sub EmitFileHeader {
  89. print OUT_FILE "REM -------------------------------------".
  90. "--------------------------------------\n";
  91. print OUT_FILE "REM\n";
  92. print OUT_FILE "REM Public pooltag.txt\n";
  93. print OUT_FILE "REM\n";
  94. print OUT_FILE "REM IMPORTANT: This file is automatically generated.\n";
  95. print OUT_FILE "REM Do not edit by hand.\n";
  96. print OUT_FILE "REM\n";
  97. print OUT_FILE "REM Generated from $PoolTagTxtFile on " . localtime() . "\n";
  98. print OUT_FILE "REM\n";
  99. print OUT_FILE "REM-------------------------------------".
  100. "--------------------------------------\n\n";
  101. print OUT_FILE "\n\n";
  102. }