1 : #ifndef MATCH_CON_H
2 : #define MATCH_CON_H 1
3 :
4 : #define HTTPD_CONF_MAIN_MATCH_CON 1
5 : #define HTTPD_CONF_MAIN_MATCH_REQ 2
6 : #define HTTPD_CONF_MAIN_MATCH_RESP 3
7 :
8 : #define HTTPD_POLICY_CON_POLICY 3
9 : #define HTTPD_POLICY_REQ_POLICY 4
10 :
11 : #define HTTPD_POLICY_CLIENT_IPV4_CIDR_EQ 5
12 : #define HTTPD_POLICY_SERVER_IPV4_CIDR_EQ 6
13 :
14 :
15 : static inline int httpd__match_iter_beg(Conf_parse *conf, Conf_token *token,
16 : Vstr_ref **ret_ref,
17 : unsigned int *ret_num)
18 : COMPILE_ATTR_NONNULL_A() COMPILE_ATTR_WARN_UNUSED_RET();
19 : static inline int httpd__match_iter_beg(Conf_parse *conf, Conf_token *token,
20 : Vstr_ref **ret_ref,
21 : unsigned int *ret_num)
22 774176 : {
23 774176 : *ret_ref = NULL;
24 774176 : *ret_num = 0;
25 :
26 774176 : if (!token->num)
27 27340 : return (FALSE);
28 :
29 746836 : *ret_ref = conf_token_get_user_value(conf, token, ret_num);
30 :
31 746836 : return (TRUE);
32 : }
33 :
34 : static inline int httpd__match_iter_nxt(Conf_parse *conf, Conf_token *token,
35 : Vstr_ref **ret_ref,
36 : unsigned int *ret_num)
37 : COMPILE_ATTR_NONNULL_A() COMPILE_ATTR_WARN_UNUSED_RET();
38 :
39 : static inline int httpd__match_iter_nxt(Conf_parse *conf, Conf_token *token,
40 : Vstr_ref **ret_ref,
41 : unsigned int *ret_num)
42 742760 : {
43 742760 : Conf_token *update = NULL;
44 :
45 742760 : if (!*ret_num)
46 27340 : token->num = 0;
47 : else
48 : {
49 715420 : if (*ret_ref)
50 : {
51 715420 : update = (*ret_ref)->ptr;
52 715420 : *token = *update;
53 715420 : if (update->num == *ret_num)
54 715110 : update = NULL;
55 : }
56 :
57 715420 : if (!conf_parse_num_token(conf, token, *ret_num))
58 0 : token = NULL;
59 :
60 715420 : if (update && token)
61 310 : *update = *token;
62 : }
63 :
64 742760 : vstr_ref_del(*ret_ref); *ret_ref = NULL;
65 :
66 742760 : if (!token)
67 0 : return (FALSE);
68 :
69 742760 : return (httpd__match_iter_beg(conf, token, ret_ref, ret_num));
70 : }
71 :
72 : static inline const Httpd_policy_opts *httpd__policy_build(struct Con *con,
73 : Conf_parse *conf,
74 : Conf_token *token,
75 : unsigned int utype)
76 150 : {
77 150 : Opt_serv_policy_opts *policy = NULL;
78 150 : Vstr_ref *ref = NULL;
79 : Conf_token save;
80 :
81 150 : save = *token;
82 150 : CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);
83 150 : if (!(policy = opt_policy_conf_find(con->policy->s->beg, conf, token)))
84 64 : return (NULL);
85 :
86 86 : ref = policy->ref;
87 86 : if (!conf_token_set_user_value(conf, &save, utype, ref, token->num))
88 0 : return (NULL);
89 :
90 86 : return ((const Httpd_policy_opts *)policy);
91 : }
92 :
93 :
94 : #endif
|