summaryrefslogtreecommitdiff
path: root/src/libtipidee/tipidee_response_header_preparebuiltin.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-10-24 09:59:08 +0000
committerLaurent Bercot <ska@appnovation.com>2023-10-24 09:59:08 +0000
commit37d2f8cb438f68eaa1da8a56ea9ce5023091f128 (patch)
tree81672ad4254ea18e7d240230ba47ef6743d491ad /src/libtipidee/tipidee_response_header_preparebuiltin.c
parent907f1c64369095b5b2d5f6fb23a8b937720d94cc (diff)
downloadtipidee-37d2f8cb438f68eaa1da8a56ea9ce5023091f128.tar.xz
Full custom header support, switch not made yet
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_response_header_preparebuiltin.c')
-rw-r--r--src/libtipidee/tipidee_response_header_preparebuiltin.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_response_header_preparebuiltin.c b/src/libtipidee/tipidee_response_header_preparebuiltin.c
new file mode 100644
index 0000000..a04b666
--- /dev/null
+++ b/src/libtipidee/tipidee_response_header_preparebuiltin.c
@@ -0,0 +1,28 @@
+/* ISC license. */
+
+#include <stdint.h>
+#include <string.h>
+
+#include <tipidee/response.h>
+
+int tipidee_response_header_preparebuiltin (tipidee_response_header *tab, uint32_t n, char const *s, size_t len)
+{
+ size_t pos = 0 ;
+ for (uint32_t i = 0 ; i < n ; i++)
+ {
+ char const *next ;
+ tab[i].key = s + pos ;
+ next = memchr(s + pos, 0, len - pos) ;
+ if (!next) return 0 ;
+ pos = next - s ;
+ if (pos++ >= len) return 0 ;
+ tab[i].options = (uint8_t)s[pos] ;
+ if (pos++ >= len) return 0 ;
+ tab[i].value = s + pos ;
+ next = memchr(s + pos, 0, len - pos) ;
+ if (!next) return 0 ;
+ pos = next - s ;
+ if (pos++ >= len) return 0 ;
+ }
+ return pos == len ;
+}