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.

117 lines
2.3 KiB

  1. # resolve.pl - combines a .have file with a .src file
  2. my @gsrvs = ();
  3. my %gsrvnames = ();
  4. sub inilist
  5. {
  6. my @lines = ();
  7. my %vars = ();
  8. open(F, $_[0]) or return %vars;
  9. @lines = <F>;
  10. close(F);
  11. for(@lines)
  12. {
  13. (!/------- SDP.*-*/) or next;
  14. ($val, $key) = split(/=/, $_, 2);
  15. $vars{$key} = $val;
  16. # print "$key=$vars{$key}\n";
  17. print "$vars{$key}=$key\n";
  18. }
  19. return %vars;
  20. }
  21. sub fillsrvlist
  22. {
  23. my @lines = ();
  24. my @srv = ();
  25. my $count = 0;
  26. open(F, $_[0]) or return @srvs;
  27. @lines = <F>;
  28. close(F);
  29. @sorted = sort {$b cmp $a} @lines;
  30. for (@sorted)
  31. {
  32. chomp;
  33. @srv = split(/=/, $_, 2);
  34. push @gsrvs, [@srv];
  35. (!defined($gsrvnames{$srv[1]})) or next;
  36. $gsrvnames{$srv[1]} = sprintf("SRV%x", $count++);
  37. print "$gsrvnames{$srv[1]}=$srv[1]\n";
  38. }
  39. return @gsrvs;
  40. }
  41. sub findsrv
  42. {
  43. my $i = 0;
  44. defined ($_[0]) or return -1;
  45. ($_[0] ne '') or return - 1;
  46. for $i ( 0 .. $#gsrvs )
  47. {
  48. $c = index($_[0], $gsrvs[$i][0]);
  49. ($c != 0) or return $i;
  50. }
  51. return -1;
  52. }
  53. sub havelist
  54. {
  55. my @lines = ();
  56. my %vars = ();
  57. open(F, $_[0]) or return %vars;
  58. @lines = <F>;
  59. close(F);
  60. for(@lines)
  61. {
  62. (!/------- SDP.*-*/) or next;
  63. chomp($_);
  64. ($val, $key) = split(/ - /, $_, 2);
  65. $vars{$key} = $val;
  66. }
  67. return %vars;
  68. }
  69. print "SRCSRV: variables ------------------------------------------\n";
  70. %gsrvnames = inilist("srcsrv.ini");
  71. %list = havelist($ARGV[0]) or die "You must specify a .have file.\n";
  72. $srvs = fillsrvlist($ARGV[1]) or die "You must specify a .srv file.\n";
  73. print "SRCSRV: source files ---------------------------------------\n";
  74. @input = <STDIN>;
  75. for (@input)
  76. {
  77. (!/Microsoft (R).*/) or next;
  78. (!/Copyright (C).*/) or next;
  79. (!/\*\*\*.*/) or next;
  80. chomp($_);
  81. if (defined($list{$_}))
  82. {
  83. $match = findsrv($_);
  84. ($match != -1) or next;
  85. print "SD: ";
  86. print $_;
  87. print "*\${" . $gsrvnames{$gsrvs[$match][1]} . "}";
  88. print "*" . $list{$_} . "\n";
  89. }
  90. }
  91. print "SRCSRV: end ------------------------------------------------\n";
  92. end: