mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
Updated helper scripts
This commit is contained in:
@@ -15,7 +15,7 @@ wget -nv https://www.iana.org/assignments/http-fields/field-names.csv -O perm-he
|
||||
echo Generating...
|
||||
echo '/**
|
||||
* @defgroup headers HTTP headers
|
||||
* These are the standard headers found in HTTP requests and responses.
|
||||
* The standard headers found in HTTP requests and responses.
|
||||
* See: https://www.iana.org/assignments/http-fields/http-fields.xhtml
|
||||
* Registry export date: '"$(date -u +%Y-%m-%d)"'
|
||||
* @{
|
||||
@@ -29,17 +29,17 @@ FNR > 1 {
|
||||
status = $3
|
||||
ref = $4
|
||||
comment = $5
|
||||
if ("RFC-ietf-httpbis" == substr(ref, 1, 16))
|
||||
if(ref ~ /^RFC911[0-2]/ && status != "obsoleted")
|
||||
{
|
||||
gsub(/\]\[/, "; ", ref)
|
||||
if (length(status) == 0)
|
||||
if(length(status) == 0)
|
||||
{ status = "No category" }
|
||||
else
|
||||
{ sub(/^./, toupper(substr(status, 1, 1)), status) }
|
||||
field_name = gensub(/\*/, "ASTERISK", "g", field_name)
|
||||
field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
|
||||
printf ("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
printf("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
}
|
||||
}' perm-headers.csv >> header_insert_headers.h && \
|
||||
echo '
|
||||
@@ -51,7 +51,24 @@ FNR > 1 {
|
||||
status = $3
|
||||
ref = $4
|
||||
comment = $5
|
||||
if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "permanent")
|
||||
if(ref !~ /^RFC911[0-2]/ && status == "permanent")
|
||||
{
|
||||
gsub(/\]\[/, "; ", ref)
|
||||
sub(/^./, toupper(substr(status, 1, 1)), status)
|
||||
field_name = gensub(/\*/, "ASTERISK", "g", field_name)
|
||||
field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
|
||||
printf("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
}
|
||||
}' perm-headers.csv >> header_insert_headers.h && \
|
||||
gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
|
||||
FNR > 1 {
|
||||
gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
|
||||
field_name = $1
|
||||
status = $3
|
||||
ref = $4
|
||||
comment = $5
|
||||
if(ref !~ /^RFC911[0-2]/ && status == "provisional")
|
||||
{
|
||||
gsub(/\]\[/, "; ", ref)
|
||||
sub(/^./, toupper(substr(status, 1, 1)), status)
|
||||
@@ -68,31 +85,14 @@ FNR > 1 {
|
||||
status = $3
|
||||
ref = $4
|
||||
comment = $5
|
||||
if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "provisional")
|
||||
{
|
||||
gsub(/\]\[/, "; ", ref)
|
||||
sub(/^./, toupper(substr(status, 1, 1)), status)
|
||||
field_name = gensub(/\*/, "ASTERISK", "g", field_name)
|
||||
field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
|
||||
printf ("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
}
|
||||
}' perm-headers.csv >> header_insert_headers.h && \
|
||||
gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
|
||||
FNR > 1 {
|
||||
gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
|
||||
field_name = $1
|
||||
status = $3
|
||||
ref = $4
|
||||
comment = $5
|
||||
if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && length(status) == 0)
|
||||
if(ref !~ /^RFC911[0-2]/ && status != "obsoleted" && status != "permanent" && status != "provisional" && status != "deprecated")
|
||||
{
|
||||
gsub(/\]\[/, "; ", ref)
|
||||
status = "No category"
|
||||
field_name = gensub(/\*/, "ASTERISK", "g", field_name)
|
||||
field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
|
||||
printf ("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
printf("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
}
|
||||
}' perm-headers.csv >> header_insert_headers.h && \
|
||||
gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
|
||||
@@ -102,14 +102,14 @@ FNR > 1 {
|
||||
status = $3
|
||||
ref = $4
|
||||
comment = $5
|
||||
if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "deprecated")
|
||||
if(ref !~ /^RFC911[0-2]/ && status == "deprecated")
|
||||
{
|
||||
gsub(/\]\[/, "; ", ref)
|
||||
sub(/^./, toupper(substr(status, 1, 1)), status)
|
||||
field_name = gensub(/\*/, "ASTERISK", "g", field_name)
|
||||
field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
|
||||
printf ("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
printf("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
}
|
||||
}' perm-headers.csv >> header_insert_headers.h && \
|
||||
gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
|
||||
@@ -119,14 +119,14 @@ FNR > 1 {
|
||||
status = $3
|
||||
ref = $4
|
||||
comment = $5
|
||||
if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "obsoleted")
|
||||
if (status == "obsoleted")
|
||||
{
|
||||
gsub(/\]\[/, "; ", ref)
|
||||
sub(/^./, toupper(substr(status, 1, 1)), status)
|
||||
field_name = gensub(/\*/, "ASTERISK", "g", field_name)
|
||||
field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
|
||||
printf ("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
printf("/* %-14.14s %s */\n", status ".", ref)
|
||||
printf("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
|
||||
}
|
||||
}' perm-headers.csv >> header_insert_headers.h && \
|
||||
echo OK && \
|
||||
|
||||
@@ -16,17 +16,71 @@ echo Generating...
|
||||
echo '/**
|
||||
* @defgroup methods HTTP methods
|
||||
* HTTP methods (as strings).
|
||||
* See: http://www.iana.org/assignments/http-methods/http-methods.xml
|
||||
* See: https://www.iana.org/assignments/http-methods/http-methods.xml
|
||||
* Registry export date: '"$(date -u +%Y-%m-%d)"'
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Main HTTP methods. */' > header_insert_methods.h && \
|
||||
gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
|
||||
function strnumcmp(s1, s2, n1, n2, a1, a2)
|
||||
{
|
||||
n1 = length(s1)
|
||||
n2 = length(s2)
|
||||
if (0 == n1 && 0 == n2)
|
||||
return 0
|
||||
if (0 == n1 && 0 < n2)
|
||||
return -1
|
||||
if (0 < n1 && 0 == n2)
|
||||
return 1
|
||||
n1 = match(s1, /^[^0-9]+/, a1)
|
||||
n2 = match(s2, /^[^0-9]+/, a2)
|
||||
if (0 != n1)
|
||||
{
|
||||
if (0 == n2)
|
||||
return 1
|
||||
if ((a1[0] "") < (a2[0] ""))
|
||||
return -1
|
||||
if ((a1[0] "") > (a2[0] ""))
|
||||
return 1
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != n2)
|
||||
return -1
|
||||
}
|
||||
s1 = substr(s1, length(a1[0]) + 1)
|
||||
s2 = substr(s2, length(a2[0]) + 1)
|
||||
n1 = match(s1, /^[0-9]+/, a1)
|
||||
n2 = match(s2, /^[0-9]+/, a2)
|
||||
if (0 != n1)
|
||||
{
|
||||
if (0 == n2)
|
||||
return 1
|
||||
if ((a1[0] + 0) < (a2[0] + 0))
|
||||
return -1
|
||||
if ((a1[0] + 0) > (a2[0] + 0))
|
||||
return 1
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != n2)
|
||||
return -1
|
||||
}
|
||||
return strnumcmp(substr(s1, length(a1[0]) + 1), substr(s2, length(a2[0]) + 1))
|
||||
}
|
||||
|
||||
function sort_indices(i1, v1, i2, v2)
|
||||
{
|
||||
return strnumcmp(gensub(/[^0-9A-Za-z]+/, " ", "g", i1), gensub(/[^0-9A-Za-z]+/, " ", "g", i2))
|
||||
}
|
||||
|
||||
FNR > 1 {
|
||||
gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
|
||||
gsub(/\]\[/, "; ", $4)
|
||||
if (substr($4, 1, 26) == "RFC-ietf-httpbis-semantics") {
|
||||
mthd_m = $1
|
||||
reference_m = $4
|
||||
gsub(/^\[|^"\[|\]"$|\]$/, "", reference_m)
|
||||
gsub(/\]\[/, "; ", reference_m)
|
||||
if (reference_m ~ /^RFC911[0-2]/ && mthd_m != "*") {
|
||||
if ($2 == "yes")
|
||||
{ safe_m = "Safe. " }
|
||||
else
|
||||
@@ -35,19 +89,27 @@ FNR > 1 {
|
||||
{ indem_m = "Idempotent. " }
|
||||
else
|
||||
{ indem_m = "Not idempotent." }
|
||||
print "/* " safe_m " " indem_m " " $4 ". */"
|
||||
mthd = gensub(/\*/, "ASTERISK", "g", $1)
|
||||
mthd = gensub(/[^a-zA-Z0-9_]/, "_", "g", mthd)
|
||||
printf ("%-32s \"%s\"\n", "#define MHD_HTTP_METHOD_" toupper(mthd), $1)
|
||||
idx_str = gensub(/[^0-9A-Za-z]+/, " ", "g", reference_m)
|
||||
main_methods[idx_str] = sprintf ("%s\n", "/* " safe_m " " indem_m " " reference_m ". */")
|
||||
mthd_tkn = gensub(/\*/, "ASTERISK", "g", mthd_m)
|
||||
gsub(/[^a-zA-Z0-9_]/, "_", mthd_tkn)
|
||||
main_methods[idx_str] = (main_methods[idx_str] sprintf ("%-32s \"%s\"\n", "#define MHD_HTTP_METHOD_" toupper(mthd_tkn), mthd_m))
|
||||
}
|
||||
}' methods.csv >> header_insert_methods.h && \
|
||||
}
|
||||
|
||||
END {
|
||||
n = asort(main_methods, main_methods, "sort_indices")
|
||||
for (i = 1; i <= n; i++)
|
||||
printf("%s", main_methods[i])
|
||||
}
|
||||
' methods.csv >> header_insert_methods.h && \
|
||||
echo '
|
||||
/* Additional HTTP methods. */' >> header_insert_methods.h && \
|
||||
gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
|
||||
FNR > 1 {
|
||||
gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
|
||||
gsub(/\]\[/, "; ", $4)
|
||||
if (substr($4, 1, 26) != "RFC-ietf-httpbis-semantics") {
|
||||
if ($4 !~ /^RFC911[0-2]/ || $1 == "*") {
|
||||
if ($2 == "yes")
|
||||
{ safe_m = "Safe. " }
|
||||
else
|
||||
@@ -62,5 +124,8 @@ FNR > 1 {
|
||||
printf ("%-38s \"%s\"\n", "#define MHD_HTTP_METHOD_" toupper(mthd), $1)
|
||||
}
|
||||
}' methods.csv >> header_insert_methods.h && \
|
||||
echo '
|
||||
/** @} */ /* end of group methods */
|
||||
' >> header_insert_methods.h &&
|
||||
echo OK && \
|
||||
rm methods.csv || exit
|
||||
|
||||
@@ -25,6 +25,9 @@ gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
|
||||
FNR > 1 {
|
||||
gsub(/^\[|^"\[|\]"$|\]$/, "", $3)
|
||||
gsub(/\]\[/, "; ", $3)
|
||||
if (sub(/ *\(OBSOLETED\)/, "", $2)) {
|
||||
$3 = "(OBSOLETED) " $3
|
||||
}
|
||||
if ($1 == 306) {
|
||||
$2 = "Switch Proxy"
|
||||
$3 = "Not used! " $3
|
||||
@@ -68,12 +71,15 @@ FNR > 1 {
|
||||
num = $1
|
||||
reason = $2
|
||||
desc = $3
|
||||
if (sub(/ *\(OBSOLETED\)/, "", reason)) {
|
||||
desc = "(OBSOLETED) " desc
|
||||
}
|
||||
if (num % 100 == 0) {
|
||||
if (num != 100) {
|
||||
printf (" /* %s */ %-36s /* %s */\n};\n\n", prev_num, "_MHD_S_STR_W_LEN (\""prev_reason"\")", prev_desc)
|
||||
}
|
||||
prev_num = num;
|
||||
print "static const struct _MHD_str_w_len " hundreds[$1/100] "_hundred[] = {"
|
||||
print "static const struct _MHD_cstr_w_len " hundreds[$1/100] "_hundred[] = {"
|
||||
}
|
||||
if (num == 306) {
|
||||
reason = "Switch Proxy"
|
||||
|
||||
Reference in New Issue
Block a user