A small http server written in C
git clone git://git.janzachar.dev/shttp.git
0#include "super.h"1#include <string.h>2#include <stdlib.h>34void header_push(struct hs *hs, const char *key, const char *value)5{6 if (hs->head == hs->size) {7 hs->size += HEADER_BLOCK;8 hs->item = (struct header*)realloc(hs->item, sizeof(struct header) * hs->size);9 }1011 hs->item[hs->head].key = key;12 hs->item[hs->head].value = value;13 hs->head++;14}1516const char *header_find(struct hs *hs, const char *key)17{18 for (int i = 0; i < hs->head; i++)19 if (!strcmp(hs->item[i].key, key))20 return hs->item[i].value;2122 return NULL;23}242526struct header header_pop(struct hs *hs)27{28 if (!hs->head) return (struct header){NULL, NULL};29 return hs->item[--hs->head];30}3132void header_free(struct hs *hs) {33 free(hs->item);34}35