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.

145 lines
2.7 KiB

  1. @rem = '
  2. @perl.exe -w %~f0 %*
  3. @goto :EOF
  4. '; undef @rem;
  5. # Creates a new source file, 'sd add's it, and fills in the comment headers.
  6. $date = "";
  7. $year = "";
  8. $changelist = "";
  9. $syntax = "Syntax: newfile [-c <changelist>] <fn>\n";
  10. while ($#ARGV > 0)
  11. {
  12. $option = $ARGV[0];
  13. $option =~ tr/A-Z/a-z/;
  14. $option =~ /^[-\/].$/ || die $syntax;
  15. ($#ARGV > 1) || die $syntax;
  16. if ($ARGV[0] eq "-c")
  17. {
  18. $changelist = "-c ".$ARGV[1]." ";
  19. shift;
  20. shift;
  21. }
  22. else
  23. {
  24. die $syntax;
  25. }
  26. }
  27. ($#ARGV == 0) || die $syntax;
  28. $fn = $ARGV[0];
  29. $username = $ENV{"USERNAME"};
  30. (!-r $fn) || die "$fn already exists\n";
  31. $username || die "USERNAME not set\n";
  32. sub getDate {
  33. local ($mday, $mon);
  34. local @currentTime;
  35. @currentTime = localtime;
  36. $mday = $currentTime[3];
  37. $mon = $currentTime[4];
  38. $year = $currentTime[5];
  39. # ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
  40. $year += 1900;
  41. $mon++;
  42. $date = sprintf("%02d/%02d/%d", $mon, $mday, $year);
  43. }
  44. %filetype = (
  45. "h", 1,
  46. "hpp", 1,
  47. "hxx", 1,
  48. "c", 2,
  49. "cpp", 2,
  50. "cxx", 2
  51. );
  52. # Check the file extension
  53. $fn =~ /\.([^.]+)$/ || die "Unrecognized file extension\n";
  54. $ext = $1;
  55. $ext =~ tr/[A-Z]/[a-z]/;
  56. $type = $filetype{$ext};
  57. $type || die "Unrecognized file extension\n";
  58. open (FILE, ">$fn") || die "Couldn't open file\n";
  59. &getDate;
  60. print FILE <<EOT;
  61. /**************************************************************************\
  62. *
  63. * Copyright (c) $year Microsoft Corporation
  64. *
  65. * Module Name:
  66. *
  67. * <an unabbreviated name for the module (not the filename)>
  68. *
  69. * Abstract:
  70. *
  71. * <Description of what this module does>
  72. *
  73. * Notes:
  74. *
  75. * <optional>
  76. *
  77. * Created:
  78. *
  79. * $date $username
  80. * Created it.
  81. *
  82. \**************************************************************************/
  83. EOT
  84. if ($type == 1) {
  85. $upfn = $fn;
  86. $upfn =~ tr/\.[a-z]/_[A-Z]/;
  87. $upfn =~ s/.*\\([^\\])+/$1/;
  88. print FILE "#ifndef _$upfn\n#define _$upfn\n\n";
  89. } else {
  90. print FILE <<EOT;
  91. /**************************************************************************\
  92. *
  93. * Function Description:
  94. *
  95. * <Description of what the function does>
  96. *
  97. * Arguments:
  98. *
  99. * [<blank> | OUT | IN/OUT] argument-name - description of argument
  100. * ......
  101. *
  102. * Return Value:
  103. *
  104. * return-value - description of return value
  105. * or NONE
  106. *
  107. * Created:
  108. *
  109. * $date $username
  110. * Created it.
  111. *
  112. \**************************************************************************/
  113. EOT
  114. }
  115. if ($type == 1) {
  116. print FILE "#endif\n";
  117. }
  118. close (FILE);
  119. system ("sd add $changelist$fn");