1c109e398Sbeck#!/usr/local/bin/perl 2c109e398Sbeck 3c109e398Sbeckopen (NUMIN,"$ARGV[1]") || die "Can't open number file $ARGV[1]"; 4c109e398Sbeck$max_nid=0; 5c109e398Sbeck$o=0; 6c109e398Sbeckwhile(<NUMIN>) 7c109e398Sbeck { 8c109e398Sbeck chop; 9c109e398Sbeck $o++; 10c109e398Sbeck s/#.*$//; 11c109e398Sbeck next if /^\s*$/; 12da347917Sbeck $_ = 'X'.$_; 13c109e398Sbeck ($Cname,$mynum) = split; 14da347917Sbeck $Cname =~ s/^X//; 15c109e398Sbeck if (defined($nidn{$mynum})) 16c109e398Sbeck { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; } 17*0a5d6edeSdjm if (defined($nid{$Cname})) 18*0a5d6edeSdjm { die "$ARGV[1]:$o:There's already an object with name ",$Cname," on line ",$order{$nid{$Cname}},"\n"; } 19c109e398Sbeck $nid{$Cname} = $mynum; 20c109e398Sbeck $nidn{$mynum} = $Cname; 21c109e398Sbeck $order{$mynum} = $o; 22c109e398Sbeck $max_nid = $mynum if $mynum > $max_nid; 23c109e398Sbeck } 24c109e398Sbeckclose NUMIN; 25c109e398Sbeck 26c109e398Sbeckopen (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]"; 27c109e398Sbeck$Cname=""; 28c109e398Sbeck$o=0; 29c109e398Sbeckwhile (<IN>) 30c109e398Sbeck { 31c109e398Sbeck chop; 32c109e398Sbeck $o++; 33c109e398Sbeck if (/^!module\s+(.*)$/) 34c109e398Sbeck { 35c109e398Sbeck $module = $1."-"; 36c109e398Sbeck $module =~ s/\./_/g; 37c109e398Sbeck $module =~ s/-/_/g; 38c109e398Sbeck } 39c109e398Sbeck if (/^!global$/) 40c109e398Sbeck { $module = ""; } 41c109e398Sbeck if (/^!Cname\s+(.*)$/) 42c109e398Sbeck { $Cname = $1; } 43c109e398Sbeck if (/^!Alias\s+(.+?)\s+(.*)$/) 44c109e398Sbeck { 45c109e398Sbeck $Cname = $module.$1; 46c109e398Sbeck $myoid = $2; 47c109e398Sbeck $myoid = &process_oid($myoid); 48c109e398Sbeck $Cname =~ s/-/_/g; 49c109e398Sbeck $ordern{$o} = $Cname; 50c109e398Sbeck $order{$Cname} = $o; 51c109e398Sbeck $obj{$Cname} = $myoid; 52c109e398Sbeck $_ = ""; 53c109e398Sbeck $Cname = ""; 54c109e398Sbeck } 55c109e398Sbeck s/!.*$//; 56c109e398Sbeck s/#.*$//; 57c109e398Sbeck next if /^\s*$/; 58c109e398Sbeck ($myoid,$mysn,$myln) = split ':'; 59c109e398Sbeck $mysn =~ s/^\s*//; 60c109e398Sbeck $mysn =~ s/\s*$//; 61c109e398Sbeck $myln =~ s/^\s*//; 62c109e398Sbeck $myln =~ s/\s*$//; 63c109e398Sbeck $myoid =~ s/^\s*//; 64c109e398Sbeck $myoid =~ s/\s*$//; 65c109e398Sbeck if ($myoid ne "") 66c109e398Sbeck { 67c109e398Sbeck $myoid = &process_oid($myoid); 68c109e398Sbeck } 69c109e398Sbeck 70c109e398Sbeck if ($Cname eq "" && !($myln =~ / /)) 71c109e398Sbeck { 72c109e398Sbeck $Cname = $myln; 73c109e398Sbeck $Cname =~ s/\./_/g; 74c109e398Sbeck $Cname =~ s/-/_/g; 75c109e398Sbeck if ($Cname ne "" && defined($ln{$module.$Cname})) 76c109e398Sbeck { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; } 77c109e398Sbeck } 78c109e398Sbeck if ($Cname eq "") 79c109e398Sbeck { 80c109e398Sbeck $Cname = $mysn; 81c109e398Sbeck $Cname =~ s/-/_/g; 82c109e398Sbeck if ($Cname ne "" && defined($sn{$module.$Cname})) 83c109e398Sbeck { die "objects.txt:$o:There's already an object with short name ",$sn{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; } 84c109e398Sbeck } 85c109e398Sbeck if ($Cname eq "") 86c109e398Sbeck { 87c109e398Sbeck $Cname = $myln; 88c109e398Sbeck $Cname =~ s/-/_/g; 89c109e398Sbeck $Cname =~ s/\./_/g; 90c109e398Sbeck $Cname =~ s/ /_/g; 91c109e398Sbeck if ($Cname ne "" && defined($ln{$module.$Cname})) 92c109e398Sbeck { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; } 93c109e398Sbeck } 94c109e398Sbeck $Cname =~ s/\./_/g; 95c109e398Sbeck $Cname =~ s/-/_/g; 96c109e398Sbeck $Cname = $module.$Cname; 97c109e398Sbeck $ordern{$o} = $Cname; 98c109e398Sbeck $order{$Cname} = $o; 99c109e398Sbeck $sn{$Cname} = $mysn; 100c109e398Sbeck $ln{$Cname} = $myln; 101c109e398Sbeck $obj{$Cname} = $myoid; 102c109e398Sbeck if (!defined($nid{$Cname})) 103c109e398Sbeck { 104c109e398Sbeck $max_nid++; 105c109e398Sbeck $nid{$Cname} = $max_nid; 106c109e398Sbeck $nidn{$max_nid} = $Cname; 107*0a5d6edeSdjmprint STDERR "Added OID $Cname\n"; 108c109e398Sbeck } 109c109e398Sbeck $Cname=""; 110c109e398Sbeck } 111c109e398Sbeckclose IN; 112c109e398Sbeck 11303f8584eSmarkus#XXX don't modify input files 11403f8584eSmarkus#open (NUMOUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]"; 11503f8584eSmarkus#foreach (sort { $a <=> $b } keys %nidn) 11603f8584eSmarkus# { 11703f8584eSmarkus# print NUMOUT $nidn{$_},"\t\t",$_,"\n"; 11803f8584eSmarkus# } 11903f8584eSmarkus#close NUMOUT; 120c109e398Sbeck 121c109e398Sbeckopen (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]"; 122c109e398Sbeckprint OUT <<'EOF'; 123da347917Sbeck/* crypto/objects/obj_mac.h */ 124da347917Sbeck 125da347917Sbeck/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the 126da347917Sbeck * following command: 127da347917Sbeck * perl objects.pl objects.txt obj_mac.num obj_mac.h 128da347917Sbeck */ 129da347917Sbeck 130c109e398Sbeck/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 131c109e398Sbeck * All rights reserved. 132c109e398Sbeck * 133c109e398Sbeck * This package is an SSL implementation written 134c109e398Sbeck * by Eric Young (eay@cryptsoft.com). 135c109e398Sbeck * The implementation was written so as to conform with Netscapes SSL. 136c109e398Sbeck * 137c109e398Sbeck * This library is free for commercial and non-commercial use as long as 138c109e398Sbeck * the following conditions are aheared to. The following conditions 139c109e398Sbeck * apply to all code found in this distribution, be it the RC4, RSA, 140c109e398Sbeck * lhash, DES, etc., code; not just the SSL code. The SSL documentation 141c109e398Sbeck * included with this distribution is covered by the same copyright terms 142c109e398Sbeck * except that the holder is Tim Hudson (tjh@cryptsoft.com). 143c109e398Sbeck * 144c109e398Sbeck * Copyright remains Eric Young's, and as such any Copyright notices in 145c109e398Sbeck * the code are not to be removed. 146c109e398Sbeck * If this package is used in a product, Eric Young should be given attribution 147c109e398Sbeck * as the author of the parts of the library used. 148c109e398Sbeck * This can be in the form of a textual message at program startup or 149c109e398Sbeck * in documentation (online or textual) provided with the package. 150c109e398Sbeck * 151c109e398Sbeck * Redistribution and use in source and binary forms, with or without 152c109e398Sbeck * modification, are permitted provided that the following conditions 153c109e398Sbeck * are met: 154c109e398Sbeck * 1. Redistributions of source code must retain the copyright 155c109e398Sbeck * notice, this list of conditions and the following disclaimer. 156c109e398Sbeck * 2. Redistributions in binary form must reproduce the above copyright 157c109e398Sbeck * notice, this list of conditions and the following disclaimer in the 158c109e398Sbeck * documentation and/or other materials provided with the distribution. 159c109e398Sbeck * 3. All advertising materials mentioning features or use of this software 160c109e398Sbeck * must display the following acknowledgement: 161c109e398Sbeck * "This product includes cryptographic software written by 162c109e398Sbeck * Eric Young (eay@cryptsoft.com)" 163c109e398Sbeck * The word 'cryptographic' can be left out if the rouines from the library 164c109e398Sbeck * being used are not cryptographic related :-). 165c109e398Sbeck * 4. If you include any Windows specific code (or a derivative thereof) from 166c109e398Sbeck * the apps directory (application code) you must include an acknowledgement: 167c109e398Sbeck * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 168c109e398Sbeck * 169c109e398Sbeck * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 170c109e398Sbeck * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 171c109e398Sbeck * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 172c109e398Sbeck * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 173c109e398Sbeck * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 174c109e398Sbeck * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 175c109e398Sbeck * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 176c109e398Sbeck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 177c109e398Sbeck * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 178c109e398Sbeck * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 179c109e398Sbeck * SUCH DAMAGE. 180c109e398Sbeck * 181c109e398Sbeck * The licence and distribution terms for any publically available version or 182c109e398Sbeck * derivative of this code cannot be changed. i.e. this code cannot simply be 183c109e398Sbeck * copied and put under another distribution licence 184c109e398Sbeck * [including the GNU Public Licence.] 185c109e398Sbeck */ 186c109e398Sbeck 187c109e398Sbeck#define SN_undef "UNDEF" 188c109e398Sbeck#define LN_undef "undefined" 189c109e398Sbeck#define NID_undef 0 190c109e398Sbeck#define OBJ_undef 0L 191c109e398Sbeck 192c109e398SbeckEOF 193c109e398Sbeck 194c109e398Sbeckforeach (sort { $a <=> $b } keys %ordern) 195c109e398Sbeck { 196c109e398Sbeck $Cname=$ordern{$_}; 197c109e398Sbeck print OUT "#define SN_",$Cname,"\t\t\"",$sn{$Cname},"\"\n" if $sn{$Cname} ne ""; 198c109e398Sbeck print OUT "#define LN_",$Cname,"\t\t\"",$ln{$Cname},"\"\n" if $ln{$Cname} ne ""; 199c109e398Sbeck print OUT "#define NID_",$Cname,"\t\t",$nid{$Cname},"\n" if $nid{$Cname} ne ""; 200c109e398Sbeck print OUT "#define OBJ_",$Cname,"\t\t",$obj{$Cname},"\n" if $obj{$Cname} ne ""; 201c109e398Sbeck print OUT "\n"; 202c109e398Sbeck } 203c109e398Sbeck 204c109e398Sbeckclose OUT; 205c109e398Sbeck 206c109e398Sbecksub process_oid 207c109e398Sbeck { 208c109e398Sbeck local($oid)=@_; 209c109e398Sbeck local(@a,$oid_pref); 210c109e398Sbeck 211c109e398Sbeck @a = split(/\s+/,$myoid); 212c109e398Sbeck $pref_oid = ""; 213c109e398Sbeck $pref_sep = ""; 214c109e398Sbeck if (!($a[0] =~ /^[0-9]+$/)) 215c109e398Sbeck { 216c109e398Sbeck $a[0] =~ s/-/_/g; 217da347917Sbeck if (!defined($obj{$a[0]})) 218da347917Sbeck { die "$ARGV[0]:$o:Undefined identifier ",$a[0],"\n"; } 219c109e398Sbeck $pref_oid = "OBJ_" . $a[0]; 220c109e398Sbeck $pref_sep = ","; 221c109e398Sbeck shift @a; 222c109e398Sbeck } 223c109e398Sbeck $oids = join('L,',@a) . "L"; 224c109e398Sbeck if ($oids ne "L") 225c109e398Sbeck { 226c109e398Sbeck $oids = $pref_oid . $pref_sep . $oids; 227c109e398Sbeck } 228c109e398Sbeck else 229c109e398Sbeck { 230c109e398Sbeck $oids = $pref_oid; 231c109e398Sbeck } 232c109e398Sbeck return($oids); 233c109e398Sbeck } 234