diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2020-09-20 22:04:47 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2020-09-20 22:04:47 +0300 |
commit | e1f5f53a5f57d5be618dc22f1d6d210509fae36a (patch) | |
tree | c0b70c374d5af2c20d83312d6dca4f010c27bc0d | |
parent | 1c90123d95d58161bf83ec6ff5be729d1ee6349c (diff) | |
download | libmicrohttpd-e1f5f53a5f57d5be618dc22f1d6d210509fae36a.tar.gz libmicrohttpd-e1f5f53a5f57d5be618dc22f1d6d210509fae36a.zip |
contrib/gen_http_statuses_inserts.sh: updated to generate better formatted C code
-rwxr-xr-x | contrib/gen_http_statuses_inserts.sh | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/contrib/gen_http_statuses_inserts.sh b/contrib/gen_http_statuses_inserts.sh index 07c2075f..6c8e6454 100755 --- a/contrib/gen_http_statuses_inserts.sh +++ b/contrib/gen_http_statuses_inserts.sh | |||
@@ -56,30 +56,45 @@ gawk -e 'BEGIN { | |||
56 | hundreds[5]="five" | 56 | hundreds[5]="five" |
57 | hundreds[6]="six" | 57 | hundreds[6]="six" |
58 | prev_num=0 | 58 | prev_num=0 |
59 | prev_reason="" | ||
60 | prev_desc="" | ||
61 | num=0 | ||
62 | reason="" | ||
63 | desc="" | ||
59 | } | 64 | } |
60 | FNR > 1 { | 65 | FNR > 1 { |
61 | gsub(/^\[|^"\[|\]"$|\]$/, "", $3) | 66 | gsub(/^\[|^"\[|\]"$|\]$/, "", $3) |
62 | gsub(/\]\[/, "; ", $3) | 67 | gsub(/\]\[/, "; ", $3) |
63 | if ($1 % 100 == 0) { | 68 | num = $1 |
64 | if ($1 != 100) { printf("\n};\n\n") } | 69 | reason = $2 |
65 | prev_num=$1 - 1; | 70 | desc = $3 |
71 | if (num % 100 == 0) { | ||
72 | if (num != 100) { | ||
73 | printf (" /* %s */ %-24s /* %s */\n};\n\n", prev_num, "\""prev_reason"\"", prev_desc) | ||
74 | } | ||
75 | prev_num = num; | ||
66 | print "static const char *const " hundreds[$1/100] "_hundred[] = {" | 76 | print "static const char *const " hundreds[$1/100] "_hundred[] = {" |
67 | } | 77 | } |
68 | if ($1 == 306) { | 78 | if (num == 306) { |
69 | $2 = "Switch Proxy" | 79 | reason = "Switch Proxy" |
70 | $3 = "Not used! " $3 | 80 | desc = "Not used! " desc |
71 | } | 81 | } |
72 | if ($2 == "Unassigned") next | 82 | if (reason == "Unassigned") next |
73 | while(++prev_num != $1) { | 83 | if (prev_num != num) |
74 | if (prev_num == 449) {reason="Reply With"; desc="MS IIS extension";} | 84 | printf (" /* %s */ %-24s /* %s */\n", prev_num, "\""prev_reason"\",", prev_desc) |
75 | else if (prev_num == 450) {reason="Blocked by Windows Parental Controls"; desc="MS extension";} | 85 | while(++prev_num < num) { |
76 | else if (prev_num == 509) {reason="Bandwidth Limit Exceeded"; desc="Apache extension";} | 86 | if (prev_num == 449) {prev_reason="Reply With"; prev_desc="MS IIS extension";} |
77 | else {reason="Unknown"; desc="Not used";} | 87 | else if (prev_num == 450) {prev_reason="Blocked by Windows Parental Controls"; prev_desc="MS extension";} |
78 | printf (",\n /* %s */ %-24s /* %s */", prev_num, "\"" reason "\"", desc) | 88 | else if (prev_num == 509) {prev_reason="Bandwidth Limit Exceeded"; prev_desc="Apache extension";} |
89 | else {prev_reason="Unknown"; prev_desc="Not used";} | ||
90 | printf (" /* %s */ %-24s /* %s */\n", prev_num, "\""prev_reason"\",", prev_desc) | ||
79 | } | 91 | } |
80 | if ($1 % 100 != 0) { print "," } | 92 | prev_num = num |
81 | printf (" /* %s */ %-24s /* %s */", $1, "\""$2"\"", $3) | 93 | prev_reason = reason |
94 | prev_desc = desc | ||
82 | } | 95 | } |
83 | END {printf("\n};\n")}' http-status-codes-1.csv >> code_insert_statuses.c && \ | 96 | END { |
97 | printf (" /* %s */ %-24s /* %s */\n};\n", prev_num, "\""prev_reason"\"", prev_desc) | ||
98 | }' http-status-codes-1.csv > code_insert_statuses.c && \ | ||
84 | echo OK && \ | 99 | echo OK && \ |
85 | rm http-status-codes-1.csv || exit | 100 | rm http-status-codes-1.csv || exit |