updated the 3.0 branch from the head branch - ready for alpha18
[samba.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 # special handling for code merge of TNG to head
45 /^#define OLD_NTDOMAIN 1/ {
46   printf "#if OLD_NTDOMAIN\n"
47 }
48 /^#undef OLD_NTDOMAIN/ {
49   printf "#endif\n"
50 }
51 /^#define NEW_NTDOMAIN 1/ {
52   printf "#if NEW_NTDOMAIN\n"
53 }
54 /^#undef NEW_NTDOMAIN/ {
55   printf "#endif\n"
56 }
57
58 # we handle the loadparm.c fns separately
59
60 /^FN_LOCAL_BOOL/ {
61   split($0,a,"[,()]")
62   printf "BOOL %s(int );\n", a[2]
63 }
64
65 /^FN_LOCAL_LIST/ {
66   split($0,a,"[,()]")
67   printf "char **%s(int );\n", a[2]
68 }
69
70 /^FN_LOCAL_STRING/ {
71   split($0,a,"[,()]")
72   printf "char *%s(int );\n", a[2]
73 }
74
75 /^FN_LOCAL_CONST_STRING/ {
76   split($0,a,"[,()]")
77   printf "const char *%s(int );\n", a[2]
78 }
79
80 /^FN_LOCAL_INT/ {
81   split($0,a,"[,()]")
82   printf "int %s(int );\n", a[2]
83 }
84
85 /^FN_LOCAL_CHAR/ {
86   split($0,a,"[,()]")
87   printf "char %s(int );\n", a[2]
88 }
89
90 /^FN_GLOBAL_BOOL/ {
91   split($0,a,"[,()]")
92   printf "BOOL %s(void);\n", a[2]
93 }
94
95 /^FN_GLOBAL_LIST/ {
96   split($0,a,"[,()]")
97   printf "char **%s(void);\n", a[2]
98 }
99
100 /^FN_GLOBAL_STRING/ {
101   split($0,a,"[,()]")
102   printf "char *%s(void);\n", a[2]
103 }
104
105 /^FN_GLOBAL_CONST_STRING/ {
106   split($0,a,"[,()]")
107   printf "const char *%s(void);\n", a[2]
108 }
109
110 /^FN_GLOBAL_INT/ {
111   split($0,a,"[,()]")
112   printf "int %s(void);\n", a[2]
113 }
114
115 /^static|^extern/ || !/^[a-zA-Z]/ || /[;]/ {
116   next;
117 }
118
119 #
120 # We have to split up the start
121 # matching as we now have so many start
122 # types that it can cause some versions
123 # of nawk/awk to choke and fail on
124 # the full match. JRA.
125 #
126
127 {
128   gotstart = 0;
129   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/ ) {
130     gotstart = 1;
131   }
132
133   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/ ) {
134     gotstart = 1;
135   }
136
137   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/ ) {
138     gotstart = 1;
139   }
140
141   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/ ) {
142     gotstart = 1;
143   }
144
145   if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject/ ) {
146     gotstart = 1;
147   }
148
149   if(!gotstart) {
150     next;
151   }
152 }
153
154
155 /[(].*[)][ \t]*$/ {
156     printf "%s;\n",$0;
157     next;
158 }
159
160 /[(]/ {
161   inheader=1;
162   printf "%s\n",$0;
163   next;
164 }
165