From dc0f2ce9ba97ebb47e05b80a511da6eb29818b63 Mon Sep 17 00:00:00 2001 From: Shav Kinderlehrer Date: Tue, 23 Jul 2024 17:48:28 -0400 Subject: Merge old-molehole --- include/response.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 include/response.h (limited to 'include/response.h') 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 -- cgit v1.2.3