blob: db3ff757fd0fb61ae01f62e3fe0a19a3592e6ef9 (
about) (
plain)
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
84
85
|
#ifndef DISFLUID_HEADER_ITERATOR_INCLUDED
# define DISFLUID_HEADER_ITERATOR_INCLUDED
struct disfluid_header_iterator;
static inline
int header_iterator_init_request (struct disfluid_header_iterator *iterator,
const struct disfluid_cache_request
*request);
static inline
void header_iterator_clear (struct disfluid_header_iterator *iterator);
static inline
const char *header_iterator_get_name (const struct disfluid_header_iterator
*iterator);
static inline
const char *header_iterator_get_value (const struct disfluid_header_iterator
*iterator);
static inline
bool header_iterator_next (struct disfluid_header_iterator *iterator);
# include "disfluid-cache-request.h"
struct disfluid_header_iterator
{
const struct disfluid_cache_request *request;
size_t i;
};
static inline int
header_iterator_init (struct disfluid_header_iterator *iterator,
const struct disfluid_cache_request *request)
{
iterator->request = request;
iterator->i = 0;
}
static inline void
header_iterator_clear (struct disfluid_header_iterator *iterator)
{
iterator->request = NULL;
}
/* Before iterating over the other headers, the request produces 1
header: Host. */
static inline const char *
header_iterator_get_name (const struct disfluid_header_iterator *iterator)
{
switch (iterator->i)
{
case 0:
return "Host";
default:
return NULL;
}
}
static inline const char *
header_iterator_get_value (const struct disfluid_header_iterator *iterator)
{
switch (iterator->i)
{
case 0:
return iterator->request->host;
default:
return NULL;
}
}
static inline bool
header_iterator_next (struct disfluid_header_iterator *iterator)
{
if (iterator->i < 1)
{
iterator->i += 1;
return true;
}
return false;
}
#endif /* DISFLUID_HEADER_ITERATOR_INCLUDED */
|