geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit dc4e34b09a5e881e4e889c5e1b71b6c2d029968d
parent b8e888a23c8a70957942fb52d0afb95b102ef72a
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 23 Oct 2021 16:52:30 +0200

Move filetype struct array declaration to separate filetypes.h.

This makes it more obvious where to add new filetype handling behaviour.

Diffstat:
filetypes.h | 42++++++++++++++++++++++++++++++++++++++++++
ind.c | 26+-------------------------
2 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/filetypes.h b/filetypes.h @@ -0,0 +1,42 @@ +/* + * Copy me if you can. + * by 20h + */ + +#ifndef FILETYPES_H +#define FILETYPES_H + +#include "ind.h" + +/* + * Before adding any filetype, see the comment in ind.c. + */ + +filetype type[] = { + {"default", "9", handlebin}, + {"gph", "1", handlegph}, + {"cgi", "0", handlecgi}, + {"dcgi", "1", handledcgi}, + {"bin", "9", handlebin}, + {"tgz", "9", handlebin}, + {"gz", "9", handlebin}, + {"jpg", "I", handlebin}, + {"gif", "g", handlebin}, + {"png", "I", handlebin}, + {"bmp", "I", handlebin}, + {"txt", "0", handlebin}, + {"vtt", "0", handlebin}, + {"html", "0", handlebin}, + {"htm", "0", handlebin}, + {"xhtml", "0", handlebin}, + {"css", "0", handlebin}, + {"md", "0", handlebin}, + {"c", "0", handlebin}, + {"sh", "0", handlebin}, + {"patch", "0", handlebin}, + {"meme", "0", handlebin}, + {NULL, NULL, NULL}, +}; + +#endif + diff --git a/ind.c b/ind.c @@ -39,31 +39,7 @@ * to be handled, if really used. */ -filetype type[] = { - {"default", "9", handlebin}, - {"gph", "1", handlegph}, - {"cgi", "0", handlecgi}, - {"dcgi", "1", handledcgi}, - {"bin", "9", handlebin}, - {"tgz", "9", handlebin}, - {"gz", "9", handlebin}, - {"jpg", "I", handlebin}, - {"gif", "g", handlebin}, - {"png", "I", handlebin}, - {"bmp", "I", handlebin}, - {"txt", "0", handlebin}, - {"vtt", "0", handlebin}, - {"html", "0", handlebin}, - {"htm", "0", handlebin}, - {"xhtml", "0", handlebin}, - {"css", "0", handlebin}, - {"md", "0", handlebin}, - {"c", "0", handlebin}, - {"sh", "0", handlebin}, - {"patch", "0", handlebin}, - {"meme", "0", handlebin}, - {NULL, NULL, NULL}, -}; +#include "filetypes.h" int pendingbytes(int sock)