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.

86 lines
2.1 KiB

  1. @rem = '--*-Perl-*--';
  2. @rem = '
  3. @if "%overbose%" == "" echo off
  4. set ARGS= %*
  5. call "%~dp0%PROCESSOR_ARCHITECTURE%\perl%OPERLOPT%" -w %~dpnx0 %ARGS:/?=-?%& goto :eof
  6. ';
  7. # xmlvar.bat
  8. # Owner: JBelt
  9. # Last updated: 5/29/01
  10. $program = "xmlvar";
  11. if ($#ARGV >= 0)
  12. {
  13. if ($ARGV[0] =~ /[\/-][hH\?]/)
  14. {
  15. print <<USAGE;
  16. -----------------------------------------------------------------------
  17. usage: $program [-v] [name=value]...
  18. All instances of &name; (for any name in the list) in the input stream
  19. are replaced by the corresponding values. Use double quotes to handle
  20. spaces. Curly brackets around values (like GUIDs) are removed.
  21. Ignores a set of reserved words (quot, gt, amp... etc)
  22. -v verbose mode
  23. ex: $program "myName=Big fish" LCID=1033 < input.xml > output.xml
  24. input.xml: <item filename='&myName;.lnk' language="&LCID;"/>
  25. output.xml: <item filename='Big fish.lnk' language="1033"/>
  26. -----------------------------------------------------------------------
  27. USAGE
  28. exit;
  29. }
  30. }
  31. # reserved variables
  32. @Reserved = ('quot', 'gt', 'amp', 'lt', 'apos');
  33. foreach (@Reserved) { $Variables{$_} = "&$_;"; }
  34. foreach (@ARGV)
  35. {
  36. if ($_ =~ /-v/i)
  37. {
  38. $fVerbose = 1;
  39. print "Name: Value\n";
  40. }
  41. else
  42. {
  43. die "$program: invalid argument: $_\n" unless ($name, $value) = /^(.*)=(.*)$/;
  44. # can't redefine variables (including reserved words)
  45. myDie("$name is already defined") if defined $Variables{$name};
  46. # strip surrounding curly braces
  47. $value =~ s/^{(.*)}$/$1/;
  48. $Variables{$name} = $value;
  49. print "$name: $value\n" if defined $fVerbose;
  50. }
  51. }
  52. # foreach (keys %Variables) { print "$_ = $Variables{$_}\n"; }
  53. while (<STDIN>)
  54. {
  55. s/&(\w+);/&myReplace($1)/ge;
  56. print;
  57. }
  58. sub myReplace()
  59. {
  60. myDie("invalid argument list to myReplace") unless ($var) = @_;
  61. return $Variables{$var} if defined $Variables{$var};
  62. warn "$program: warning: $var neither defined nor reserved\n";
  63. return "&$var;";
  64. }
  65. sub myDie()
  66. {
  67. print STDERR "$program: ";
  68. print STDERR @_;
  69. print STDERR "\n";
  70. exit 1;
  71. }