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
|
#!/usr/bin/awk -f
BEGIN {
printf "#ifndef PHP_PQ_TYPE\n"
printf "# define PHP_PQ_TYPE(t,o)\n"
printf "#endif\n"
}
END {
printf "#ifndef PHP_PQ_TYPE_IS_ARRAY\n"
printf "# define PHP_PQ_TYPE_IS_ARRAY(oid) (\\\n\t\t0 \\\n"
for (oid in arrays) {
printf "\t||\t((oid) == %d) \\\n", oid
}
printf ")\n#endif\n"
printf "#ifndef PHP_PQ_TYPE_OF_ARRAY\n"
printf "# define PHP_PQ_TYPE_OF_ARRAY(oid) ("
for (oid in arrays) {
printf "\\\n\t(oid) == %d ? %s : ", oid, arrays[oid]
}
printf "0 \\\n)\n#endif\n"
printf "#ifndef PHP_PQ_DELIM_OF_ARRAY\n"
printf "# define PHP_PQ_DELIM_OF_ARRAY(oid) ("
for (oid in delims) {
printf "\\\n\t(oid) == %d ? '%s' : ", oid, delims[oid]
}
printf "\\\n\t0 \\\n)\n#endif\n"
}
/^DATA/ {
oid = $4
name = toupper($6)
adelim = $15
atypoid = $17
if (sub("^_", "", name)) {
arrays[oid] = atypoid
name = name "ARRAY"
}
delims[oid] = adelim
printf "#ifndef PHP_PQ_OID_%s\n", name
printf "# define PHP_PQ_OID_%s %d\n", name, oid
printf "#endif\n"
printf "PHP_PQ_TYPE(\"%s\", %d)\n", name, oid
}
|