lib: Fix CID 1034723 Explicit null dereferenced
[Samba.git] / source3 / script / mksyms.awk
blob94a405ca689ff8741a8b188df27be210efb378f6
2 # mksyms.awk
4 # Extract symbols to export from C-header files.
5 # output in version-script format for linking shared libraries.
7 # Copyright (C) 2008 Michael Adam <obnox@samba.org>
9 BEGIN {
10 inheader=0;
11 current_file="";
12 print "#"
13 print "# This file is automatically generated with \"make symbols\". DO NOT EDIT "
14 print "#"
15 print "{"
16 print "\tglobal:"
19 END {
20 print""
21 print "\tlocal: *;"
22 print "};"
26 if (FILENAME!=current_file) {
27 print "\t\t# The following definitions come from",FILENAME
28 current_file=FILENAME
30 if (inheader) {
31 if (match($0,"[)][^()]*[;][ \t]*$")) {
32 inheader = 0;
34 next;
38 /^static/ || /^[ \t]*typedef/ || !/^[a-zA-Z\_]/ {
39 next;
42 /^extern[ \t]+[^()]+[;][ \t]*$/ {
43 gsub(/[^ \t]+[ \t]+/, "");
44 sub(/[;][ \t]*$/, "");
45 printf "\t\t%s;\n", $0;
46 next;
49 # look for function headers:
51 gotstart = 0;
52 if ($0 ~ /^[A-Za-z_][A-Za-z0-9_]+/) {
53 gotstart = 1;
55 if(!gotstart) {
56 next;
60 /[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ {
61 sub(/[(].*$/, "");
62 gsub(/[^ \t]+[ \t]+/, "");
63 gsub(/^[*]+/, "");
64 printf "\t\t%s;\n",$0;
65 next;
68 /[_A-Za-z0-9]+[ \t]*[(]/ {
69 inheader=1;
70 sub(/[(].*$/, "");
71 gsub(/[^ \t]+[ \t]+/, "");
72 gsub(/^[*]/, "");
73 printf "\t\t%s;\n",$0;
74 next;