3 if ($ARGV[0] eq "-s") { $static=1; shift @ARGV; }
5 ($#ARGV == 1) || die "usage: $0 [-s] <header file> <output C file>\n";
6 open(IN,"<$ARGV[0]") || die "unable to open $ARGV[0]:$!\n";
7 open(STDOUT,">$ARGV[1]") || die "unable to open $ARGV[1]:$!\n";
11 $fuction{'FOPEN'}='fopen';
18 ($upper=$t) =~ tr/a-z/A-Z/;
21 next unless (/^#define\s+(\S+)\s/);
24 if ($o =~ /^([^_]+)_F_(.*)/)
29 $n=$fuction{$n} if (defined($fuction{$n}));
30 $out{$1."_str_functs"}.=
31 sprintf("{ERR_PACK(0,%s,0),\t\"$n\"},\n",$o);
33 elsif ($o =~ /^([^_]+)_R_(.*)/)
39 $pkg{$type."_str_reasons"}=$type;
40 $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o);
42 elsif ($ARGV[0] =~ /rsaref/ && $o =~ /^RE_(.*)/)
48 $pkg{$type."_str_reasons"}=$type;
49 $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o);
54 &header($type,$ARGV[0]);
56 foreach (sort keys %out)
58 print "static ERR_STRING_DATA ${_}[]=\n\t{\n";
66 { $lib="ERR_LIB_$type"; }
71 #ifdef ${type}_LIB_NAME
72 static ERR_STRING_DATA ${type}_lib_name[]=
74 {0 ,${type}_LIB_NAME},
80 $lib="${type}_lib_error_code";
87 $str.="#ifndef NO_ERR\n";
88 $str.="\t\tERR_load_strings($lib,${type}_str_functs);\n" if $Func;
89 $str.="\t\tERR_load_strings($lib,${type}_str_reasons);\n" if $Reas;
96 int ${type}_lib_error_code=0;
98 void ERR_load_${type}_strings()
102 if (${type}_lib_error_code == 0)
103 ${type}_lib_error_code=ERR_get_next_error_library();
109 #ifdef ${type}_LIB_NAME
110 ${type}_lib_name->error = ERR_PACK(${type}_lib_error_code,0,0);
111 ERR_load_strings(0,${type}_lib_name);
116 void ERR_${type}_error(function,reason,file,line)
122 if (${type}_lib_error_code == 0)
123 ${type}_lib_error_code=ERR_get_next_error_library();
124 ERR_PUT_error(${type}_lib_error_code,function,reason,file,line);
132 void ERR_load_${type}_strings()
149 ($lc=$type) =~ tr/A-Z/a-z/;
150 $header =~ s/^.*\///;
152 print "/* lib/$lc/${lc}\_err.c */\n";
154 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
155 * All rights reserved.
157 * This package is an SSL implementation written
158 * by Eric Young (eay@cryptsoft.com).
159 * The implementation was written so as to conform with Netscapes SSL.
161 * This library is free for commercial and non-commercial use as long as
162 * the following conditions are aheared to. The following conditions
163 * apply to all code found in this distribution, be it the RC4, RSA,
164 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
165 * included with this distribution is covered by the same copyright terms
166 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
168 * Copyright remains Eric Young's, and as such any Copyright notices in
169 * the code are not to be removed.
170 * If this package is used in a product, Eric Young should be given attribution
171 * as the author of the parts of the library used.
172 * This can be in the form of a textual message at program startup or
173 * in documentation (online or textual) provided with the package.
175 * Redistribution and use in source and binary forms, with or without
176 * modification, are permitted provided that the following conditions
178 * 1. Redistributions of source code must retain the copyright
179 * notice, this list of conditions and the following disclaimer.
180 * 2. Redistributions in binary form must reproduce the above copyright
181 * notice, this list of conditions and the following disclaimer in the
182 * documentation and/or other materials provided with the distribution.
183 * 3. All advertising materials mentioning features or use of this software
184 * must display the following acknowledgement:
185 * "This product includes cryptographic software written by
186 * Eric Young (eay@cryptsoft.com)"
187 * The word 'cryptographic' can be left out if the rouines from the library
188 * being used are not cryptographic related :-).
189 * 4. If you include any Windows specific code (or a derivative thereof) from
190 * the apps directory (application code) you must include an acknowledgement:
191 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
193 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
194 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
195 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
196 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
197 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
198 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
200 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
201 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
202 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
205 * The licence and distribution terms for any publically available version or
206 * derivative of this code cannot be changed. i.e. this code cannot simply be
207 * copied and put under another distribution licence
208 * [including the GNU Public Licence.]
212 print "#include <stdio.h>\n";
213 print "#include \"err.h\"\n";
214 print "#include \"$header\"\n";
215 print "\n/* BEGIN ERROR CODES */\n";
216 print "#ifndef NO_ERR\n";