#! /bin/sh case "$1" in c|h) ;; *) echo "Usage: $0 [c|h]" 1>&2 exit 1 ;; esac awk 'BEGIN { kind = "'$1'"; if (kind == "h") { printf("#include \"verbose-hdr.h\"\n"); } if (kind == "c") { printf("#include \"verbose.h\"\n"); printf("VERBOSITY verbosities[] = {\n"); } n = 0; } /^[ ]*#/ { next; } /^[ ]*$/ { next; } { key = $1; rest = gensub("^[ ]*" key "[ ]*","",1,$0); if (kind == "h") { printf("#define VERBOSE_%s %d\n",toupper(key),n); } if (kind == "c") { printf("{ \"%s\", \"%s\" },\n",key,gensub("[\\\\\"]","\\\\&","g",rest)); } n ++; } END { if (kind == "c") { printf("{ 0 } };\n"); } }'