1 #!/usr/local/bin/perl -w
3 # This is a utility that searches out "DECLARE_STACK_OF()"
4 # declarations in header files, and updates/creates/replaces
5 # the corresponding macro declarations that follow it. The
6 # reason is that with "DEBUG_SAFESTACK" defined, each type
7 # will generate 19 functions, all type-safe variants of the
8 # base "sk_***" functions for the general STACK type. Without
9 # DEBUG_SAFESTACK defined, we need to macro define all the
10 # "type'd sk_##type##_***" functions as mapping directly to
11 # the standard sk_*** equivalents. As it's not generally
12 # possible to have macros that generate macros, we need to
13 # control this from the "outside", here in this script.
15 # Geoff Thorpe, June, 2000 (with massive Perl-hacking
16 # help from Steve Robb)
24 if($arg eq "-recurse") {
33 @source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <rsaref/*.[ch]>, <ssl/*.[ch]>);
38 foreach $file (@source) {
39 # After "Configure" has been run, we need to make sure we don't
40 # overwrite symbollic links with new header files!
43 # Open the .c/.h file for reading
44 open(IN, "< $file") || die "Can't open $file for reading: $!";
47 if (/^DECLARE_STACK_OF\(([^)]+)\)/) {
52 write_defines("crypto/stack/safestack");
53 unlink("crypto/stack/safestack.h");
54 rename("crypto/stack/safestack.tmp","crypto/stack/safestack.h");
59 my $stackfile = $_[0];
61 open IN, "< $stackfile.h" || die "Can't open input file";
62 open OUT, "> $stackfile.tmp" || die "Can't open output file";
64 if (m|^/\* This block of defines is updated by a perl script, please do not touch! \*/|) {
67 if (m|^/\* End of perl script block, you may now edit :-\) \*/|) {
69 } elsif ($inside_block == 0) {
72 next if($inside_block != 1);
74 /* This block of defines is updated by a perl script, please do not touch! */
76 foreach $type_thing (@stacklst) {
78 #define sk_${type_thing}_new(a) SKM_sk_new($type_thing, (a))
79 #define sk_${type_thing}_new_null() SKM_sk_new_null($type_thing)
80 #define sk_${type_thing}_free(a) SKM_sk_free($type_thing, (a))
81 #define sk_${type_thing}_num(a) SKM_sk_num($type_thing, (a))
82 #define sk_${type_thing}_value(a,b) SKM_sk_value($type_thing, (a), (b))
83 #define sk_${type_thing}_set(a,b,c) SKM_sk_set($type_thing, (a), (b), (c))
84 #define sk_${type_thing}_zero(a) SKM_sk_zero($type_thing, (a))
85 #define sk_${type_thing}_push(a,b) SKM_sk_push($type_thing, (a),(b))
86 #define sk_${type_thing}_unshift(a,b) SKM_sk_unshift($type_thing, (a),(b))
87 #define sk_${type_thing}_find(a,b) SKM_sk_find($type_thing, (a), (b))
88 #define sk_${type_thing}_delete(a,b) SKM_sk_delete($type_thing, (a),(b))
89 #define sk_${type_thing}_delete_ptr(a,b) SKM_sk_delete_ptr($type_thing, (a),(b))
90 #define sk_${type_thing}_insert(a,b,c) SKM_sk_insert($type_thing, (a),(b),(c))
91 #define sk_${type_thing}_set_cmp_func(a,b) SKM_sk_set_cmp_func($type_thing, (a),(b))
92 #define sk_${type_thing}_dup(a) SKM_sk_dup($type_thing, a)
93 #define sk_${type_thing}_pop_free(a,b) SKM_sk_pop_free($type_thing, (a),(b))
94 #define sk_${type_thing}_shift(a) SKM_sk_shift($type_thing, (a))
95 #define sk_${type_thing}_pop(a) SKM_sk_pop($type_thing, (a))
96 #define sk_${type_thing}_sort(a) SKM_sk_sort($type_thing, (a))
101 /* End of perl script block, you may now edit :-) */