]>
git.ipfire.org Git - people/ms/strongswan.git/blob - Source/lib/asn1/oid.pl
a3725e57d71b65e53ec61d6d3d0845cb5988d98c
2 # Generates oid.h and oid.c out of oid.txt
3 # Copyright (C) 2003-2004 Andreas Steffen, Zuercher Hochschule Winterthur
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 $copyright="Copyright (C) 2003-2004 Andreas Steffen, Zuercher Hochschule Winterthur";
17 $automatic="This file has been automatically generated by the script oid.pl";
18 $warning="Do not edit manually!";
20 print "oid.pl generating oid.h and oid.c\n";
25 or die "could not open 'oid.h': $!";
27 print OID_H
"/* Object identifiers (OIDs) used by FreeS/WAN\n",
28 " * ", $copyright, "\n",
30 " * ", $automatic, "\n",
31 " * ", $warning, "\n",
39 " const u_char *name;\n",
42 "extern const oid_t oid_names[];\n",
44 "#define OID_UNKNOWN -1\n";
49 or die "could not open 'oid.txt': $!";
57 $line =~ m/( *?)(0x\w{2})\s+(".*?")[ \t]*?([\w_]*?)\Z/;
59 @order[$counter] = length($1);
60 @octet[$counter] = $2;
63 if (length($1) > $max_order)
65 $max_order = length($1);
67 if (length($3) > $max_name)
69 $max_name = length($3);
73 printf OID_H
"#define %s%s%d\n", $4, "\t" x
((39-length($4))/8), $counter;
78 print OID_H
"\n#endif /* OID_H_ */\n";
86 or die "could not open 'oid.c': $!";
88 print OID_C
"/* List of some useful object identifiers (OIDs)\n",
89 " * ", $copyright, "\n",
91 " * ", $automatic, "\n",
92 " * ", $warning, "\n",
95 "#include <stdlib.h>\n",
97 "#include \"oid.h\"\n",
99 "const oid_t oid_names[] = {\n";
101 for ($c = 0; $c < $counter; $c++)
105 for ($d = $c+1; $d < $counter && @order[$d] >= @order[$c]; $d++)
107 if (@order[$d] == @order[$c])
114 printf OID_C
" {%s%s,%s%3d, %d, %s%s}%s /* %3d */\n"
117 , ' ' x
(1 + $max_order - @order[$c])
119 , @order[$c+1] > @order[$c]
121 , ' ' x
($max_name - length(@name[$c]))
122 , $c != $counter-1 ?
"," : " "