#ifndef vger_h_INCLUDED #define vger_h_INCLUDED /* length of "gemini://" */ #define GEMINI_PART 9 /* * number of bytes to read with fgets() : 2014 + 1. * fgets() reads at most size-1 (1024 here). * See https://gemini.circumlunar.space/docs/specification.html. */ #define GEMINI_REQUEST_MAX 1025 /* max subexpression in regex : 3 + 1 */ #define SE_MAX 4 /* gemini_regex: * ============= * ^gemini://+ : in case of gemini:/// * 1: hostname * ([^/|^\?|^:]*) : * catch everything, stop when /, ? or : is found * don't catch :port * [:[0-9]*]? : skip :1234 (port number) if any * / * : skip "/" if any * 2: path * ([^\?]*) : * catch everything and stop at ? if any * 3 : query * [\?]?(.*)$: * catch everything after ? if any */ static const char *_gemini_regex = "^gemini://+([^/|^\?|^:]*)[:[0-9]*]?/*([^\?]*)[\?]?(.*)$"; /* global vars */ static int _retcode = 0; static ssize_t _datasiz = 0; static char _request[GEMINI_REQUEST_MAX] = {'\0'}; /* functions */ ssize_t autoindex(const char *); void cgi(const char *); char * read_request(char *); void check_path(char *, size_t); ssize_t display_file(const char *); int do_cgi(const char *, const char *, const char *, const char *); void drop_privileges(const char *); void set_rootdir(const char *, const char *, const char *); void remove_double_dot(char *); void split_request(const char *, char *, char *, char *); void status(const int, const char *, ...); void stop(const int, const char *, ...); int uridecode (char *); #endif // vger_h_INCLUDED