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