2
0

add_cr.pl 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/local/bin/perl
  2. #
  3. # This adds a copyright message to a souce code file.
  4. # It also gets the file name correct.
  5. #
  6. # perl util/add_cr.pl *.[ch] */*.[ch] */*/*.[ch]
  7. #
  8. foreach (@ARGV)
  9. {
  10. &dofile($_);
  11. }
  12. sub dofile
  13. {
  14. local($file)=@_;
  15. open(IN,"<$file") || die "unable to open $file:$!\n";
  16. print STDERR "doing $file\n";
  17. @in=<IN>;
  18. return(1) if ($in[0] =~ / NOCW /);
  19. @out=();
  20. open(OUT,">$file.out") || die "unable to open $file.$$:$!\n";
  21. push(@out,"/* $file */\n");
  22. if (($in[1] !~ /^\/\* Copyright \(C\) [0-9-]+ Eric Young \(eay\@cryptsoft.com\)/))
  23. {
  24. push(@out,&Copyright);
  25. $i=2;
  26. @a=grep(/ Copyright \(C\) /,@in);
  27. if ($#a >= 0)
  28. {
  29. while (($i <= $#in) && ($in[$i] ne " */\n"))
  30. { $i++; }
  31. $i++ if ($in[$i] eq " */\n");
  32. while (($i <= $#in) && ($in[$i] =~ /^\s*$/))
  33. { $i++; }
  34. push(@out,"\n");
  35. for ( ; $i <= $#in; $i++)
  36. { push(@out,$in[$i]); }
  37. }
  38. else
  39. { push(@out,@in); }
  40. }
  41. else
  42. {
  43. shift(@in);
  44. push(@out,@in);
  45. }
  46. print OUT @out;
  47. close(IN);
  48. close(OUT);
  49. rename("$file","$file.orig") || die "unable to rename $file:$!\n";
  50. rename("$file.out",$file) || die "unable to rename $file.out:$!\n";
  51. }
  52. sub Copyright
  53. {
  54. return <<'EOF';
  55. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  56. * All rights reserved.
  57. *
  58. * This package is an SSL implementation written
  59. * by Eric Young (eay@cryptsoft.com).
  60. * The implementation was written so as to conform with Netscapes SSL.
  61. *
  62. * This library is free for commercial and non-commercial use as long as
  63. * the following conditions are aheared to. The following conditions
  64. * apply to all code found in this distribution, be it the RC4, RSA,
  65. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  66. * included with this distribution is covered by the same copyright terms
  67. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  68. *
  69. * Copyright remains Eric Young's, and as such any Copyright notices in
  70. * the code are not to be removed.
  71. * If this package is used in a product, Eric Young should be given attribution
  72. * as the author of the parts of the library used.
  73. * This can be in the form of a textual message at program startup or
  74. * in documentation (online or textual) provided with the package.
  75. *
  76. * Redistribution and use in source and binary forms, with or without
  77. * modification, are permitted provided that the following conditions
  78. * are met:
  79. * 1. Redistributions of source code must retain the copyright
  80. * notice, this list of conditions and the following disclaimer.
  81. * 2. Redistributions in binary form must reproduce the above copyright
  82. * notice, this list of conditions and the following disclaimer in the
  83. * documentation and/or other materials provided with the distribution.
  84. * 3. All advertising materials mentioning features or use of this software
  85. * must display the following acknowledgement:
  86. * "This product includes cryptographic software written by
  87. * Eric Young (eay@cryptsoft.com)"
  88. * The word 'cryptographic' can be left out if the rouines from the library
  89. * being used are not cryptographic related :-).
  90. * 4. If you include any Windows specific code (or a derivative thereof) from
  91. * the apps directory (application code) you must include an acknowledgement:
  92. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  93. *
  94. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  95. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  96. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  97. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  98. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  99. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  100. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  101. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  102. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  103. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  104. * SUCH DAMAGE.
  105. *
  106. * The licence and distribution terms for any publically available version or
  107. * derivative of this code cannot be changed. i.e. this code cannot simply be
  108. * copied and put under another distribution licence
  109. * [including the GNU Public Licence.]
  110. */
  111. EOF
  112. }