1 diff -Nru apache_1.3.20/src/include/ap_ctx.h apache_1.3.20.new/src/include/ap_ctx.h
2 --- apache_1.3.20/src/include/ap_ctx.h Thu Jan 1 01:00:00 1970
3 +++ apache_1.3.20.new/src/include/ap_ctx.h Mon Mar 12 21:00:54 2001
5 +/* ====================================================================
6 + * Copyright (c) 1998-2000 The Apache Group. All rights reserved.
8 + * Redistribution and use in source and binary forms, with or without
9 + * modification, are permitted provided that the following conditions
12 + * 1. Redistributions of source code must retain the above copyright
13 + * notice, this list of conditions and the following disclaimer.
15 + * 2. Redistributions in binary form must reproduce the above copyright
16 + * notice, this list of conditions and the following disclaimer in
17 + * the documentation and/or other materials provided with the
20 + * 3. All advertising materials mentioning features or use of this
21 + * software must display the following acknowledgment:
22 + * "This product includes software developed by the Apache Group
23 + * for use in the Apache HTTP server project (http://www.apache.org/)."
25 + * 4. The names "Apache Server" and "Apache Group" must not be used to
26 + * endorse or promote products derived from this software without
27 + * prior written permission. For written permission, please contact
28 + * apache@apache.org.
30 + * 5. Products derived from this software may not be called "Apache"
31 + * nor may "Apache" appear in their names without prior written
32 + * permission of the Apache Group.
34 + * 6. Redistributions of any form whatsoever must retain the following
36 + * "This product includes software developed by the Apache Group
37 + * for use in the Apache HTTP server project (http://www.apache.org/)."
39 + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
40 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
43 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 + * OF THE POSSIBILITY OF SUCH DAMAGE.
51 + * ====================================================================
53 + * This software consists of voluntary contributions made by many
54 + * individuals on behalf of the Apache Group and was originally based
55 + * on public domain software written at the National Center for
56 + * Supercomputing Applications, University of Illinois, Urbana-Champaign.
57 + * For more information on the Apache Group and the Apache HTTP server
58 + * project, please see <http://www.apache.org/>.
63 +** Generic Context Interface for Apache
64 +** Written by Ralf S. Engelschall <rse@engelschall.com>
78 + * Internal Context Record Definition
81 +#define AP_CTX_MAX_ENTRIES 1024
90 + ap_ctx_entry **cr_entry;
93 +typedef ap_ctx_rec ap_ctx;
96 + * Some convinience macros for storing _numbers_ 0...n in contexts, i.e.
97 + * treating numbers as pointers but keeping track of the NULL return code of
100 +#define AP_CTX_NUM2PTR(n) (void *)(((unsigned long)(n))+1)
101 +#define AP_CTX_PTR2NUM(p) (unsigned long)(((char *)(p))-1)
104 + * Prototypes for Context Handling Functions
107 +API_EXPORT(ap_ctx *)ap_ctx_new(pool *p);
108 +API_EXPORT(void) ap_ctx_set(ap_ctx *ctx, char *key, void *val);
109 +API_EXPORT(void *) ap_ctx_get(ap_ctx *ctx, char *key);
110 +API_EXPORT(ap_ctx *)ap_ctx_overlay(pool *p, ap_ctx *over, ap_ctx *base);
112 +#endif /* AP_CTX_H */
115 diff -Nru apache_1.3.20/src/include/ap_hook.h apache_1.3.20.new/src/include/ap_hook.h
116 --- apache_1.3.20/src/include/ap_hook.h Thu Jan 1 01:00:00 1970
117 +++ apache_1.3.20.new/src/include/ap_hook.h Thu Dec 30 22:02:59 1999
122 +/* ====================================================================
123 + * Copyright (c) 1998-2000 The Apache Group. All rights reserved.
125 + * Redistribution and use in source and binary forms, with or without
126 + * modification, are permitted provided that the following conditions
129 + * 1. Redistributions of source code must retain the above copyright
130 + * notice, this list of conditions and the following disclaimer.
132 + * 2. Redistributions in binary form must reproduce the above copyright
133 + * notice, this list of conditions and the following disclaimer in
134 + * the documentation and/or other materials provided with the
137 + * 3. All advertising materials mentioning features or use of this
138 + * software must display the following acknowledgment:
139 + * "This product includes software developed by the Apache Group
140 + * for use in the Apache HTTP server project (http://www.apache.org/)."
142 + * 4. The names "Apache Server" and "Apache Group" must not be used to
143 + * endorse or promote products derived from this software without
144 + * prior written permission. For written permission, please contact
145 + * apache@apache.org.
147 + * 5. Products derived from this software may not be called "Apache"
148 + * nor may "Apache" appear in their names without prior written
149 + * permission of the Apache Group.
151 + * 6. Redistributions of any form whatsoever must retain the following
153 + * "This product includes software developed by the Apache Group
154 + * for use in the Apache HTTP server project (http://www.apache.org/)."
156 + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
157 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
158 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
159 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
160 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
161 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
162 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
163 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
164 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
165 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
166 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
167 + * OF THE POSSIBILITY OF SUCH DAMAGE.
168 + * ====================================================================
170 + * This software consists of voluntary contributions made by many
171 + * individuals on behalf of the Apache Group and was originally based
172 + * on public domain software written at the National Center for
173 + * Supercomputing Applications, University of Illinois, Urbana-Champaign.
174 + * For more information on the Apache Group and the Apache HTTP server
175 + * project, please see <http://www.apache.org/>.
180 +** Implementation of a Generic Hook Interface for Apache
181 +** Written by Ralf S. Engelschall <rse@engelschall.com>
183 +** See POD document at end of this file for description.
184 +** View it with the command ``pod2man ap_hook.h | nroff -man | more''
186 +** Attention: This header file is a little bit tricky.
187 +** It's a combination of a C source and an embedded POD document
188 +** The purpose of this is to have both things together at one
189 +** place. So you can both pass this file to the C compiler and
190 +** the pod2man translater.
199 + * Function Signature Specification:
201 + * We encode the complete signature ingredients as a bitfield
202 + * stored in a single unsigned long integer value, which can be
203 + * constructed with AP_HOOK_SIGx(...)
206 +/* the type of the signature bitfield */
207 +typedef unsigned long int ap_hook_sig;
209 +/* the mask (bin) 111 (hex 0x7) for the triples in the bitfield */
210 +#define AP_HOOK_SIG_TRIPLE_MASK 0x7
212 +/* the position of the triple */
213 +#define AP_HOOK_SIG_TRIPLE_POS(n) ((n)*3)
215 +/* the constructor for triple #n with value v */
216 +#define AP_HOOK_SIG_TRIPLE(n,v) \
217 + (((ap_hook_sig)(v))<<((AP_HOOK_##n)*3))
219 +/* the check whether triple #n in sig contains value v */
220 +#define AP_HOOK_SIG_HAS(sig,n,v) \
221 + ((((ap_hook_sig)(sig))&AP_HOOK_SIG_TRIPLE(n, AP_HOOK_SIG_TRIPLE_MASK)) == (AP_HOOK_##n##_##v))
223 +/* utility function to get triple #n in sig */
224 +#define AP_HOOK_SIG_TRIPLE_GET(sig,n) \
225 + ((((ap_hook_sig)(sig))>>AP_HOOK_SIG_TRIPLE_POS(n))&(AP_HOOK_SIG_TRIPLE_MASK))
227 +/* utility function to set triple #n in sig to value v */
228 +#define AP_HOOK_SIG_TRIPLE_SET(sig,n,v) \
229 + ((((ap_hook_sig)(sig))&~(AP_HOOK_SIG_TRIPLE_MASK<<AP_HOOK_SIG_TRIPLE_POS(n)))|((v)<<AP_HOOK_SIG_TRIPLE_POS(n)))
231 +/* define the ingredients for the triple #0: id stuff */
232 +#define AP_HOOK_ID 0
233 +#define AP_HOOK_ID_ok AP_HOOK_SIG_TRIPLE(ID,0)
234 +#define AP_HOOK_ID_undef AP_HOOK_SIG_TRIPLE(ID,1)
236 +/* define the ingredients for the triple #1: return code */
237 +#define AP_HOOK_RC 1
238 +#define AP_HOOK_RC_void AP_HOOK_SIG_TRIPLE(RC,0)
239 +#define AP_HOOK_RC_char AP_HOOK_SIG_TRIPLE(RC,1)
240 +#define AP_HOOK_RC_int AP_HOOK_SIG_TRIPLE(RC,2)
241 +#define AP_HOOK_RC_long AP_HOOK_SIG_TRIPLE(RC,3)
242 +#define AP_HOOK_RC_float AP_HOOK_SIG_TRIPLE(RC,4)
243 +#define AP_HOOK_RC_double AP_HOOK_SIG_TRIPLE(RC,5)
244 +#define AP_HOOK_RC_ptr AP_HOOK_SIG_TRIPLE(RC,6)
246 +/* define the ingredients for the triple #2: argument 1 */
247 +#define AP_HOOK_A1 2
248 +#define AP_HOOK_A1_ctx AP_HOOK_SIG_TRIPLE(A1,0)
249 +#define AP_HOOK_A1_char AP_HOOK_SIG_TRIPLE(A1,1)
250 +#define AP_HOOK_A1_int AP_HOOK_SIG_TRIPLE(A1,2)
251 +#define AP_HOOK_A1_long AP_HOOK_SIG_TRIPLE(A1,3)
252 +#define AP_HOOK_A1_float AP_HOOK_SIG_TRIPLE(A1,4)
253 +#define AP_HOOK_A1_double AP_HOOK_SIG_TRIPLE(A1,5)
254 +#define AP_HOOK_A1_ptr AP_HOOK_SIG_TRIPLE(A1,6)
256 +/* define the ingredients for the triple #3: argument 2 */
257 +#define AP_HOOK_A2 3
258 +#define AP_HOOK_A2_ctx AP_HOOK_SIG_TRIPLE(A2,0)
259 +#define AP_HOOK_A2_char AP_HOOK_SIG_TRIPLE(A2,1)
260 +#define AP_HOOK_A2_int AP_HOOK_SIG_TRIPLE(A2,2)
261 +#define AP_HOOK_A2_long AP_HOOK_SIG_TRIPLE(A2,3)
262 +#define AP_HOOK_A2_float AP_HOOK_SIG_TRIPLE(A2,4)
263 +#define AP_HOOK_A2_double AP_HOOK_SIG_TRIPLE(A2,5)
264 +#define AP_HOOK_A2_ptr AP_HOOK_SIG_TRIPLE(A2,6)
266 +/* define the ingredients for the triple #4: argument 3 */
267 +#define AP_HOOK_A3 4
268 +#define AP_HOOK_A3_ctx AP_HOOK_SIG_TRIPLE(A3,0)
269 +#define AP_HOOK_A3_char AP_HOOK_SIG_TRIPLE(A3,1)
270 +#define AP_HOOK_A3_int AP_HOOK_SIG_TRIPLE(A3,2)
271 +#define AP_HOOK_A3_long AP_HOOK_SIG_TRIPLE(A3,3)
272 +#define AP_HOOK_A3_float AP_HOOK_SIG_TRIPLE(A3,4)
273 +#define AP_HOOK_A3_double AP_HOOK_SIG_TRIPLE(A3,5)
274 +#define AP_HOOK_A3_ptr AP_HOOK_SIG_TRIPLE(A3,6)
276 +/* define the ingredients for the triple #5: argument 4 */
277 +#define AP_HOOK_A4 5
278 +#define AP_HOOK_A4_ctx AP_HOOK_SIG_TRIPLE(A4,0)
279 +#define AP_HOOK_A4_char AP_HOOK_SIG_TRIPLE(A4,1)
280 +#define AP_HOOK_A4_int AP_HOOK_SIG_TRIPLE(A4,2)
281 +#define AP_HOOK_A4_long AP_HOOK_SIG_TRIPLE(A4,3)
282 +#define AP_HOOK_A4_float AP_HOOK_SIG_TRIPLE(A4,4)
283 +#define AP_HOOK_A4_double AP_HOOK_SIG_TRIPLE(A4,5)
284 +#define AP_HOOK_A4_ptr AP_HOOK_SIG_TRIPLE(A4,6)
286 +/* define the ingredients for the triple #6: argument 5 */
287 +#define AP_HOOK_A5 6
288 +#define AP_HOOK_A5_ctx AP_HOOK_SIG_TRIPLE(A5,0)
289 +#define AP_HOOK_A5_char AP_HOOK_SIG_TRIPLE(A5,1)
290 +#define AP_HOOK_A5_int AP_HOOK_SIG_TRIPLE(A5,2)
291 +#define AP_HOOK_A5_long AP_HOOK_SIG_TRIPLE(A5,3)
292 +#define AP_HOOK_A5_float AP_HOOK_SIG_TRIPLE(A5,4)
293 +#define AP_HOOK_A5_double AP_HOOK_SIG_TRIPLE(A5,5)
294 +#define AP_HOOK_A5_ptr AP_HOOK_SIG_TRIPLE(A5,6)
296 +/* define the ingredients for the triple #7: argument 6 */
297 +#define AP_HOOK_A6 7
298 +#define AP_HOOK_A6_ctx AP_HOOK_SIG_TRIPLE(A6,0)
299 +#define AP_HOOK_A6_char AP_HOOK_SIG_TRIPLE(A6,1)
300 +#define AP_HOOK_A6_int AP_HOOK_SIG_TRIPLE(A6,2)
301 +#define AP_HOOK_A6_long AP_HOOK_SIG_TRIPLE(A6,3)
302 +#define AP_HOOK_A6_float AP_HOOK_SIG_TRIPLE(A6,4)
303 +#define AP_HOOK_A6_double AP_HOOK_SIG_TRIPLE(A6,5)
304 +#define AP_HOOK_A6_ptr AP_HOOK_SIG_TRIPLE(A6,6)
306 +/* define the ingredients for the triple #8: argument 7 */
307 +#define AP_HOOK_A7 8
308 +#define AP_HOOK_A7_ctx AP_HOOK_SIG_TRIPLE(A7,0)
309 +#define AP_HOOK_A7_char AP_HOOK_SIG_TRIPLE(A7,1)
310 +#define AP_HOOK_A7_int AP_HOOK_SIG_TRIPLE(A7,2)
311 +#define AP_HOOK_A7_long AP_HOOK_SIG_TRIPLE(A7,3)
312 +#define AP_HOOK_A7_float AP_HOOK_SIG_TRIPLE(A7,4)
313 +#define AP_HOOK_A7_double AP_HOOK_SIG_TRIPLE(A7,5)
314 +#define AP_HOOK_A7_ptr AP_HOOK_SIG_TRIPLE(A7,6)
316 +/* define the ingredients for the triple #9: argument 8 */
317 +#define AP_HOOK_A8 9
318 +#define AP_HOOK_A8_ctx AP_HOOK_SIG_TRIPLE(9,0)
319 +#define AP_HOOK_A8_char AP_HOOK_SIG_TRIPLE(9,1)
320 +#define AP_HOOK_A8_int AP_HOOK_SIG_TRIPLE(9,2)
321 +#define AP_HOOK_A8_long AP_HOOK_SIG_TRIPLE(9,3)
322 +#define AP_HOOK_A8_float AP_HOOK_SIG_TRIPLE(9,4)
323 +#define AP_HOOK_A8_double AP_HOOK_SIG_TRIPLE(9,5)
324 +#define AP_HOOK_A8_ptr AP_HOOK_SIG_TRIPLE(9,6)
326 +/* the constructor for unknown signatures */
327 +#define AP_HOOK_SIG_UNKNOWN AP_HOOK_ID_undef
329 +/* the constructor for signatures with 1 type */
330 +#define AP_HOOK_SIG1(rc) \
333 +/* the constructor for signatures with 2 types */
334 +#define AP_HOOK_SIG2(rc,a1) \
335 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1)
337 +/* the constructor for signatures with 3 types */
338 +#define AP_HOOK_SIG3(rc,a1,a2) \
339 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2)
341 +/* the constructor for signatures with 4 types */
342 +#define AP_HOOK_SIG4(rc,a1,a2,a3) \
343 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3)
345 +/* the constructor for signatures with 5 types */
346 +#define AP_HOOK_SIG5(rc,a1,a2,a3,a4) \
347 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4)
349 +/* the constructor for signatures with 6 types */
350 +#define AP_HOOK_SIG6(rc,a1,a2,a3,a4,a5) \
351 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5)
353 +/* the constructor for signatures with 7 types */
354 +#define AP_HOOK_SIG7(rc,a1,a2,a3,a4,a5,a6) \
355 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5|AP_HOOK_A6_##a6)
357 +/* the constructor for signatures with 8 types */
358 +#define AP_HOOK_SIG8(rc,a1,a2,a3,a4,a5,a6,a7) \
359 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5|AP_HOOK_A6_##a6|AP_HOOK_A7_##a7)
361 +/* the constructor for signatures with 9 types */
362 +#define AP_HOOK_SIG9(rc,a1,a2,a3,a4,a5,a6,a7,a8) \
363 + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5|AP_HOOK_A6_##a6|AP_HOOK_A7_##a7|AP_HOOK_A8_##a8)
366 + * Return Value Mode Identification
369 +/* the type of the return value modes */
370 +typedef unsigned int ap_hook_mode;
372 +/* the mode of the return value */
373 +#define AP_HOOK_MODE_UNKNOWN 0
374 +#define AP_HOOK_MODE_TOPMOST 1
375 +#define AP_HOOK_MODE_DECLINE 2
376 +#define AP_HOOK_MODE_DECLTMP 3
377 +#define AP_HOOK_MODE_ALL 4
379 +/* the constructors for the return value modes */
380 +#define AP_HOOK_TOPMOST AP_HOOK_MODE_TOPMOST
381 +#define AP_HOOK_DECLINE(val) AP_HOOK_MODE_DECLINE, (val)
382 +#define AP_HOOK_DECLTMP(val) AP_HOOK_MODE_DECLTMP, (val)
383 +#define AP_HOOK_ALL AP_HOOK_MODE_ALL
386 + * Hook State Identification
389 +/* the type of the hook state */
390 +typedef unsigned short int ap_hook_state;
392 +/* the values of the hook state */
393 +#define AP_HOOK_STATE_UNDEF 0
394 +#define AP_HOOK_STATE_NOTEXISTANT 1
395 +#define AP_HOOK_STATE_ESTABLISHED 2
396 +#define AP_HOOK_STATE_CONFIGURED 3
397 +#define AP_HOOK_STATE_REGISTERED 4
400 + * Hook Context Identification
402 + * Notice: Null is ok here, because AP_HOOK_NOCTX is just a dummy argument
403 + * because we know from the signature whether the argument is a
404 + * context value or just the dummy value.
407 +#define AP_HOOK_NOCTX (void *)(0)
408 +#define AP_HOOK_CTX(v) (void *)(v)
411 + * Internal Hook Record Definition
414 +/* the union holding the arbitrary decline values */
424 +/* the structure holding one hook function and its context */
426 + void *hf_ptr; /* function pointer */
427 + void *hf_ctx; /* function context */
430 +/* the structure holding one hook entry with all its registered functions */
432 + char *he_hook; /* hook name (=unique id) */
433 + ap_hook_sig he_sig; /* hook signature */
434 + int he_modeid; /* hook mode id */
435 + ap_hook_value he_modeval; /* hook mode value */
436 + ap_hook_func **he_func; /* hook registered funcs */
439 +/* the maximum number of hooks and functions per hook */
440 +#define AP_HOOK_MAX_ENTRIES 512
441 +#define AP_HOOK_MAX_FUNCS 128
444 + * Extended Variable Argument (vararg) Support
446 + * In ANSI C varargs exists, but because the prototypes of function with
447 + * varargs cannot reflect the types of the varargs, K&R argument passing
448 + * conventions have to apply for the compiler. This means mainly a conversion
449 + * of shorter type variants to the maximum variant (according to sizeof). The
450 + * above va_type() macro provides this mapping from the wanted types to the
451 + * physically used ones.
455 +#define VA_TYPE_char int
456 +#define VA_TYPE_short int
457 +#define VA_TYPE_int int
458 +#define VA_TYPE_long long
459 +#define VA_TYPE_float double
460 +#define VA_TYPE_double double
461 +#define VA_TYPE_ptr void *
462 +#define VA_TYPE_ctx void *
464 +/* the constructor */
468 +#define va_type(type) VA_TYPE_ ## type
471 + * Miscellaneous stuff
480 + * Wrapper macros for the callback-function register/unregister calls.
482 + * Background: Strict ANSI C doesn't allow a function pointer to be treated as
483 + * a void pointer on argument passing, but we cannot declare the argument as a
484 + * function prototype, because the functions can have arbitrary signatures. So
485 + * we have to use a void pointer here. But to not require explicit casts on
486 + * function pointers for every register/unregister call, we smooth the API a
487 + * little bit by providing these macros.
490 +#define ap_hook_register(hook,func,ctx) ap_hook_register_I(hook,(void *)(func),ctx)
491 +#define ap_hook_unregister(hook,func) ap_hook_unregister_I(hook,(void *)(func))
494 + * Prototypes for the hook API functions
497 +API_EXPORT(void) ap_hook_init (void);
498 +API_EXPORT(void) ap_hook_kill (void);
499 +API_EXPORT(int) ap_hook_configure (char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...);
500 +API_EXPORT(int) ap_hook_register_I (char *hook, void *func, void *ctx);
501 +API_EXPORT(int) ap_hook_unregister_I (char *hook, void *func);
502 +API_EXPORT(ap_hook_state) ap_hook_status (char *hook);
503 +API_EXPORT(int) ap_hook_use (char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...);
504 +API_EXPORT(int) ap_hook_call (char *hook, ...);
506 +#endif /* AP_HOOK_H */
512 +## Embedded POD document
517 +B<ap_hook> - B<Generic Hook Interface for Apache>
521 +B<Hook Library Setup:>
523 + void ap_hook_init(void);
524 + void ap_hook_kill(void);
526 +B<Hook Configuration and Registration:>
528 + int ap_hook_configure(char *hook, ap_hook_sig sig, ap_hook_mode mode);
529 + int ap_hook_register(char *hook, void *func, void *ctx);
530 + int ap_hook_unregister(char *hook, void *func);
534 + ap_hook_state ap_hook_status(char *hook);
535 + int ap_hook_use(char *hook, ap_hook_sig sig, ap_hook_mode mode, ...);
536 + int ap_hook_call(char *hook, ...);
538 +B<Hook Signature Constructors> (ap_hook_sig):
541 + AP_HOOK_SIG2(rc,a1)
542 + AP_HOOK_SIG3(rc,a1,a2)
543 + AP_HOOK_SIG4(rc,a1,a2,a3)
544 + AP_HOOK_SIG5(rc,a1,a2,a3,a4)
545 + AP_HOOK_SIG6(rc,a1,a2,a3,a4,a5)
546 + AP_HOOK_SIG7(rc,a1,a2,a3,a4,a5,a6)
547 + AP_HOOK_SIG8(rc,a1,a2,a3,a4,a5,a6,a7)
549 +B<Hook Modes Constructors> (ap_hook_mode):
552 + AP_HOOK_DECLINE(value)
553 + AP_HOOK_DECLTMP(value)
556 +B<Hook States> (ap_hook_state):
558 + AP_HOOK_STATE_UNDEF
559 + AP_HOOK_STATE_NOTEXISTANT
560 + AP_HOOK_STATE_ESTABLISHED
561 + AP_HOOK_STATE_CONFIGURED
562 + AP_HOOK_STATE_REGISTERED
566 +This library implements a generic hook interface for Apache which can be used
567 +to loosely couple code through arbitrary hooks. There are two use cases for
572 +=item B<1. Extension and Overrides>
574 +Inside a specific code section you want to perform a specific function call
575 +for extension reasons. But you want to allow one or more modules to implement
576 +this function by registering hooks. Those hooks are registered on a stack and
577 +can be even configured to have a I<decline> return value. As long as there are
578 +functions which return the decline value the next function on the stack is
579 +tried. When the first function doesn't return the decline value the hook call
582 +The original intent of this use case is to provide a flexible extension
583 +mechanism where modules can override functionality.
585 +=item B<2. Intercommunication>
587 +Inside a specific code you have a function you want to export. But you first
588 +want to allow other code to override this function. And second you want to
589 +export this function without real object file symbol references. Instead you
590 +want to register the function and let the users call this function by name.
592 +The original intent of this use case is to allow inter-module communication
593 +without direct symbol references, which are a big I<no-no> for the I<Dynamic
594 +Shared Object> (DSO) situation.
598 +And the following design goals existed:
602 +=item B<1. Minimum code changes>
604 +The hook calls should look very similar to the corresponding direct function
605 +call to allow one to easily translate it. And the total amount of changes for
606 +the hook registration, hook configuration and hook usage should be as small as
607 +possible to minimize the total code changes. Additionally a shorthand API
608 +function (ap_hook_use) should be provided which lets one trivially add a hook
609 +by just changing the code at a single location.
611 +=item B<2. The hook call has to be maximum flexible>
613 +In order to avoid nasty hacks, maximum flexiblity for the hook calls is
614 +needed, i.e. any function signature (the set of types for the return value and
615 +the arguments) should be supported. And it should be possible to
616 +register always a context (ctx) variable with a function which is passed to
617 +the corresponding function when the hook call is performed.
621 +The implementation of this library directly followed these two design goals.
625 +Using this hook API is a four-step process:
629 +=item B<1. Initialization>
631 +Initialize or destroy the hook mechanism inside your application program:
637 +=item B<2. Configuration>
639 +Configure a particular hook by specifing its name, signature and return type
642 + ap_hook_configure("lookup", AP_HOOK_SIG2(ptr,ptr,ctx), AP_HOOK_DECLINE(NULL));
643 + ap_hook_configure("setup", AP_HOOK_SIG2(int,ptr,char), AP_HOOK_DECLTMP(FALSE));
644 + ap_hook_configure("read", AP_HOOK_SIG2(void,ptr), AP_HOOK_TOPMOST);
645 + ap_hook_configure("logit", AP_HOOK_SIG2(void,ptr), AP_HOOK_ALL);
647 +This configures four hooks:
649 +A hook named C<lookup> with the signature C<void *lookup(void *, void *)>
650 +(where the second argument is C<NULL> or the private context pointer of the
651 +hook function which can be optionally provided at the registration step
652 +later) and a return code semantic which says: Proceed as long as the
653 +registered lookup functions return C<NULL> or no more registered functions
654 +exists. A call for this hook has to provide 2 argument only (a pointer to the
655 +return variable and the first argument), because the context is
656 +implicitly provided by the hook mechanism. Sample idea: I<The first function
657 +who was successful in looking up a variable provides the value>.
659 +A hook named C<setup> with the signature C<int setup(void *, char)" and a
660 +return code semantic equal to the one of the C<lookup> hook. But the decline
661 +return value is implemented by a temporay variable of the hook mechanism and
662 +only used for the decline decision. So a call to this hook has to provide 2
663 +arguments only (the first and second argument, but no address to a return
664 +value). Sample idea: I<Any function can handle the setup and when one
665 +function handled it stops the processing by indicating this with the return
668 +A hook named C<read> with the signature C<void read(void *)> and a return code
669 +semantic which says: Only the top most function on the registered function
670 +stack is tried (and independet of a possible return value in non-void
671 +context). A call to this hook has to provide exactly 1 argument (the
672 +single argument to the hook function). Sample idea: I<We want to
673 +use a read function and allow others to override it, but independent how much
674 +registered functions exists, only top most (= last registered) function
675 +overrides and is used>.
677 +A hook named C<logit> with the signature C<void logit(void *)> and a return
678 +code semantic which says: All registered functions on the hook functioin stack
679 +are tried. Sample idea: I<We pass a FILE pointer to the logging functions and
680 +any function can log whatever it wants>.
682 +=item B<3. Registration>
684 +Register the actual functions which should be used by the hook:
686 + ap_hook_register("lookup", mylookup, mycontext);
687 + ap_hook_register("setup", mysetup);
688 + ap_hook_register("read", myread);
689 + ap_hook_register("logit", mylogit);
691 +This registers the function C<mylookup()> under the C<lookup> hook with the
692 +private context given by the variable C<mycontext>. And it registers the
693 +function C<mysetup()> under the C<setup> hook without any context. Same for
694 +C<myread> and C<mylogit>.
698 +Finally use the hooks, i.e. instead of using direct function calls like
700 + rc = mylookup(a1, a2);
701 + rc = mysetup(a1, a2);
707 + ap_hook_call("lookup", &rc, a1, a2);
708 + ap_hook_call("setup", &rc, a1, a2);
709 + ap_hook_call("read", a1);
710 + ap_hook_call("logit", a1);
712 +which are internally translated to:
714 + rc = mylookup(a1, a2, mycontext);
715 + rc = mysetup(a1, a2);
719 +Notice two things here: First the context (C<mycontext>) for the C<mylookup()>
720 +function is automatically added by the hook mechanism. And it is a different
721 +(and not fixed) context for each registered function, of course. Second,
722 +return values always have to be pushed into variables and a pointer to them
723 +has to be given as the second argument to C<ap_hook_call> (except for
724 +functions which have a void return type, of course).
726 +BTW, the return value of C<ap_hook_call()> is always C<TRUE> or C<FALSE>.
727 +C<TRUE> when at least one function call was successful (always the case for
728 +C<AP_HOOK_TOPMOST> and C<AP_HOOK_ALL>). C<FALSE> when all functions
729 +returned the decline value or no functions are registered at all.
735 +To make the hook implementation efficient and to not bloat up the code too
736 +much a few restrictions have to make:
742 +Only function calls with up to 4 arguments are implemented. When more are
743 +needed you can either extend the hook implementation by using more bits for
744 +the signature configuration or you can do a workaround when the function is
745 +your own one: Put the remaining (N-4-1) arguments into a structure and pass
746 +only a pointer (one argument) as the forth argument.
750 +Only the following ANSI C variable types are supported:
752 + - For the return value:
753 + void (= none), char, int, float, double, ptr (= void *)
754 + - For the arguments:
755 + ctx (= context), char, int, float, double, ptr (= void *)
757 +This means in theory that 6^5 (=7776) signature combinations are possible. But
758 +because we don't need all of them inside Apache and it would bloat up the code
759 +too dramatically we implement only a subset of those combinations. The
760 +implemented signatures can be specified inside C<ap_hook.c> and the
761 +corresponding code can be automatically generated by running ``C<perl
762 +ap_hook.c>'' (yeah, no joke ;-). So when you need a hook with a different
763 +still not implemented signature you either have to again use a workaround as
764 +above (i.e. use a structure) or just add the signature to the C<ap_hook.c>
769 +We want to call `C<ssize_t read(int, void *, size_t)>' through hooks in order
770 +to allow modules to override this call. So, somewhere we have a replacement
771 +function for C<read()> defined (same signature, of course):
773 + ssize_t my_read(int, void *, size_t);
775 +We now configure a C<read> hook. Here the C<AP_HOOK_SIGx()> macro defines the
776 +signature of the C<read()>-like callback functions and has to match the
777 +prototype of C<read()>. But we have to replace typedefs with the physical
778 +underlaying ANSI C types. And C<AP_HOOK_DECLINE()> sets the return value of
779 +the read()-like functions which forces the next hook to be called (here -1).
780 +And we register the original C<read()> function as the default hook.
782 + ap_hook_configure("read",
783 + AP_HOOK_SIG4(int,int,ptr,int),
784 + AP_HOOK_DECLINE(-1));
785 + ap_hook_register("read", read);
787 +Now a module wants to override the C<read()> call and registers the
788 +C<my_read()> function:
790 + ap_hook_register("read", my_read);
792 +The function logically gets pushed onto a stack, so the execution order is the
793 +reverse registering order, i.e. I<last registered - first called>. Now we can
794 +replace the standard C<read()> call
796 + bytes = read(fd, buf, bufsize);
800 +with the hook based call:
802 + rc = ap_hook_call("read", &bytes, fd, buf, bufsize);
806 +Now internally the following is done: The call `C<bytes = my_read(fd, buf,
807 +bufsize)>' is done. When it returns not -1 (the decline value) nothing
808 +more is done. But when C<my_read()> returns -1 the next function is tried:
809 +`C<bytes = read(fd, buf, bufsize)>'. When this one also returns -1 you get
810 +`rc == FALSE'. When it finally returns not -1 you get `rc == TRUE'.
818 +The ap_hook(3) interface was originally designed and
819 +implemented in October 1998 by Ralf S. Engelschall.
823 + Ralf S. Engelschall
824 + rse@engelschall.com
825 + www.engelschall.com
829 diff -Nru apache_1.3.20/src/include/ap_mm.h apache_1.3.20.new/src/include/ap_mm.h
830 --- apache_1.3.20/src/include/ap_mm.h Thu Jan 1 01:00:00 1970
831 +++ apache_1.3.20.new/src/include/ap_mm.h Thu Dec 30 22:02:59 1999
833 +/* ====================================================================
834 + * Copyright (c) 1999-2000 The Apache Group. All rights reserved.
836 + * Redistribution and use in source and binary forms, with or without
837 + * modification, are permitted provided that the following conditions
840 + * 1. Redistributions of source code must retain the above copyright
841 + * notice, this list of conditions and the following disclaimer.
843 + * 2. Redistributions in binary form must reproduce the above copyright
844 + * notice, this list of conditions and the following disclaimer in
845 + * the documentation and/or other materials provided with the
848 + * 3. All advertising materials mentioning features or use of this
849 + * software must display the following acknowledgment:
850 + * "This product includes software developed by the Apache Group
851 + * for use in the Apache HTTP server project (http://www.apache.org/)."
853 + * 4. The names "Apache Server" and "Apache Group" must not be used to
854 + * endorse or promote products derived from this software without
855 + * prior written permission. For written permission, please contact
856 + * apache@apache.org.
858 + * 5. Products derived from this software may not be called "Apache"
859 + * nor may "Apache" appear in their names without prior written
860 + * permission of the Apache Group.
862 + * 6. Redistributions of any form whatsoever must retain the following
864 + * "This product includes software developed by the Apache Group
865 + * for use in the Apache HTTP server project (http://www.apache.org/)."
867 + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
868 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
869 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
870 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
871 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
872 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
873 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
874 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
875 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
876 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
877 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
878 + * OF THE POSSIBILITY OF SUCH DAMAGE.
879 + * ====================================================================
881 + * This software consists of voluntary contributions made by many
882 + * individuals on behalf of the Apache Group and was originally based
883 + * on public domain software written at the National Center for
884 + * Supercomputing Applications, University of Illinois, Urbana-Champaign.
885 + * For more information on the Apache Group and the Apache HTTP server
886 + * project, please see <http://www.apache.org/>.
891 +** ap_mm.h -- wrapper code for MM shared memory library
905 +API_EXPORT(int) ap_mm_useable(void);
908 +typedef enum { AP_MM_LOCK_RD, AP_MM_LOCK_RW } ap_mm_lock_mode;
910 +/* Global Malloc-Replacement API */
911 +API_EXPORT(int) ap_MM_create(size_t size, char *file);
912 +API_EXPORT(int) ap_MM_permission(mode_t mode, uid_t owner, gid_t group);
913 +API_EXPORT(void) ap_MM_destroy(void);
914 +API_EXPORT(int) ap_MM_lock(ap_mm_lock_mode mode);
915 +API_EXPORT(int) ap_MM_unlock(void);
916 +API_EXPORT(void *) ap_MM_malloc(size_t size);
917 +API_EXPORT(void *) ap_MM_realloc(void *ptr, size_t size);
918 +API_EXPORT(void) ap_MM_free(void *ptr);
919 +API_EXPORT(void *) ap_MM_calloc(size_t number, size_t size);
920 +API_EXPORT(char *) ap_MM_strdup(const char *str);
921 +API_EXPORT(size_t) ap_MM_sizeof(void *ptr);
922 +API_EXPORT(size_t) ap_MM_maxsize(void);
923 +API_EXPORT(size_t) ap_MM_available(void);
924 +API_EXPORT(char *) ap_MM_error(void);
926 +/* Standard Malloc-Style API */
927 +API_EXPORT(AP_MM *) ap_mm_create(size_t size, char *file);
928 +API_EXPORT(int) ap_mm_permission(AP_MM *mm, mode_t mode, uid_t owner, gid_t group);
929 +API_EXPORT(void) ap_mm_destroy(AP_MM *mm);
930 +API_EXPORT(int) ap_mm_lock(AP_MM *mm, ap_mm_lock_mode mode);
931 +API_EXPORT(int) ap_mm_unlock(AP_MM *mm);
932 +API_EXPORT(void *) ap_mm_malloc(AP_MM *mm, size_t size);
933 +API_EXPORT(void *) ap_mm_realloc(AP_MM *mm, void *ptr, size_t size);
934 +API_EXPORT(void) ap_mm_free(AP_MM *mm, void *ptr);
935 +API_EXPORT(void *) ap_mm_calloc(AP_MM *mm, size_t number, size_t size);
936 +API_EXPORT(char *) ap_mm_strdup(AP_MM *mm, const char *str);
937 +API_EXPORT(size_t) ap_mm_sizeof(AP_MM *mm, void *ptr);
938 +API_EXPORT(size_t) ap_mm_maxsize(void);
939 +API_EXPORT(size_t) ap_mm_available(AP_MM *mm);
940 +API_EXPORT(char *) ap_mm_error(void);
941 +API_EXPORT(void) ap_mm_display_info(AP_MM *mm);
943 +/* Low-Level Shared Memory API */
944 +API_EXPORT(void *) ap_mm_core_create(size_t size, char *file);
945 +API_EXPORT(int) ap_mm_core_permission(void *core, mode_t mode, uid_t owner, gid_t group);
946 +API_EXPORT(void) ap_mm_core_delete(void *core);
947 +API_EXPORT(size_t) ap_mm_core_size(void *core);
948 +API_EXPORT(int) ap_mm_core_lock(void *core, ap_mm_lock_mode mode);
949 +API_EXPORT(int) ap_mm_core_unlock(void *core);
950 +API_EXPORT(size_t) ap_mm_core_maxsegsize(void);
951 +API_EXPORT(size_t) ap_mm_core_align2page(size_t size);
952 +API_EXPORT(size_t) ap_mm_core_align2word(size_t size);
954 +/* Internal Library API */
955 +API_EXPORT(void) ap_mm_lib_error_set(unsigned int, const char *str);
956 +API_EXPORT(char *) ap_mm_lib_error_get(void);
957 +API_EXPORT(int) ap_mm_lib_version(void);
959 +#endif /* AP_MM_H */
963 diff -Nru apache_1.3.20/htdocs/manual/mod/mod_define.html apache_1.3.20.new/htdocs/manual/mod/mod_define.html
964 --- apache_1.3.20/htdocs/manual/mod/mod_define.html Thu Jan 1 01:00:00 1970
965 +++ apache_1.3.20.new/htdocs/manual/mod/mod_define.html Fri Aug 27 11:23:39 1999
967 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
969 +<!-- mod_define.html -->
970 +<!-- Documentation for the mod_define Apache module -->
973 +<TITLE>Apache module mod_define</TITLE>
976 +<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
984 +<BLOCKQUOTE><!-- page indentation -->
985 +<!--#include virtual="header.html" -->
988 +<H1 ALIGN="CENTER">Module mod_define</H1>
989 +<H2 ALIGN="CENTER">Variable Definition For Arbitrary Directives</H2>
991 +This module is contained in the <CODE>mod_define.c</CODE> file. It provides
992 +the definition variables for arbitrary directives, i.e. variables which can be
993 +expanded on any(!) directive line. It needs Extended API (EAPI). It is not
994 +compiled into the server by default. To use <CODE>mod_define</CODE> you have
995 +to enable the following line in the server build <CODE>Configuration</CODE>
1000 + AddModule modules/extra/mod_define.o
1004 +<HR NOSHADE SIZE=1>
1006 +<H3><A NAME="Define">Define</A></H3>
1008 + HREF="directive-dict.html#Syntax"
1010 +><STRONG>Syntax:</STRONG></A>
1011 + <CODE>Define</CODE> <EM>variable</EM> <EM>value</EM><BR>
1013 + HREF="directive-dict.html#Default"
1015 +><STRONG>Default:</STRONG></A>
1018 + HREF="directive-dict.html#Context"
1020 +><STRONG>Context:</STRONG></A>
1021 + server config, virtual host, directory, .htaccess<BR>
1023 + HREF="directive-dict.html#Override"
1025 +><STRONG>Override:</STRONG></A> none<BR>
1027 + HREF="directive-dict.html#Status"
1029 +><STRONG>Status:</STRONG></A> Extension<BR>
1031 + HREF="directive-dict.html#Module"
1033 +><STRONG>Module:</STRONG></A> mod_define.c<BR>
1035 + HREF="directive-dict.html#Compatibility"
1037 +><STRONG>Compatibility:</STRONG></A> Apache+EAPI<BR>
1040 +The <CODE>Define</CODE> directive defines a variable which later can be
1041 +expanded with the unsafe but short construct
1042 +``<CODE>$</CODE><EM>variable</EM>'' or the safe but longer construct
1043 +``<CODE>${</CODE><EM>variable</EM><CODE>}</CODE>'' on any configuration line.
1044 +Do not intermix this with the third-party module <CODE>mod_macro</CODE>. The
1045 +<CODE>mod_define</CODE> module doesn't provide a general macro mechanism,
1046 +although one can consider variable substitutions as a special form of macros.
1047 +Because the value of to which ``<CODE>$</CODE><EM>variable</EM>'' expands has
1048 +to fit into one line. When you need macros which can span more lines, you've
1049 +to use <CODE>mod_macro</CODE>. OTOH <CODE>mod_macro</CODE> cannot be used to
1050 +expand a variable/macro on an arbitrary directive line. So, the typical use
1051 +case of <CODE>mod_define</CODE> is to make strings <EM>variable</EM> (and this
1052 +way easily changeable at one location) and not to <EM>bundle</EM> things
1053 +together (as it's the typical use case for macros).
1056 +The syntax of the expansion construct (
1057 +``<CODE>${</CODE><EM>variable</EM><CODE>}</CODE>'') follows the Perl and Shell
1058 +syntax, but can be changed via the <CODE>Define</CODE> directive, too. Four
1059 +internal variables can be used for this. The default is:
1063 +Define mod_define::escape "\\"
1064 +Define mod_define::dollar "$"
1065 +Define mod_define::open "{"
1066 +Define mod_define::close "}"
1071 +When you need to escape some of the expansion constructs you place the
1072 +mod_define::escape character in front of it. The default is the backslash as
1073 +in Perl or the Shell.
1076 +<STRONG>Example:</STRONG>
1079 +Define master "Joe Average <joe@average.dom>"
1080 +Define docroot /usr/local/apache/htdocs
1081 +Define hostname foo
1082 +Define domainname bar.dom
1083 +Define portnumber 80
1085 +<VirtualHost $hostname.$domainname:$portnumber>
1086 +SetEnv SERVER_MASTER "$master"
1087 +ServerName $hostname.$domainname
1088 +ServerAlias $hostname
1090 +DocumentRoot $docroot
1091 +<Directory $docroot>
1097 +<!--#include virtual="footer.html" -->
1098 +</BLOCKQUOTE><!-- page indentation -->
1101 +<!--/%hypertext -->
1102 diff -Nru apache_1.3.20/src/ap/ap_ctx.c apache_1.3.20.new/src/ap/ap_ctx.c
1103 --- apache_1.3.20/src/ap/ap_ctx.c Thu Jan 1 01:00:00 1970
1104 +++ apache_1.3.20.new/src/ap/ap_ctx.c Thu Dec 30 22:02:56 1999
1106 +/* ====================================================================
1107 + * Copyright (c) 1998-2000 The Apache Group. All rights reserved.
1109 + * Redistribution and use in source and binary forms, with or without
1110 + * modification, are permitted provided that the following conditions
1113 + * 1. Redistributions of source code must retain the above copyright
1114 + * notice, this list of conditions and the following disclaimer.
1116 + * 2. Redistributions in binary form must reproduce the above copyright
1117 + * notice, this list of conditions and the following disclaimer in
1118 + * the documentation and/or other materials provided with the
1121 + * 3. All advertising materials mentioning features or use of this
1122 + * software must display the following acknowledgment:
1123 + * "This product includes software developed by the Apache Group
1124 + * for use in the Apache HTTP server project (http://www.apache.org/)."
1126 + * 4. The names "Apache Server" and "Apache Group" must not be used to
1127 + * endorse or promote products derived from this software without
1128 + * prior written permission. For written permission, please contact
1129 + * apache@apache.org.
1131 + * 5. Products derived from this software may not be called "Apache"
1132 + * nor may "Apache" appear in their names without prior written
1133 + * permission of the Apache Group.
1135 + * 6. Redistributions of any form whatsoever must retain the following
1137 + * "This product includes software developed by the Apache Group
1138 + * for use in the Apache HTTP server project (http://www.apache.org/)."
1140 + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
1141 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1142 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1143 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
1144 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1145 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1146 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1147 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1148 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1149 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1150 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1151 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1152 + * ====================================================================
1154 + * This software consists of voluntary contributions made by many
1155 + * individuals on behalf of the Apache Group and was originally based
1156 + * on public domain software written at the National Center for
1157 + * Supercomputing Applications, University of Illinois, Urbana-Champaign.
1158 + * For more information on the Apache Group and the Apache HTTP server
1159 + * project, please see <http://www.apache.org/>.
1164 +** Generic Context Interface for Apache
1165 +** Written by Ralf S. Engelschall <rse@engelschall.com>
1171 +#include "ap_config.h"
1172 +#include "ap_ctx.h"
1174 +API_EXPORT(ap_ctx *) ap_ctx_new(pool *p)
1180 + ctx = (ap_ctx *)ap_palloc(p, sizeof(ap_ctx_rec));
1182 + ctx->cr_entry = (ap_ctx_entry **)
1183 + ap_palloc(p, sizeof(ap_ctx_entry *)*(AP_CTX_MAX_ENTRIES+1));
1186 + ctx = (ap_ctx *)malloc(sizeof(ap_ctx_rec));
1187 + ctx->cr_pool = NULL;
1188 + ctx->cr_entry = (ap_ctx_entry **)
1189 + malloc(sizeof(ap_ctx_entry *)*(AP_CTX_MAX_ENTRIES+1));
1191 + for (i = 0; i < AP_CTX_MAX_ENTRIES+1; i++)
1192 + ctx->cr_entry[i] = NULL;
1196 +API_EXPORT(void) ap_ctx_set(ap_ctx *ctx, char *key, void *val)
1202 + for (i = 0; ctx->cr_entry[i] != NULL; i++) {
1203 + if (strcmp(ctx->cr_entry[i]->ce_key, key) == 0) {
1204 + ce = ctx->cr_entry[i];
1209 + if (i == AP_CTX_MAX_ENTRIES)
1211 + if (ctx->cr_pool != NULL) {
1212 + ce = (ap_ctx_entry *)ap_palloc(ctx->cr_pool, sizeof(ap_ctx_entry));
1213 + ce->ce_key = ap_pstrdup(ctx->cr_pool, key);
1216 + ce = (ap_ctx_entry *)malloc(sizeof(ap_ctx_entry));
1217 + ce->ce_key = strdup(key);
1219 + ctx->cr_entry[i] = ce;
1220 + ctx->cr_entry[i+1] = NULL;
1226 +API_EXPORT(void *) ap_ctx_get(ap_ctx *ctx, char *key)
1230 + for (i = 0; ctx->cr_entry[i] != NULL; i++)
1231 + if (strcmp(ctx->cr_entry[i]->ce_key, key) == 0)
1232 + return ctx->cr_entry[i]->ce_val;
1236 +API_EXPORT(ap_ctx *) ap_ctx_overlay(pool *p, ap_ctx *over, ap_ctx *base)
1243 + if (!ap_pool_is_ancestor(over->cr_pool, p))
1244 + ap_log_assert("ap_ctx_overlay: overlay's pool is not an ancestor of p",
1245 + __FILE__, __LINE__);
1246 + if (!ap_pool_is_ancestor(base->cr_pool, p))
1247 + ap_log_assert("ap_ctx_overlay: base's pool is not an ancestor of p",
1248 + __FILE__, __LINE__);
1251 + if ((new = ap_ctx_new(p)) == NULL)
1253 + memcpy(new->cr_entry, base->cr_entry,
1254 + sizeof(ap_ctx_entry *)*(AP_CTX_MAX_ENTRIES+1));
1255 + for (i = 0; over->cr_entry[i] != NULL; i++)
1256 + ap_ctx_set(new, over->cr_entry[i]->ce_key, over->cr_entry[i]->ce_val);
1261 diff -Nru apache_1.3.20/src/ap/ap_hook.c apache_1.3.20.new/src/ap/ap_hook.c
1262 --- apache_1.3.20/src/ap/ap_hook.c Thu Jan 1 01:00:00 1970
1263 +++ apache_1.3.20.new/src/ap/ap_hook.c Thu Dec 30 22:02:56 1999
1268 +/* ====================================================================
1269 + * Copyright (c) 1998-2000 The Apache Group. All rights reserved.
1271 + * Redistribution and use in source and binary forms, with or without
1272 + * modification, are permitted provided that the following conditions
1275 + * 1. Redistributions of source code must retain the above copyright
1276 + * notice, this list of conditions and the following disclaimer.
1278 + * 2. Redistributions in binary form must reproduce the above copyright
1279 + * notice, this list of conditions and the following disclaimer in
1280 + * the documentation and/or other materials provided with the
1283 + * 3. All advertising materials mentioning features or use of this
1284 + * software must display the following acknowledgment:
1285 + * "This product includes software developed by the Apache Group
1286 + * for use in the Apache HTTP server project (http://www.apache.org/)."
1288 + * 4. The names "Apache Server" and "Apache Group" must not be used to
1289 + * endorse or promote products derived from this software without
1290 + * prior written permission. For written permission, please contact
1291 + * apache@apache.org.
1293 + * 5. Products derived from this software may not be called "Apache"
1294 + * nor may "Apache" appear in their names without prior written
1295 + * permission of the Apache Group.
1297 + * 6. Redistributions of any form whatsoever must retain the following
1299 + * "This product includes software developed by the Apache Group
1300 + * for use in the Apache HTTP server project (http://www.apache.org/)."
1302 + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
1303 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1304 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1305 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
1306 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1307 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1308 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1309 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1310 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1311 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1312 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1313 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1314 + * ====================================================================
1316 + * This software consists of voluntary contributions made by many
1317 + * individuals on behalf of the Apache Group and was originally based
1318 + * on public domain software written at the National Center for
1319 + * Supercomputing Applications, University of Illinois, Urbana-Champaign.
1320 + * For more information on the Apache Group and the Apache HTTP server
1321 + * project, please see <http://www.apache.org/>.
1326 +** Implementation of a Generic Hook Interface for Apache
1327 +** Written by Ralf S. Engelschall <rse@engelschall.com>
1329 +** See POD document at end of ap_hook.h for description.
1330 +** View it with the command ``pod2man ap_hook.h | nroff -man | more''
1332 +** Attention: This source file is a little bit tricky.
1333 +** It's a combination of a C source and an embedded Perl script
1334 +** (which updates the C source). The purpose of this is to have
1335 +** both things together at one place. So you can both pass
1336 +** this file to the C compiler and the Perl interpreter.
1340 + * Premature optimization is
1341 + * the root of all evil.
1348 +#include "http_log.h"
1349 +#include "ap_config.h"
1350 +#include "ap_hook.h"
1353 + * the internal hook pool
1355 +static ap_hook_entry **ap_hook_pool = NULL;
1358 + * forward prototypes for internal functions
1360 +static int ap_hook_call_func(va_list ap, ap_hook_entry *he, ap_hook_func *hf);
1361 +static ap_hook_entry *ap_hook_create(char *hook);
1362 +static ap_hook_entry *ap_hook_find(char *hook);
1363 +static void ap_hook_destroy(ap_hook_entry *he);
1366 + * Initialize the hook mechanism
1368 +API_EXPORT(void) ap_hook_init(void)
1372 + if (ap_hook_pool != NULL)
1374 + ap_hook_pool = (ap_hook_entry **)malloc(sizeof(ap_hook_entry *)
1375 + *(AP_HOOK_MAX_ENTRIES+1));
1376 + for (i = 0; i < AP_HOOK_MAX_ENTRIES; i++)
1377 + ap_hook_pool[i] = NULL;
1382 + * Kill the hook mechanism
1384 +API_EXPORT(void) ap_hook_kill(void)
1388 + if (ap_hook_pool == NULL)
1390 + for (i = 0; ap_hook_pool[i] != NULL; i++)
1391 + ap_hook_destroy(ap_hook_pool[i]);
1392 + free(ap_hook_pool);
1393 + ap_hook_pool = NULL;
1398 + * Smart creation of a hook (when it exist this is the same as
1399 + * ap_hook_find, when it doesn't exists it is created)
1401 +static ap_hook_entry *ap_hook_create(char *hook)
1404 + ap_hook_entry *he;
1406 + for (i = 0; ap_hook_pool[i] != NULL; i++)
1407 + if (strcmp(ap_hook_pool[i]->he_hook, hook) == 0)
1408 + return ap_hook_pool[i];
1410 + if (i >= AP_HOOK_MAX_ENTRIES)
1413 + if ((he = (ap_hook_entry *)malloc(sizeof(ap_hook_entry))) == NULL)
1415 + ap_hook_pool[i] = he;
1417 + he->he_hook = strdup(hook);
1418 + he->he_sig = AP_HOOK_SIG_UNKNOWN;
1419 + he->he_modeid = AP_HOOK_MODE_UNKNOWN;
1420 + he->he_modeval.v_int = 0;
1422 + he->he_func = (ap_hook_func **)malloc(sizeof(ap_hook_func *)
1423 + *(AP_HOOK_MAX_FUNCS+1));
1424 + if (he->he_func == NULL)
1427 + for (i = 0; i < AP_HOOK_MAX_FUNCS; i++)
1428 + he->he_func[i] = NULL;
1433 + * Find a particular hook
1435 +static ap_hook_entry *ap_hook_find(char *hook)
1439 + for (i = 0; ap_hook_pool[i] != NULL; i++)
1440 + if (strcmp(ap_hook_pool[i]->he_hook, hook) == 0)
1441 + return ap_hook_pool[i];
1446 + * Destroy a particular hook
1448 +static void ap_hook_destroy(ap_hook_entry *he)
1454 + free(he->he_hook);
1455 + for (i = 0; he->he_func[i] != NULL; i++)
1456 + free(he->he_func[i]);
1457 + free(he->he_func);
1463 + * Configure a particular hook,
1464 + * i.e. remember its signature and return value mode
1466 +API_EXPORT(int) ap_hook_configure(char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...)
1468 + ap_hook_entry *he;
1472 + va_start(ap, modeid);
1473 + if ((he = ap_hook_create(hook)) == NULL)
1477 + he->he_modeid = modeid;
1478 + if (modeid == AP_HOOK_MODE_DECLINE || modeid == AP_HOOK_MODE_DECLTMP) {
1479 + if (AP_HOOK_SIG_HAS(sig, RC, char))
1480 + he->he_modeval.v_char = va_arg(ap, va_type(char));
1481 + else if (AP_HOOK_SIG_HAS(sig, RC, int))
1482 + he->he_modeval.v_int = va_arg(ap, va_type(int));
1483 + else if (AP_HOOK_SIG_HAS(sig, RC, long))
1484 + he->he_modeval.v_long = va_arg(ap, va_type(long));
1485 + else if (AP_HOOK_SIG_HAS(sig, RC, float))
1486 + he->he_modeval.v_float = va_arg(ap, va_type(float));
1487 + else if (AP_HOOK_SIG_HAS(sig, RC, double))
1488 + he->he_modeval.v_double = va_arg(ap, va_type(double));
1489 + else if (AP_HOOK_SIG_HAS(sig, RC, ptr))
1490 + he->he_modeval.v_ptr = va_arg(ap, va_type(ptr));
1499 + * Register a function to call for a hook
1501 +API_EXPORT(int) ap_hook_register_I(char *hook, void *func, void *ctx)
1504 + ap_hook_entry *he;
1507 + if ((he = ap_hook_create(hook)) == NULL)
1510 + for (i = 0; he->he_func[i] != NULL; i++)
1511 + if (he->he_func[i]->hf_ptr == func)
1514 + if (i == AP_HOOK_MAX_FUNCS)
1517 + if ((hf = (ap_hook_func *)malloc(sizeof(ap_hook_func))) == NULL)
1520 + for (j = i; j >= 0; j--)
1521 + he->he_func[j+1] = he->he_func[j];
1522 + he->he_func[0] = hf;
1524 + hf->hf_ptr = func;
1531 + * Unregister a function to call for a hook
1533 +API_EXPORT(int) ap_hook_unregister_I(char *hook, void *func)
1536 + ap_hook_entry *he;
1538 + if ((he = ap_hook_find(hook)) == NULL)
1540 + for (i = 0; he->he_func[i] != NULL; i++) {
1541 + if (he->he_func[i]->hf_ptr == func) {
1542 + free(he->he_func[i]);
1543 + for (j = i; he->he_func[j] != NULL; j++)
1544 + he->he_func[j] = he->he_func[j+1];
1552 + * Retrieve the status of a particular hook
1554 +API_EXPORT(ap_hook_state) ap_hook_status(char *hook)
1556 + ap_hook_entry *he;
1558 + if ((he = ap_hook_find(hook)) == NULL)
1559 + return AP_HOOK_STATE_NOTEXISTANT;
1560 + if ( he->he_func[0] != NULL
1561 + && he->he_sig != AP_HOOK_SIG_UNKNOWN
1562 + && he->he_modeid != AP_HOOK_MODE_UNKNOWN)
1563 + return AP_HOOK_STATE_REGISTERED;
1564 + if ( he->he_sig != AP_HOOK_SIG_UNKNOWN
1565 + && he->he_modeid != AP_HOOK_MODE_UNKNOWN)
1566 + return AP_HOOK_STATE_CONFIGURED;
1567 + return AP_HOOK_STATE_ESTABLISHED;
1571 + * Use a hook, i.e. optional on-the-fly configure it before calling it
1573 +API_EXPORT(int) ap_hook_use(char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...)
1576 + ap_hook_value modeval;
1577 + ap_hook_entry *he;
1581 + va_start(ap, modeid);
1583 + if (modeid == AP_HOOK_MODE_DECLINE || modeid == AP_HOOK_MODE_DECLTMP) {
1584 + if (AP_HOOK_SIG_HAS(sig, RC, char))
1585 + modeval.v_char = va_arg(ap, va_type(char));
1586 + else if (AP_HOOK_SIG_HAS(sig, RC, int))
1587 + modeval.v_int = va_arg(ap, va_type(int));
1588 + else if (AP_HOOK_SIG_HAS(sig, RC, long))
1589 + modeval.v_long = va_arg(ap, va_type(long));
1590 + else if (AP_HOOK_SIG_HAS(sig, RC, float))
1591 + modeval.v_float = va_arg(ap, va_type(float));
1592 + else if (AP_HOOK_SIG_HAS(sig, RC, double))
1593 + modeval.v_double = va_arg(ap, va_type(double));
1594 + else if (AP_HOOK_SIG_HAS(sig, RC, ptr))
1595 + modeval.v_ptr = va_arg(ap, va_type(ptr));
1598 + if ((he = ap_hook_create(hook)) == NULL)
1601 + if (he->he_sig == AP_HOOK_SIG_UNKNOWN)
1603 + if (he->he_modeid == AP_HOOK_MODE_UNKNOWN) {
1604 + he->he_modeid = modeid;
1605 + he->he_modeval = modeval;
1608 + for (i = 0; he->he_func[i] != NULL; i++)
1609 + if (ap_hook_call_func(ap, he, he->he_func[i]))
1612 + if (i > 0 && he->he_modeid == AP_HOOK_MODE_ALL)
1614 + else if (i == AP_HOOK_MAX_FUNCS || he->he_func[i] == NULL)
1626 +API_EXPORT(int) ap_hook_call(char *hook, ...)
1629 + ap_hook_entry *he;
1633 + va_start(ap, hook);
1635 + if ((he = ap_hook_find(hook)) == NULL) {
1639 + if ( he->he_sig == AP_HOOK_SIG_UNKNOWN
1640 + || he->he_modeid == AP_HOOK_MODE_UNKNOWN) {
1645 + for (i = 0; he->he_func[i] != NULL; i++)
1646 + if (ap_hook_call_func(ap, he, he->he_func[i]))
1649 + if (i > 0 && he->he_modeid == AP_HOOK_MODE_ALL)
1651 + else if (i == AP_HOOK_MAX_FUNCS || he->he_func[i] == NULL)
1660 +static int ap_hook_call_func(va_list ap, ap_hook_entry *he, ap_hook_func *hf)
1663 + ap_hook_value v_tmp;
1667 + * Now we dispatch the various function calls. We support function
1668 + * signatures with up to 9 types (1 return type, 8 argument types) where
1669 + * each argument can have 7 different types (ctx, char, int, long, float,
1670 + * double, ptr), so theoretically there are 9^7 (=4782969) combinations
1671 + * possible. But because we don't need all of them, of course, we
1672 + * implement only the following well chosen subset (duplicates are ok):
1674 + * 1. `The basic hook'.
1678 + * 2. The standard set of signatures which form all combinations of
1679 + * int&ptr based signatures for up to 3 arguments. We provide
1680 + * them per default for module authors.
1688 + * int func(int,int)
1689 + * int func(int,ptr)
1690 + * int func(ptr,int)
1691 + * int func(ptr,ptr)
1692 + * ptr func(int,int)
1693 + * ptr func(int,ptr)
1694 + * ptr func(ptr,int)
1695 + * ptr func(ptr,ptr)
1696 + * int func(int,int,int)
1697 + * int func(int,int,ptr)
1698 + * int func(int,ptr,int)
1699 + * int func(int,ptr,ptr)
1700 + * int func(ptr,int,int)
1701 + * int func(ptr,int,ptr)
1702 + * int func(ptr,ptr,int)
1703 + * int func(ptr,ptr,ptr)
1704 + * ptr func(int,int,int)
1705 + * ptr func(int,int,ptr)
1706 + * ptr func(int,ptr,int)
1707 + * ptr func(int,ptr,ptr)
1708 + * ptr func(ptr,int,int)
1709 + * ptr func(ptr,int,ptr)
1710 + * ptr func(ptr,ptr,int)
1711 + * ptr func(ptr,ptr,ptr)
1713 + * 3. Actually currently used hooks.
1715 + * int func(ptr) [2x]
1716 + * int func(ptr,ptr) [2x]
1717 + * int func(ptr,ptr,int) [5x]
1718 + * int func(ptr,ptr,ptr,int) [1x]
1719 + * int func(ptr,ptr,ptr,int,ptr) [1x]
1720 + * int func(ptr,ptr,ptr,ptr,int) [1x]
1721 + * int func(ptr,ptr,ptr,ptr,int,ptr) [1x]
1722 + * ptr func(ptr,ptr) [3x]
1723 + * ptr func(ptr,ptr,ptr,ptr,ptr) [1x]
1724 + * void func(ptr) [2x]
1725 + * void func(ptr,int,int) [1x]
1726 + * void func(ptr,ptr) [5x]
1727 + * void func(ptr,ptr,ptr) [3x]
1728 + * void func(ptr,ptr,ptr,ptr) [2x]
1730 + * To simplify the programming task we generate the actual dispatch code
1731 + * for these calls via the embedded Perl script at the end of this source
1732 + * file. This script parses the above lines and generates the section
1733 + * below. So, when you need more signature variants just add them to the
1734 + * above list and run
1736 + * $ perl ap_hook.c
1738 + * This automatically updates the above code.
1743 + if (!AP_HOOK_SIG_HAS(he->he_sig, RC, void)) {
1744 + if (he->he_modeid == AP_HOOK_MODE_DECLTMP) {
1745 + /* the return variable is a temporary one */
1746 + if (AP_HOOK_SIG_HAS(he->he_sig, RC, char))
1747 + v_rc = &v_tmp.v_char;
1748 + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, int))
1749 + v_rc = &v_tmp.v_int;
1750 + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, long))
1751 + v_rc = &v_tmp.v_long;
1752 + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, float))
1753 + v_rc = &v_tmp.v_float;
1754 + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, double))
1755 + v_rc = &v_tmp.v_double;
1756 + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, ptr))
1757 + v_rc = &v_tmp.v_ptr;
1760 + /* the return variable is provided by caller */
1761 + v_rc = va_arg(ap, void *);
1765 + /* ----BEGIN GENERATED SECTION-------- */
1766 + if (he->he_sig == AP_HOOK_SIG1(void)) {
1767 + /* Call: void func() */
1768 + ((void(*)())(hf->hf_ptr))();
1770 + else if (he->he_sig == AP_HOOK_SIG1(int)) {
1771 + /* Call: int func() */
1772 + *((int *)v_rc) = ((int(*)())(hf->hf_ptr))();
1773 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1775 + else if (he->he_sig == AP_HOOK_SIG1(ptr)) {
1776 + /* Call: ptr func() */
1777 + *((void * *)v_rc) = ((void *(*)())(hf->hf_ptr))();
1778 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1780 + else if (he->he_sig == AP_HOOK_SIG2(int, int)) {
1781 + /* Call: int func(int) */
1782 + int v1 = va_arg(ap, va_type(int));
1783 + *((int *)v_rc) = ((int(*)(int))(hf->hf_ptr))(v1);
1784 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1786 + else if (he->he_sig == AP_HOOK_SIG2(int, ptr)) {
1787 + /* Call: int func(ptr) */
1788 + void *v1 = va_arg(ap, va_type(ptr));
1789 + *((int *)v_rc) = ((int(*)(void *))(hf->hf_ptr))(v1);
1790 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1792 + else if (he->he_sig == AP_HOOK_SIG2(ptr, int)) {
1793 + /* Call: ptr func(int) */
1794 + int v1 = va_arg(ap, va_type(int));
1795 + *((void * *)v_rc) = ((void *(*)(int))(hf->hf_ptr))(v1);
1796 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1798 + else if (he->he_sig == AP_HOOK_SIG2(ptr, ptr)) {
1799 + /* Call: ptr func(ptr) */
1800 + void *v1 = va_arg(ap, va_type(ptr));
1801 + *((void * *)v_rc) = ((void *(*)(void *))(hf->hf_ptr))(v1);
1802 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1804 + else if (he->he_sig == AP_HOOK_SIG3(int, int, int)) {
1805 + /* Call: int func(int,int) */
1806 + int v1 = va_arg(ap, va_type(int));
1807 + int v2 = va_arg(ap, va_type(int));
1808 + *((int *)v_rc) = ((int(*)(int, int))(hf->hf_ptr))(v1, v2);
1809 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1811 + else if (he->he_sig == AP_HOOK_SIG3(int, int, ptr)) {
1812 + /* Call: int func(int,ptr) */
1813 + int v1 = va_arg(ap, va_type(int));
1814 + void *v2 = va_arg(ap, va_type(ptr));
1815 + *((int *)v_rc) = ((int(*)(int, void *))(hf->hf_ptr))(v1, v2);
1816 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1818 + else if (he->he_sig == AP_HOOK_SIG3(int, ptr, int)) {
1819 + /* Call: int func(ptr,int) */
1820 + void *v1 = va_arg(ap, va_type(ptr));
1821 + int v2 = va_arg(ap, va_type(int));
1822 + *((int *)v_rc) = ((int(*)(void *, int))(hf->hf_ptr))(v1, v2);
1823 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1825 + else if (he->he_sig == AP_HOOK_SIG3(int, ptr, ptr)) {
1826 + /* Call: int func(ptr,ptr) */
1827 + void *v1 = va_arg(ap, va_type(ptr));
1828 + void *v2 = va_arg(ap, va_type(ptr));
1829 + *((int *)v_rc) = ((int(*)(void *, void *))(hf->hf_ptr))(v1, v2);
1830 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1832 + else if (he->he_sig == AP_HOOK_SIG3(ptr, int, int)) {
1833 + /* Call: ptr func(int,int) */
1834 + int v1 = va_arg(ap, va_type(int));
1835 + int v2 = va_arg(ap, va_type(int));
1836 + *((void * *)v_rc) = ((void *(*)(int, int))(hf->hf_ptr))(v1, v2);
1837 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1839 + else if (he->he_sig == AP_HOOK_SIG3(ptr, int, ptr)) {
1840 + /* Call: ptr func(int,ptr) */
1841 + int v1 = va_arg(ap, va_type(int));
1842 + void *v2 = va_arg(ap, va_type(ptr));
1843 + *((void * *)v_rc) = ((void *(*)(int, void *))(hf->hf_ptr))(v1, v2);
1844 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1846 + else if (he->he_sig == AP_HOOK_SIG3(ptr, ptr, int)) {
1847 + /* Call: ptr func(ptr,int) */
1848 + void *v1 = va_arg(ap, va_type(ptr));
1849 + int v2 = va_arg(ap, va_type(int));
1850 + *((void * *)v_rc) = ((void *(*)(void *, int))(hf->hf_ptr))(v1, v2);
1851 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1853 + else if (he->he_sig == AP_HOOK_SIG3(ptr, ptr, ptr)) {
1854 + /* Call: ptr func(ptr,ptr) */
1855 + void *v1 = va_arg(ap, va_type(ptr));
1856 + void *v2 = va_arg(ap, va_type(ptr));
1857 + *((void * *)v_rc) = ((void *(*)(void *, void *))(hf->hf_ptr))(v1, v2);
1858 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1860 + else if (he->he_sig == AP_HOOK_SIG4(int, int, int, int)) {
1861 + /* Call: int func(int,int,int) */
1862 + int v1 = va_arg(ap, va_type(int));
1863 + int v2 = va_arg(ap, va_type(int));
1864 + int v3 = va_arg(ap, va_type(int));
1865 + *((int *)v_rc) = ((int(*)(int, int, int))(hf->hf_ptr))(v1, v2, v3);
1866 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1868 + else if (he->he_sig == AP_HOOK_SIG4(int, int, int, ptr)) {
1869 + /* Call: int func(int,int,ptr) */
1870 + int v1 = va_arg(ap, va_type(int));
1871 + int v2 = va_arg(ap, va_type(int));
1872 + void *v3 = va_arg(ap, va_type(ptr));
1873 + *((int *)v_rc) = ((int(*)(int, int, void *))(hf->hf_ptr))(v1, v2, v3);
1874 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1876 + else if (he->he_sig == AP_HOOK_SIG4(int, int, ptr, int)) {
1877 + /* Call: int func(int,ptr,int) */
1878 + int v1 = va_arg(ap, va_type(int));
1879 + void *v2 = va_arg(ap, va_type(ptr));
1880 + int v3 = va_arg(ap, va_type(int));
1881 + *((int *)v_rc) = ((int(*)(int, void *, int))(hf->hf_ptr))(v1, v2, v3);
1882 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1884 + else if (he->he_sig == AP_HOOK_SIG4(int, int, ptr, ptr)) {
1885 + /* Call: int func(int,ptr,ptr) */
1886 + int v1 = va_arg(ap, va_type(int));
1887 + void *v2 = va_arg(ap, va_type(ptr));
1888 + void *v3 = va_arg(ap, va_type(ptr));
1889 + *((int *)v_rc) = ((int(*)(int, void *, void *))(hf->hf_ptr))(v1, v2, v3);
1890 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1892 + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, int, int)) {
1893 + /* Call: int func(ptr,int,int) */
1894 + void *v1 = va_arg(ap, va_type(ptr));
1895 + int v2 = va_arg(ap, va_type(int));
1896 + int v3 = va_arg(ap, va_type(int));
1897 + *((int *)v_rc) = ((int(*)(void *, int, int))(hf->hf_ptr))(v1, v2, v3);
1898 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1900 + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, int, ptr)) {
1901 + /* Call: int func(ptr,int,ptr) */
1902 + void *v1 = va_arg(ap, va_type(ptr));
1903 + int v2 = va_arg(ap, va_type(int));
1904 + void *v3 = va_arg(ap, va_type(ptr));
1905 + *((int *)v_rc) = ((int(*)(void *, int, void *))(hf->hf_ptr))(v1, v2, v3);
1906 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1908 + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, ptr, int)) {
1909 + /* Call: int func(ptr,ptr,int) */
1910 + void *v1 = va_arg(ap, va_type(ptr));
1911 + void *v2 = va_arg(ap, va_type(ptr));
1912 + int v3 = va_arg(ap, va_type(int));
1913 + *((int *)v_rc) = ((int(*)(void *, void *, int))(hf->hf_ptr))(v1, v2, v3);
1914 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1916 + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, ptr, ptr)) {
1917 + /* Call: int func(ptr,ptr,ptr) */
1918 + void *v1 = va_arg(ap, va_type(ptr));
1919 + void *v2 = va_arg(ap, va_type(ptr));
1920 + void *v3 = va_arg(ap, va_type(ptr));
1921 + *((int *)v_rc) = ((int(*)(void *, void *, void *))(hf->hf_ptr))(v1, v2, v3);
1922 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1924 + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, int, int)) {
1925 + /* Call: ptr func(int,int,int) */
1926 + int v1 = va_arg(ap, va_type(int));
1927 + int v2 = va_arg(ap, va_type(int));
1928 + int v3 = va_arg(ap, va_type(int));
1929 + *((void * *)v_rc) = ((void *(*)(int, int, int))(hf->hf_ptr))(v1, v2, v3);
1930 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1932 + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, int, ptr)) {
1933 + /* Call: ptr func(int,int,ptr) */
1934 + int v1 = va_arg(ap, va_type(int));
1935 + int v2 = va_arg(ap, va_type(int));
1936 + void *v3 = va_arg(ap, va_type(ptr));
1937 + *((void * *)v_rc) = ((void *(*)(int, int, void *))(hf->hf_ptr))(v1, v2, v3);
1938 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1940 + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, ptr, int)) {
1941 + /* Call: ptr func(int,ptr,int) */
1942 + int v1 = va_arg(ap, va_type(int));
1943 + void *v2 = va_arg(ap, va_type(ptr));
1944 + int v3 = va_arg(ap, va_type(int));
1945 + *((void * *)v_rc) = ((void *(*)(int, void *, int))(hf->hf_ptr))(v1, v2, v3);
1946 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1948 + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, ptr, ptr)) {
1949 + /* Call: ptr func(int,ptr,ptr) */
1950 + int v1 = va_arg(ap, va_type(int));
1951 + void *v2 = va_arg(ap, va_type(ptr));
1952 + void *v3 = va_arg(ap, va_type(ptr));
1953 + *((void * *)v_rc) = ((void *(*)(int, void *, void *))(hf->hf_ptr))(v1, v2, v3);
1954 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1956 + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, int, int)) {
1957 + /* Call: ptr func(ptr,int,int) */
1958 + void *v1 = va_arg(ap, va_type(ptr));
1959 + int v2 = va_arg(ap, va_type(int));
1960 + int v3 = va_arg(ap, va_type(int));
1961 + *((void * *)v_rc) = ((void *(*)(void *, int, int))(hf->hf_ptr))(v1, v2, v3);
1962 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1964 + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, int, ptr)) {
1965 + /* Call: ptr func(ptr,int,ptr) */
1966 + void *v1 = va_arg(ap, va_type(ptr));
1967 + int v2 = va_arg(ap, va_type(int));
1968 + void *v3 = va_arg(ap, va_type(ptr));
1969 + *((void * *)v_rc) = ((void *(*)(void *, int, void *))(hf->hf_ptr))(v1, v2, v3);
1970 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1972 + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, ptr, int)) {
1973 + /* Call: ptr func(ptr,ptr,int) */
1974 + void *v1 = va_arg(ap, va_type(ptr));
1975 + void *v2 = va_arg(ap, va_type(ptr));
1976 + int v3 = va_arg(ap, va_type(int));
1977 + *((void * *)v_rc) = ((void *(*)(void *, void *, int))(hf->hf_ptr))(v1, v2, v3);
1978 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1980 + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, ptr, ptr)) {
1981 + /* Call: ptr func(ptr,ptr,ptr) */
1982 + void *v1 = va_arg(ap, va_type(ptr));
1983 + void *v2 = va_arg(ap, va_type(ptr));
1984 + void *v3 = va_arg(ap, va_type(ptr));
1985 + *((void * *)v_rc) = ((void *(*)(void *, void *, void *))(hf->hf_ptr))(v1, v2, v3);
1986 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
1988 + else if (he->he_sig == AP_HOOK_SIG5(int, ptr, ptr, ptr, int)) {
1989 + /* Call: int func(ptr,ptr,ptr,int) */
1990 + void *v1 = va_arg(ap, va_type(ptr));
1991 + void *v2 = va_arg(ap, va_type(ptr));
1992 + void *v3 = va_arg(ap, va_type(ptr));
1993 + int v4 = va_arg(ap, va_type(int));
1994 + *((int *)v_rc) = ((int(*)(void *, void *, void *, int))(hf->hf_ptr))(v1, v2, v3, v4);
1995 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
1997 + else if (he->he_sig == AP_HOOK_SIG6(int, ptr, ptr, ptr, int, ptr)) {
1998 + /* Call: int func(ptr,ptr,ptr,int,ptr) */
1999 + void *v1 = va_arg(ap, va_type(ptr));
2000 + void *v2 = va_arg(ap, va_type(ptr));
2001 + void *v3 = va_arg(ap, va_type(ptr));
2002 + int v4 = va_arg(ap, va_type(int));
2003 + void *v5 = va_arg(ap, va_type(ptr));
2004 + *((int *)v_rc) = ((int(*)(void *, void *, void *, int, void *))(hf->hf_ptr))(v1, v2, v3, v4, v5);
2005 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
2007 + else if (he->he_sig == AP_HOOK_SIG6(int, ptr, ptr, ptr, ptr, int)) {
2008 + /* Call: int func(ptr,ptr,ptr,ptr,int) */
2009 + void *v1 = va_arg(ap, va_type(ptr));
2010 + void *v2 = va_arg(ap, va_type(ptr));
2011 + void *v3 = va_arg(ap, va_type(ptr));
2012 + void *v4 = va_arg(ap, va_type(ptr));
2013 + int v5 = va_arg(ap, va_type(int));
2014 + *((int *)v_rc) = ((int(*)(void *, void *, void *, void *, int))(hf->hf_ptr))(v1, v2, v3, v4, v5);
2015 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
2017 + else if (he->he_sig == AP_HOOK_SIG7(int, ptr, ptr, ptr, ptr, int, ptr)) {
2018 + /* Call: int func(ptr,ptr,ptr,ptr,int,ptr) */
2019 + void *v1 = va_arg(ap, va_type(ptr));
2020 + void *v2 = va_arg(ap, va_type(ptr));
2021 + void *v3 = va_arg(ap, va_type(ptr));
2022 + void *v4 = va_arg(ap, va_type(ptr));
2023 + int v5 = va_arg(ap, va_type(int));
2024 + void *v6 = va_arg(ap, va_type(ptr));
2025 + *((int *)v_rc) = ((int(*)(void *, void *, void *, void *, int, void *))(hf->hf_ptr))(v1, v2, v3, v4, v5, v6);
2026 + rc = (*((int *)v_rc) != he->he_modeval.v_int);
2028 + else if (he->he_sig == AP_HOOK_SIG6(ptr, ptr, ptr, ptr, ptr, ptr)) {
2029 + /* Call: ptr func(ptr,ptr,ptr,ptr,ptr) */
2030 + void *v1 = va_arg(ap, va_type(ptr));
2031 + void *v2 = va_arg(ap, va_type(ptr));
2032 + void *v3 = va_arg(ap, va_type(ptr));
2033 + void *v4 = va_arg(ap, va_type(ptr));
2034 + void *v5 = va_arg(ap, va_type(ptr));
2035 + *((void * *)v_rc) = ((void *(*)(void *, void *, void *, void *, void *))(hf->hf_ptr))(v1, v2, v3, v4, v5);
2036 + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr);
2038 + else if (he->he_sig == AP_HOOK_SIG2(void, ptr)) {
2039 + /* Call: void func(ptr) */
2040 + void *v1 = va_arg(ap, va_type(ptr));
2041 + ((void(*)(void *))(hf->hf_ptr))(v1);
2043 + else if (he->he_sig == AP_HOOK_SIG4(void, ptr, int, int)) {
2044 + /* Call: void func(ptr,int,int) */
2045 + void *v1 = va_arg(ap, va_type(ptr));
2046 + int v2 = va_arg(ap, va_type(int));
2047 + int v3 = va_arg(ap, va_type(int));
2048 + ((void(*)(void *, int, int))(hf->hf_ptr))(v1, v2, v3);
2050 + else if (he->he_sig == AP_HOOK_SIG3(void, ptr, ptr)) {
2051 + /* Call: void func(ptr,ptr) */
2052 + void *v1 = va_arg(ap, va_type(ptr));
2053 + void *v2 = va_arg(ap, va_type(ptr));
2054 + ((void(*)(void *, void *))(hf->hf_ptr))(v1, v2);
2056 + else if (he->he_sig == AP_HOOK_SIG4(void, ptr, ptr, ptr)) {
2057 + /* Call: void func(ptr,ptr,ptr) */
2058 + void *v1 = va_arg(ap, va_type(ptr));
2059 + void *v2 = va_arg(ap, va_type(ptr));
2060 + void *v3 = va_arg(ap, va_type(ptr));
2061 + ((void(*)(void *, void *, void *))(hf->hf_ptr))(v1, v2, v3);
2063 + else if (he->he_sig == AP_HOOK_SIG5(void, ptr, ptr, ptr, ptr)) {
2064 + /* Call: void func(ptr,ptr,ptr,ptr) */
2065 + void *v1 = va_arg(ap, va_type(ptr));
2066 + void *v2 = va_arg(ap, va_type(ptr));
2067 + void *v3 = va_arg(ap, va_type(ptr));
2068 + void *v4 = va_arg(ap, va_type(ptr));
2069 + ((void(*)(void *, void *, void *, void *))(hf->hf_ptr))(v1, v2, v3, v4);
2071 + /* ----END GENERATED SECTION---------- */
2073 + ap_log_assert("hook signature not implemented", __FILE__, __LINE__);
2075 + if (he->he_modeid == AP_HOOK_MODE_ALL)
2077 + else if (he->he_modeid == AP_HOOK_MODE_TOPMOST)
2088 +## Embedded Perl script for generating the dispatch section
2096 +my $begin = '----BEGIN GENERATED SECTION--------';
2097 +my $end = '----END GENERATED SECTION----------';
2099 +# special command: find used signatures
2100 +if ($ARGV[0] eq 'used') {
2101 + my @S = `find .. -type f -name "*.c" -print`;
2106 + open(FP, "<$s") || die;
2108 + $source .= $_ while (<FP>);
2112 + my ($src, $hook, $sig) = @_;
2113 + return if ($seen{$hook} == 1);
2115 + my ($rc, $args) = ($sig =~ m|^([^,]+)(.*)$|);
2118 + my $sig = sprintf("%-6sfunc(%s)", $rc, $args);
2121 + $source =~ s|\("([^"]+)",\s*AP_HOOK_SIG[0-9]\((.+?)\)|&printme($s, $1, $2), ''|sge;
2124 + foreach $t (sort(keys(%T))) {
2125 + printf(" * %-40s [%dx]\n", $t, $T{$t});
2130 +# read ourself and keep a backup
2131 +open(FP, "<$file") || die;
2133 +$source .= $_ while (<FP>);
2135 +open(FP, ">$file.bak") || die;
2139 +# now parse the signature lines and update the code
2144 +foreach $line (split(/\n/, $source)) {
2145 + next if (not $line =~ m|\*\s+\S+\s+func\(.*\)|);
2146 + my ($sig, $rc, $param) = ($line =~ m|\*\s+((\S+)\s+func\((.*?)\))|);
2147 + $sig =~ s|\s+| |g;
2149 + next if ($seen{$sig} == 1);
2152 + print "Generating code for `$sig'\n";
2154 + my @S = ($rc, split(/[\s,]+/, $param));
2157 + for ($i = 0; $i <= $#RS; $i++) {
2158 + $RS[$i] = 'void *' if ($RS[$i] eq 'ptr');
2159 + $RS[$i] = 'void *' if ($RS[$i] eq 'ctx');
2162 + $o .= "else " if ($next); $next++;
2163 + $o .= sprintf("if (he->he_sig == AP_HOOK_SIG%d(%s)) {\n", $#S+1, join(', ',@S));
2164 + $o .= sprintf(" \/\* Call: %s \*\/\n", $sig);
2165 + for ($i = 1; $i <= $#S; $i++) {
2166 + $o .= sprintf(" %-6sv%d = va_arg(ap, va_type(%s));\n", $RS[$i], $i, $S[$i]);
2169 + $o .= sprintf("*((%s *)v_rc) = ", $RS[0]) if ($S[0] ne 'void');
2170 + $o .= sprintf("((%s(*)(%s))(hf->hf_ptr))", $RS[0], join(', ', @RS[1..$#RS]));
2172 + for ($i = 1; $i <= $#S; $i++) {
2173 + $o .= "hf->hf_ctx" if ($S[$i] eq 'ctx');
2174 + $o .= sprintf("v%d", $i) if ($S[$i] ne 'ctx');
2175 + $o .= ", " if ($i < $#S);
2178 + $o .= sprintf(" rc = (*((%s *)v_rc) != he->he_modeval.v_%s);\n",
2179 + $RS[0], $S[0]) if ($S[0] ne 'void');
2183 +# insert the generated code at the target location
2185 +$source =~ s|(\/\* $begin.+?\n).*\n(.*?\/\* $end)|$1$o$2|s;
2187 +# and update the source on disk
2188 +print "Updating file `$file'\n";
2189 +open(FP, ">$file") || die;
2195 diff -Nru apache_1.3.20/src/ap/ap_mm.c apache_1.3.20.new/src/ap/ap_mm.c
2196 --- apache_1.3.20/src/ap/ap_mm.c Thu Jan 1 01:00:00 1970
2197 +++ apache_1.3.20.new/src/ap/ap_mm.c Thu Dec 30 22:02:56 1999
2199 +/* ====================================================================
2200 + * Copyright (c) 1999-2000 The Apache Group. All rights reserved.
2202 + * Redistribution and use in source and binary forms, with or without
2203 + * modification, are permitted provided that the following conditions
2206 + * 1. Redistributions of source code must retain the above copyright
2207 + * notice, this list of conditions and the following disclaimer.
2209 + * 2. Redistributions in binary form must reproduce the above copyright
2210 + * notice, this list of conditions and the following disclaimer in
2211 + * the documentation and/or other materials provided with the
2214 + * 3. All advertising materials mentioning features or use of this
2215 + * software must display the following acknowledgment:
2216 + * "This product includes software developed by the Apache Group
2217 + * for use in the Apache HTTP server project (http://www.apache.org/)."
2219 + * 4. The names "Apache Server" and "Apache Group" must not be used to
2220 + * endorse or promote products derived from this software without
2221 + * prior written permission. For written permission, please contact
2222 + * apache@apache.org.
2224 + * 5. Products derived from this software may not be called "Apache"
2225 + * nor may "Apache" appear in their names without prior written
2226 + * permission of the Apache Group.
2228 + * 6. Redistributions of any form whatsoever must retain the following
2230 + * "This product includes software developed by the Apache Group
2231 + * for use in the Apache HTTP server project (http://www.apache.org/)."
2233 + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
2234 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2235 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2236 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
2237 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2238 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2239 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2240 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2241 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
2242 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2243 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
2244 + * OF THE POSSIBILITY OF SUCH DAMAGE.
2245 + * ====================================================================
2247 + * This software consists of voluntary contributions made by many
2248 + * individuals on behalf of the Apache Group and was originally based
2249 + * on public domain software written at the National Center for
2250 + * Supercomputing Applications, University of Illinois, Urbana-Champaign.
2251 + * For more information on the Apache Group and the Apache HTTP server
2252 + * project, please see <http://www.apache.org/>.
2256 +** ap_mm.c -- wrapper for MM shared memory library
2258 +** This file has two reason:
2260 +** 1. Under DSO context we need stubs inside the Apache core code
2261 +** to make sure the MM library's code is actually available
2262 +** to the module DSOs.
2264 +** 2. When the MM library cannot be built on the current platform
2265 +** still provide dummy stubs so modules using the ap_mm_xxx()
2266 +** functions can be still built. But modules should use
2267 +** ap_mm_useable() to find out whether they really can use
2271 + * "What you see is all you get."
2272 + * -- Brian Kernighan
2281 +API_EXPORT(int) ap_mm_useable(void) { return TRUE; }
2282 +#define STUB(val,nul) { return val; }
2283 +#define STUB_STMT(stmt) { stmt; return; }
2285 +API_EXPORT(int) ap_mm_useable(void) { return FALSE; }
2286 +#define STUB(val,nul) { return nul; }
2287 +#define STUB_STMT(stmt) { return; }
2290 +API_EXPORT(int) ap_MM_create(size_t size, char *file)
2291 + STUB(MM_create(size, file), FALSE)
2292 +API_EXPORT(int) ap_MM_permission(mode_t mode, uid_t owner, gid_t group)
2293 + STUB(MM_permission(mode, owner, group), -1)
2294 +API_EXPORT(void) ap_MM_destroy(void)
2295 + STUB_STMT(MM_destroy())
2296 +API_EXPORT(int) ap_MM_lock(ap_mm_lock_mode mode)
2297 + STUB(MM_lock(mode), FALSE)
2298 +API_EXPORT(int) ap_MM_unlock(void)
2299 + STUB(MM_unlock(), FALSE)
2300 +API_EXPORT(void *) ap_MM_malloc(size_t size)
2301 + STUB(MM_malloc(size), NULL)
2302 +API_EXPORT(void *) ap_MM_realloc(void *ptr, size_t size)
2303 + STUB(MM_realloc(ptr, size), NULL)
2304 +API_EXPORT(void) ap_MM_free(void *ptr)
2305 + STUB_STMT(MM_free(ptr))
2306 +API_EXPORT(void *) ap_MM_calloc(size_t number, size_t size)
2307 + STUB(MM_calloc(number, size), NULL)
2308 +API_EXPORT(char *) ap_MM_strdup(const char *str)
2309 + STUB(MM_strdup(str), NULL)
2310 +API_EXPORT(size_t) ap_MM_sizeof(void *ptr)
2311 + STUB(MM_sizeof(ptr), 0)
2312 +API_EXPORT(size_t) ap_MM_maxsize(void)
2313 + STUB(MM_maxsize(), 0)
2314 +API_EXPORT(size_t) ap_MM_available(void)
2315 + STUB(MM_available(), 0)
2316 +API_EXPORT(char *) ap_MM_error(void)
2317 + STUB(MM_error(), NULL)
2319 +API_EXPORT(AP_MM *) ap_mm_create(size_t size, char *file)
2320 + STUB(mm_create(size, file), NULL)
2321 +API_EXPORT(int) ap_mm_permission(AP_MM *mm, mode_t mode, uid_t owner, gid_t group)
2322 + STUB(mm_permission(mm, mode, owner, group), -1)
2323 +API_EXPORT(void) ap_mm_destroy(AP_MM *mm)
2324 + STUB_STMT(mm_destroy(mm))
2325 +API_EXPORT(int) ap_mm_lock(AP_MM *mm, ap_mm_lock_mode mode)
2326 + STUB(mm_lock(mm, mode), FALSE)
2327 +API_EXPORT(int) ap_mm_unlock(AP_MM *mm)
2328 + STUB(mm_unlock(mm), FALSE)
2329 +API_EXPORT(void *) ap_mm_malloc(AP_MM *mm, size_t size)
2330 + STUB(mm_malloc(mm, size), NULL)
2331 +API_EXPORT(void *) ap_mm_realloc(AP_MM *mm, void *ptr, size_t size)
2332 + STUB(mm_realloc(mm, ptr, size), NULL)
2333 +API_EXPORT(void) ap_mm_free(AP_MM *mm, void *ptr)
2334 + STUB_STMT(mm_free(mm, ptr))
2335 +API_EXPORT(void *) ap_mm_calloc(AP_MM *mm, size_t number, size_t size)
2336 + STUB(mm_calloc(mm, number, size), NULL)
2337 +API_EXPORT(char *) ap_mm_strdup(AP_MM *mm, const char *str)
2338 + STUB(mm_strdup(mm, str), NULL)
2339 +API_EXPORT(size_t) ap_mm_sizeof(AP_MM *mm, void *ptr)
2340 + STUB(mm_sizeof(mm, ptr), 0)
2341 +API_EXPORT(size_t) ap_mm_maxsize(void)
2342 + STUB(mm_maxsize(), 0)
2343 +API_EXPORT(size_t) ap_mm_available(AP_MM *mm)
2344 + STUB(mm_available(mm), 0)
2345 +API_EXPORT(char *) ap_mm_error(void)
2346 + STUB(mm_error(), NULL)
2347 +API_EXPORT(void) ap_mm_display_info(AP_MM *mm)
2348 + STUB_STMT(mm_display_info(mm))
2350 +API_EXPORT(void *) ap_mm_core_create(size_t size, char *file)
2351 + STUB(mm_core_create(size, file), NULL)
2352 +API_EXPORT(int) ap_mm_core_permission(void *core, mode_t mode, uid_t owner, gid_t group)
2353 + STUB(mm_core_permission(core, mode, owner, group), -1)
2354 +API_EXPORT(void) ap_mm_core_delete(void *core)
2355 + STUB_STMT(mm_core_delete(core))
2356 +API_EXPORT(size_t) ap_mm_core_size(void *core)
2357 + STUB(mm_core_size(core), 0)
2358 +API_EXPORT(int) ap_mm_core_lock(void *core, ap_mm_lock_mode mode)
2359 + STUB(mm_core_lock(core, mode), FALSE)
2360 +API_EXPORT(int) ap_mm_core_unlock(void *core)
2361 + STUB(mm_core_unlock(core), FALSE)
2362 +API_EXPORT(size_t) ap_mm_core_maxsegsize(void)
2363 + STUB(mm_core_maxsegsize(), 0)
2364 +API_EXPORT(size_t) ap_mm_core_align2page(size_t size)
2365 + STUB(mm_core_align2page(size), 0)
2366 +API_EXPORT(size_t) ap_mm_core_align2word(size_t size)
2367 + STUB(mm_core_align2word(size), 0)
2369 +API_EXPORT(void) ap_mm_lib_error_set(unsigned int type, const char *str)
2370 + STUB_STMT(mm_lib_error_set(type, str))
2371 +API_EXPORT(char *) ap_mm_lib_error_get(void)
2372 + STUB(mm_lib_error_get(), NULL)
2373 +API_EXPORT(int) ap_mm_lib_version(void)
2374 + STUB(mm_lib_version(), 0)
2377 diff -Nru apache_1.3.20/src/modules/extra/mod_define.c apache_1.3.20.new/src/modules/extra/mod_define.c
2378 --- apache_1.3.20/src/modules/extra/mod_define.c Thu Jan 1 01:00:00 1970
2379 +++ apache_1.3.20.new/src/modules/extra/mod_define.c Thu Dec 30 22:00:58 1999
2382 +** mod_define.c - Apache module for configuration defines ($xxx)
2384 +** Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
2385 +** Copyright (c) 1998-2000 Christian Reiber <chrei@en.muc.de>
2387 +** Permission to use, copy, modify, and distribute this software for
2388 +** any purpose with or without fee is hereby granted, provided that
2389 +** the above copyright notice and this permission notice appear in all
2392 +** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
2393 +** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2394 +** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2395 +** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
2396 +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2397 +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2398 +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2399 +** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2400 +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2401 +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2402 +** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2409 + * v1.0: Originally written in December 1998 by
2410 + * Ralf S. Engelschall <rse@engelschall.com> and
2411 + * Christian Reiber <chrei@en.muc.de>
2413 + * v1.1: Completely Overhauled in August 1999 by
2414 + * Ralf S. Engelschall <rse@engelschall.com>
2417 +#include "ap_config.h"
2418 +#include "ap_ctype.h"
2420 +#include "http_config.h"
2421 +#include "http_conf_globals.h"
2422 +#include "http_core.h"
2423 +#include "http_log.h"
2426 +#error "This module requires the Extended API (EAPI) facilities."
2430 + * The global table of defines
2433 +static table *tDefines = NULL; /* global table of defines */
2434 +static int bOnceSeenADefine = FALSE; /* optimization flag */
2437 + * Forward declaration
2439 +static int DefineIndex (pool *, char *, int *, int *, char **);
2440 +static char *DefineFetch (pool *, char *);
2441 +static char *DefineExpand (pool *, char *, int, char *);
2442 +static void DefineInit (pool *);
2443 +static void DefineCleanup (void *);
2444 +static char *DefineRewriteHook(cmd_parms *, void *, const char *);
2447 + * Character classes for scanner function
2450 + CC_ESCAPE, CC_DOLLAR, CC_BRACEOPEN, CC_BRACECLOSE,
2451 + CC_IDCHAR1, CC_IDCHAR, CC_OTHER, CC_EOS
2455 + * Scanner states for scanner function
2458 + SS_NONE, SS_SKIP, SS_DOLLAR, SS_TOKEN_BRACED,
2459 + SS_TOKEN_UNBRACED, SS_ERROR, SS_FOUND
2463 + * Default meta characters
2465 +#define DEFAULT_MC_ESCAPE "\\"
2466 +#define DEFAULT_MC_DOLLAR "$"
2467 +#define DEFAULT_MC_BRACEOPEN "{"
2468 +#define DEFAULT_MC_BRACECLOSE "}"
2471 + * Scanner for variable constructs $xxx and ${xxx}
2473 +static int DefineIndex(pool *p, char *cpLine, int *pos, int *len, char **cpVar)
2486 + cEscape = DEFAULT_MC_ESCAPE[0];
2487 + if ((cp = DefineFetch(p, "mod_define::escape")) != NULL)
2489 + cDefine = DEFAULT_MC_DOLLAR[0];
2490 + if ((cp = DefineFetch(p, "mod_define::dollar")) != NULL)
2492 + cBraceOpen = DEFAULT_MC_BRACEOPEN[0];
2493 + if ((cp = DefineFetch(p, "mod_define::braceopen")) != NULL)
2494 + cBraceOpen = cp[0];
2495 + cBraceClose = DEFAULT_MC_BRACECLOSE[0];
2496 + if ((cp = DefineFetch(p, "mod_define::braceclose")) != NULL)
2497 + cBraceClose = cp[0];
2503 + for (cp = cpLine+(*pos); cc != CC_EOS; cp++) {
2504 + if (*cp == cEscape)
2506 + else if (*cp == cDefine)
2508 + else if (*cp == cBraceOpen)
2509 + cc = CC_BRACEOPEN;
2510 + else if (*cp == cBraceClose)
2511 + cc = CC_BRACECLOSE;
2512 + else if (ap_isalpha(*cp))
2514 + else if (ap_isdigit(*cp) || *cp == '_' || *cp == ':')
2516 + else if (*cp == '\0')
2539 + case CC_BRACEOPEN:
2540 + s = SS_TOKEN_BRACED;
2541 + *pos = cp-cpLine-1;
2546 + s = SS_TOKEN_UNBRACED;
2547 + *pos = cp-cpLine-1;
2559 + case SS_TOKEN_BRACED:
2565 + case CC_BRACECLOSE:
2567 + cp2 = ap_palloc(p, cp-*cpVar+1);
2568 + ap_cpystrn(cp2, *cpVar, cp-*cpVar+1);
2573 + cpError = ap_psprintf(p, "Illegal character '%c' in identifier", *cp);
2578 + case SS_TOKEN_UNBRACED:
2585 + cp2 = ap_palloc(p, cp-*cpVar+1);
2586 + ap_cpystrn(cp2, *cpVar, cp-*cpVar+1);
2596 + if (s == SS_ERROR) {
2597 + fprintf(stderr, "Error\n");
2600 + else if (s == SS_FOUND) {
2609 + * Determine the value of a variable
2611 +static char *DefineFetch(pool *p, char *cpVar)
2615 + /* first try out table */
2616 + if ((cpVal = (char *)ap_table_get(tDefines, (char *)cpVar)) != NULL)
2618 + /* second try the environment */
2619 + if ((cpVal = getenv(cpVar)) != NULL)
2625 + * Expand a variable
2627 +static char *DefineExpand(pool *p, char *cpToken, int tok_len, char *cpVal)
2630 + int val_len, rest_len;
2632 + val_len = strlen(cpVal);
2633 + rest_len = strlen(cpToken+tok_len);
2634 + if (val_len < tok_len)
2635 + memcpy(cpToken+val_len, cpToken+tok_len, rest_len+1);
2636 + else if (val_len > tok_len)
2637 + for (cp = cpToken+strlen(cpToken); cp > cpToken+tok_len-1; cp--)
2638 + *(cp+(val_len-tok_len)) = *cp;
2639 + memcpy(cpToken, cpVal, val_len);
2644 + * The EAPI hook which is called after Apache has read a
2645 + * configuration line and before it's actually processed
2647 +static char *DefineRewriteHook(cmd_parms *cmd, void *config, const char *line)
2659 + /* runtime optimization */
2660 + if (!bOnceSeenADefine)
2668 + * ....\$[a-zA-Z][:_a-zA-Z0-9]*....
2669 + * ....\${[a-zA-Z][:_a-zA-Z0-9]*}....
2672 + cpLine = (char *)line;
2674 + while (DefineIndex(p, cpLine, &pos, &len, &cpVar)) {
2675 +#ifdef DEFINE_DEBUG
2677 + char prefix[1024];
2678 + char marker[1024];
2680 + for (i = 0; i < pos; i++)
2683 + for (i = 0; i < len; i++)
2687 + "Found variable `%s' (pos: %d, len: %d)\n"
2690 + cpVar, pos, len, cpLine, prefix, marker);
2693 + if (cpBuf == NULL) {
2694 + cpBuf = ap_palloc(p, MAX_STRING_LEN);
2695 + ap_cpystrn(cpBuf, line, MAX_STRING_LEN);
2698 + if ((cpVal = DefineFetch(p, cpVar)) == NULL) {
2699 + ap_log_error(APLOG_MARK, APLOG_ERR, s,
2700 + "mod_define: Variable '%s' not defined: file %s, line %d",
2701 + cpVar, cmd->config_file->name,
2702 + cmd->config_file->line_number);
2706 + if ((cpError = DefineExpand(p, cpLine+pos, len, cpVal)) != NULL) {
2707 + ap_log_error(APLOG_MARK, APLOG_ERR, s,
2708 + "mod_define: %s: file %s, line %d",
2709 + cpError, cmd->config_file->name,
2710 + cmd->config_file->line_number);
2719 + * Implementation of the `Define' configuration directive
2721 +static const char *cmd_define(cmd_parms *cmd, void *config,
2722 + char *cpVar, char *cpVal)
2724 + if (tDefines == NULL)
2725 + DefineInit(cmd->pool);
2726 + ap_table_set(tDefines, cpVar, cpVal);
2727 + bOnceSeenADefine = TRUE;
2732 + * Module Initialization
2735 +static void DefineInit(pool *p)
2737 + tDefines = ap_make_table(p, 10);
2738 + /* predefine delimiters */
2739 + ap_table_set(tDefines, "mod_define::escape", DEFAULT_MC_ESCAPE);
2740 + ap_table_set(tDefines, "mod_define::dollar", DEFAULT_MC_DOLLAR);
2741 + ap_table_set(tDefines, "mod_define::open", DEFAULT_MC_BRACEOPEN);
2742 + ap_table_set(tDefines, "mod_define::close", DEFAULT_MC_BRACECLOSE);
2743 + ap_register_cleanup(p, NULL, DefineCleanup, ap_null_cleanup);
2751 +static void DefineCleanup(void *data)
2753 + /* reset private variables when config pool is cleared */
2755 + bOnceSeenADefine = FALSE;
2760 + * Module Directive lists
2762 +static const command_rec DefineDirectives[] = {
2763 + { "Define", cmd_define, NULL, RSRC_CONF|ACCESS_CONF, TAKE2,
2764 + "Define a configuration variable" },
2769 + * Module API dispatch list
2771 +module MODULE_VAR_EXPORT define_module = {
2772 + STANDARD_MODULE_STUFF,
2773 + NULL, /* module initializer */
2774 + NULL, /* create per-dir config structures */
2775 + NULL, /* merge per-dir config structures */
2776 + NULL, /* create per-server config structures */
2777 + NULL, /* merge per-server config structures */
2778 + DefineDirectives, /* table of config file commands */
2779 + NULL, /* [#8] MIME-typed-dispatched handlers */
2780 + NULL, /* [#1] URI to filename translation */
2781 + NULL, /* [#4] validate user id from request */
2782 + NULL, /* [#5] check if the user is ok _here_ */
2783 + NULL, /* [#2] check access by host address */
2784 + NULL, /* [#6] determine MIME type */
2785 + NULL, /* [#7] pre-run fixups */
2786 + NULL, /* [#9] log a transaction */
2787 + NULL, /* [#3] header parser */
2788 + NULL, /* child_init */
2789 + NULL, /* child_exit */
2790 + NULL, /* [#0] post read-request */
2791 + NULL, /* EAPI: add_module */
2792 + NULL, /* EAPI: del_module */
2793 + DefineRewriteHook, /* EAPI: rewrite_command */
2794 + NULL /* EAPI: new_connection */