3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is the Netscape security libraries.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1994-2000
21 # the Initial Developer. All Rights Reserved.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
38 $cvs_id = '@(#) $RCSfile: oidgen.perl,v $ $Revision: 1.6 $ $Date: 2005/03/14 18:02:00 $';
43 s/^((?:[^"#]+|"[^"]*")*)(\s*#.*$)/$1/;
46 /^([\S]+)\s+([^"][\S]*|"[^"]*")/;
49 # This is certainly not the best way to dequote the data.
52 if( $name =~ "OID" ) {
54 $x[$count]{$name} = $value;
55 $enc = encodeoid
($value);
56 $x[$count]{" encoding"} = escapeoid
($enc);
57 $x[$count]{" encoding length"} = length($enc);
62 $x[$count]{$name} = $value;
69 doprint
($cfile,$hfile);
72 for( $i = 0; $i <= $count; $i++ ) {
75 while(($n,$v) = each(%y)) {
76 print "\t$n ==> $v\n";
82 open(CFILE
, "> $cfile") || die "Can't open $cfile: $!";
83 open(HFILE
, "> $hfile") || die "Can't open $hfile: $!";
86 /* THIS IS A GENERATED FILE */
87 /* ***** BEGIN LICENSE BLOCK *****
88 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
90 * The contents of this file are subject to the Mozilla Public License Version
91 * 1.1 (the "License"); you may not use this file except in compliance with
92 * the License. You may obtain a copy of the License at
93 * http://www.mozilla.org/MPL/
95 * Software distributed under the License is distributed on an "AS IS" basis,
96 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
97 * for the specific language governing rights and limitations under the
100 * The Original Code is the Netscape security libraries.
102 * The Initial Developer of the Original Code is
103 * Netscape Communications Corporation.
104 * Portions created by the Initial Developer are Copyright (C) 1994-2000
105 * the Initial Developer. All Rights Reserved.
109 * Alternatively, the contents of this file may be used under the terms of
110 * either the GNU General Public License Version 2 or later (the "GPL"), or
111 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
112 * in which case the provisions of the GPL or the LGPL are applicable instead
113 * of those above. If you wish to allow use of your version of this file only
114 * under the terms of either the GPL or the LGPL, and not to allow others to
115 * use your version of this file under the terms of the MPL, indicate your
116 * decision by deleting the provisions above and replace them with the notice
117 * and other provisions required by the GPL or the LGPL. If you do not delete
118 * the provisions above, a recipient may use your version of this file under
119 * the terms of any one of the MPL, the GPL or the LGPL.
121 * ***** END LICENSE BLOCK ***** */
124 static const char CVS_ID[] = "$g{CVS_ID} ; $cvs_id";
131 const NSSOID nss_builtin_oids[] = {
135 for( $i = 0; $i <= $count; $i++ ) {
138 print CFILE
"#ifdef DEBUG\n";
139 print CFILE
" \"$y{TAG}\",\n";
140 print CFILE
" \"$y{EXPL}\",\n";
141 print CFILE
"#endif /* DEBUG */\n";
142 print CFILE
" { \"", $y{" encoding"};
143 print CFILE
"\", ", $y{" encoding length"}, " }\n";
152 print CFILE
"};\n\n";
154 print CFILE
"const PRUint32 nss_builtin_oid_count = ", ($count+1), ";\n\n";
156 for( $i = 0; $i <= $count; $i++ ) {
158 if( defined($y{NAME
}) ) {
159 print CFILE
"const NSSOID *$y{NAME} = (NSSOID *)&nss_builtin_oids[$i];\n";
166 for( $i = 0; $i <= $count; $i++ ) {
168 if( defined($y{ATTR
}) ) {
169 if( defined($y{NAME
}) ) {
171 $attr[$attrcount]{ATTR
} = $y{ATTR
};
172 $attr[$attrcount]{NAME
} = $y{NAME
};
174 warn "Attribute $y{ATTR} has no name, and will be omitted!";
179 print CFILE
"const nssAttributeTypeAliasTable nss_attribute_type_aliases[] = {\n";
181 for( $i = 0; $i <= $attrcount; $i++ ) {
184 print CFILE
" \"$y{ATTR}\",\n";
185 print CFILE
" &$y{NAME}\n";
187 if( $i == $attrcount ) {
194 print CFILE
"};\n\n";
196 print CFILE
"const PRUint32 nss_attribute_type_alias_count = ", ($attrcount+1), ";\n\n";
199 /* THIS IS A GENERATED FILE */
200 /* ***** BEGIN LICENSE BLOCK *****
201 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
203 * The contents of this file are subject to the Mozilla Public License Version
204 * 1.1 (the "License"); you may not use this file except in compliance with
205 * the License. You may obtain a copy of the License at
206 * http://www.mozilla.org/MPL/
208 * Software distributed under the License is distributed on an "AS IS" basis,
209 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
210 * for the specific language governing rights and limitations under the
213 * The Original Code is the Netscape security libraries.
215 * The Initial Developer of the Original Code is
216 * Netscape Communications Corporation.
217 * Portions created by the Initial Developer are Copyright (C) 1994-2000
218 * the Initial Developer. All Rights Reserved.
222 * Alternatively, the contents of this file may be used under the terms of
223 * either the GNU General Public License Version 2 or later (the "GPL"), or
224 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
225 * in which case the provisions of the GPL or the LGPL are applicable instead
226 * of those above. If you wish to allow use of your version of this file only
227 * under the terms of either the GPL or the LGPL, and not to allow others to
228 * use your version of this file under the terms of the MPL, indicate your
229 * decision by deleting the provisions above and replace them with the notice
230 * and other provisions required by the GPL or the LGPL. If you do not delete
231 * the provisions above, a recipient may use your version of this file under
232 * the terms of any one of the MPL, the GPL or the LGPL.
234 * ***** END LICENSE BLOCK ***** */
240 static const char OIDDATA_CVS_ID[] = "$g{CVS_ID} ; $cvs_id";
244 #include "nsspki1t.h"
245 #endif /* NSSPKI1T_H */
250 for( $i = 0; $i <= $count; $i++ ) {
252 if( defined($y{NAME
}) ) {
253 print HFILE
"extern const NSSOID *$y{NAME};\n";
259 #endif /* OIDDATA_H */
279 for( $i = @d-1; $i > 0; $i-- ) {
280 $rv = $rv . chr(128 + $d[$i]);
283 $rv = $rv . chr($d[0]);
289 my @o = split(/\./, $_[0]);
294 # NSS's special "illegal" encoding
295 return chr(128) . encodenum
($o[0]);
298 $rv = encodenum
($o[0] * 40 + $o[1]);
302 $rv = $rv . encodenum
($i);
309 my @v = unpack("C*", $_[0]);
314 $rv = $rv . sprintf("\\x%02x", $a);