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.

116 lines
2.5 KiB

  1. use strict;
  2. use IO::File;
  3. #
  4. # tok_bldnum.pl
  5. #
  6. # Arguments: property.idt productversion
  7. #
  8. # Purpose:
  9. #
  10. # Returns: 0 if success, non-zero otherwise
  11. #
  12. my( $BuildNumber );
  13. my( $QFENumber );
  14. my( $ProductNumber );
  15. my( $Search ) = "ProductVersion";
  16. my( $File ) = "upgrade.idt";
  17. my( $Line ) = "";
  18. # use unless as GetBuildNumber returns zero on failure
  19. unless ( $BuildNumber = &GetBuildNumber ) {
  20. print( "Failed to generate build number, exiting ...\n" );
  21. exit( 1 );
  22. }
  23. if ($ARGV[0] ne "") {
  24. $File = $ARGV[0];
  25. }
  26. if ($ARGV[1] ne "") {
  27. $Search = $ARGV[1];
  28. }
  29. $ProductNumber = "5.2.$BuildNumber.0";
  30. if ( &SearchReplaceInFile ) {
  31. print( "Failed to update ProductVersion.\n" );
  32. exit( 1 );
  33. }
  34. # if we're here, we returned successfully
  35. exit( 0 );
  36. #
  37. # GetBuildNumber
  38. #
  39. # Arguments: none
  40. #
  41. # Purpose: parse ntverp.h from published, return the build number
  42. #
  43. # Returns: the build number if successful, zero otherwise
  44. #
  45. sub GetBuildNumber
  46. {
  47. # find the file
  48. my( $VerFile ) = $ENV{ "SDXROOT" } . "\\public\\sdk\\inc\\ntverp.h";
  49. if ( ! -e $VerFile ) {
  50. print( "$VerFile does not exist ...\n" );
  51. return( 0 );
  52. }
  53. # parse the file
  54. if ( -e $VerFile ) {
  55. # open the file
  56. if ( defined( my $fh = new IO::File $VerFile, "r" ) ) {
  57. my( $ThisLine );
  58. # read through the file
  59. while ( $ThisLine = <$fh> ) {
  60. # see if this is the build number defining line
  61. if ( $ThisLine =~ /#define VER_PRODUCTBUILD\s*\/\* NT \*\/\s*(\d*)/ ) {
  62. # $1 is now the build number
  63. undef( $fh );
  64. return( $1 );
  65. }
  66. }
  67. undef( $fh );
  68. } else {
  69. print( "Failed to open $VerFile ...\n" );
  70. return( 0 );
  71. }
  72. }
  73. # if we're here, we didn't find a build number in the VerFile
  74. print( "Failed to find a build number in $VerFile ..." );
  75. return( 0 );
  76. }
  77. #
  78. # SearchReplaceInFile
  79. #
  80. # Arguments: none
  81. #
  82. # Purpose:
  83. #
  84. # Returns:
  85. #
  86. sub SearchReplaceInFile
  87. {
  88. open FILE, $File;
  89. while (<FILE>) {
  90. $Line = $_;
  91. $Line =~ s/{D1D35D5E-83EB-4518-B4F5-69E25446A03D}\s\t\d.\d.\d+.\d/{D1D35D5E-83EB-4518-B4F5-69E25446A03D}\t\t$ProductNumber/;
  92. $Line =~
  93. s/{D1D35D5E-83EB-4518-B4F5-69E25446A03D}\s\d.\d.\d+.\d/{D1D35D5E-83EB-4518-B4F5-69E25446A03D}\t$ProductNumber/;
  94. print( $Line );
  95. }
  96. close(FILE);
  97. return( 0 );
  98. }