2 # Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
14 # Output year depends on the year of the script and the input file.
15 my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
16 my $iYEAR = [localtime([stat($ARGV[0])]->[9])]->[5] + 1900;
17 $YEAR = $iYEAR if $iYEAR > $YEAR;
18 $iYEAR = [localtime([stat($ARGV[1])]->[9])]->[5] + 1900;
19 $YEAR = $iYEAR if $iYEAR > $YEAR;
21 open (NUMIN,"$ARGV[1]") || die "Can't open number file $ARGV[1]";
31 ($Cname,$mynum) = split;
33 if (defined($nidn{$mynum}))
34 { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; }
35 if (defined($nid{$Cname}))
36 { die "$ARGV[1]:$o:There's already an object with name ",$Cname," on line ",$order{$nid{$Cname}},"\n"; }
37 $nid{$Cname} = $mynum;
38 $nidn{$mynum} = $Cname;
40 $max_nid = $mynum if $mynum > $max_nid;
44 open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
51 if (/^!module\s+(.*)$/)
59 if (/^!Cname\s+(.*)$/)
61 if (/^!Alias\s+(.+?)\s+(.*)$/)
65 $myoid = &process_oid($myoid);
69 $obj{$Cname} = $myoid;
76 ($myoid,$mysn,$myln) = split ':';
85 $myoid = &process_oid($myoid);
88 if ($Cname eq "" && ($myln =~ /^[_A-Za-z][\w.-]*$/ ))
93 if ($Cname ne "" && defined($ln{$module.$Cname}))
94 { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
100 if ($Cname ne "" && defined($sn{$module.$Cname}))
101 { die "objects.txt:$o:There's already an object with short name ",$sn{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
109 if ($Cname ne "" && defined($ln{$module.$Cname}))
110 { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
114 $Cname = $module.$Cname;
115 $ordern{$o} = $Cname;
119 $obj{$Cname} = $myoid;
120 if (!defined($nid{$Cname}))
123 $nid{$Cname} = $max_nid;
124 $nidn{$max_nid} = $Cname;
125 print STDERR "Added OID $Cname\n";
132 foreach (sort { $a <=> $b } keys %nidn)
134 print $nidn{$_},"\t\t",$_,"\n";
141 * WARNING: do not edit!
142 * Generated by crypto/objects/objects.pl
144 * Copyright 2000-$YEAR The OpenSSL Project Authors. All Rights Reserved.
145 * Licensed under the Apache License 2.0 (the "License"). You may not use
146 * this file except in compliance with the License. You can obtain a copy
147 * in the file LICENSE in the source distribution or at
148 * https://www.openssl.org/source/license.html
151 #define SN_undef "UNDEF"
152 #define LN_undef "undefined"
161 1 while $string =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
166 foreach (sort { $a <=> $b } keys %ordern)
170 print expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne "";
171 print expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne "";
172 print expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne "";
173 print expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne "";
181 @a = split(/\s+/,$myoid);
184 if (!($a[0] =~ /^[0-9]+$/))
187 if (!defined($obj{$a[0]}))
188 { die "$ARGV[0]:$o:Undefined identifier ",$a[0],"\n"; }
189 $pref_oid = "OBJ_" . $a[0];
193 $oids = join('L,',@a) . "L";
196 $oids = $pref_oid . $pref_sep . $oids;