5 # don't use warnings module as it is not portable enough
8 my $header_name = '_PROTO_H_';
10 if ($ARGV[0] eq '-h') {
12 $header_name = shift @ARGV;
16 print "#ifndef $header_name\n";
17 print "#define $header_name\n\n";
18 print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n\n";
22 printf "\n#endif /* %s */\n", $header_name;
29 if ($line =~ /^FN_(GLOBAL|LOCAL)_(CONST_STRING|STRING|BOOL|CHAR|INTEGER|LIST)\((\w+),.*\)/o) {
36 "CONST_STRING" => "const char *",
37 "STRING" => "const char *",
40 "LIST" => "const char **",
48 print "$tmap{$type}$name($smap{$scope});\n";
57 open(FH, "< $filename") || die "Failed to open $filename";
59 print "\n/* The following definitions come from $filename */\n\n";
61 while (my $line = <FH>) {
62 # these are ordered for maximum speed
63 next if ($line =~ /^\s/);
65 next unless ($line =~ /\(/);
67 next if ($line =~ /^\/|[;]/);
69 next unless ( $line =~ /
70 ^void|^BOOL|^int|^struct|^char|^const|^\w+_[tT]\s|^uint|^unsigned|^long|
71 ^NTSTATUS|^ADS_STATUS|^enum\s.*\(|^DATA_BLOB|^WERROR|^XFILE|^FILE|^DIR|
72 ^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NTTIME|^FN_|^REG_KEY|^REG_HANDLE|^REG_VAL|
73 ^GtkWidget|^GType|^smb_ucs2_t
76 next if ($line =~ /^int\s*main/);
78 if ($line =~ /^FN_/) {
79 handle_loadparm($line);
83 if ( $line =~ /\(.*\)\s*$/o ) {
91 while ($line = <FH>) {
92 if ($line =~ /\)\s*$/o) {
105 foreach my $filename (@ARGV) {
106 process_file($filename);