first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[nivanova/samba-autobuild/.git] / source3 / script / mkproto.awk
1 BEGIN {
2   inheader=0;
3 #  use_ldap_define = 0;
4   current_file="";
5   print "#ifndef _PROTO_H_"
6   print "#define _PROTO_H_"
7   print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */"
8   print ""
9 }
10
11 END {
12   print "#endif /* _PROTO_H_ */"
13 }
14
15 {
16   if (FILENAME!=current_file) {
17 #    if (use_ldap_define)
18 #    {
19 #      print "#endif /* USE_LDAP */"
20 #      use_ldap_define = 0;
21 #    }
22     print ""
23     print "/*The following definitions come from ",FILENAME," */"
24     print ""
25     current_file=FILENAME
26 #    if (current_file=="ldap.c") {
27 #      print "#ifdef USE_LDAP"
28 #      use_ldap_define = 1;
29 #    }
30   }
31   if (inheader) {
32     if (match($0,"[)][ \t]*$")) {
33       inheader = 0;
34       printf "%s;\n",$0;
35     } else {
36       printf "%s\n",$0;
37     }
38     next;
39   }
40 }
41
42 # we handle the loadparm.c fns separately
43
44 /^FN_LOCAL_BOOL/ {
45   split($0,a,"[,()]")
46   printf "BOOL %s(int );\n", a[2]
47 }
48
49 /^FN_LOCAL_STRING/ {
50   split($0,a,"[,()]")
51   printf "char *%s(int );\n", a[2]
52 }
53
54 /^FN_LOCAL_INT/ {
55   split($0,a,"[,()]")
56   printf "int %s(int );\n", a[2]
57 }
58
59 /^FN_LOCAL_CHAR/ {
60   split($0,a,"[,()]")
61   printf "char %s(int );\n", a[2]
62 }
63
64 /^FN_GLOBAL_BOOL/ {
65   split($0,a,"[,()]")
66   printf "BOOL %s(void);\n", a[2]
67 }
68
69 /^FN_GLOBAL_STRING/ {
70   split($0,a,"[,()]")
71   printf "char *%s(void);\n", a[2]
72 }
73
74 /^FN_GLOBAL_INT/ {
75   split($0,a,"[,()]")
76   printf "int %s(void);\n", a[2]
77 }
78
79 /^static|^extern/ || !/^[a-zA-Z]/ || /[;]/ {
80   next;
81 }
82
83 #
84 # We have to split up the start
85 # matching as we now have so many start
86 # types that it can cause some versions
87 # of nawk/awk to choke and fail on
88 # the full match. JRA.
89 #
90
91 {
92   gotstart = 0;
93   if( $0 ~ /^connection_struct|^pipes_struct|^file_fd_struct|^files_struct|^connection_struct|^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^pid_t|^ino_t|^off_t/ ) {
94     gotstart = 1;
95   }
96
97   if( $0 ~ /^LOCAL_GRP|^DOMAIN_GRP|^SMB_STRUCT_DIRENT|^SEC_ACL|^SEC_DESC|^SEC_DESC_BUF|^DOM_SID/ ) {
98     gotstart = 1;
99   }
100
101   if( $0 ~ /^long|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE|^SMB_OFF_T|^size_t|^ssize_t|^SMB_BIG_UINT/ ) {
102     gotstart = 1;
103   }
104   if(!gotstart) {
105     next;
106   }
107 }
108
109
110 /[(].*[)][ \t]*$/ {
111     printf "%s;\n",$0;
112     next;
113 }
114
115 /[(]/ {
116   inheader=1;
117   printf "%s\n",$0;
118   next;
119 }
120