typo: oid of bool is 16, not 18
[m6w6/ext-pq] / php_pq_type.awk
1 #!/usr/bin/awk -f
2
3 BEGIN {
4 printf "#ifndef PHP_PQ_TYPE\n"
5 printf "# define PHP_PQ_TYPE(t,o)\n"
6 printf "#endif\n"
7 }
8
9 END {
10 printf "#ifndef PHP_PQ_TYPE_IS_ARRAY\n"
11 printf "# define PHP_PQ_TYPE_IS_ARRAY(oid) (\\\n\t\t0 \\\n"
12 for (name in arrays) {
13 printf "\t||\t((oid) == %d) \\\n", arrays[name]
14 }
15 printf ")\n#endif\n"
16 }
17
18 /^DATA/ {
19 oid = $4
20 name = toupper($6)
21 if (sub("^_", "", name)) {
22 arrays[name] = oid
23 name = name "ARRAY"
24 }
25 printf "#ifndef PHP_PQ_OID_%s\n", name
26 printf "# define PHP_PQ_OID_%s %d\n", name, oid
27 printf "#endif\n"
28 printf "PHP_PQ_TYPE(\"%s\", %d)\n", name, oid
29 }