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: $!";
45 open(OUT, "> $file.tmp") || die "Can't open $file.tmp for writing: $!";
54 rename("$file.tmp", $file);
57 sub process_the_file {
60 my $output_defines = 0;
63 if (/^DECLARE_STACK_OF\(([^)]+)\)/) {
67 if (m|^/\* This block of defines is updated by a perl script, please do not touch! \*/|) {
70 if (m|^/\* End of perl script block, you may now edit :-\) \*/|) {
72 } elsif ($inside_block == 0) {
75 if($output_defines == 1) {
77 /* This block of defines is updated by a perl script, please do not touch! */
78 #ifndef DEBUG_SAFESTACK
79 #define sk_${type_thing}_new(a) sk_new((int (*) \\
80 (const char * const *, const char * const *))(a))
81 #define sk_${type_thing}_new_null() sk_new_null()
82 #define sk_${type_thing}_free(a) sk_free(a)
83 #define sk_${type_thing}_num(a) sk_num(a)
84 #define sk_${type_thing}_value(a,b) ((${type_thing} *) \\
86 #define sk_${type_thing}_set(a,b,c) ((${type_thing} *) \\
87 sk_set((a),(b),(char *)(c)))
88 #define sk_${type_thing}_zero(a) sk_zero(a)
89 #define sk_${type_thing}_push(a,b) sk_push((a),(char *)(b))
90 #define sk_${type_thing}_unshift(a,b) sk_unshift((a),(b))
91 #define sk_${type_thing}_find(a,b) sk_find((a), (char *)(b))
92 #define sk_${type_thing}_delete(a,b) ((${type_thing} *) \\
94 #define sk_${type_thing}_delete_ptr(a,b) ((${type_thing} *) \\
95 sk_delete_ptr((a),(char *)(b)))
96 #define sk_${type_thing}_insert(a,b,c) sk_insert((a),(char *)(b),(c))
97 #define sk_${type_thing}_set_cmp_func(a,b) ((int (*) \\
98 (const ${type_thing} * const *,const ${type_thing} * const *)) \\
99 sk_set_cmp_func((a),(int (*) \\
100 (const char * const *, const char * const *))(b)))
101 #define sk_${type_thing}_dup(a) sk_dup(a)
102 #define sk_${type_thing}_pop_free(a,b) sk_pop_free((a),(void (*)(void *))(b))
103 #define sk_${type_thing}_shift(a) ((${type_thing} *)sk_shift(a))
104 #define sk_${type_thing}_pop(a) ((${type_thing} *)sk_pop(a))
105 #define sk_${type_thing}_sort(a) sk_sort(a)
106 #endif /* !DEBUG_SAFESTACK */
107 /* End of perl script block, you may now edit :-) */