phroxy

Gopher to HTTP proxy
git clone git://git.z3bra.org/phroxy.git
Log | Files | Refs | LICENSE

commit 6ceb8388d1a86ed1bc3a2fc6131fa4b7f8641a39
parent 2c74d506ef51934700306ade00e35cf380d35d30
Author: Willy Goiffon <dev@z3bra.org>
Date:   Thu, 24 Sep 2020 11:55:33 +0200

Make item names configurable

Diffstat:
Mconfig.def.h | 16++++++++++++++++
Mphroxy.c | 48+++++++++++++++++++++++++++++++++---------------
2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -10,3 +10,19 @@ const char *head = "<body>\n"; const char *foot = "</body></html>\n"; +const char *items[] = { + [ITEM_0] = "📄", + [ITEM_1] = "📂", + [ITEM_2] = "☎️", + [ITEM_3] = "3", + [ITEM_4] = "4", + [ITEM_5] = "5", + [ITEM_6] = "6", + [ITEM_7] = "?", + [ITEM_8] = "8", + [ITEM_9] = "📦", + [ITEM_I] = "📷", + [ITEM_g] = "🎥", + [ITEM_h] = "⛓", + [ITEM_s] = "🔊", +}; diff --git a/phroxy.c b/phroxy.c @@ -13,6 +13,24 @@ #include <sys/socket.h> #include <sys/socket.h> +/* supported items */ +enum { + ITEM_0, + ITEM_1, + ITEM_2, + ITEM_3, + ITEM_4, + ITEM_5, + ITEM_6, + ITEM_7, + ITEM_8, + ITEM_9, + ITEM_I, + ITEM_g, + ITEM_h, + ITEM_s, +}; + #include "config.h" void * @@ -189,24 +207,24 @@ contenttype(char i, char *path) return NULL; } -char * +const char * itemname(char i) { switch(i) { - case '0': return "TXT"; - case '1': return "DIR"; - case '2': return "CSO"; - case '3': return "ERR"; - case '4': return "MAC"; - case '5': return "WIN"; - case '6': return "UUE"; - case '7': return "QRY"; - case '8': return "TNT"; - case '9': return "BIN"; - case 'I': return "IMG"; - case 'g': return "GIF"; - case 'h': return "URL"; - case 's': return "SND"; + case '0': return items[ITEM_0]; + case '1': return items[ITEM_1]; + case '2': return items[ITEM_2]; + case '3': return items[ITEM_3]; + case '4': return items[ITEM_4]; + case '5': return items[ITEM_5]; + case '6': return items[ITEM_6]; + case '7': return items[ITEM_7]; + case '8': return items[ITEM_8]; + case '9': return items[ITEM_9]; + case 'I': return items[ITEM_I]; + case 'g': return items[ITEM_g]; + case 'h': return items[ITEM_h]; + case 's': return items[ITEM_s]; } return NULL;