155714Skris#!/usr/local/bin/perl 255714Skris# 355714Skris# This adds a copyright message to a souce code file. 455714Skris# It also gets the file name correct. 555714Skris# 655714Skris# perl util/add_cr.pl *.[ch] */*.[ch] */*/*.[ch] 755714Skris# 855714Skris 955714Skrisforeach (@ARGV) 1055714Skris { 1155714Skris &dofile($_); 1255714Skris } 1355714Skris 1455714Skrissub dofile 1555714Skris { 1655714Skris local($file)=@_; 1755714Skris 1855714Skris open(IN,"<$file") || die "unable to open $file:$!\n"; 1955714Skris 2055714Skris print STDERR "doing $file\n"; 2155714Skris @in=<IN>; 2255714Skris 2355714Skris return(1) if ($in[0] =~ / NOCW /); 2455714Skris 2555714Skris @out=(); 2655714Skris open(OUT,">$file.out") || die "unable to open $file.$$:$!\n"; 2755714Skris push(@out,"/* $file */\n"); 2855714Skris if (($in[1] !~ /^\/\* Copyright \(C\) [0-9-]+ Eric Young \(eay\@cryptsoft.com\)/)) 2955714Skris { 3055714Skris push(@out,&Copyright); 3155714Skris $i=2; 3255714Skris @a=grep(/ Copyright \(C\) /,@in); 3355714Skris if ($#a >= 0) 3455714Skris { 3555714Skris while (($i <= $#in) && ($in[$i] ne " */\n")) 3655714Skris { $i++; } 3755714Skris $i++ if ($in[$i] eq " */\n"); 3855714Skris 3955714Skris while (($i <= $#in) && ($in[$i] =~ /^\s*$/)) 4055714Skris { $i++; } 4155714Skris 4255714Skris push(@out,"\n"); 4355714Skris for ( ; $i <= $#in; $i++) 4455714Skris { push(@out,$in[$i]); } 4555714Skris } 4655714Skris else 4755714Skris { push(@out,@in); } 4855714Skris } 4955714Skris else 5055714Skris { 5155714Skris shift(@in); 5255714Skris push(@out,@in); 5355714Skris } 5455714Skris print OUT @out; 5555714Skris close(IN); 5655714Skris close(OUT); 5755714Skris rename("$file","$file.orig") || die "unable to rename $file:$!\n"; 5855714Skris rename("$file.out",$file) || die "unable to rename $file.out:$!\n"; 5955714Skris } 6055714Skris 6155714Skris 6255714Skris 6355714Skrissub Copyright 6455714Skris { 6555714Skris return <<'EOF'; 6655714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 6755714Skris * All rights reserved. 6855714Skris * 6955714Skris * This package is an SSL implementation written 7055714Skris * by Eric Young (eay@cryptsoft.com). 7155714Skris * The implementation was written so as to conform with Netscapes SSL. 7255714Skris * 7355714Skris * This library is free for commercial and non-commercial use as long as 7455714Skris * the following conditions are aheared to. The following conditions 7555714Skris * apply to all code found in this distribution, be it the RC4, RSA, 7655714Skris * lhash, DES, etc., code; not just the SSL code. The SSL documentation 7755714Skris * included with this distribution is covered by the same copyright terms 7855714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com). 7955714Skris * 8055714Skris * Copyright remains Eric Young's, and as such any Copyright notices in 8155714Skris * the code are not to be removed. 8255714Skris * If this package is used in a product, Eric Young should be given attribution 8355714Skris * as the author of the parts of the library used. 8455714Skris * This can be in the form of a textual message at program startup or 8555714Skris * in documentation (online or textual) provided with the package. 8655714Skris * 8755714Skris * Redistribution and use in source and binary forms, with or without 8855714Skris * modification, are permitted provided that the following conditions 8955714Skris * are met: 9055714Skris * 1. Redistributions of source code must retain the copyright 9155714Skris * notice, this list of conditions and the following disclaimer. 9255714Skris * 2. Redistributions in binary form must reproduce the above copyright 9355714Skris * notice, this list of conditions and the following disclaimer in the 9455714Skris * documentation and/or other materials provided with the distribution. 9555714Skris * 3. All advertising materials mentioning features or use of this software 9655714Skris * must display the following acknowledgement: 9755714Skris * "This product includes cryptographic software written by 9855714Skris * Eric Young (eay@cryptsoft.com)" 9955714Skris * The word 'cryptographic' can be left out if the rouines from the library 10055714Skris * being used are not cryptographic related :-). 10155714Skris * 4. If you include any Windows specific code (or a derivative thereof) from 10255714Skris * the apps directory (application code) you must include an acknowledgement: 10355714Skris * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 10455714Skris * 10555714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 10655714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 10755714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 10855714Skris * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 10955714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 11055714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 11155714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 11255714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 11355714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 11455714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 11555714Skris * SUCH DAMAGE. 11655714Skris * 11755714Skris * The licence and distribution terms for any publically available version or 11855714Skris * derivative of this code cannot be changed. i.e. this code cannot simply be 11955714Skris * copied and put under another distribution licence 12055714Skris * [including the GNU Public Licence.] 12155714Skris */ 12255714SkrisEOF 12355714Skris } 124