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"; }
68 { $lib="${type}_lib_error_code"; }
71 $str.="#ifndef NO_ERR\n";
72 $str.="\t\tERR_load_strings($lib,${type}_str_functs);\n" if $Func;
73 $str.="\t\tERR_load_strings($lib,${type}_str_reasons);\n" if $Reas;
80 static int ${type}_lib_error_code=0;
82 void ERR_load_${type}_strings()
86 if (${type}_lib_error_code == 0)
87 ${type}_lib_error_code=ERR_get_next_error_library();
96 void ERR_${type}_error(function,reason,file,line)
102 if (${type}_lib_error_code == 0)
103 ${type}_lib_error_code=ERR_get_next_error_library();
104 ERR_PUT_error(${type}_lib_error_code,function,reason,file,line);
112 void ERR_load_${type}_strings()
129 ($lc=$type) =~ tr/A-Z/a-z/;
130 $header =~ s/^.*\///;
132 print "/* lib/$lc/${lc}\_err.c */\n";
134 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
135 * All rights reserved.
137 * This package is an SSL implementation written
138 * by Eric Young (eay@cryptsoft.com).
139 * The implementation was written so as to conform with Netscapes SSL.
141 * This library is free for commercial and non-commercial use as long as
142 * the following conditions are aheared to. The following conditions
143 * apply to all code found in this distribution, be it the RC4, RSA,
144 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
145 * included with this distribution is covered by the same copyright terms
146 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
148 * Copyright remains Eric Young's, and as such any Copyright notices in
149 * the code are not to be removed.
150 * If this package is used in a product, Eric Young should be given attribution
151 * as the author of the parts of the library used.
152 * This can be in the form of a textual message at program startup or
153 * in documentation (online or textual) provided with the package.
155 * Redistribution and use in source and binary forms, with or without
156 * modification, are permitted provided that the following conditions
158 * 1. Redistributions of source code must retain the copyright
159 * notice, this list of conditions and the following disclaimer.
160 * 2. Redistributions in binary form must reproduce the above copyright
161 * notice, this list of conditions and the following disclaimer in the
162 * documentation and/or other materials provided with the distribution.
163 * 3. All advertising materials mentioning features or use of this software
164 * must display the following acknowledgement:
165 * "This product includes cryptographic software written by
166 * Eric Young (eay@cryptsoft.com)"
167 * The word 'cryptographic' can be left out if the rouines from the library
168 * being used are not cryptographic related :-).
169 * 4. If you include any Windows specific code (or a derivative thereof) from
170 * the apps directory (application code) you must include an acknowledgement:
171 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
173 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
174 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
175 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
176 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
177 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
178 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
179 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
180 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
181 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
182 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
185 * The licence and distribution terms for any publically available version or
186 * derivative of this code cannot be changed. i.e. this code cannot simply be
187 * copied and put under another distribution licence
188 * [including the GNU Public Licence.]
192 print "#include <stdio.h>\n";
193 print "#include \"err.h\"\n";
194 print "#include \"$header\"\n";
195 print "\n/* BEGIN ERROR CODES */\n";
196 print "#ifndef NO_ERR\n";