diff options
author | cvs2svn <admin@example.com> | 2012-07-13 17:49:55 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 2012-07-13 17:49:55 +0000 |
commit | 6fdb436ab2cd5b35066babb3a03be7ad0daf1ae2 (patch) | |
tree | a760cf389e7ea59961bb306a1f50bf5443205176 /src/lib/libcrypto/util | |
parent | 9204e59073bcf27e1487ec4ac46e981902ddd904 (diff) | |
download | openbsd-OPENBSD_5_2_BASE.tar.gz openbsd-OPENBSD_5_2_BASE.tar.bz2 openbsd-OPENBSD_5_2_BASE.zip |
This commit was manufactured by cvs2git to create tag 'OPENBSD_5_2_BASE'.OPENBSD_5_2_BASE
Diffstat (limited to 'src/lib/libcrypto/util')
-rw-r--r-- | src/lib/libcrypto/util/mkerr.pl | 810 | ||||
-rw-r--r-- | src/lib/libcrypto/util/mkstack.pl | 192 |
2 files changed, 0 insertions, 1002 deletions
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl deleted file mode 100644 index aec401c773..0000000000 --- a/src/lib/libcrypto/util/mkerr.pl +++ /dev/null | |||
@@ -1,810 +0,0 @@ | |||
1 | #!/usr/local/bin/perl -w | ||
2 | |||
3 | my $config = "crypto/err/openssl.ec"; | ||
4 | my $hprefix = "openssl/"; | ||
5 | my $debug = 0; | ||
6 | my $rebuild = 0; | ||
7 | my $static = 1; | ||
8 | my $recurse = 0; | ||
9 | my $reindex = 0; | ||
10 | my $dowrite = 0; | ||
11 | my $staticloader = ""; | ||
12 | |||
13 | my $pack_errcode; | ||
14 | my $load_errcode; | ||
15 | |||
16 | my $errcount; | ||
17 | |||
18 | while (@ARGV) { | ||
19 | my $arg = $ARGV[0]; | ||
20 | if($arg eq "-conf") { | ||
21 | shift @ARGV; | ||
22 | $config = shift @ARGV; | ||
23 | } elsif($arg eq "-hprefix") { | ||
24 | shift @ARGV; | ||
25 | $hprefix = shift @ARGV; | ||
26 | } elsif($arg eq "-debug") { | ||
27 | $debug = 1; | ||
28 | shift @ARGV; | ||
29 | } elsif($arg eq "-rebuild") { | ||
30 | $rebuild = 1; | ||
31 | shift @ARGV; | ||
32 | } elsif($arg eq "-recurse") { | ||
33 | $recurse = 1; | ||
34 | shift @ARGV; | ||
35 | } elsif($arg eq "-reindex") { | ||
36 | $reindex = 1; | ||
37 | shift @ARGV; | ||
38 | } elsif($arg eq "-nostatic") { | ||
39 | $static = 0; | ||
40 | shift @ARGV; | ||
41 | } elsif($arg eq "-staticloader") { | ||
42 | $staticloader = "static "; | ||
43 | shift @ARGV; | ||
44 | } elsif($arg eq "-write") { | ||
45 | $dowrite = 1; | ||
46 | shift @ARGV; | ||
47 | } elsif($arg eq "-help" || $arg eq "-h" || $arg eq "-?" || $arg eq "--help") { | ||
48 | print STDERR <<"EOF"; | ||
49 | mkerr.pl [options] ... | ||
50 | |||
51 | Options: | ||
52 | |||
53 | -conf F Use the config file F instead of the default one: | ||
54 | crypto/err/openssl.ec | ||
55 | |||
56 | -hprefix P Prepend the filenames in generated #include <header> | ||
57 | statements with prefix P. Default: 'openssl/' (without | ||
58 | the quotes, naturally) | ||
59 | |||
60 | -debug Turn on debugging verbose output on stderr. | ||
61 | |||
62 | -rebuild Rebuild all header and C source files, irrespective of the | ||
63 | fact if any error or function codes have been added/removed. | ||
64 | Default: only update files for libraries which saw change | ||
65 | (of course, this requires '-write' as well, or no | ||
66 | files will be touched!) | ||
67 | |||
68 | -recurse scan a preconfigured set of directories / files for error and | ||
69 | function codes: | ||
70 | (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>, <apps/*.c>) | ||
71 | When this option is NOT specified, the filelist is taken from | ||
72 | the commandline instead. Here, wildcards may be embedded. (Be | ||
73 | sure to escape those to prevent the shell from expanding them | ||
74 | for you when you wish mkerr.pl to do so instead.) | ||
75 | Default: take file list to scan from the command line. | ||
76 | |||
77 | -reindex Discard the numeric values previously assigned to the error | ||
78 | and function codes as extracted from the scanned header files; | ||
79 | instead renumber all of them starting from 100. (Note that | ||
80 | the numbers assigned through 'R' records in the config file | ||
81 | remain intact.) | ||
82 | Default: keep previously assigned numbers. (You are warned | ||
83 | when collisions are detected.) | ||
84 | |||
85 | -nostatic Generates a different source code, where these additional | ||
86 | functions are generated for each library specified in the | ||
87 | config file: | ||
88 | void ERR_load_<LIB>_strings(void); | ||
89 | void ERR_unload_<LIB>_strings(void); | ||
90 | void ERR_<LIB>_error(int f, int r, char *fn, int ln); | ||
91 | #define <LIB>err(f,r) ERR_<LIB>_error(f,r,__FILE__,__LINE__) | ||
92 | while the code facilitates the use of these in an environment | ||
93 | where the error support routines are dynamically loaded at | ||
94 | runtime. | ||
95 | Default: 'static' code generation. | ||
96 | |||
97 | -staticloader Prefix generated functions with the 'static' scope modifier. | ||
98 | Default: don't write any scope modifier prefix. | ||
99 | |||
100 | -write Actually (over)write the generated code to the header and C | ||
101 | source files as assigned to each library through the config | ||
102 | file. | ||
103 | Default: don't write. | ||
104 | |||
105 | -help / -h / -? / --help Show this help text. | ||
106 | |||
107 | ... Additional arguments are added to the file list to scan, | ||
108 | assuming '-recurse' was NOT specified on the command line. | ||
109 | |||
110 | EOF | ||
111 | exit 1; | ||
112 | } else { | ||
113 | last; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | if($recurse) { | ||
118 | @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>); | ||
119 | } else { | ||
120 | @source = @ARGV; | ||
121 | } | ||
122 | |||
123 | # Read in the config file | ||
124 | |||
125 | open(IN, "<$config") || die "Can't open config file $config"; | ||
126 | |||
127 | # Parse config file | ||
128 | |||
129 | while(<IN>) | ||
130 | { | ||
131 | if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) { | ||
132 | $hinc{$1} = $2; | ||
133 | $libinc{$2} = $1; | ||
134 | $cskip{$3} = $1; | ||
135 | if($3 ne "NONE") { | ||
136 | $csrc{$1} = $3; | ||
137 | $fmax{$1} = 100; | ||
138 | $rmax{$1} = 100; | ||
139 | $fassigned{$1} = ":"; | ||
140 | $rassigned{$1} = ":"; | ||
141 | $fnew{$1} = 0; | ||
142 | $rnew{$1} = 0; | ||
143 | } | ||
144 | } elsif (/^F\s+(\S+)/) { | ||
145 | # Add extra function with $1 | ||
146 | } elsif (/^R\s+(\S+)\s+(\S+)/) { | ||
147 | $rextra{$1} = $2; | ||
148 | $rcodes{$1} = $2; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | close IN; | ||
153 | |||
154 | # Scan each header file in turn and make a list of error codes | ||
155 | # and function names | ||
156 | |||
157 | while (($hdr, $lib) = each %libinc) | ||
158 | { | ||
159 | next if($hdr eq "NONE"); | ||
160 | print STDERR "Scanning header file $hdr\n" if $debug; | ||
161 | my $line = "", $def= "", $linenr = 0, $gotfile = 0; | ||
162 | if (open(IN, "<$hdr")) { | ||
163 | $gotfile = 1; | ||
164 | while(<IN>) { | ||
165 | $linenr++; | ||
166 | print STDERR "line: $linenr\r" if $debug; | ||
167 | |||
168 | last if(/BEGIN\s+ERROR\s+CODES/); | ||
169 | if ($line ne '') { | ||
170 | $_ = $line . $_; | ||
171 | $line = ''; | ||
172 | } | ||
173 | |||
174 | if (/\\$/) { | ||
175 | $line = $_; | ||
176 | next; | ||
177 | } | ||
178 | |||
179 | if(/\/\*/) { | ||
180 | if (not /\*\//) { # multiline comment... | ||
181 | $line = $_; # ... just accumulate | ||
182 | next; | ||
183 | } else { | ||
184 | s/\/\*.*?\*\///gs; # wipe it | ||
185 | } | ||
186 | } | ||
187 | |||
188 | if ($cpp) { | ||
189 | $cpp++ if /^#\s*if/; | ||
190 | $cpp-- if /^#\s*endif/; | ||
191 | next; | ||
192 | } | ||
193 | $cpp = 1 if /^#.*ifdef.*cplusplus/; # skip "C" declaration | ||
194 | |||
195 | next if (/^\#/); # skip preprocessor directives | ||
196 | |||
197 | s/{[^{}]*}//gs; # ignore {} blocks | ||
198 | |||
199 | if (/\{|\/\*/) { # Add a } so editor works... | ||
200 | $line = $_; | ||
201 | } else { | ||
202 | $def .= $_; | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | |||
207 | print STDERR " \r" if $debug; | ||
208 | $defnr = 0; | ||
209 | # Delete any DECLARE_ macros | ||
210 | $def =~ s/DECLARE_\w+\([\w,\s]+\)//gs; | ||
211 | foreach (split /;/, $def) { | ||
212 | $defnr++; | ||
213 | print STDERR "def: $defnr\r" if $debug; | ||
214 | |||
215 | # The goal is to collect function names from function declarations. | ||
216 | |||
217 | s/^[\n\s]*//g; | ||
218 | s/[\n\s]*$//g; | ||
219 | |||
220 | # Skip over recognized non-function declarations | ||
221 | next if(/typedef\W/ or /DECLARE_STACK_OF/ or /TYPEDEF_.*_OF/); | ||
222 | |||
223 | # Remove STACK_OF(foo) | ||
224 | s/STACK_OF\(\w+\)/void/; | ||
225 | |||
226 | # Reduce argument lists to empty () | ||
227 | # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {} | ||
228 | while(/\(.*\)/s) { | ||
229 | s/\([^\(\)]+\)/\{\}/gs; | ||
230 | s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs; #(*f{}) -> f | ||
231 | } | ||
232 | # pretend as we didn't use curly braces: {} -> () | ||
233 | s/\{\}/\(\)/gs; | ||
234 | |||
235 | if (/(\w+)\s*\(\).*/s) { # first token prior [first] () is | ||
236 | my $name = $1; # a function name! | ||
237 | $name =~ tr/[a-z]/[A-Z]/; | ||
238 | $ftrans{$name} = $1; | ||
239 | } elsif (/[\(\)]/ and not (/=/)) { | ||
240 | print STDERR "Header $hdr: cannot parse: $_;\n"; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | print STDERR " \r" if $debug; | ||
245 | |||
246 | next if $reindex; | ||
247 | |||
248 | # Scan function and reason codes and store them: keep a note of the | ||
249 | # maximum code used. | ||
250 | |||
251 | if ($gotfile) { | ||
252 | while(<IN>) { | ||
253 | if(/^\#define\s+(\S+)\s+(\S+)/) { | ||
254 | $name = $1; | ||
255 | $code = $2; | ||
256 | next if $name =~ /^${lib}err/; | ||
257 | unless($name =~ /^${lib}_([RF])_(\w+)$/) { | ||
258 | print STDERR "Invalid error code $name\n"; | ||
259 | next; | ||
260 | } | ||
261 | if($1 eq "R") { | ||
262 | $rcodes{$name} = $code; | ||
263 | if ($rassigned{$lib} =~ /:$code:/) { | ||
264 | print STDERR "!! ERROR: $lib reason code $code assigned twice (collision at $name)\n"; | ||
265 | ++$errcount; | ||
266 | } | ||
267 | $rassigned{$lib} .= "$code:"; | ||
268 | if(!(exists $rextra{$name}) && | ||
269 | ($code > $rmax{$lib}) ) { | ||
270 | $rmax{$lib} = $code; | ||
271 | } | ||
272 | } else { | ||
273 | if ($fassigned{$lib} =~ /:$code:/) { | ||
274 | print STDERR "!! ERROR: $lib function code $code assigned twice (collision at $name)\n"; | ||
275 | ++$errcount; | ||
276 | } | ||
277 | $fassigned{$lib} .= "$code:"; | ||
278 | if($code > $fmax{$lib}) { | ||
279 | $fmax{$lib} = $code; | ||
280 | } | ||
281 | $fcodes{$name} = $code; | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | } | ||
286 | |||
287 | if ($debug) { | ||
288 | if (defined($fmax{$lib})) { | ||
289 | print STDERR "Max function code fmax" . "{" . "$lib" . "} = $fmax{$lib}\n"; | ||
290 | $fassigned{$lib} =~ m/^:(.*):$/; | ||
291 | @fassigned = sort {$a <=> $b} split(":", $1); | ||
292 | print STDERR " @fassigned\n"; | ||
293 | } | ||
294 | if (defined($rmax{$lib})) { | ||
295 | print STDERR "Max reason code rmax" . "{" . "$lib" . "} = $rmax{$lib}\n"; | ||
296 | $rassigned{$lib} =~ m/^:(.*):$/; | ||
297 | @rassigned = sort {$a <=> $b} split(":", $1); | ||
298 | print STDERR " @rassigned\n"; | ||
299 | } | ||
300 | } | ||
301 | |||
302 | if ($lib eq "SSL") { | ||
303 | if ($rmax{$lib} >= 1000) { | ||
304 | print STDERR "!! ERROR: SSL error codes 1000+ are reserved for alerts.\n"; | ||
305 | print STDERR "!! Any new alerts must be added to $config.\n"; | ||
306 | ++$errcount; | ||
307 | print STDERR "\n"; | ||
308 | } | ||
309 | } | ||
310 | close IN; | ||
311 | } | ||
312 | |||
313 | # Scan each C source file and look for function and reason codes | ||
314 | # This is done by looking for strings that "look like" function or | ||
315 | # reason codes: basically anything consisting of all upper case and | ||
316 | # numerics which has _F_ or _R_ in it and which has the name of an | ||
317 | # error library at the start. This seems to work fine except for the | ||
318 | # oddly named structure BIO_F_CTX which needs to be ignored. | ||
319 | # If a code doesn't exist in list compiled from headers then mark it | ||
320 | # with the value "X" as a place holder to give it a value later. | ||
321 | # Store all function and reason codes found in %ufcodes and %urcodes | ||
322 | # so all those unreferenced can be printed out. | ||
323 | |||
324 | |||
325 | foreach $file (@source) { | ||
326 | # Don't parse the error source file. | ||
327 | next if exists $cskip{$file}; | ||
328 | print STDERR "File loaded: ".$file."\r" if $debug; | ||
329 | open(IN, "<$file") || die "Can't open source file $file\n"; | ||
330 | while(<IN>) { | ||
331 | # skip obsoleted source files entirely! | ||
332 | last if(/^#error\s+obsolete/); | ||
333 | |||
334 | if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) { | ||
335 | next unless exists $csrc{$2}; | ||
336 | next if($1 eq "BIO_F_BUFFER_CTX"); | ||
337 | $ufcodes{$1} = 1; | ||
338 | if(!exists $fcodes{$1}) { | ||
339 | $fcodes{$1} = "X"; | ||
340 | $fnew{$2}++; | ||
341 | } | ||
342 | $notrans{$1} = 1 unless exists $ftrans{$3}; | ||
343 | print STDERR "Function: $1\t= $fcodes{$1} (lib: $2, name: $3)\n" if $debug; | ||
344 | } | ||
345 | if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) { | ||
346 | next unless exists $csrc{$2}; | ||
347 | $urcodes{$1} = 1; | ||
348 | if(!exists $rcodes{$1}) { | ||
349 | $rcodes{$1} = "X"; | ||
350 | $rnew{$2}++; | ||
351 | } | ||
352 | print STDERR "Reason: $1\t= $rcodes{$1} (lib: $2)\n" if $debug; | ||
353 | } | ||
354 | } | ||
355 | close IN; | ||
356 | } | ||
357 | print STDERR " \n" if $debug; | ||
358 | |||
359 | # Now process each library in turn. | ||
360 | |||
361 | foreach $lib (keys %csrc) | ||
362 | { | ||
363 | my $hfile = $hinc{$lib}; | ||
364 | my $cfile = $csrc{$lib}; | ||
365 | if(!$fnew{$lib} && !$rnew{$lib}) { | ||
366 | print STDERR "$lib:\t\tNo new error codes\n"; | ||
367 | next unless $rebuild; | ||
368 | } else { | ||
369 | print STDERR "$lib:\t\t$fnew{$lib} New Functions,"; | ||
370 | print STDERR " $rnew{$lib} New Reasons.\n"; | ||
371 | next unless $dowrite; | ||
372 | } | ||
373 | |||
374 | # If we get here then we have some new error codes so we | ||
375 | # need to rebuild the header file and C file. | ||
376 | |||
377 | # Make a sorted list of error and reason codes for later use. | ||
378 | |||
379 | my @function = sort grep(/^${lib}_/,keys %fcodes); | ||
380 | my @reasons = sort grep(/^${lib}_/,keys %rcodes); | ||
381 | |||
382 | # Rewrite the header file | ||
383 | |||
384 | if (open(IN, "<$hfile")) { | ||
385 | # Copy across the old file | ||
386 | while(<IN>) { | ||
387 | push @out, $_; | ||
388 | last if (/BEGIN ERROR CODES/); | ||
389 | } | ||
390 | close IN; | ||
391 | } else { | ||
392 | push @out, | ||
393 | "/* ====================================================================\n", | ||
394 | " * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.\n", | ||
395 | " *\n", | ||
396 | " * Redistribution and use in source and binary forms, with or without\n", | ||
397 | " * modification, are permitted provided that the following conditions\n", | ||
398 | " * are met:\n", | ||
399 | " *\n", | ||
400 | " * 1. Redistributions of source code must retain the above copyright\n", | ||
401 | " * notice, this list of conditions and the following disclaimer. \n", | ||
402 | " *\n", | ||
403 | " * 2. Redistributions in binary form must reproduce the above copyright\n", | ||
404 | " * notice, this list of conditions and the following disclaimer in\n", | ||
405 | " * the documentation and/or other materials provided with the\n", | ||
406 | " * distribution.\n", | ||
407 | " *\n", | ||
408 | " * 3. All advertising materials mentioning features or use of this\n", | ||
409 | " * software must display the following acknowledgment:\n", | ||
410 | " * \"This product includes software developed by the OpenSSL Project\n", | ||
411 | " * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n", | ||
412 | " *\n", | ||
413 | " * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n", | ||
414 | " * endorse or promote products derived from this software without\n", | ||
415 | " * prior written permission. For written permission, please contact\n", | ||
416 | " * openssl-core\@openssl.org.\n", | ||
417 | " *\n", | ||
418 | " * 5. Products derived from this software may not be called \"OpenSSL\"\n", | ||
419 | " * nor may \"OpenSSL\" appear in their names without prior written\n", | ||
420 | " * permission of the OpenSSL Project.\n", | ||
421 | " *\n", | ||
422 | " * 6. Redistributions of any form whatsoever must retain the following\n", | ||
423 | " * acknowledgment:\n", | ||
424 | " * \"This product includes software developed by the OpenSSL Project\n", | ||
425 | " * for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n", | ||
426 | " *\n", | ||
427 | " * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n", | ||
428 | " * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n", | ||
429 | " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n", | ||
430 | " * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n", | ||
431 | " * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n", | ||
432 | " * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n", | ||
433 | " * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n", | ||
434 | " * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n", | ||
435 | " * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n", | ||
436 | " * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n", | ||
437 | " * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n", | ||
438 | " * OF THE POSSIBILITY OF SUCH DAMAGE.\n", | ||
439 | " * ====================================================================\n", | ||
440 | " *\n", | ||
441 | " * This product includes cryptographic software written by Eric Young\n", | ||
442 | " * (eay\@cryptsoft.com). This product includes software written by Tim\n", | ||
443 | " * Hudson (tjh\@cryptsoft.com).\n", | ||
444 | " *\n", | ||
445 | " */\n", | ||
446 | "\n", | ||
447 | "#ifndef HEADER_${lib}_ERR_H\n", | ||
448 | "#define HEADER_${lib}_ERR_H\n", | ||
449 | "\n", | ||
450 | "#ifdef __cplusplus\n", | ||
451 | "extern \"C\" {\n", | ||
452 | "#endif\n", | ||
453 | "\n", | ||
454 | "/* BEGIN ERROR CODES */\n"; | ||
455 | } | ||
456 | open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n"; | ||
457 | |||
458 | print OUT @out; | ||
459 | undef @out; | ||
460 | print OUT <<"EOF"; | ||
461 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
462 | * made after this point may be overwritten when the script is next run. | ||
463 | */ | ||
464 | EOF | ||
465 | if($static) { | ||
466 | print OUT <<"EOF"; | ||
467 | ${staticloader}void ERR_load_${lib}_strings(void); | ||
468 | |||
469 | EOF | ||
470 | } else { | ||
471 | print OUT <<"EOF"; | ||
472 | ${staticloader}void ERR_load_${lib}_strings(void); | ||
473 | ${staticloader}void ERR_unload_${lib}_strings(void); | ||
474 | ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line); | ||
475 | #define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__) | ||
476 | |||
477 | EOF | ||
478 | } | ||
479 | print OUT <<"EOF"; | ||
480 | /* Error codes for the $lib functions. */ | ||
481 | |||
482 | /* Function codes. */ | ||
483 | EOF | ||
484 | |||
485 | foreach $i (@function) { | ||
486 | $z=6-int(length($i)/8); | ||
487 | if($fcodes{$i} eq "X") { | ||
488 | $fassigned{$lib} =~ m/^:([^:]*):/; | ||
489 | $findcode = $1; | ||
490 | if (!defined($findcode)) { | ||
491 | $findcode = $fmax{$lib}; | ||
492 | } | ||
493 | while ($fassigned{$lib} =~ m/:$findcode:/) { | ||
494 | $findcode++; | ||
495 | } | ||
496 | $fcodes{$i} = $findcode; | ||
497 | $fassigned{$lib} .= "$findcode:"; | ||
498 | print STDERR "New Function code $i\n" if $debug; | ||
499 | } | ||
500 | printf OUT "#define $i%s $fcodes{$i}\n","\t" x $z; | ||
501 | } | ||
502 | |||
503 | print OUT "\n/* Reason codes. */\n"; | ||
504 | |||
505 | foreach $i (@reasons) { | ||
506 | $z=6-int(length($i)/8); | ||
507 | if($rcodes{$i} eq "X") { | ||
508 | $rassigned{$lib} =~ m/^:([^:]*):/; | ||
509 | $findcode = $1; | ||
510 | if (!defined($findcode)) { | ||
511 | $findcode = $rmax{$lib}; | ||
512 | } | ||
513 | while ($rassigned{$lib} =~ m/:$findcode:/) { | ||
514 | $findcode++; | ||
515 | } | ||
516 | $rcodes{$i} = $findcode; | ||
517 | $rassigned{$lib} .= "$findcode:"; | ||
518 | print STDERR "New Reason code $i\n" if $debug; | ||
519 | } | ||
520 | printf OUT "#define $i%s $rcodes{$i}\n","\t" x $z; | ||
521 | } | ||
522 | print OUT <<"EOF"; | ||
523 | |||
524 | #ifdef __cplusplus | ||
525 | } | ||
526 | #endif | ||
527 | #endif | ||
528 | EOF | ||
529 | close OUT; | ||
530 | |||
531 | # Rewrite the C source file containing the error details. | ||
532 | |||
533 | # First, read any existing reason string definitions: | ||
534 | my %err_reason_strings; | ||
535 | if (open(IN,"<$cfile")) { | ||
536 | while (<IN>) { | ||
537 | if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) { | ||
538 | $err_reason_strings{$1} = $2; | ||
539 | } | ||
540 | if (/\b${lib}_F_(\w*)\b.*\"(.*)\"/) { | ||
541 | if (!exists $ftrans{$1} && ($1 ne $2)) { | ||
542 | print STDERR "WARNING: Mismatched function string $2\n"; | ||
543 | $ftrans{$1} = $2; | ||
544 | } | ||
545 | } | ||
546 | } | ||
547 | close(IN); | ||
548 | } | ||
549 | |||
550 | |||
551 | my $hincf; | ||
552 | if($static) { | ||
553 | $hfile =~ /([^\/]+)$/; | ||
554 | $hincf = "<${hprefix}$1>"; | ||
555 | } else { | ||
556 | $hincf = "\"$hfile\""; | ||
557 | } | ||
558 | |||
559 | # If static we know the error code at compile time so use it | ||
560 | # in error definitions. | ||
561 | |||
562 | if ($static) | ||
563 | { | ||
564 | $pack_errcode = "ERR_LIB_${lib}"; | ||
565 | $load_errcode = "0"; | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | $pack_errcode = "0"; | ||
570 | $load_errcode = "ERR_LIB_${lib}"; | ||
571 | } | ||
572 | |||
573 | |||
574 | open (OUT,">$cfile") || die "Can't open $cfile for writing"; | ||
575 | |||
576 | print OUT <<"EOF"; | ||
577 | /* $cfile */ | ||
578 | /* ==================================================================== | ||
579 | * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. | ||
580 | * | ||
581 | * Redistribution and use in source and binary forms, with or without | ||
582 | * modification, are permitted provided that the following conditions | ||
583 | * are met: | ||
584 | * | ||
585 | * 1. Redistributions of source code must retain the above copyright | ||
586 | * notice, this list of conditions and the following disclaimer. | ||
587 | * | ||
588 | * 2. Redistributions in binary form must reproduce the above copyright | ||
589 | * notice, this list of conditions and the following disclaimer in | ||
590 | * the documentation and/or other materials provided with the | ||
591 | * distribution. | ||
592 | * | ||
593 | * 3. All advertising materials mentioning features or use of this | ||
594 | * software must display the following acknowledgment: | ||
595 | * "This product includes software developed by the OpenSSL Project | ||
596 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
597 | * | ||
598 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
599 | * endorse or promote products derived from this software without | ||
600 | * prior written permission. For written permission, please contact | ||
601 | * openssl-core\@OpenSSL.org. | ||
602 | * | ||
603 | * 5. Products derived from this software may not be called "OpenSSL" | ||
604 | * nor may "OpenSSL" appear in their names without prior written | ||
605 | * permission of the OpenSSL Project. | ||
606 | * | ||
607 | * 6. Redistributions of any form whatsoever must retain the following | ||
608 | * acknowledgment: | ||
609 | * "This product includes software developed by the OpenSSL Project | ||
610 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
611 | * | ||
612 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
613 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
614 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
615 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
616 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
617 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
618 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
619 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
620 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
621 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
622 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
623 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
624 | * ==================================================================== | ||
625 | * | ||
626 | * This product includes cryptographic software written by Eric Young | ||
627 | * (eay\@cryptsoft.com). This product includes software written by Tim | ||
628 | * Hudson (tjh\@cryptsoft.com). | ||
629 | * | ||
630 | */ | ||
631 | |||
632 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
633 | * made to it will be overwritten when the script next updates this file, | ||
634 | * only reason strings will be preserved. | ||
635 | */ | ||
636 | |||
637 | #include <stdio.h> | ||
638 | #include <openssl/err.h> | ||
639 | #include $hincf | ||
640 | |||
641 | /* BEGIN ERROR CODES */ | ||
642 | #ifndef OPENSSL_NO_ERR | ||
643 | |||
644 | #define ERR_FUNC(func) ERR_PACK($pack_errcode,func,0) | ||
645 | #define ERR_REASON(reason) ERR_PACK($pack_errcode,0,reason) | ||
646 | |||
647 | static ERR_STRING_DATA ${lib}_str_functs[]= | ||
648 | { | ||
649 | EOF | ||
650 | # Add each function code: if a function name is found then use it. | ||
651 | foreach $i (@function) { | ||
652 | my $fn; | ||
653 | $i =~ /^${lib}_F_(\S+)$/; | ||
654 | $fn = $1; | ||
655 | if(exists $ftrans{$fn}) { | ||
656 | $fn = $ftrans{$fn}; | ||
657 | } | ||
658 | # print OUT "{ERR_PACK($pack_errcode,$i,0),\t\"$fn\"},\n"; | ||
659 | print OUT "{ERR_FUNC($i),\t\"$fn\"},\n"; | ||
660 | } | ||
661 | print OUT <<"EOF"; | ||
662 | {0,NULL} | ||
663 | }; | ||
664 | |||
665 | static ERR_STRING_DATA ${lib}_str_reasons[]= | ||
666 | { | ||
667 | EOF | ||
668 | # Add each reason code. | ||
669 | foreach $i (@reasons) { | ||
670 | my $rn; | ||
671 | my $rstr = "ERR_REASON($i)"; | ||
672 | my $nspc = 0; | ||
673 | if (exists $err_reason_strings{$i}) { | ||
674 | $rn = $err_reason_strings{$i}; | ||
675 | } else { | ||
676 | $i =~ /^${lib}_R_(\S+)$/; | ||
677 | $rn = $1; | ||
678 | $rn =~ tr/_[A-Z]/ [a-z]/; | ||
679 | } | ||
680 | $nspc = 40 - length($rstr) unless length($rstr) > 40; | ||
681 | $nspc = " " x $nspc; | ||
682 | print OUT "{${rstr}${nspc},\"$rn\"},\n"; | ||
683 | } | ||
684 | if($static) { | ||
685 | print OUT <<"EOF"; | ||
686 | {0,NULL} | ||
687 | }; | ||
688 | |||
689 | #endif | ||
690 | |||
691 | ${staticloader}void ERR_load_${lib}_strings(void) | ||
692 | { | ||
693 | #ifndef OPENSSL_NO_ERR | ||
694 | |||
695 | if (ERR_func_error_string(${lib}_str_functs[0].error) == NULL) | ||
696 | { | ||
697 | ERR_load_strings($load_errcode,${lib}_str_functs); | ||
698 | ERR_load_strings($load_errcode,${lib}_str_reasons); | ||
699 | } | ||
700 | #endif | ||
701 | } | ||
702 | EOF | ||
703 | } else { | ||
704 | print OUT <<"EOF"; | ||
705 | {0,NULL} | ||
706 | }; | ||
707 | |||
708 | #endif | ||
709 | |||
710 | #ifdef ${lib}_LIB_NAME | ||
711 | static ERR_STRING_DATA ${lib}_lib_name[]= | ||
712 | { | ||
713 | {0 ,${lib}_LIB_NAME}, | ||
714 | {0,NULL} | ||
715 | }; | ||
716 | #endif | ||
717 | |||
718 | |||
719 | static int ${lib}_lib_error_code=0; | ||
720 | static int ${lib}_error_init=1; | ||
721 | |||
722 | ${staticloader}void ERR_load_${lib}_strings(void) | ||
723 | { | ||
724 | if (${lib}_lib_error_code == 0) | ||
725 | ${lib}_lib_error_code=ERR_get_next_error_library(); | ||
726 | |||
727 | if (${lib}_error_init) | ||
728 | { | ||
729 | ${lib}_error_init=0; | ||
730 | #ifndef OPENSSL_NO_ERR | ||
731 | ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs); | ||
732 | ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons); | ||
733 | #endif | ||
734 | |||
735 | #ifdef ${lib}_LIB_NAME | ||
736 | ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0); | ||
737 | ERR_load_strings(0,${lib}_lib_name); | ||
738 | #endif | ||
739 | } | ||
740 | } | ||
741 | |||
742 | ${staticloader}void ERR_unload_${lib}_strings(void) | ||
743 | { | ||
744 | if (${lib}_error_init == 0) | ||
745 | { | ||
746 | #ifndef OPENSSL_NO_ERR | ||
747 | ERR_unload_strings(${lib}_lib_error_code,${lib}_str_functs); | ||
748 | ERR_unload_strings(${lib}_lib_error_code,${lib}_str_reasons); | ||
749 | #endif | ||
750 | |||
751 | #ifdef ${lib}_LIB_NAME | ||
752 | ERR_unload_strings(0,${lib}_lib_name); | ||
753 | #endif | ||
754 | ${lib}_error_init=1; | ||
755 | } | ||
756 | } | ||
757 | |||
758 | ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line) | ||
759 | { | ||
760 | if (${lib}_lib_error_code == 0) | ||
761 | ${lib}_lib_error_code=ERR_get_next_error_library(); | ||
762 | ERR_PUT_error(${lib}_lib_error_code,function,reason,file,line); | ||
763 | } | ||
764 | EOF | ||
765 | |||
766 | } | ||
767 | |||
768 | close OUT; | ||
769 | undef %err_reason_strings; | ||
770 | } | ||
771 | |||
772 | if($debug && %notrans) { | ||
773 | print STDERR "The following function codes were not translated:\n"; | ||
774 | foreach(sort keys %notrans) | ||
775 | { | ||
776 | print STDERR "$_\n"; | ||
777 | } | ||
778 | } | ||
779 | |||
780 | # Make a list of unreferenced function and reason codes | ||
781 | |||
782 | foreach (keys %fcodes) { | ||
783 | push (@funref, $_) unless exists $ufcodes{$_}; | ||
784 | } | ||
785 | |||
786 | foreach (keys %rcodes) { | ||
787 | push (@runref, $_) unless exists $urcodes{$_}; | ||
788 | } | ||
789 | |||
790 | if($debug && defined(@funref) ) { | ||
791 | print STDERR "The following function codes were not referenced:\n"; | ||
792 | foreach(sort @funref) | ||
793 | { | ||
794 | print STDERR "$_\n"; | ||
795 | } | ||
796 | } | ||
797 | |||
798 | if($debug && defined(@runref) ) { | ||
799 | print STDERR "The following reason codes were not referenced:\n"; | ||
800 | foreach(sort @runref) | ||
801 | { | ||
802 | print STDERR "$_\n"; | ||
803 | } | ||
804 | } | ||
805 | |||
806 | if($errcount) { | ||
807 | print STDERR "There were errors, failing...\n\n"; | ||
808 | exit $errcount; | ||
809 | } | ||
810 | |||
diff --git a/src/lib/libcrypto/util/mkstack.pl b/src/lib/libcrypto/util/mkstack.pl deleted file mode 100644 index f708610a78..0000000000 --- a/src/lib/libcrypto/util/mkstack.pl +++ /dev/null | |||
@@ -1,192 +0,0 @@ | |||
1 | #!/usr/local/bin/perl -w | ||
2 | |||
3 | # This is a utility that searches out "DECLARE_STACK_OF()" | ||
4 | # declarations in .h and .c files, and updates/creates/replaces | ||
5 | # the corresponding macro declarations in crypto/stack/safestack.h. | ||
6 | # As it's not generally possible to have macros that generate macros, | ||
7 | # we need to control this from the "outside", here in this script. | ||
8 | # | ||
9 | # Geoff Thorpe, June, 2000 (with massive Perl-hacking | ||
10 | # help from Steve Robb) | ||
11 | |||
12 | my $safestack = "crypto/stack/safestack"; | ||
13 | |||
14 | my $do_write; | ||
15 | while (@ARGV) { | ||
16 | my $arg = $ARGV[0]; | ||
17 | if($arg eq "-write") { | ||
18 | $do_write = 1; | ||
19 | } | ||
20 | shift @ARGV; | ||
21 | } | ||
22 | |||
23 | |||
24 | @source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>, <apps/*.[ch]>); | ||
25 | foreach $file (@source) { | ||
26 | next if -l $file; | ||
27 | |||
28 | # Open the .c/.h file for reading | ||
29 | open(IN, "< $file") || die "Can't open $file for reading: $!"; | ||
30 | |||
31 | while(<IN>) { | ||
32 | if (/^DECLARE_STACK_OF\(([^)]+)\)/) { | ||
33 | push @stacklst, $1; | ||
34 | } | ||
35 | if (/^DECLARE_SPECIAL_STACK_OF\(([^,\s]+)\s*,\s*([^>\s]+)\)/) { | ||
36 | push @sstacklst, [$1, $2]; | ||
37 | } | ||
38 | if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) { | ||
39 | push @asn1setlst, $1; | ||
40 | } | ||
41 | if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) { | ||
42 | push @p12stklst, $1; | ||
43 | } | ||
44 | if (/^DECLARE_LHASH_OF\(([^)]+)\)/) { | ||
45 | push @lhashlst, $1; | ||
46 | } | ||
47 | } | ||
48 | close(IN); | ||
49 | } | ||
50 | |||
51 | |||
52 | |||
53 | my $old_stackfile = ""; | ||
54 | my $new_stackfile = ""; | ||
55 | my $inside_block = 0; | ||
56 | my $type_thing; | ||
57 | |||
58 | open(IN, "< $safestack.h") || die "Can't open input file: $!"; | ||
59 | while(<IN>) { | ||
60 | $old_stackfile .= $_; | ||
61 | |||
62 | if (m|^/\* This block of defines is updated by util/mkstack.pl, please do not touch! \*/|) { | ||
63 | $inside_block = 1; | ||
64 | } | ||
65 | if (m|^/\* End of util/mkstack.pl block, you may now edit :-\) \*/|) { | ||
66 | $inside_block = 0; | ||
67 | } elsif ($inside_block == 0) { | ||
68 | $new_stackfile .= $_; | ||
69 | } | ||
70 | next if($inside_block != 1); | ||
71 | $new_stackfile .= "/* This block of defines is updated by util/mkstack.pl, please do not touch! */"; | ||
72 | |||
73 | foreach $type_thing (sort @stacklst) { | ||
74 | $new_stackfile .= <<EOF; | ||
75 | |||
76 | #define sk_${type_thing}_new(cmp) SKM_sk_new($type_thing, (cmp)) | ||
77 | #define sk_${type_thing}_new_null() SKM_sk_new_null($type_thing) | ||
78 | #define sk_${type_thing}_free(st) SKM_sk_free($type_thing, (st)) | ||
79 | #define sk_${type_thing}_num(st) SKM_sk_num($type_thing, (st)) | ||
80 | #define sk_${type_thing}_value(st, i) SKM_sk_value($type_thing, (st), (i)) | ||
81 | #define sk_${type_thing}_set(st, i, val) SKM_sk_set($type_thing, (st), (i), (val)) | ||
82 | #define sk_${type_thing}_zero(st) SKM_sk_zero($type_thing, (st)) | ||
83 | #define sk_${type_thing}_push(st, val) SKM_sk_push($type_thing, (st), (val)) | ||
84 | #define sk_${type_thing}_unshift(st, val) SKM_sk_unshift($type_thing, (st), (val)) | ||
85 | #define sk_${type_thing}_find(st, val) SKM_sk_find($type_thing, (st), (val)) | ||
86 | #define sk_${type_thing}_find_ex(st, val) SKM_sk_find_ex($type_thing, (st), (val)) | ||
87 | #define sk_${type_thing}_delete(st, i) SKM_sk_delete($type_thing, (st), (i)) | ||
88 | #define sk_${type_thing}_delete_ptr(st, ptr) SKM_sk_delete_ptr($type_thing, (st), (ptr)) | ||
89 | #define sk_${type_thing}_insert(st, val, i) SKM_sk_insert($type_thing, (st), (val), (i)) | ||
90 | #define sk_${type_thing}_set_cmp_func(st, cmp) SKM_sk_set_cmp_func($type_thing, (st), (cmp)) | ||
91 | #define sk_${type_thing}_dup(st) SKM_sk_dup($type_thing, st) | ||
92 | #define sk_${type_thing}_pop_free(st, free_func) SKM_sk_pop_free($type_thing, (st), (free_func)) | ||
93 | #define sk_${type_thing}_shift(st) SKM_sk_shift($type_thing, (st)) | ||
94 | #define sk_${type_thing}_pop(st) SKM_sk_pop($type_thing, (st)) | ||
95 | #define sk_${type_thing}_sort(st) SKM_sk_sort($type_thing, (st)) | ||
96 | #define sk_${type_thing}_is_sorted(st) SKM_sk_is_sorted($type_thing, (st)) | ||
97 | EOF | ||
98 | } | ||
99 | |||
100 | foreach $type_thing (sort @sstacklst) { | ||
101 | my $t1 = $type_thing->[0]; | ||
102 | my $t2 = $type_thing->[1]; | ||
103 | $new_stackfile .= <<EOF; | ||
104 | |||
105 | #define sk_${t1}_new(cmp) ((STACK_OF($t1) *)sk_new(CHECKED_SK_CMP_FUNC($t2, cmp))) | ||
106 | #define sk_${t1}_new_null() ((STACK_OF($t1) *)sk_new_null()) | ||
107 | #define sk_${t1}_push(st, val) sk_push(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val)) | ||
108 | #define sk_${t1}_find(st, val) sk_find(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val)) | ||
109 | #define sk_${t1}_value(st, i) (($t1)sk_value(CHECKED_STACK_OF($t1, st), i)) | ||
110 | #define sk_${t1}_num(st) SKM_sk_num($t1, st) | ||
111 | #define sk_${t1}_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF($t1, st), CHECKED_SK_FREE_FUNC2($t1, free_func)) | ||
112 | #define sk_${t1}_insert(st, val, i) sk_insert(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val), i) | ||
113 | #define sk_${t1}_free(st) SKM_sk_free(${t1}, st) | ||
114 | #define sk_${t1}_set(st, i, val) sk_set(CHECKED_STACK_OF($t1, st), i, CHECKED_PTR_OF($t2, val)) | ||
115 | #define sk_${t1}_zero(st) SKM_sk_zero($t1, (st)) | ||
116 | #define sk_${t1}_unshift(st, val) sk_unshift(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val)) | ||
117 | #define sk_${t1}_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF($t1), st), CHECKED_CONST_PTR_OF($t2, val)) | ||
118 | #define sk_${t1}_delete(st, i) SKM_sk_delete($t1, (st), (i)) | ||
119 | #define sk_${t1}_delete_ptr(st, ptr) ($t1 *)sk_delete_ptr(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, ptr)) | ||
120 | #define sk_${t1}_set_cmp_func(st, cmp) \\ | ||
121 | ((int (*)(const $t2 * const *,const $t2 * const *)) \\ | ||
122 | sk_set_cmp_func(CHECKED_STACK_OF($t1, st), CHECKED_SK_CMP_FUNC($t2, cmp))) | ||
123 | #define sk_${t1}_dup(st) SKM_sk_dup($t1, st) | ||
124 | #define sk_${t1}_shift(st) SKM_sk_shift($t1, (st)) | ||
125 | #define sk_${t1}_pop(st) ($t2 *)sk_pop(CHECKED_STACK_OF($t1, st)) | ||
126 | #define sk_${t1}_sort(st) SKM_sk_sort($t1, (st)) | ||
127 | #define sk_${t1}_is_sorted(st) SKM_sk_is_sorted($t1, (st)) | ||
128 | |||
129 | EOF | ||
130 | } | ||
131 | |||
132 | foreach $type_thing (sort @asn1setlst) { | ||
133 | $new_stackfile .= <<EOF; | ||
134 | |||
135 | #define d2i_ASN1_SET_OF_${type_thing}(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\ | ||
136 | SKM_ASN1_SET_OF_d2i($type_thing, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) | ||
137 | #define i2d_ASN1_SET_OF_${type_thing}(st, pp, i2d_func, ex_tag, ex_class, is_set) \\ | ||
138 | SKM_ASN1_SET_OF_i2d($type_thing, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) | ||
139 | #define ASN1_seq_pack_${type_thing}(st, i2d_func, buf, len) \\ | ||
140 | SKM_ASN1_seq_pack($type_thing, (st), (i2d_func), (buf), (len)) | ||
141 | #define ASN1_seq_unpack_${type_thing}(buf, len, d2i_func, free_func) \\ | ||
142 | SKM_ASN1_seq_unpack($type_thing, (buf), (len), (d2i_func), (free_func)) | ||
143 | EOF | ||
144 | } | ||
145 | foreach $type_thing (sort @p12stklst) { | ||
146 | $new_stackfile .= <<EOF; | ||
147 | |||
148 | #define PKCS12_decrypt_d2i_${type_thing}(algor, d2i_func, free_func, pass, passlen, oct, seq) \\ | ||
149 | SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) | ||
150 | EOF | ||
151 | } | ||
152 | |||
153 | foreach $type_thing (sort @lhashlst) { | ||
154 | my $lc_tt = lc $type_thing; | ||
155 | $new_stackfile .= <<EOF; | ||
156 | |||
157 | #define lh_${type_thing}_new() LHM_lh_new(${type_thing},${lc_tt}) | ||
158 | #define lh_${type_thing}_insert(lh,inst) LHM_lh_insert(${type_thing},lh,inst) | ||
159 | #define lh_${type_thing}_retrieve(lh,inst) LHM_lh_retrieve(${type_thing},lh,inst) | ||
160 | #define lh_${type_thing}_delete(lh,inst) LHM_lh_delete(${type_thing},lh,inst) | ||
161 | #define lh_${type_thing}_doall(lh,fn) LHM_lh_doall(${type_thing},lh,fn) | ||
162 | #define lh_${type_thing}_doall_arg(lh,fn,arg_type,arg) \\ | ||
163 | LHM_lh_doall_arg(${type_thing},lh,fn,arg_type,arg) | ||
164 | #define lh_${type_thing}_error(lh) LHM_lh_error(${type_thing},lh) | ||
165 | #define lh_${type_thing}_num_items(lh) LHM_lh_num_items(${type_thing},lh) | ||
166 | #define lh_${type_thing}_down_load(lh) LHM_lh_down_load(${type_thing},lh) | ||
167 | #define lh_${type_thing}_node_stats_bio(lh,out) \\ | ||
168 | LHM_lh_node_stats_bio(${type_thing},lh,out) | ||
169 | #define lh_${type_thing}_node_usage_stats_bio(lh,out) \\ | ||
170 | LHM_lh_node_usage_stats_bio(${type_thing},lh,out) | ||
171 | #define lh_${type_thing}_stats_bio(lh,out) \\ | ||
172 | LHM_lh_stats_bio(${type_thing},lh,out) | ||
173 | #define lh_${type_thing}_free(lh) LHM_lh_free(${type_thing},lh) | ||
174 | EOF | ||
175 | } | ||
176 | |||
177 | $new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n"; | ||
178 | $inside_block = 2; | ||
179 | } | ||
180 | |||
181 | |||
182 | if ($new_stackfile eq $old_stackfile) { | ||
183 | print "No changes to $safestack.h.\n"; | ||
184 | exit 0; # avoid unnecessary rebuild | ||
185 | } | ||
186 | |||
187 | if ($do_write) { | ||
188 | print "Writing new $safestack.h.\n"; | ||
189 | open OUT, ">$safestack.h" || die "Can't open output file"; | ||
190 | print OUT $new_stackfile; | ||
191 | close OUT; | ||
192 | } | ||