-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_header.c
More file actions
40 lines (33 loc) · 837 Bytes
/
http_header.c
File metadata and controls
40 lines (33 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* license: MIT license
* Copyright (C) 2021 Edward LEI <edward_lei72@hotmail.com> */
#include <stdio.h>
#include <string.h>
#include "xmalloc.h"
#include "http_header.h"
#define DEBUG
#include "debug.h"
httpheader_t *httpheader_new()
{
httpheader_t *header = xmalloc(sizeof(httpheader_t));
return header;
}
void httpheader_delete(void *data)
{
httpheader_t *header = (httpheader_t *)data;
if (header) {
if (header->kvpair) xfree(header->kvpair);
}
xfree(data);
}
int httpheader_compare(const void *curr,
const void *header)
{
char *s1 = ((httpheader_t *)curr)->kvpair;
char *s2 = ((httpheader_t *)header)->kvpair;
return strcmp(s1, s2);
}
void httpheader_print(const void *header)
{
httpheader_t *p = (httpheader_t *)header;
D_PRINT("[HEADER] %s: %s\n", p->kvpair, p->value);
}