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.

205 lines
4.7 KiB

  1. #-----------------------------------------------------------------//
  2. # Script: cklang.pm
  3. #
  4. # (c) 2000 Microsoft Corporation. All rights reserved.
  5. #
  6. # Purpose: This script validate the language/class from
  7. # the Command Argument/Parameter.
  8. #
  9. # Version: <1.00> 06/16/2000 : Suemiao Rossognol
  10. #-----------------------------------------------------------------//
  11. ###-----Set current script Name/Version.----------------//
  12. package cklang;
  13. $VERSION = '1.00';
  14. ###-----Require section and extern modual.---------------//
  15. require 5.003;
  16. use strict;
  17. use lib $ENV{ "RazzleToolPath" };
  18. use lib $ENV{ "RazzleToolPath" }. "\\PostBuildScripts";
  19. no strict 'vars';
  20. no strict 'subs';
  21. use GetParams;
  22. use ParseTable;
  23. my %hashCodes=();
  24. ###-----CkLang function.----------------------------------//
  25. sub CkLang
  26. {
  27. my ( $pLang, $pClass ) = @_;
  28. $pClass = uc( $pClass );
  29. $pLang = uc( $pLang );
  30. $pLang = "USA" if( $ENV{_COVERAGE_BUILD} && $pLang eq "COV" );
  31. ###(1)Validate Language by Codes.txt file.-----------//
  32. # scalar (%hashCodes) or print STDERR "scalar (\%hashcodes)\n";
  33. scalar (%hashCodes) or parse_table_file($ENV{"RazzleToolPath"}."\\Codes.txt", \%hashCodes );
  34. if ( !exists( $hashCodes{ $pLang } ) ){ return(0); }
  35. ###(2)Stop here if calss is not defined.------------//
  36. if( !$pClass ){ return (1);}
  37. ###(3)Sort ( @fe; jpn; ~cht )->( ~cht; @fe; jpn )
  38. @theClasses = ();
  39. &ReOrder( $pClass, \@theClasses );
  40. ###(4)Validate class.------------------------------//
  41. foreach $curClass( @theClasses )
  42. {
  43. ###Case: ~jpn.---------------------------------//
  44. if( $curClass =~ /^\~.*$/ )
  45. {
  46. if( $pLang ne substr( $curClass, 1, length($curClass)-1 ) )
  47. {
  48. next;
  49. }
  50. return(0);
  51. }
  52. ###Case: jpn.----------------------------------//
  53. if( $curClass !~ /^\@.*/ )
  54. {
  55. if( $pLang ne $curClass )
  56. {
  57. next;
  58. }
  59. return(1);
  60. }
  61. ###-----(3)Case: @FE.--------------------------//
  62. if ( $curClass ne $hashCodes{ $pLang }->{ "Class" })
  63. {
  64. next;
  65. }
  66. return(1);
  67. }
  68. return(0);
  69. }
  70. #-------------------------------------------------------------//
  71. #Function ReOrder: ( @fe; jpn; ~cht )->( ~cht; @fe; jpn )
  72. #-------------------------------------------------------------//
  73. sub ReOrder
  74. {
  75. my( $pStr, $rClass ) = @_;
  76. my @theClasses = split( /\;/,$pStr );
  77. $cnt = 0;
  78. $flag=0;
  79. $k=0;
  80. foreach ( @theClasses )
  81. {
  82. if( $_ =~ /^\~/ )
  83. {
  84. $rClass->[$k++]= $_;
  85. $flag |= ( 1 << $cnt );
  86. }
  87. ++$cnt;
  88. }
  89. $cnt =0;
  90. foreach ( @theClasses )
  91. {
  92. if( ( $flag >> $cnt++) & 1){ next; }
  93. $rClass->[$k++]= $_;
  94. }
  95. }
  96. #--------------------------------------------------------------//
  97. #Function Usage
  98. #--------------------------------------------------------------//
  99. sub Usage
  100. {
  101. print <<USAGE;
  102. Validates the given language and class by checking aganist
  103. the listed inforamtion in tools\codes.txt.
  104. Usage: $0 -l lang [ -c class ]
  105. -l Language.
  106. -c Class, with the following combination format, seperated by ;
  107. XXX considered as language
  108. \@XX considered as class of languages
  109. ~XXX considered as excluded language.
  110. /? Displays usage
  111. Examples:
  112. $0 -l:jpn -c:jpn ->>>> returns 0 (valid)
  113. $0 -l:jpn -c:\@fe;\@eu ->>>> returns 0 (valid)
  114. $0 -l:jpn -c:~chs;jpn;\@eu ->>>> returns 0 (valid)
  115. $0 -l:jpn -c:~jpn;\@fe ->>>> returns 1 (invalid)
  116. USAGE
  117. exit(1);
  118. }
  119. ###-----Cmd entry point for script.-------------------------------//
  120. if (eval("\$0 =~ /" . __PACKAGE__ . "\\.pm\$/i"))
  121. {
  122. # <run perl.exe GetParams.pm /? to get the complete usage for GetParams.pm>
  123. &GetParams ('-n', 'l:','-o', 'c:', '-p', 'lang class', @ARGV);
  124. $rtno = &cklang::CkLang( uc($lang), uc($class) );
  125. exit( !$rtno );
  126. }
  127. sub GetParams
  128. {
  129. #Call pm getparams with specified arguments
  130. &GetParams::getparams(@_);
  131. #Call the usage if specified by /?
  132. if ($HELP) {
  133. &Usage();
  134. }
  135. }
  136. #-------------------------------------------------------------//
  137. =head1 NAME
  138. B<cklang> - Check Language
  139. =head1 SYNOPSIS
  140. perl cklang.pm -l jpn [-c jpn]
  141. =head1 DESCRIPTION
  142. Check language jpn with class jpn
  143. =head1 INSTANCES
  144. =head2 <myinstances>
  145. <Description of myinstances>
  146. =head1 METHODS
  147. =head2 <mymathods>
  148. <Description of mymathods>
  149. =head1 SEE ALSO
  150. package ParseTable;
  151. =head1 AUTHOR
  152. <Suemiao Rossignol <[email protected]>>
  153. =cut
  154. 1;