]> granicus.if.org Git - apache/blob - build/make_nw_export.awk
check: merge warning fixes from feature branch
[apache] / build / make_nw_export.awk
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements.  See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License.  You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # Based on apr's make_export.awk, which is
17 # based on Ryan Bloom's make_export.pl
18 #
19
20 BEGIN {
21 }
22
23 function add_symbol(sym_name) {
24     sub(" ", "", sym_name)
25     exports[++idx] = sym_name
26 }
27
28 # List of functions that we don't support, yet??
29 #/ap_some_name/{next}
30
31 /^[ \t]*(AP|DAV|CACHE|PROXY)([RU]|REQ|_CORE)?_DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ {
32     sub("[ \t]*(AP|DAV|CACHE|PROXY)([RU]|REQ|_CORE)?_DECLARE[^(]*[(][^)]*[)][ \t]*", "")
33     sub("[(].*", "")
34     sub("([^ ]* (^([ \t]*[(])))+", "")
35     add_symbol($0)
36     next
37 }
38
39 /^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ {
40     split($0, args, ",")
41     symbol = args[2]
42     sub("^[ \t]+", "", symbol)
43     sub("[ \t]+$", "", symbol)
44     add_symbol("ap_hook_" symbol)
45     add_symbol("ap_hook_get_" symbol)
46     add_symbol("ap_run_" symbol)
47     next
48 }
49
50 /^[ \t]*AP[RU]?_DECLARE_EXTERNAL_HOOK[^(]*[(][^)]*/ {
51     split($0, args, ",")
52     prefix = args[1]
53     sub("^.*[(]", "", prefix)
54     symbol = args[4]
55     sub("^[ \t]+", "", symbol)
56     sub("[ \t]+$", "", symbol)
57     add_symbol(prefix "_hook_" symbol)
58     add_symbol(prefix "_hook_get_" symbol)
59     add_symbol(prefix "_run_" symbol)
60     next
61 }
62
63 /^[ \t]*PROXY_DECLARE_OPTIONAL_HOOK[^(]*[(][^)]*/ {
64     split($0, args, ",")
65     prefix = args[1]
66     sub("^.*[(]", "", prefix)
67     symbol = args[4]
68     sub("^[ \t]+", "", symbol)
69     sub("[ \t]+$", "", symbol)
70     add_symbol(prefix "_run_" symbol)
71     next
72 }
73
74 /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ {
75     sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0)
76     sub("[)].*$", "", $0)
77     add_symbol("apr_" $0 "_pool_get")
78     next
79 }
80
81 /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ {
82     sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0)
83     sub("[)].*$", "", $0)
84     add_symbol("apr_" $0 "_inherit_set")
85     next
86 }
87
88 /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ {
89     sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0)
90     sub("[)].*$", "", $0)
91     add_symbol("apr_" $0 "_inherit_unset")
92     next
93 }
94
95 /^[ \t]*(extern[ \t]+)?AP[RU]?_DECLARE_DATA .*;/ {
96     gsub(/[*;\n\r]/, "")
97     gsub(/\[.*\]/, "")
98     add_symbol($NF)
99 }
100
101 /^[ \t]*(extern[ \t]+(module[ \t]+)?)?PROXY_DECLARE_DATA .*;/ {
102     gsub(/[*;\n\r]/, "")
103     gsub(/\[.*\]/, "")
104     add_symbol($NF)
105 }
106
107 END {
108     printf("Added %d symbols to export list.\n", idx) > "/dev/stderr"
109     # sort symbols with shell sort
110     increment = int(idx / 2)
111     while (increment > 0) {
112         for (i = increment+1; i <= idx; i++) {
113             j = i
114             temp = exports[i]
115             while ((j >= increment+1) && (exports[j-increment] > temp)) {
116                 exports[j] = exports[j-increment]
117                 j -= increment
118             }
119             exports[j] = temp
120         }
121         if (increment == 2)
122             increment = 1
123         else
124             increment = int(increment*5/11)
125     }
126     # print the array
127     printf(" (%s)\n", EXPPREFIX)
128     while (x < idx - 1) {
129         printf(" %s,\n", exports[++x])
130     }
131     printf(" %s\n", exports[++x])
132 }
133