2 * Copyright (c) 2021 Matthias Schmidt <xhr@giessen.ccc.de>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <openssl/ssl.h>
22 #define VERSION "2021.a"
23 #define MAXREQLEN 1025
26 int check_gemini_file(const char *);
27 int send_response(SSL*, int, const char *, const char *);
28 int send_non_success_response(SSL*, int);
31 int get_path_from_request(char *, char *);
34 char* get_file_extension(const char*);
35 char* get_mime_type(const char *);
38 void* xmalloc(size_t);
39 char* xstrdup(const char *);
40 size_t strlcpy(char *, const char *, size_t);
44 STATUS_SENSITIVE_INPUT = 11,
46 STATUS_REDIRECT_TEMP = 30,
47 STATUS_REDIRECT_PERM = 31,
48 STATUS_TEMP_UNAVAILABLE = 40,
49 STATUS_SERVER_UNAVAILABLE = 41,
50 STATUS_CGI_ERROR = 42,
51 STATUS_PROXY_ERROR = 43,
52 STATUS_SLOW_DOWN = 44,
53 STATUS_PERM_FAILURE = 50,
54 STATUS_NOT_FOUND = 51,
56 STATUS_PROXY_REQUEST_REFUSED = 53,
57 STATUS_BAD_REQUEST = 59,
58 STATUS_CLIENT_CERT_REQUIRED = 60,
59 STATUS_CERT_NOT_AUTHORIZED = 61,
60 STATUS_CERT_NOT_VALID = 62,