sort table with types and extensions alphabetically by extension - gopher-validator - Simple gopher menu validator. HTML git clone git://bitreich.org/gopher-validator git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/gopher-validator DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit d2d0e95268db4d42a56e0b8967af42b146a3a7e3 DIR parent d9abe6e45e708f965778fba7a66e56300fc0b814 HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Fri, 18 Feb 2022 14:27:16 +0100 sort table with types and extensions alphabetically by extension Diffstat: M gopher-validator.c | 77 ++++++++++++++++--------------- 1 file changed, 40 insertions(+), 37 deletions(-) --- DIR diff --git a/gopher-validator.c b/gopher-validator.c @@ -36,54 +36,57 @@ struct visited { }; /* check valid types with extension in path */ -struct { - const char *ext; - const char *allow; -} types [] = { +struct gophertype { + const char *ext; /* filename extension */ + const char *allow; /* allowed types for this extension */ +}; + +/* must be sorted alphabetically by extension */ +struct gophertype types[] = { + { .ext = "asc", "0" }, + { .ext = "avi", "9" }, + { .ext = "bz2", "9" }, + { .ext = "c", "0" }, + { .ext = "dcgi", "17" }, + { .ext = "doc", "9" }, + { .ext = "exe", "9" }, + { .ext = "gif", "gI" }, + { .ext = "go", "0" }, + { .ext = "gph", "1" }, + { .ext = "gz", "9" }, + { .ext = "h", "0" }, + { .ext = "htm", "0h" }, + { .ext = "html", "0h" }, + { .ext = "iso", "9" }, + { .ext = "jpeg", "I" }, + { .ext = "jpg", "I" }, + { .ext = "json", "0" }, + { .ext = "lzma", "9" }, + { .ext = "m3u", "0" }, + { .ext = "md", "0" }, { .ext = "md5", "0" }, { .ext = "md5sum", "0" }, + { .ext = "mkv", "9" }, + { .ext = "mp3", "9" }, + { .ext = "mp4", "9" }, + { .ext = "ogg", "9" }, + { .ext = "ogv", "9" }, + { .ext = "pdf", "9" }, + { .ext = "png", "I" }, + { .ext = "rss", "0" }, + { .ext = "sh", "0" }, { .ext = "sha1", "0" }, { .ext = "sha1sum", "0" }, { .ext = "sha256", "0" }, { .ext = "sha256sum", "0" }, { .ext = "sha512", "0" }, { .ext = "sha512sum", "0" }, - { .ext = "asc", "0" }, - { .ext = "rss", "0" }, - { .ext = "xml", "0" }, - { .ext = "txt", "0" }, - { .ext = "json", "0" }, - { .ext = "md", "0" }, - { .ext = "c", "0" }, - { .ext = "h", "0" }, - { .ext = "sh", "0" }, - { .ext = "go", "0" }, { .ext = "srt", "0" }, - { .ext = "m3u", "0" }, - { .ext = "htm", "0h" }, - { .ext = "html", "0h" }, - { .ext = "gph", "1" }, - { .ext = "dcgi", "17" }, - { .ext = "gif", "gI" }, - { .ext = "jpg", "I" }, - { .ext = "jpeg", "I" }, - { .ext = "png", "I" }, - { .ext = "doc", "9" }, - { .ext = "pdf", "9" }, - { .ext = "iso", "9" }, - { .ext = "exe", "9" }, - { .ext = "gz", "9" }, { .ext = "tgz", "9" }, - { .ext = "bz2", "9" }, - { .ext = "xz", "9" }, - { .ext = "lzma", "9" }, + { .ext = "txt", "0" }, { .ext = "wav", "9" }, - { .ext = "mp3", "9" }, - { .ext = "ogg", "9" }, - { .ext = "avi", "9" }, - { .ext = "mp4", "9" }, - { .ext = "mkv", "9" }, - { .ext = "ogv", "9" }, + { .ext = "xml", "0" }, + { .ext = "xz", "9" }, }; int exitcode = 0;