1 2BEGIN { 3 printf("/*\n") 4 printf(" * THIS FILE WAS AUTOGENERATED BY make_exports.awk\n") 5 printf(" *\n") 6 printf(" * This is an ugly hack that needs to be here, so\n") 7 printf(" * that libtool will link all of the APR functions\n") 8 printf(" * into server regardless of whether the base server\n") 9 printf(" * uses them.\n") 10 printf(" */\n") 11 printf("\n") 12 printf("#define CORE_PRIVATE\n") 13 printf("\n") 14 15 for (i = 1; i < ARGC; i++) { 16 file = ARGV[i] 17 sub("([^/]*[/])*", "", file) 18 printf("#include \"%s\"\n", file) 19 } 20 21 printf("\n") 22 printf("const void *ap_ugly_hack = NULL;\n") 23 printf("\n") 24 25 TYPE_NORMAL = 0 26 TYPE_HEADER = 1 27 28 stackptr = 0 29} 30 31function push(line) { 32 stack[stackptr] = line 33 stackptr++ 34} 35 36function do_output() { 37 printf("/*\n") 38 printf(" * %s\n", FILENAME) 39 printf(" */\n") 40 41 for (i = 0; i < stackptr; i++) { 42 printf("%s\n", stack[i]) 43 } 44 45 stackptr = 0 46 47 printf("\n"); 48} 49 50function enter_scope(type) { 51 scope++ 52 scope_type[scope] = type 53 scope_stack[scope] = stackptr 54 delete scope_used[scope] 55} 56 57function leave_scope() { 58 used = scope_used[scope] 59 60 if (!used) 61 stackptr = scope_stack[scope] 62 63 scope-- 64 if (used) { 65 scope_used[scope] = 1 66 67 if (!scope) 68 do_output() 69 } 70} 71 72function add_symbol(symbol) { 73 if (!index(symbol, "#")) { 74 push("const void *ap_hack_" symbol " = (const void *)" symbol ";") 75 scope_used[scope] = 1 76 } 77} 78 79/^[ \t]*AP[RUI]?_(CORE_)?DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ { 80 sub("[ \t]*AP[RUI]?_(CORE_)?DECLARE[^(]*[(][^)]*[)][ \t]*", "") 81 sub("[(].*", "") 82 sub("([^ ]* (^([ \t]*[(])))+", "") 83 84 add_symbol($0) 85 next 86} 87 88/^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ { 89 split($0, args, ",") 90 symbol = args[2] 91 sub("^[ \t]+", "", symbol) 92 sub("[ \t]+$", "", symbol) 93 94 add_symbol("ap_hook_" symbol) 95 add_symbol("ap_hook_get_" symbol) 96 add_symbol("ap_run_" symbol) 97 next 98} 99 100/^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ { 101 sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0) 102 sub("[)].*$", "", $0) 103 add_symbol("apr_" $0 "_pool_get") 104 next 105} 106 107/^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ { 108 sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0) 109 sub("[)].*$", "", $0) 110 add_symbol("apr_" $0 "_inherit_set") 111 next 112} 113 114/^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ { 115 sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0) 116 sub("[)].*$", "", $0) 117 add_symbol("apr_" $0 "_inherit_unset") 118 next 119} 120 121/^#[ \t]*if(ndef| !defined[(])([^_]*_)*H/ { 122 enter_scope(TYPE_HEADER) 123 next 124} 125 126/^#[ \t]*if([n]?def)? / { 127 enter_scope(TYPE_NORMAL) 128 push($0) 129 next 130} 131 132/^#[ \t]*endif/ { 133 if (scope_type[scope] == TYPE_NORMAL) 134 push($0) 135 136 leave_scope() 137 next 138} 139 140/^#[ \t]*else/ { 141 push($0) 142 next 143} 144 145/^#[ \t]*elif/ { 146 push($0) 147 next 148} 149 150 151