summaryrefslogtreecommitdiffstats
path: root/source/script/mkproto.awk
blob: e3c94905ae54ffa738bca8b5f2c4e3c874885df5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
BEGIN {
  inheader=0;
#  use_ldap_define = 0;
  if (headername=="") {
    headername="_PROTO_H_";
  }
  current_file="";
  print "#ifndef",headername
  print "#define",headername
  print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */"
  print ""
}

END {
  print "#endif /*",headername,"*/"
}

{
  if (FILENAME!=current_file) {
#    if (use_ldap_define)
#    {
#      print "#endif /* USE_LDAP */"
#      use_ldap_define = 0;
#    }
    print ""
    print "/*The following definitions come from ",FILENAME," */"
    print ""
    current_file=FILENAME
#    if (current_file=="ldap.c") {
#      print "#ifdef USE_LDAP"
#      use_ldap_define = 1;
#    }
  }
  if (inheader) {
    if (match($0,"[)][ \t]*$")) {
      inheader = 0;
      printf "%s;\n",$0;
    } else {
      printf "%s\n",$0;
    }
    next;
  }
}

# we handle the loadparm.c fns separately

/^FN_VUSER_STRING/ {
  split($0,a,"[,()]")
  printf "char *%s(const vuser_key* );\n", a[2]
}

/^FN_LOCAL_BOOL/ {
  split($0,a,"[,()]")
  printf "BOOL %s(int );\n", a[2]
}

/^FN_LOCAL_STRING/ {
  split($0,a,"[,()]")
  printf "char *%s(int );\n", a[2]
}

/^FN_LOCAL_INT/ {
  split($0,a,"[,()]")
  printf "int %s(int );\n", a[2]
}

/^FN_LOCAL_CHAR/ {
  split($0,a,"[,()]")
  printf "char %s(int );\n", a[2]
}

/^FN_GLOBAL_BOOL/ {
  split($0,a,"[,()]")
  printf "BOOL %s(void);\n", a[2]
}

/^FN_GLOBAL_STRING/ {
  split($0,a,"[,()]")
  printf "char *%s(void);\n", a[2]
}

/^FN_GLOBAL_INT/ {
  split($0,a,"[,()]")
  printf "int %s(void);\n", a[2]
}

/^static|^extern/ || !/^[a-zA-Z]/ || /[;]/ {
  next;
}

#
# We have to split up the start
# matching as we now have so many start
# types that it can cause some versions
# of nawk/awk to choke and fail on
# the full match. JRA.
#

{
  gotstart = 0;
  if( $0 ~ /^connection_struct|^LOCAL_GRP|^DOMAIN_GRP|^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/ ) {
    gotstart = 1;
  }

  if( $0 ~ /^JOB_INFO_1|^JOB_INFO_2/ ) {
    gotstart = 1;
  }

  if( $0 ~ /^PRINTER_INFO_1|^PRINTER_INFO_2/ ) {
    gotstart = 1;
  }

  if( $0 ~ /^UNISTR2|^LOCAL_GRP|^DOMAIN_GRP|^DOM_SID|^SEC_DESC/ ) {
    gotstart = 1;
  }

  if( $0 ~ /^msrpc_service_fns/ ) {
    gotstart = 1;
  }

  if( $0 ~ /^TDB_CONTEXT|^TDB_DATA|^smb_ucs2_t/ ) {
    gotstart = 1;
  }

  if( $0 ~ /^const|^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|dbg_Token/ ) {
    gotstart = 1;
  }
  if(!gotstart) {
    next;
  }
}


/[(].*[)][ \t]*$/ {
    printf "%s;\n",$0;
    next;
}

/[(]/ {
  inheader=1;
  printf "%s\n",$0;
  next;
}