aboutsummaryrefslogtreecommitdiff
path: root/include/response.h
diff options
context:
space:
mode:
authorShav Kinderlehrer <[email protected]>2024-07-23 17:48:28 -0400
committerShav Kinderlehrer <[email protected]>2024-07-23 17:48:28 -0400
commitdc0f2ce9ba97ebb47e05b80a511da6eb29818b63 (patch)
treedc83035069f5a015047be1ca3da6f65781eb4695 /include/response.h
parentf638f4bd1e3a03bc2bdd5f9dcd57d4830fd3c553 (diff)
downloadmolehole-dc0f2ce9ba97ebb47e05b80a511da6eb29818b63.tar.gz
molehole-dc0f2ce9ba97ebb47e05b80a511da6eb29818b63.zip
Merge old-moleholencurses
Diffstat (limited to 'include/response.h')
-rwxr-xr-xinclude/response.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/response.h b/include/response.h
new file mode 100755
index 0000000..e4242a5
--- /dev/null
+++ b/include/response.h
@@ -0,0 +1,50 @@
+#ifndef _RESPONSE_H_
+#define _RESPONSE_H_
+
+enum ResponseStatus {
+ SUCCESS = 10,
+ CONTENT_UNCHANGED = 11,
+
+ PERMANENT_REDIRECT = 20,
+ TEMPORARY_REDIRECT = 21,
+
+ MALFORMED_REQUEST = 30,
+ INVALID_REQUEST = 31,
+ NOT_AVAILABLE = 32,
+
+ INTERNAL_ERROR = 40,
+ NOT_SUPPORTED = 41,
+ SLOW_DOWN = 42,
+
+ CLIENT_CERTIFICATE_REQUIRED = 50
+};
+
+struct mime_type {
+ char *type;
+ char *subtype;
+};
+
+struct response {
+ enum ResponseStatus status;
+ char *message;
+ struct mime_type type;
+ unsigned int length;
+ char *hash;
+ char *content;
+};
+
+/**
+ * Parses a string into a `struct response`.
+ */
+int parse_response(struct response *res, char *s);
+
+/**
+ * Deallocates `struct response *res`.
+ */
+void free_response(struct response *res);
+
+enum ResponseError {
+ INVALID_STATUS = -1,
+ UNKNOWN_KEY = -2,
+};
+#endif