-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
83 lines (65 loc) · 1.54 KB
/
utils.h
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <syslog.h>
#include <stdint.h>
#include <unistd.h>
#ifndef UTILS_H_
#define UTILS_H_
#ifdef __cplusplus
extern "C" {
#endif
struct lal_entry {
const char* key;
size_t keylen;
const char *val;
size_t vallen;
struct lal_entry *next;
};
struct lal_body_part {
const char *val;
size_t len;
struct lal_body_part *next;
struct lal_body_part *prev;
};
enum lal_content_type {
TEXT,
HTML,
JSON,
NONE
};
const char *
lal_content_type_to_string(enum lal_content_type t);
void
lal_url_decode(char *dst, const char *src);
void
lal_parse_url_encoded_entries(struct lal_entry *entry, const char *body);
struct lal_entry *
lal_new_entry();
struct lal_entry *
lal_append_to_entries(struct lal_entry *entry, const char *key, const char *val);
const char *
lal_get_entry(struct lal_entry *entry, const char *key);
struct lal_body_part *
lal_new_body_part();
struct lal_body_part *
lal_create_body_part(const char *init);
struct lal_body_part *
lal_append_to_body(struct lal_body_part *part, const char *src);
struct lal_body_part *
lal_nappend_to_body(struct lal_body_part *part, const uint8_t *src, size_t len);
struct lal_body_part *
lal_prepend_to_body(struct lal_body_part *part, const char *src);
size_t
lal_body_len(struct lal_body_part *part);
char *
lal_join_body(struct lal_body_part *body, const char *separator);
void
lal_destroy_entries(struct lal_entry *entries);
void
lal_destroy_body(struct lal_body_part *body);
#ifdef __cplusplus
}
#endif
#endif // UTILS_H_