Added source filename to give crude index
[samba.git] / source3 / script / mkproto.awk
1 # generate prototypes for Samba C code
2 # tridge, June 1996
3 # added comment for each source file for use as crude index
4 # dan, 17 June 1996
5
6 BEGIN {
7   inheader=0;
8   current_file="";
9   print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */"
10   print ""
11 }
12
13 {
14   if (FILENAME!=current_file) {
15     print ""
16     print "/*The following definitions come from ",FILENAME," */"
17     print ""
18     current_file=FILENAME
19   }
20   if (inheader) {
21     if (match($0,"[)][ \t]*$")) {
22       inheader = 0;
23       printf "%s;\n",$0;
24     } else {
25       printf "%s\n",$0;
26     }
27     next;
28   }
29 }
30
31 # we handle the loadparm.c fns separately
32
33 /^FN_LOCAL_BOOL/ {
34   split($0,a,"[,()]")
35   printf "BOOL %s(int );\n", a[2]
36 }
37
38 /^FN_LOCAL_STRING/ {
39   split($0,a,"[,()]")
40   printf "char *%s(int );\n", a[2]
41 }
42
43 /^FN_LOCAL_INT/ {
44   split($0,a,"[,()]")
45   printf "int %s(int );\n", a[2]
46 }
47
48 /^FN_LOCAL_CHAR/ {
49   split($0,a,"[,()]")
50   printf "char %s(int );\n", a[2]
51 }
52
53 /^FN_GLOBAL_BOOL/ {
54   split($0,a,"[,()]")
55   printf "BOOL %s(void);\n", a[2]
56 }
57
58 /^FN_GLOBAL_STRING/ {
59   split($0,a,"[,()]")
60   printf "char *%s(void);\n", a[2]
61 }
62
63 /^FN_GLOBAL_INT/ {
64   split($0,a,"[,()]")
65   printf "int %s(void);\n", a[2]
66 }
67
68 /^static|^extern/ || !/^[a-zA-Z]/ || /[;]/ {
69   next;
70 }
71
72 !/^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time/ {
73   next;
74 }
75
76
77 /[(].*[)][ \t]*$/ {
78     printf "%s;\n",$0;
79     next;
80 }
81
82 /[(]/ {
83   inheader=1;
84   printf "%s\n",$0;
85   next;
86 }
87