-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathechttp_hash.h
52 lines (37 loc) · 1.4 KB
/
echttp_hash.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
/* echttp - Embedded HTTP server.
*
* A minimal HTTP server library designed for simplicity and embedding in
* existing applications.
* This module implements the mechanism used to map names to values. This is
* used for query parameters, HTTP attributes, etc.
*/
#include "time.h"
typedef struct {
const char *name;
void *value;
unsigned int signature;
time_t timestamp;
int next;
} echttp_symbol;
#define ECHTTP_HASH 127
#define ECHTTP_MAX_SYMBOL 256
typedef struct {
int count;
int index[ECHTTP_HASH];
echttp_symbol item[ECHTTP_MAX_SYMBOL];
} echttp_hash;
typedef int echttp_hash_action (int i, const char *name);
unsigned int echttp_hash_signature (const char *name);
void echttp_hash_reset (echttp_hash *d, echttp_hash_action *action);
int echttp_hash_find (echttp_hash *d, const char *name);
int echttp_hash_next (echttp_hash *d, int from, const char *name);
int echttp_hash_add (echttp_hash *d, const char *name);
int echttp_hash_insert (echttp_hash *d, const char *name);
int echttp_hash_iterate (echttp_hash *d,
const char *name, echttp_hash_action *action);
// Compatibility API, to be phased out.
//
void echttp_hash_set (echttp_hash *d, const char *name, void *value);
void *echttp_hash_refresh
(echttp_hash *d, const char *name, void *value, time_t timestamp);
void *echttp_hash_get (echttp_hash *d, const char *name);