summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gemini.h27
-rw-r--r--include/server.h22
2 files changed, 47 insertions, 2 deletions
diff --git a/include/gemini.h b/include/gemini.h
new file mode 100644
index 0000000..dccaf4e
--- /dev/null
+++ b/include/gemini.h
@@ -0,0 +1,27 @@
+#ifndef GMNISRV_GEMINI_H
+#define GMNISRV_GEMINI_H
+#define GEMINI_MAX_URL 1024
+
+enum gemini_status {
+ GEMINI_STATUS_NONE = 0,
+ GEMINI_STATUS_INPUT = 10,
+ GEMINI_STATUS_SENSITIVE_INPUT = 11,
+ GEMINI_STATUS_SUCCESS = 20,
+ GEMINI_STATUS_REDIRECT_TEMPORARY = 30,
+ GEMINI_STATUS_REDIRECT_PERMANENT = 31,
+ GEMINI_STATUS_TEMPORARY_FAILURE = 40,
+ GEMINI_STATUS_SERVER_UNAVAILABLE = 41,
+ GEMINI_STATUS_CGI_ERROR = 42,
+ GEMINI_STATUS_PROXY_ERROR = 43,
+ GEMINI_STATUS_SLOW_DOWN = 44,
+ GEMINI_STATUS_PERMANENT_FAILURE = 50,
+ GEMINI_STATUS_NOT_FOUND = 51,
+ GEMINI_STATUS_GONE = 52,
+ GEMINI_STATUS_PROXY_REQUEST_REFUSED = 53,
+ GEMINI_STATUS_BAD_REQUEST = 59,
+ GEMINI_STATUS_CLIENT_CERTIFICATE_REQUIRED = 60,
+ GEMINI_STATUS_CERTIFICATE_NOT_AUTHORIZED = 61,
+ GEMINI_STATUS_CERTIFICATE_NOT_VALID = 62,
+};
+
+#endif
diff --git a/include/server.h b/include/server.h
index 5624b52..0317de9 100644
--- a/include/server.h
+++ b/include/server.h
@@ -2,21 +2,39 @@
#define GMNISRV_SERVER
#include <openssl/ssl.h>
#include <poll.h>
+#include <time.h>
#include <stdbool.h>
+#include "gemini.h"
+#include "url.h"
-#define GEMINI_MAX_URL 1024
+struct gmnisrv_server;
+
+enum response_state {
+ RESPOND_HEADER,
+ RESPOND_BODY,
+};
struct gmnisrv_client {
+ struct gmnisrv_server *server;
+ struct timespec ctime;
struct sockaddr addr;
socklen_t addrlen;
int sockfd;
+ struct pollfd *pollfd;
SSL *ssl;
- BIO *bio;
+ BIO *bio, *sbio;
char buf[GEMINI_MAX_URL + 3];
+ size_t bufix, bufln;
+ enum response_state state;
+ enum gemini_status status;
+ char *meta;
+ int bodyfd;
+
struct gmnisrv_host *host;
+ char *path;
};
struct gmisrv_config;