r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
[vlendec/samba-autobuild/.git] / source3 / script / mkproto.awk
1 BEGIN {
2   inheader=0;
3 #  use_ldap_define = 0;
4   current_file="";
5   if (headername=="") {
6     headername="_PROTO_H_";
7   }
8
9   print "#ifndef",headername
10   print "#define",headername
11   print ""
12   print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */"
13   print ""
14 }
15
16 END {
17   print ""
18   print "#endif /* ",headername," */"
19 }
20
21 {
22   if (FILENAME!=current_file) {
23 #    if (use_ldap_define)
24 #    {
25 #      print "#endif /* USE_LDAP */"
26 #      use_ldap_define = 0;
27 #    }
28     print ""
29     print "/* The following definitions come from",FILENAME," */"
30     print ""
31     current_file=FILENAME
32   }
33   if (inheader) {
34     if (match($0,"[)][ \t]*$")) {
35       inheader = 0;
36       printf "%s;\n",$0;
37     } else {
38       printf "%s\n",$0;
39     }
40     next;
41   }
42 }
43
44 # we handle the loadparm.c fns separately
45
46 /^FN_LOCAL_BOOL/ {
47   split($0,a,"[,()]")
48   printf "BOOL %s(int );\n", a[2]
49 }
50
51 /^FN_LOCAL_PARM_BOOL/ {
52   split($0,a,"[,()]")
53   printf "BOOL %s(const struct share_params *p );\n", a[2]
54 }
55
56 /^FN_LOCAL_LIST/ {
57   split($0,a,"[,()]")
58   printf "const char **%s(int );\n", a[2]
59 }
60
61 /^FN_LOCAL_STRING/ {
62   split($0,a,"[,()]")
63   printf "char *%s(int );\n", a[2]
64 }
65
66 /^FN_LOCAL_PARM_STRING/ {
67   split($0,a,"[,()]")
68   printf "char *%s(const struct share_params *p );\n", a[2]
69 }
70
71 /^FN_LOCAL_CONST_STRING/ {
72   split($0,a,"[,()]")
73   printf "const char *%s(int );\n", a[2]
74 }
75
76 /^FN_LOCAL_INT/ {
77   split($0,a,"[,()]")
78   printf "int %s(int );\n", a[2]
79 }
80
81 /^FN_LOCAL_CHAR/ {
82   split($0,a,"[,()]")
83   printf "char %s(const struct share_params *p );\n", a[2]
84 }
85
86 /^FN_GLOBAL_BOOL/ {
87   split($0,a,"[,()]")
88   printf "BOOL %s(void);\n", a[2]
89 }
90
91 /^FN_GLOBAL_LIST/ {
92   split($0,a,"[,()]")
93   printf "const char **%s(void);\n", a[2]
94 }
95
96 /^FN_GLOBAL_STRING/ {
97   split($0,a,"[,()]")
98   printf "char *%s(void);\n", a[2]
99 }
100
101 /^FN_GLOBAL_CONST_STRING/ {
102   split($0,a,"[,()]")
103   printf "const char *%s(void);\n", a[2]
104 }
105
106 /^FN_GLOBAL_INT/ {
107   split($0,a,"[,()]")
108   printf "int %s(void);\n", a[2]
109 }
110
111 /^static|^extern/ || !/^[a-zA-Z]/ || /[;]/ {
112   next;
113 }
114
115 #
116 # We have to split up the start
117 # matching as we now have so many start
118 # types that it can cause some versions
119 # of nawk/awk to choke and fail on
120 # the full match. JRA.
121 #
122
123 {
124   gotstart = 0;
125   if( $0 ~ /^const|^connection_struct|^pipes_struct|^smb_np_struct|^file_fd_struct|^files_struct|^connection_struct|^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^pid_t|^ino_t|^off_t|^double/ ) {
126     gotstart = 1;
127   }
128
129   if( $0 ~ /^vuser_key|^UNISTR2|^LOCAL_GRP|^DOMAIN_GRP|^SMB_STRUCT_DIRENT|^SEC_ACL|^SEC_DESC|^SEC_DESC_BUF|^DOM_SID|^RPC_HND_NODE|^BYTE/ ) {
130     gotstart = 1;
131   }
132
133   if( $0 ~ /^ADS_STRUCT|^ADS_STATUS|^DATA_BLOB|^ASN1_DATA|^TDB_CONTEXT|^TDB_DATA|^smb_ucs2_t|^TALLOC_CTX|^hash_element|^NT_DEVICEMODE|^enum.*\(|^NT_USER_TOKEN|^SAM_ACCOUNT|^NTTIME/ ) {
134     gotstart = 1;
135   }
136
137   if( $0 ~ /^smb_iconv_t|^long|^char|^uint|^NTSTATUS|^WERROR|^CLI_POLICY_HND|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^FILE|^XFILE|^SMB_OFF_T|^size_t|^ssize_t|^SMB_BIG_UINT|^SMB_BIG_INT/ ) {
138     gotstart = 1;
139   }
140
141   if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_VALUE|^REGVAL_CTR|^DEVICEMODE|^PAC_DATA|^NET_USER_INFO_3|^smb_event_id_t/ ) {
142     gotstart = 1;
143   }
144
145   if( $0 ~ /^WINBINDD_PW|^WINBINDD_GR|^NT_PRINTER_INFO_LEVEL_2|^LOGIN_CACHE|^krb5_error_code|^LDAP|^u32|^LUID_ATTR|^NSS_STATUS/ ) {
146     gotstart = 1;
147   }
148
149   if( $0 ~ /^NODE_STATUS_STRUCT|SMB_STRUCT_DIR|ELOG_TDB/ ) {
150     gotstart = 1;
151   }
152
153   if(!gotstart) {
154     next;
155   }
156 }
157
158
159 /[(].*[)][ \t]*$/ {
160     printf "%s;\n",$0;
161     next;
162 }
163
164 /[(]/ {
165   inheader=1;
166   printf "%s\n",$0;
167   next;
168 }
169