bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / tomcat-connectors-1.2.32-src / native / common / jk_util.h
1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17
18 /***************************************************************************
19  * Description: Various utility functions                                  *
20  * Author:      Gal Shachor <shachor@il.ibm.com>                           *
21  * Author:      Henri Gomez <hgomez@apache.org>                            *
22  * Author:      Rainer Jung <rjung@apache.org>                             *
23  * Version:     $Revision: 751914 $                                          *
24  ***************************************************************************/
25 #ifndef _JK_UTIL_H
26 #define _JK_UTIL_H
27
28 #include "jk_global.h"
29 #include "jk_logger.h"
30 #include "jk_map.h"
31 #include "jk_pool.h"
32 #include "jk_service.h"
33
34 #define JK_SLEEP_DEF     (100)
35
36 const char *jk_get_bool(int v);
37
38 int jk_get_bool_code(const char *v, int def);
39
40 void jk_sleep(int ms);
41
42 void jk_set_time_fmt(jk_logger_t *l, const char *jk_log_fmt);
43
44 int jk_parse_log_level(const char *level);
45
46 int jk_open_file_logger(jk_logger_t **l, const char *file, int level);
47
48 int jk_attach_file_logger(jk_logger_t **l, int fd, int level);
49
50 int jk_close_file_logger(jk_logger_t **l);
51
52 int jk_log(jk_logger_t *l,
53            const char *file, int line, const char *funcname, int level,
54            const char *fmt, ...);
55
56 /* [V] Two general purpose functions. Should ease the function bloat. */
57 int jk_get_worker_str_prop(jk_map_t *m,
58                            const char *wname, const char *pname, const char **prop);
59
60 int jk_get_worker_int_prop(jk_map_t *m,
61                            const char *wname, const char *pname, int *prop);
62
63 const char *jk_get_worker_host(jk_map_t *m, const char *wname, const char *def);
64
65 const char *jk_get_worker_type(jk_map_t *m, const char *wname);
66
67 int jk_get_worker_port(jk_map_t *m, const char *wname, int def);
68
69 int jk_get_worker_cache_size(jk_map_t *m, const char *wname, int def);
70
71 int jk_get_worker_cache_size_min(jk_map_t *m, const char *wname, int def);
72
73 int jk_get_worker_cache_acquire_timeout(jk_map_t *m, const char *wname, int def);
74
75 int jk_get_worker_socket_timeout(jk_map_t *m, const char *wname, int def);
76
77 int jk_get_worker_socket_connect_timeout(jk_map_t *m, const char *wname, int def);
78
79 int jk_get_worker_socket_buffer(jk_map_t *m, const char *wname, int def);
80
81 int jk_get_worker_socket_keepalive(jk_map_t *m, const char *wname, int def);
82
83 int jk_get_worker_conn_ping_interval(jk_map_t *m, const char *wname, int def);
84
85 int jk_get_worker_cache_timeout(jk_map_t *m, const char *wname, int def);
86
87 int jk_get_worker_recovery_opts(jk_map_t *m, const char *wname, int def);
88
89 int jk_get_worker_connect_timeout(jk_map_t *m, const char *wname, int def);
90
91 int jk_get_worker_reply_timeout(jk_map_t *m, const char *wname, int def);
92
93 int jk_get_worker_prepost_timeout(jk_map_t *m, const char *wname, int def);
94
95 int jk_get_worker_ping_timeout(jk_map_t *m, const char *wname, int def);
96
97 int jk_get_worker_ping_mode(jk_map_t *m, const char *wname, int def);
98
99 int jk_get_worker_recycle_timeout(jk_map_t *m, const char *wname, int def);
100
101 int jk_get_worker_recover_timeout(jk_map_t *m, const char *wname, int def);
102
103 int jk_get_worker_error_escalation_time(jk_map_t *m, const char *wname, int def);
104
105 int jk_get_worker_max_reply_timeouts(jk_map_t *m, const char *wname, int def);
106
107 int jk_get_worker_retry_interval(jk_map_t *m, const char *wname, int def);
108
109 const char *jk_get_worker_route(jk_map_t *m, const char *wname, const char *def);
110
111 const char *jk_get_worker_domain(jk_map_t *m, const char *wname, const char *def);
112
113 const char *jk_get_worker_redirect(jk_map_t *m, const char *wname, const char *def);
114
115 const char *jk_get_worker_secret_key(jk_map_t *m, const char *wname);
116
117 const char *jk_get_lb_session_cookie(jk_map_t *m, const char *wname, const char *def);
118
119 const char *jk_get_lb_session_path(jk_map_t *m, const char *wname, const char *def);
120
121 int jk_get_worker_retries(jk_map_t *m, const char *wname, int def);
122
123 int jk_get_is_worker_disabled(jk_map_t *m, const char *wname);
124
125 int jk_get_is_worker_stopped(jk_map_t *m, const char *wname);
126
127 int jk_get_worker_activation(jk_map_t *m, const char *wname);
128
129 int jk_get_worker_list(jk_map_t *m, char ***list, unsigned *num_of_workers);
130
131 int jk_get_lb_factor(jk_map_t *m, const char *wname);
132
133 int jk_get_distance(jk_map_t *m, const char *wname);
134
135 int jk_get_is_sticky_session(jk_map_t *m, const char *wname);
136
137 int jk_get_is_sticky_session_force(jk_map_t *m, const char *wname);
138
139 int jk_get_lb_method(jk_map_t *m, const char *wname);
140
141 int jk_get_lb_lock(jk_map_t *m, const char *wname);
142
143 int jk_get_lb_worker_list(jk_map_t *m,
144                           const char *lb_wname,
145                           char ***list, unsigned int *num_of_workers);
146 int jk_get_worker_mount_list(jk_map_t *m,
147                              const char *wname,
148                              char ***list, unsigned int *num_of_maps);
149 const char *jk_get_worker_secret(jk_map_t *m, const char *wname);
150
151 int jk_get_worker_mx(jk_map_t *m, const char *wname, unsigned *mx);
152
153 int jk_get_worker_ms(jk_map_t *m, const char *wname, unsigned *ms);
154
155 int jk_get_worker_classpath(jk_map_t *m, const char *wname, const char **cp);
156
157
158 int jk_get_worker_bridge_type(jk_map_t *m, const char *wname, unsigned *bt);
159
160 int jk_get_worker_jvm_path(jk_map_t *m, const char *wname, const char **vm_path);
161
162 int jk_get_worker_callback_dll(jk_map_t *m,
163                                const char *wname, const char **cb_path);
164
165 int jk_get_worker_cmd_line(jk_map_t *m, const char *wname, const char **cmd_line);
166
167 int jk_file_exists(const char *f);
168
169 int jk_is_list_property(const char *prp_name);
170
171 int jk_is_path_property(const char *prp_name);
172
173 int jk_is_cmd_line_property(const char *prp_name);
174
175 int jk_is_unique_property(const char *prp_name);
176
177 int jk_is_deprecated_property(const char *prp_name);
178
179 int jk_is_valid_property(const char *prp_name);
180
181 int jk_get_worker_stdout(jk_map_t *m, const char *wname, const char **stdout_name);
182
183 int jk_get_worker_stderr(jk_map_t *m, const char *wname, const char **stderr_name);
184
185 int jk_get_worker_sysprops(jk_map_t *m, const char *wname, const char **sysprops);
186
187 int jk_get_worker_libpath(jk_map_t *m, const char *wname, const char **libpath);
188
189 char **jk_parse_sysprops(jk_pool_t *p, const char *sysprops);
190
191
192 void jk_append_libpath(jk_pool_t *p, const char *libpath);
193
194 void jk_set_worker_def_cache_size(int sz);
195
196 int jk_get_worker_def_cache_size(int protocol);
197
198 int jk_get_worker_maintain_time(jk_map_t *m);
199
200 int jk_get_max_packet_size(jk_map_t *m, const char *wname);
201
202 const char *jk_get_worker_style_sheet(jk_map_t *m, const char *wname, const char *def);
203
204 int jk_get_is_read_only(jk_map_t *m, const char *wname);
205
206 int jk_get_worker_user_list(jk_map_t *m,
207                             const char *wname,
208                             char ***list, unsigned int *num);
209
210 int jk_get_worker_good_rating(jk_map_t *m,
211                               const char *wname,
212                               char ***list, unsigned int *num);
213
214 int jk_get_worker_bad_rating(jk_map_t *m,
215                              const char *wname,
216                              char ***list, unsigned int *num);
217
218 const char *jk_get_worker_name_space(jk_map_t *m, const char *wname, const char *def);
219
220 const char *jk_get_worker_xmlns(jk_map_t *m, const char *wname, const char *def);
221
222 const char *jk_get_worker_xml_doctype(jk_map_t *m, const char *wname, const char *def);
223
224 const char *jk_get_worker_prop_prefix(jk_map_t *m, const char *wname, const char *def);
225
226 int jk_get_worker_fail_on_status(jk_map_t *m, const char *wname,
227                                  int *list, unsigned int list_size);
228
229 int jk_get_worker_user_case_insensitive(jk_map_t *m, const char *wname);
230
231 int is_http_status_fail(unsigned int http_status_fail_num,
232                         int *http_status_fail, int status);
233
234 int jk_wildchar_match(const char *str, const char *exp, int icase);
235
236 #define TC32_BRIDGE_TYPE    32
237 #define TC33_BRIDGE_TYPE    33
238 #define TC40_BRIDGE_TYPE    40
239 #define TC41_BRIDGE_TYPE    41
240 #define TC50_BRIDGE_TYPE    50
241
242 #ifdef AS400
243
244 #define S_IFREG _S_IFREG
245
246 #ifdef AS400_UTF8
247
248 void jk_ascii2ebcdic(char *src, char *dst);
249 void jk_ebcdic2ascii(char *src, char *dst);
250
251 #endif /* AS400_UTF8 */
252
253 #endif
254
255 /* i5/OS V5R4 need ASCII-EBCDIC conversion before stat() call */
256 /* added a stat() mapper function, jk_stat, for such purpose */
257
258 int jk_stat(const char *f, struct stat * statbuf);
259
260 #ifdef __cplusplus
261 extern "C"
262 {
263 #endif                          /* __cplusplus */
264
265
266 #ifdef __cplusplus
267 }
268 #endif                          /* __cplusplus */
269 #endif                          /* _JK_UTIL_H */