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