2 # Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (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
9 # Output year depends on the year of the script and the input files.
10 my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
11 my $iYEAR = [localtime([stat($ARGV[0])]->[9])]->[5] + 1900;
12 $YEAR = $iYEAR if $iYEAR > $YEAR;
13 $iYEAR = [localtime([stat($ARGV[1])]->[9])]->[5] + 1900;
14 $YEAR = $iYEAR if $iYEAR > $YEAR;
16 open (NUMIN,"$ARGV[1]") || die "Can't open number file $ARGV[1]";
26 ($Cname,$mynum) = split;
28 if (defined($nidn{$mynum}))
29 { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; }
30 if (defined($nid{$Cname}))
31 { die "$ARGV[1]:$o:There's already an object with name ",$Cname," on line ",$order{$nid{$Cname}},"\n"; }
32 $nid{$Cname} = $mynum;
33 $nidn{$mynum} = $Cname;
35 $max_nid = $mynum if $mynum > $max_nid;
39 open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
46 if (/^!module\s+(.*)$/)
54 if (/^!Cname\s+(.*)$/)
56 if (/^!Alias\s+(.+?)\s+(.*)$/)
60 $myoid = &process_oid($myoid);
64 $obj{$Cname} = $myoid;
71 ($myoid,$mysn,$myln) = split ':';
80 $myoid = &process_oid($myoid);
83 if ($Cname eq "" && ($myln =~ /^[_A-Za-z][\w.-]*$/ ))
88 if ($Cname ne "" && defined($ln{$module.$Cname}))
89 { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
95 if ($Cname ne "" && defined($sn{$module.$Cname}))
96 { die "objects.txt:$o:There's already an object with short name ",$sn{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
104 if ($Cname ne "" && defined($ln{$module.$Cname}))
105 { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
109 $Cname = $module.$Cname;
110 $ordern{$o} = $Cname;
114 $obj{$Cname} = $myoid;
115 if (!defined($nid{$Cname}))
118 $nid{$Cname} = $max_nid;
119 $nidn{$max_nid} = $Cname;
120 print STDERR "Added OID $Cname\n";
126 open (NUMOUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
127 foreach (sort { $a <=> $b } keys %nidn)
129 print NUMOUT $nidn{$_},"\t\t",$_,"\n";
133 open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]";
136 * WARNING: do not edit!
137 * Generated by crypto/objects/objects.pl
139 * Copyright 2000-$YEAR The OpenSSL Project Authors. All Rights Reserved.
140 * Licensed under the OpenSSL license (the "License"). You may not use
141 * this file except in compliance with the License. You can obtain a copy
142 * in the file LICENSE in the source distribution or at
143 * https://www.openssl.org/source/license.html
146 #define SN_undef "UNDEF"
147 #define LN_undef "undefined"
156 1 while $string =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
161 foreach (sort { $a <=> $b } keys %ordern)
165 print OUT expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne "";
166 print OUT expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne "";
167 print OUT expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne "";
168 print OUT expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne "";
178 @a = split(/\s+/,$myoid);
181 if (!($a[0] =~ /^[0-9]+$/))
184 if (!defined($obj{$a[0]}))
185 { die "$ARGV[0]:$o:Undefined identifier ",$a[0],"\n"; }
186 $pref_oid = "OBJ_" . $a[0];
190 $oids = join('L,',@a) . "L";
193 $oids = $pref_oid . $pref_sep . $oids;