Sun, 19 Feb 2017 11:56:39 +0100
adds new tool for webserver control
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
44
3da1f7b6847f
added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
4 | * Copyright 2013 Olaf Wintermann. All rights reserved. |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "common.h" |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include "../daemon/httprequest.h" |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include "../daemon/log.h" |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | |
154
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
34 | #include "../util/pblock.h" |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
35 | #include "../util/util.h" |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
36 | #include "../../ucx/map.h" |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
37 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
38 | static UcxMap *var_names; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
39 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
40 | enum SAFVarNames { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
41 | COMMONSAF_INSERT_CLIENT = 0, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
42 | COMMONSAF_INSERT_VARS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
43 | COMMONSAF_INSERT_REQPB, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
44 | COMMONSAF_INSERT_HEADERS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
45 | COMMONSAF_INSERT_SRVHDRS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
46 | COMMONSAF_SET_CLIENT, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
47 | COMMONSAF_SET_VARS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
48 | COMMONSAF_SET_REQPB, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
49 | COMMONSAF_SET_HEADERS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
50 | COMMONSAF_SET_SRVHDRS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
51 | COMMONSAF_REMOVE_CLIENT, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
52 | COMMONSAF_REMOVE_VARS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
53 | COMMONSAF_REMOVE_REQPB, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
54 | COMMONSAF_REMOVE_HEADERS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
55 | COMMONSAF_REMOVE_SRVHDRS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
56 | COMMONSAF_ABORT, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
57 | COMMONSAF_NOACTION, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
58 | COMMONSAF_ERROR, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
59 | COMMONSAF_ESCAPE, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
60 | COMMONSAF_FIND_PATHINFO_FORWARD, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
61 | COMMONSAF_HTTP_DOWNGRADE, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
62 | COMMONSAF_HTTP_UPGRADE, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
63 | COMMONSAF_KEEP_ALIVE, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
64 | COMMONSAF_NAME, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
65 | COMMONSAF_SENTHDRS, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
66 | COMMONSAF_STOP, |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
67 | COMMONSAF_URL |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
68 | }; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
69 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
70 | #define COMMONSAF_RET_DEF 0 |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
71 | #define COMMONSAF_RET_NOACTION 1 |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
72 | #define COMMONSAF_RET_STOP 2 |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
73 | #define COMMONSAF_REQ_ABORTED -1 |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
74 | #define COMMONSAF_RET_ERROR -2 |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
75 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
76 | void common_saf_init() { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
77 | var_names = ucx_map_new(12); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
78 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
79 | ucx_map_cstr_put(var_names, "insert-client", (intptr_t)COMMONSAF_INSERT_CLIENT); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
80 | ucx_map_cstr_put(var_names, "insert-vars", (intptr_t)COMMONSAF_INSERT_VARS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
81 | ucx_map_cstr_put(var_names, "insert-reqpb", (intptr_t)COMMONSAF_INSERT_REQPB); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
82 | ucx_map_cstr_put(var_names, "insert-headers", (intptr_t)COMMONSAF_INSERT_HEADERS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
83 | ucx_map_cstr_put(var_names, "insert-srvhdrs", (intptr_t)COMMONSAF_INSERT_SRVHDRS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
84 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
85 | ucx_map_cstr_put(var_names, "set-client", (intptr_t)COMMONSAF_SET_CLIENT); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
86 | ucx_map_cstr_put(var_names, "set-vars", (intptr_t)COMMONSAF_SET_VARS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
87 | ucx_map_cstr_put(var_names, "set-reqpb", (intptr_t)COMMONSAF_SET_REQPB); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
88 | ucx_map_cstr_put(var_names, "set-headers", (intptr_t)COMMONSAF_SET_HEADERS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
89 | ucx_map_cstr_put(var_names, "set-srvhdrs", (intptr_t)COMMONSAF_SET_SRVHDRS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
90 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
91 | ucx_map_cstr_put(var_names, "remove-client", (intptr_t)COMMONSAF_REMOVE_CLIENT); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
92 | ucx_map_cstr_put(var_names, "remove-vars", (intptr_t)COMMONSAF_REMOVE_VARS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
93 | ucx_map_cstr_put(var_names, "remove-reqpb", (intptr_t)COMMONSAF_REMOVE_REQPB); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
94 | ucx_map_cstr_put(var_names, "remove-headers", (intptr_t)COMMONSAF_REMOVE_HEADERS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
95 | ucx_map_cstr_put(var_names, "remove-srvhdrs", (intptr_t)COMMONSAF_REMOVE_SRVHDRS); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
96 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
97 | ucx_map_cstr_put(var_names, "abort", (intptr_t)COMMONSAF_ABORT); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
98 | ucx_map_cstr_put(var_names, "noaction", (intptr_t)COMMONSAF_NOACTION); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
99 | ucx_map_cstr_put(var_names, "error", (intptr_t)COMMONSAF_ERROR); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
100 | ucx_map_cstr_put(var_names, "escape", (intptr_t)COMMONSAF_ESCAPE); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
101 | ucx_map_cstr_put(var_names, "find-pathinfo-forward", (intptr_t)COMMONSAF_FIND_PATHINFO_FORWARD); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
102 | ucx_map_cstr_put(var_names, "http-downgrade", (intptr_t)COMMONSAF_HTTP_DOWNGRADE); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
103 | ucx_map_cstr_put(var_names, "http-upgrade", (intptr_t)COMMONSAF_HTTP_UPGRADE); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
104 | ucx_map_cstr_put(var_names, "keep-alive", (intptr_t)COMMONSAF_KEEP_ALIVE); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
105 | ucx_map_cstr_put(var_names, "name", (intptr_t)COMMONSAF_NAME); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
106 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
107 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | int print_message(pblock *pb, Session *sn, Request *rq) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | char *msg = pblock_findval("msg", pb); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | if(msg) { |
60
feb2f1e115c6
improved logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
111 | log_ereport(LOG_INFORM, "%s", msg); |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | return REQ_NOACTION; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | } |
154
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
116 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
117 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
118 | static int set_var(Session *sn, Request *rq, char *var, char *value) { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
119 | intptr_t v = (intptr_t)ucx_map_cstr_get(var_names, var); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
120 | switch(v) { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
121 | default: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
122 | case COMMONSAF_INSERT_CLIENT: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
123 | case COMMONSAF_INSERT_VARS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
124 | case COMMONSAF_INSERT_REQPB: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
125 | case COMMONSAF_INSERT_HEADERS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
126 | case COMMONSAF_INSERT_SRVHDRS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
127 | case COMMONSAF_SET_CLIENT: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
128 | case COMMONSAF_SET_VARS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
129 | case COMMONSAF_SET_REQPB: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
130 | case COMMONSAF_SET_HEADERS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
131 | case COMMONSAF_SET_SRVHDRS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
132 | case COMMONSAF_REMOVE_CLIENT: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
133 | case COMMONSAF_REMOVE_VARS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
134 | case COMMONSAF_REMOVE_HEADERS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
135 | case COMMONSAF_REMOVE_SRVHDRS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
136 | case COMMONSAF_ABORT: return COMMONSAF_REQ_ABORTED; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
137 | case COMMONSAF_ERROR: { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
138 | return COMMONSAF_REQ_ABORTED; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
139 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
140 | case COMMONSAF_ESCAPE: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
141 | case COMMONSAF_FIND_PATHINFO_FORWARD: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
142 | case COMMONSAF_HTTP_DOWNGRADE: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
143 | case COMMONSAF_HTTP_UPGRADE: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
144 | case COMMONSAF_KEEP_ALIVE: { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
145 | rq->rq_attr.keep_alive = util_getboolean(var, 0); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
146 | break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
147 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
148 | case COMMONSAF_NAME: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
149 | case COMMONSAF_SENTHDRS: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
150 | case COMMONSAF_STOP: return COMMONSAF_RET_STOP; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
151 | case COMMONSAF_URL: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
152 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
153 | return COMMONSAF_RET_DEF; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
154 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
155 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
156 | int set_variable(pblock *pb, Session *sn, Request *rq) { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
157 | int ret = REQ_NOACTION; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
158 | int set = 0; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
159 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
160 | for(int i=0;i<pb->hsize;i++) { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
161 | pb_entry *entry = pb->ht[i]; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
162 | while(entry) { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
163 | int r = set_var(sn, rq, entry->param->name, entry->param->value); |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
164 | switch(r) { |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
165 | default: |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
166 | case COMMONSAF_RET_DEF: break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
167 | case COMMONSAF_RET_NOACTION: set = 1; ret = REQ_NOACTION; break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
168 | case COMMONSAF_RET_STOP: set = 1; ret = REQ_PROCEED; break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
169 | case COMMONSAF_REQ_ABORTED: ret = set ? ret : REQ_ABORTED; break; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
170 | case COMMONSAF_RET_ERROR: return REQ_ABORTED; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
171 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
172 | entry = entry->next; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
173 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
174 | } |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
175 | |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
176 | return ret; |
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
177 | } |