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.

143 lines
3.3 KiB

  1. #!perl
  2. use strict;
  3. sub TRUE {return(1);} # BOOLEAN TRUE
  4. sub FALSE {return(0);} # BOOLEAN FALSE
  5. #
  6. # See if the caller just wants usage information.
  7. #
  8. if ((defined $ARGV[0] && $ARGV[0] eq "-?") || !defined($ARGV[1]) ) {
  9. Usage();
  10. exit(0);
  11. }
  12. my $triage_old = shift; # file to read
  13. my $triage_new = shift; # new file
  14. my $new_owner = "<new_owner>"; # new owner value
  15. local *hFile; # handle to $triage_ini
  16. my $line; # holds line to write
  17. my $i; # generic looping var
  18. my @lines; # holds new file to write
  19. #
  20. # Open the file or fail gracefully
  21. #
  22. if ( ! open(hFile, " $triage_old") ) {
  23. die("ERROR: Can't open $triage_old for read: \"$!\"\n");
  24. }
  25. #
  26. # Process the file
  27. #
  28. while (<hFile>) {
  29. my $keep = FALSE;
  30. chomp;
  31. #
  32. # Keep comment lines unchanged
  33. #
  34. if (m/^;/) {
  35. $line = $_;
  36. $keep = TRUE;
  37. } else {
  38. #
  39. # split line into <source>=<owner>
  40. # then split <owner> into <owners>
  41. #
  42. my @temp = split(/=/, $_);
  43. my $source = shift @temp;
  44. $" = '=';
  45. my $owner = "@temp";
  46. my(@owners) = split(/;/, $owner);
  47. #
  48. # Don't change lines where source contains any of:
  49. # memorycorruptors!
  50. # oldimages!
  51. # poolcorruptors!
  52. # bugchecking!
  53. #
  54. if ( $source =~ /^(memorycorruptors|oldimages|poolcorruptors|bugcheckingdriver)!/i ) {
  55. # nothing to change
  56. $keep = TRUE;
  57. #
  58. # Change owner of bugcheck!.* to new owner but preserve the rule to keep
  59. # leading "maybe_", "last_", or "specific_"
  60. #
  61. } elsif ($source =~ /^bugcheck!/i) {
  62. #
  63. # translate the owners list
  64. #
  65. for ($i=0;$i<=$#owners;$i++) {
  66. $owners[$i] =~ s/last_.*/last_$new_owner/i;
  67. $owners[$i] =~ s/maybe_.*/maybe_$new_owner/i;
  68. $owners[$i] =~ s/specific_.*/specific_$new_owner/i;
  69. if ( $owners[$i] !~ /$new_owner/ ) {
  70. $owners[$i] = $new_owner;
  71. }
  72. }
  73. $keep = TRUE;
  74. #
  75. # translate all other owners to replace and entry after "maybe_", "last_", or
  76. # "specific_" with <prefix>$new_owner
  77. #
  78. } else {
  79. for ($i=0;$i<=$#owners;$i++) {
  80. if ( $owners[$i] =~ s/last_.*/last_$new_owner/i ) {
  81. $keep = TRUE;
  82. }
  83. if ( $owners[$i] =~ s/maybe_.*/maybe_$new_owner/i ) {
  84. $keep = TRUE;
  85. }
  86. if ( $owners[$i] =~ s/specific_.*/specific_$new_owner/i ) {
  87. $keep = TRUE;
  88. }
  89. if ( lc($owners[$i]) eq "ignore" ) {
  90. $keep = TRUE;
  91. }
  92. }
  93. }
  94. $" = ';';
  95. $line = "$source=@owners";
  96. }
  97. if ($keep) {
  98. push(@lines, $line);
  99. }
  100. }
  101. close(hFile);
  102. # override char used to seperate array elements interpolated with in a double quoted string
  103. $" = "\n";
  104. #
  105. # open the file for output or fail gracefully
  106. #
  107. if ( ! open(hFile, ">$triage_new") ) {
  108. die("ERROR: Can't open $triage_new for write: \"$!\"\n");
  109. }
  110. #
  111. # write the new file
  112. #
  113. print hFile "@lines\n";
  114. close(hFile);
  115. #
  116. # usage
  117. #
  118. sub Usage {
  119. printf("Usage: $0 <source> <dest>\n");
  120. printf(" Performs static set of translations on a <source> and writes the new file to <dest>.\n");
  121. }