1 # mkoidtbl.awk - Create OID table from Peter Gutmann's dumpasn1.cfg
2 # Copyright (C) 2004 g10 Code GmbH
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
8 # This file is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # This file takes a list of OID description in a format like
15 # # Comment line, the next line identifies a new record
16 # OID = 06 05 02 82 06 01 0A
17 # Comment = Deutsche Telekom
18 # Description = Telesec (0 2 262 1 10)
20 # And creates a new table in IETF notation with lines like
21 # 0.2.262.1.10 Telesec Deutsche Telekom
22 # comment lines may also occur in the output.
27 print "static struct { char *oid, *desc, *comment; } oidtranstbl[] = {"
32 oid = substr($0, index($0, "=") + 2)
33 gsub (/[ \t]+/, ".", oid)
35 /^Comment/ { comment = substr($0, index($0, "=") + 2 )
36 gsub(/\r/, "", comment)
37 gsub (/\\/, "\\\\", comment)
38 gsub (/"/, "\\\"", comment)
39 gsub (/\(\?\?\?\)/, "(?)", comment)
42 desc = substr($0, index($0, "=") + 2)
44 if (match (desc, /\([0-9 \t]+\)/) > 2) {
45 oid = substr(desc, RSTART+1, RLENGTH-2 )
46 desc = substr(desc, 1, RSTART-1);
48 gsub (/[ \t]+/, ".", oid)
49 gsub (/\\/, "\\\\", desc)
50 gsub (/"/, "\\\"", desc)
51 sub (/[ \t]*$/, "", desc)
54 END { flush(); print " { NULL, NULL, NULL }\n};" }
58 printf " { \"%s\", \"%s\", \"%s\" },\n", oid, desc, comment
59 oid = desc = comment = ""