]> git.armaanb.net Git - asd-repo.git/blob - rsync/files/mkproto.awk
mutt: remove /etc/Mutt*
[asd-repo.git] / rsync / files / mkproto.awk
1 #!/usr/bin/awk -f
2
3 BEGIN {
4     while ((getline i < "proto.h") > 0) old_protos = old_protos ? old_protos "\n" i : i
5     protos = "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n"
6 }
7
8 inheader {
9     protos = protos "\n" ((inheader = /\)[ \t]*$/ ? 0 : 1) ? $0 : $0 ";")
10     next
11 }
12
13 /^FN_(LOCAL|GLOBAL)_[^(]+\([^,()]+/ {
14     local = /^FN_LOCAL/
15     gsub(/^FN_(LOC|GLOB)AL_|,.*$/, "")
16     sub(/^BOOL\(/, "BOOL ")
17     sub(/^CHAR\(/, "char ")
18     sub(/^INTEGER\(/, "int ")
19     sub(/^STRING\(/, "char *")
20     protos = protos "\n" $0 (local ? "(int module_id);" : "(void);")
21     next
22 }
23
24 /^static|^extern|;/||!/^[A-Za-z][A-Za-z0-9_]* / { next }
25
26 /\(.*\)[ \t]*$/ {
27     protos = protos "\n" $0 ";"
28     next
29 }
30
31 /\(/ {
32     inheader = 1
33     protos = protos "\n" $0
34 }
35
36 END {
37     if (old_protos != protos) print protos > "proto.h"
38     print "" > "proto.h-tstamp"
39 }