#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 * then skip multiple / * 2: path * ([^\?]*) : * catch everything and stop at ? if any * 3 : query * [\?]?(.*)$: * catch everything after ? if any */ static const char *_gemini_regex = "^gemini://+([^/|^\?]*)/*([^\?]*)[\?]?(.*)$"; /* 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 * check_request(char *); void check_path(char *, size_t, const char *, int); ssize_t display_file(const char *); int do_cgi(const char *, const char *, const char *, const char *, const char *); void drop_privileges(const char *, const char *, const char *); void get_dir_file(char *, char *, size_t, char *, size_t); char * get_hostname(const char *, char *, size_t); char * get_path(const char *, char *, size_t, int, const char *); char * get_query(char *, char *, size_t); void status(const int, const char *, ...); void strip_trailing_slash(char *); int uridecode (char *); void split_request(const char *, char *, char *, char *); void stop(const int, const char *, ...); #endif // vger_h_INCLUDED