summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/tipidee/body.h25
-rw-r--r--src/include/tipidee/conf.h44
-rw-r--r--src/include/tipidee/headers.h38
-rw-r--r--src/include/tipidee/method.h32
-rw-r--r--src/include/tipidee/response.h36
-rw-r--r--src/include/tipidee/rql.h31
-rw-r--r--src/include/tipidee/tipidee.h15
-rw-r--r--src/include/tipidee/uri.h31
8 files changed, 252 insertions, 0 deletions
diff --git a/src/include/tipidee/body.h b/src/include/tipidee/body.h
new file mode 100644
index 0000000..fc8bd9a
--- /dev/null
+++ b/src/include/tipidee/body.h
@@ -0,0 +1,25 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_BODY_H
+#define TIPIDEE_BODY_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <skalibs/buffer.h>
+#include <skalibs/tai.h>
+#include <skalibs/stralloc.h>
+
+typedef enum tipidee_transfercoding_e tipidee_transfercoding, *tipidee_transfercoding_ref ;
+enum tipidee_transfercoding_e
+{
+ TIPIDEE_TRANSFERCODING_NONE = 0,
+ TIPIDEE_TRANSFERCODING_FIXED,
+ TIPIDEE_TRANSFERCODING_CHUNKED,
+ TIPIDEE_TRANSFERCODING_UNKNOWN
+} ;
+
+extern int tipidee_chunked_read (buffer *, stralloc *, size_t, tain const *, tain *) ;
+#define tipidee_chunked_read_g(b, sa, max, deadline) tipidee_chunked_read(b, sa, max, (deadline), &STAMP)
+
+#endif
diff --git a/src/include/tipidee/conf.h b/src/include/tipidee/conf.h
new file mode 100644
index 0000000..bc66d76
--- /dev/null
+++ b/src/include/tipidee/conf.h
@@ -0,0 +1,44 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_CONF_H
+#define TIPIDEE_CONF_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <skalibs/uint16.h>
+#include <skalibs/cdb.h>
+
+#include <tipidee/uri.h>
+
+#define TIPIDEE_CONF_KEY_MAXLEN 0x1000U
+
+typedef struct tipidee_conf_s tipidee_conf, *tipidee_conf_ref ;
+struct tipidee_conf_s
+{
+ cdb c ;
+} ;
+#define TIPIDEE_CONF_ZERO { .c = CDB_ZERO }
+
+typedef struct tipidee_redirection_s tipidee_redirection, *tipidee_redirection_ref ;
+struct tipidee_redirection_s
+{
+ char const *location ;
+ char const *sub ;
+ uint32_t type : 2 ;
+} ;
+#define TIPIDEE_REDIRECTION_ZERO { .location = 0, .sub = 0, .type = 0 }
+
+extern void tipidee_conf_free (tipidee_conf *) ;
+extern int tipidee_conf_init (tipidee_conf *, char const *) ;
+
+extern int tipidee_conf_get (tipidee_conf const *, char const *, cdb_data *) ;
+extern char const *tipidee_conf_get_string (tipidee_conf const *, char const *) ;
+extern int tipidee_conf_get_uint32 (tipidee_conf const *, char const *, uint32_t *) ;
+extern unsigned int tipidee_conf_get_argv (tipidee_conf const *, char const *, char const **, unsigned int, size_t *) ;
+
+extern char const *tipidee_conf_get_docroot (tipidee_conf const *, tipidee_uri const *, uint16_t) ;
+extern int tipidee_conf_get_redirection (tipidee_conf const *, char const *, size_t, tipidee_redirection *) ;
+extern char const *tipidee_conf_get_content_type (tipidee_conf const *, char const *) ;
+
+#endif
diff --git a/src/include/tipidee/headers.h b/src/include/tipidee/headers.h
new file mode 100644
index 0000000..420b4c9
--- /dev/null
+++ b/src/include/tipidee/headers.h
@@ -0,0 +1,38 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_HEADERS_H
+#define TIPIDEE_HEADERS_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <skalibs/disize.h>
+#include <skalibs/buffer.h>
+#include <skalibs/tai.h>
+#include <skalibs/avltreen.h>
+
+#define TIPIDEE_HEADERS_MAX 32
+
+typedef struct tipidee_headers_s tipidee_headers, *tipidee_headers_ref ;
+struct tipidee_headers_s
+{
+ char *buf ;
+ size_t max ;
+ size_t len ;
+ disize list[TIPIDEE_HEADERS_MAX] ;
+ avltreen map ;
+ uint32_t map_freelist[TIPIDEE_HEADERS_MAX] ;
+ avlnode map_storage[TIPIDEE_HEADERS_MAX] ;
+ uint32_t n ;
+} ;
+
+extern void tipidee_headers_init (tipidee_headers *, char *, size_t) ;
+
+extern int tipidee_headers_parse_nb (buffer *, tipidee_headers *, disize *, uint32_t *) ;
+extern int tipidee_headers_timed_parse (buffer *, tipidee_headers *, tain const *, tain *) ;
+#define tipidee_headers_timed_parse_g(b, hdr, deadline) tipidee_headers_timed_parse(b, hdr, (deadline), &STAMP)
+
+extern char const *tipidee_headers_search (tipidee_headers const *, char const *) ;
+extern ssize_t tipidee_headers_get_content_length (tipidee_headers const *) ;
+
+#endif
diff --git a/src/include/tipidee/method.h b/src/include/tipidee/method.h
new file mode 100644
index 0000000..05123e8
--- /dev/null
+++ b/src/include/tipidee/method.h
@@ -0,0 +1,32 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_METHOD_H
+#define TIPIDEE_METHOD_H
+
+typedef enum tipidee_method_e tipidee_method, *tipidee_method_ref ;
+enum tipidee_method_e
+{
+ TIPIDEE_METHOD_GET = 0,
+ TIPIDEE_METHOD_HEAD,
+ TIPIDEE_METHOD_OPTIONS,
+ TIPIDEE_METHOD_POST,
+ TIPIDEE_METHOD_PUT,
+ TIPIDEE_METHOD_DELETE,
+ TIPIDEE_METHOD_TRACE,
+ TIPIDEE_METHOD_CONNECT,
+ TIPIDEE_METHOD_PRI,
+ TIPIDEE_METHOD_UNKNOWN
+} ;
+
+typedef struct tipidee_method_conv_s tipidee_method_conv, *tipidee_method_conv_ref ;
+struct tipidee_method_conv_s
+{
+ tipidee_method num ;
+ char const *str ;
+} ;
+
+extern tipidee_method_conv const *tipidee_method_conv_table ;
+extern char const *tipidee_method_tostr (tipidee_method) ;
+extern tipidee_method tipidee_method_tonum (char const *) ;
+
+#endif
diff --git a/src/include/tipidee/response.h b/src/include/tipidee/response.h
new file mode 100644
index 0000000..e0a6177
--- /dev/null
+++ b/src/include/tipidee/response.h
@@ -0,0 +1,36 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_RESPONSE_H
+#define TIPIDEE_RESPONSE_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <skalibs/gccattributes.h>
+#include <skalibs/buffer.h>
+#include <skalibs/strerr.h>
+#include <skalibs/tai.h>
+
+#include <tipidee/rql.h>
+
+typedef struct tipidee_response_header_builtin_s tipidee_response_header_builtin, *tipidee_response_header_builtin_ref ;
+struct tipidee_response_header_builtin_s
+{
+ char const *key ;
+ char const *value ;
+} ;
+
+extern size_t tipidee_response_status (buffer *, tipidee_rql const *, unsigned int, char const *) ;
+#define tipidee_response_status_line(b, rql, line) tipidee_response_status(b, rql, 0, (line))
+
+extern size_t tipidee_response_header_date_fmt (char *, size_t, tain const *) ;
+#define tipidee_response_header_date_fmt_g(buf, max) tipidee_response_header_date_fmt(buf, (max), &STAMP)
+extern size_t tipidee_response_header_common_put (buffer *, uint32_t, tain const *) ;
+#define tipidee_response_header_common_put_g(b, options) tipidee_response_header_common_put(b, (options), &STAMP)
+
+extern size_t tipidee_response_error (buffer *, tipidee_rql const *, char const *, char const *, uint32_t) ;
+
+extern tipidee_response_header_builtin const *tipidee_response_header_builtin_table ;
+extern char const *tipidee_response_header_builtin_search (char const *) ;
+
+#endif
diff --git a/src/include/tipidee/rql.h b/src/include/tipidee/rql.h
new file mode 100644
index 0000000..471c4ad
--- /dev/null
+++ b/src/include/tipidee/rql.h
@@ -0,0 +1,31 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_RQL_H
+#define TIPIDEE_RQL_H
+
+#include <skalibs/buffer.h>
+#include <skalibs/tai.h>
+
+#include <tipidee/method.h>
+#include <tipidee/uri.h>
+
+typedef struct tipidee_rql_s tipidee_rql, *tipidee_rql_ref ;
+struct tipidee_rql_s
+{
+ tipidee_method m ;
+ unsigned int http_major ;
+ unsigned int http_minor ;
+ tipidee_uri uri ;
+} ;
+#define TIPIDEE_RQL_ZERO \
+{ \
+ .m = TIPIDEE_METHOD_UNKNOWN, \
+ .http_major = 0, \
+ .http_minor = 0, \
+ .uri = TIPIDEE_URI_ZERO \
+}
+
+extern int tipidee_rql_read (buffer *, char *, size_t, size_t *, tipidee_rql *, tain const *, tain *) ;
+#define tipidee_rql_read_g(b, buf, max, w, rql, deadline) tipidee_rql_read(b, buf, max, w, rql, (deadline), &STAMP)
+
+#endif
diff --git a/src/include/tipidee/tipidee.h b/src/include/tipidee/tipidee.h
new file mode 100644
index 0000000..ddd1348
--- /dev/null
+++ b/src/include/tipidee/tipidee.h
@@ -0,0 +1,15 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_H
+#define TIPIDEE_H
+
+#include <tipidee/body.h>
+#include <tipidee/config.h>
+#include <tipidee/conf.h>
+#include <tipidee/headers.h>
+#include <tipidee/method.h>
+#include <tipidee/response.h>
+#include <tipidee/rql.h>
+#include <tipidee/uri.h>
+
+#endif
diff --git a/src/include/tipidee/uri.h b/src/include/tipidee/uri.h
new file mode 100644
index 0000000..6e5148b
--- /dev/null
+++ b/src/include/tipidee/uri.h
@@ -0,0 +1,31 @@
+/* ISC license. */
+
+#ifndef TIPIDEE_URI_H
+#define TIPIDEE_URI_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct tipidee_uri_s tipidee_uri, *tipidee_uri_ref ;
+struct tipidee_uri_s
+{
+ char const *host ;
+ char const *path ;
+ char const *query ;
+ size_t lastslash ;
+ uint16_t port ;
+ uint8_t https : 1 ;
+} ;
+#define TIPIDEE_URI_ZERO \
+{ \
+ .host = 0, \
+ .path = 0, \
+ .query = 0, \
+ .lastslash = 0, \
+ .port = 0, \
+ .https = 0 \
+}
+
+extern size_t tipidee_uri_parse (char *, size_t, char const *, tipidee_uri *) ;
+
+#endif