]> git.pld-linux.org Git - packages/apache1.git/blob - apache1-EAPI-missing_files.patch
- add missing config reload for -defaultindex
[packages/apache1.git] / apache1-EAPI-missing_files.patch
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
4 @@ -0,0 +1,110 @@
5 +/* ====================================================================
6 + * Copyright (c) 1998-2000 The Apache Group.  All rights reserved.
7 + *
8 + * Redistribution and use in source and binary forms, with or without
9 + * modification, are permitted provided that the following conditions
10 + * are met:
11 + *
12 + * 1. Redistributions of source code must retain the above copyright
13 + *    notice, this list of conditions and the following disclaimer. 
14 + *
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
18 + *    distribution.
19 + *
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/)."
24 + *
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.
29 + *
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.
33 + *
34 + * 6. Redistributions of any form whatsoever must retain the following
35 + *    acknowledgment:
36 + *    "This product includes software developed by the Apache Group
37 + *    for use in the Apache HTTP server project (http://www.apache.org/)."
38 + *
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 + * ====================================================================
52 + *
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/>.
59 + *
60 + */
61 +
62 +/*
63 +**  Generic Context Interface for Apache
64 +**  Written by Ralf S. Engelschall <rse@engelschall.com> 
65 +*/
66 +
67 +#ifdef EAPI
68 +
69 +#ifndef AP_CTX_H
70 +#define AP_CTX_H
71 +
72 +#ifndef FALSE
73 +#define FALSE 0
74 +#define TRUE  !FALSE
75 +#endif
76 +
77 +/*
78 + * Internal Context Record Definition
79 + */
80 +
81 +#define AP_CTX_MAX_ENTRIES 1024
82 +
83 +typedef struct {
84 +    char *ce_key;
85 +    void *ce_val;
86 +} ap_ctx_entry;
87 +
88 +typedef struct {
89 +    pool          *cr_pool;
90 +    ap_ctx_entry **cr_entry;
91 +} ap_ctx_rec;
92 +
93 +typedef ap_ctx_rec ap_ctx;
94 +
95 +/*
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
98 + * ap_ctx_get.
99 + */
100 +#define AP_CTX_NUM2PTR(n) (void *)(((unsigned long)(n))+1)
101 +#define AP_CTX_PTR2NUM(p) (unsigned long)(((char *)(p))-1)
102 +
103 +/*
104 + * Prototypes for Context Handling Functions
105 + */
106 +
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);
111 +
112 +#endif /* AP_CTX_H */
113 +
114 +#endif /* EAPI */
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
118 @@ -0,0 +1,710 @@
119 +#if 0
120 +=cut
121 +#endif
122 +/* ====================================================================
123 + * Copyright (c) 1998-2000 The Apache Group.  All rights reserved.
124 + *
125 + * Redistribution and use in source and binary forms, with or without
126 + * modification, are permitted provided that the following conditions
127 + * are met:
128 + *
129 + * 1. Redistributions of source code must retain the above copyright
130 + *    notice, this list of conditions and the following disclaimer. 
131 + *
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
135 + *    distribution.
136 + *
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/)."
141 + *
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.
146 + *
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.
150 + *
151 + * 6. Redistributions of any form whatsoever must retain the following
152 + *    acknowledgment:
153 + *    "This product includes software developed by the Apache Group
154 + *    for use in the Apache HTTP server project (http://www.apache.org/)."
155 + *
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 + * ====================================================================
169 + *
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/>.
176 + *
177 + */
178 +
179 +/*
180 +**  Implementation of a Generic Hook Interface for Apache
181 +**  Written by Ralf S. Engelschall <rse@engelschall.com> 
182 +**
183 +**  See POD document at end of this file for description.
184 +**  View it with the command ``pod2man ap_hook.h | nroff -man | more''
185 +**
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.
191 +*/
192 +
193 +#ifdef EAPI
194 +
195 +#ifndef AP_HOOK_H
196 +#define AP_HOOK_H
197 +
198 +/*
199 + * Function Signature Specification:
200 + *
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(...)
204 + */
205 +
206 +/* the type of the signature bitfield */
207 +typedef unsigned long int ap_hook_sig;
208 +
209 +/* the mask (bin) 111 (hex 0x7) for the triples in the bitfield */
210 +#define AP_HOOK_SIG_TRIPLE_MASK  0x7
211 +
212 +/* the position of the triple */
213 +#define AP_HOOK_SIG_TRIPLE_POS(n) ((n)*3)
214 +
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))
218 +
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))
222 +
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))
226 +
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)))
230 +
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)
235 +
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)
245 +
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)
255 +
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)
265 +
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)
275 +
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)
285 +
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)
295 +
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)
305 +
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)
315 +
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)
325 +  
326 +/* the constructor for unknown signatures */
327 +#define AP_HOOK_SIG_UNKNOWN AP_HOOK_ID_undef
328 +
329 +/* the constructor for signatures with 1 type */
330 +#define AP_HOOK_SIG1(rc) \
331 +        (AP_HOOK_RC_##rc)
332 +
333 +/* the constructor for signatures with 2 types */
334 +#define AP_HOOK_SIG2(rc,a1) \
335 +        (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1)
336 +
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)
340 +
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)
344 +
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)
348 +
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)
352 +
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)
356 +
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)
360 +
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)
364 +
365 +/*
366 + * Return Value Mode Identification
367 + */
368 +
369 +/* the type of the return value modes */
370 +typedef unsigned int ap_hook_mode;
371 +
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
378 +
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
384 +
385 +/*
386 + * Hook State Identification
387 + */
388 +
389 +/* the type of the hook state */
390 +typedef unsigned short int ap_hook_state;
391 +
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
398 +
399 +/*
400 + * Hook Context Identification
401 + *
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.
405 + */
406 +
407 +#define AP_HOOK_NOCTX  (void *)(0)
408 +#define AP_HOOK_CTX(v) (void *)(v)
409 +
410 +/*
411 + * Internal Hook Record Definition
412 + */
413 +
414 +/* the union holding the arbitrary decline values */
415 +typedef union {
416 +    char   v_char;
417 +    int    v_int;
418 +    long   v_long;
419 +    float  v_float;
420 +    double v_double;
421 +    void  *v_ptr;
422 +} ap_hook_value;
423 +
424 +/* the structure holding one hook function and its context */
425 +typedef struct {
426 +    void *hf_ptr;              /* function pointer       */
427 +    void *hf_ctx;              /* function context       */
428 +} ap_hook_func;
429 +
430 +/* the structure holding one hook entry with all its registered functions */
431 +typedef struct {
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  */
437 +} ap_hook_entry;
438 +
439 +/* the maximum number of hooks and functions per hook */
440 +#define AP_HOOK_MAX_ENTRIES 512
441 +#define AP_HOOK_MAX_FUNCS   128
442 +
443 +/*
444 + * Extended Variable Argument (vararg) Support
445 + *
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.
452 + */
453 +
454 +/* the mapping */
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 *
463 +
464 +/* the constructor */
465 +#ifdef  va_type
466 +#undef  va_type
467 +#endif
468 +#define va_type(type)  VA_TYPE_ ## type
469 +
470 +/*
471 + * Miscellaneous stuff
472 + */
473 +
474 +#ifndef FALSE
475 +#define FALSE 0
476 +#define TRUE  !FALSE
477 +#endif
478 +
479 +/*
480 + * Wrapper macros for the callback-function register/unregister calls.  
481 + * 
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.
488 + */
489 +
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))
492 +
493 +/*
494 + * Prototypes for the hook API functions
495 + */
496 +
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, ...);
505 +
506 +#endif /* AP_HOOK_H */
507 +
508 +#endif /* EAPI */
509 +/*
510 +=pod
511 +##
512 +##  Embedded POD document
513 +##
514 +
515 +=head1 NAME
516 +
517 +B<ap_hook> - B<Generic Hook Interface for Apache>
518 +
519 +=head1 SYNOPSIS
520 +
521 +B<Hook Library Setup:>
522 +
523 + void ap_hook_init(void);
524 + void ap_hook_kill(void);
525 +
526 +B<Hook Configuration and Registration:>
527 +
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);
531 +
532 +B<Hook Usage:>
533 +
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, ...);
537 +
538 +B<Hook Signature Constructors> (ap_hook_sig):
539 +
540 + AP_HOOK_SIG1(rc)
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)
548 +
549 +B<Hook Modes Constructors> (ap_hook_mode):
550 +
551 + AP_HOOK_TOPMOST
552 + AP_HOOK_DECLINE(value)
553 + AP_HOOK_DECLTMP(value)
554 + AP_HOOK_ALL
555 +
556 +B<Hook States> (ap_hook_state):
557 +
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
563 +
564 +=head1 DESCRIPTION
565 +
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
568 +this mechanism:
569 +
570 +=over 3
571 +
572 +=item B<1. Extension and Overrides>
573 +
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
580 +stops. 
581 +
582 +The original intent of this use case is to provide a flexible extension
583 +mechanism where modules can override functionality.
584 +
585 +=item B<2. Intercommunication>
586 +
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. 
591 +
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.
595 +
596 +=back
597 +
598 +And the following design goals existed:
599 +
600 +=over 3
601 +
602 +=item B<1. Minimum code changes>
603 +
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.
610 +
611 +=item B<2. The hook call has to be maximum flexible>
612 +
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.
618 +
619 +=back
620 +
621 +The implementation of this library directly followed these two design goals.
622 +
623 +=head1 USAGE
624 +
625 +Using this hook API is a four-step process:
626 +
627 +=over 3
628 +
629 +=item B<1. Initialization>
630 +
631 +Initialize or destroy the hook mechanism inside your application program:
632 +
633 + ap_hook_init();
634 +    :
635 + ap_hook_kill();
636 +
637 +=item B<2. Configuration>
638 +
639 +Configure a particular hook by specifing its name, signature and return type
640 +semantic:
641 +
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);
646 +
647 +This configures four hooks: 
648 +
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>.
658 +
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
666 +value>.
667 +
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>.
676 +
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>.
681 +
682 +=item B<3. Registration>
683 +
684 +Register the actual functions which should be used by the hook:
685 +
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);
690 +
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>.
695 +
696 +=item B<4. Usage>
697 +
698 +Finally use the hooks, i.e. instead of using direct function calls like
699 +        
700 + rc = mylookup(a1, a2);
701 + rc = mysetup(a1, a2);
702 + myread(a1);
703 + mylogit(a1);
704 +
705 +you now use:
706 +
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);
711 +
712 +which are internally translated to:
713 +
714 + rc = mylookup(a1, a2, mycontext);
715 + rc = mysetup(a1, a2);
716 + myread(a1);
717 + mylogit(a1);
718 +
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).
725 +
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.
730 +
731 +=back
732 +
733 +=head1 RESTRICTIONS
734 +
735 +To make the hook implementation efficient and to not bloat up the code too
736 +much a few restrictions have to make:
737 +
738 +=over 3
739 +
740 +=item 1.
741 +
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.
747 +
748 +=item 2.
749 +
750 +Only the following ANSI C variable types are supported:
751 +
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 *)
756 +
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>
765 +file.
766 +
767 +=head1 EXAMPLE
768 +
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):
772 +
773 + ssize_t my_read(int, void *, size_t);
774 +
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.
781 +
782 + ap_hook_configure("read", 
783 +                   AP_HOOK_SIG4(int,int,ptr,int), 
784 +                   AP_HOOK_DECLINE(-1));
785 + ap_hook_register("read", read);
786 +
787 +Now a module wants to override the C<read()> call and registers the
788 +C<my_read()> function:
789 +
790 + ap_hook_register("read", my_read);
791 +
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
795 +
796 + bytes = read(fd, buf, bufsize);
797 + if (bytes == -1)
798 +    ...error...
799 +
800 +with the hook based call:
801 +
802 +  rc = ap_hook_call("read", &bytes, fd, buf, bufsize);
803 +  if (rc == FALSE)
804 +     ...error...
805 +
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'.
811 +
812 +=head1 SEE ALSO
813 +
814 +ap_ctx(3)
815 +
816 +=head1 HISTORY
817 +
818 +The ap_hook(3) interface was originally designed and 
819 +implemented in October 1998 by Ralf S. Engelschall.
820 +
821 +=head1 AUTHOR
822 +
823 + Ralf S. Engelschall
824 + rse@engelschall.com
825 + www.engelschall.com
826 +
827 +=cut
828 +*/
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
832 @@ -0,0 +1,130 @@
833 +/* ====================================================================
834 + * Copyright (c) 1999-2000 The Apache Group.  All rights reserved.
835 + *
836 + * Redistribution and use in source and binary forms, with or without
837 + * modification, are permitted provided that the following conditions
838 + * are met:
839 + *
840 + * 1. Redistributions of source code must retain the above copyright
841 + *    notice, this list of conditions and the following disclaimer. 
842 + *
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
846 + *    distribution.
847 + *
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/)."
852 + *
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.
857 + *
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.
861 + *
862 + * 6. Redistributions of any form whatsoever must retain the following
863 + *    acknowledgment:
864 + *    "This product includes software developed by the Apache Group
865 + *    for use in the Apache HTTP server project (http://www.apache.org/)."
866 + *
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 + * ====================================================================
880 + *
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/>.
887 + */
888 +
889 +/*
890 +**
891 +** ap_mm.h -- wrapper code for MM shared memory library
892 +**
893 +*/
894 +
895 +#ifdef EAPI
896 +
897 +#ifndef AP_MM_H 
898 +#define AP_MM_H 1
899 +
900 +#ifndef FALSE
901 +#define FALSE 0
902 +#define TRUE  !FALSE
903 +#endif
904 +
905 +API_EXPORT(int) ap_mm_useable(void);
906 +
907 +typedef void AP_MM;
908 +typedef enum { AP_MM_LOCK_RD, AP_MM_LOCK_RW } ap_mm_lock_mode;
909 +
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);
925 +
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);
942 +
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);
953 +
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);
958 +
959 +#endif /* AP_MM_H */
960 +
961 +#endif /* EAPI */
962 +
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
966 @@ -0,0 +1,135 @@
967 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
968 +<!--%hypertext -->
969 +<!-- mod_define.html                                  -->
970 +<!-- Documentation for the mod_define Apache module   -->
971 +<HTML>
972 +<HEAD>
973 +<TITLE>Apache module mod_define</TITLE>
974 +</HEAD>
975 +
976 +<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
977 +<BODY
978 + BGCOLOR="#FFFFFF"
979 + TEXT="#000000"
980 + LINK="#0000FF"
981 + VLINK="#000080"
982 + ALINK="#FF0000"
983 +>
984 +<BLOCKQUOTE><!-- page indentation -->
985 +<!--#include virtual="header.html" -->
986 +
987 +<BR>
988 +<H1 ALIGN="CENTER">Module mod_define</H1>
989 +<H2 ALIGN="CENTER">Variable Definition For Arbitrary Directives</H2>
990 +
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>
996 +file:
997 +
998 +<P>
999 +<PRE>
1000 +    AddModule  modules/extra/mod_define.o
1001 +</PRE>
1002 +
1003 +<P>
1004 +<HR NOSHADE SIZE=1>
1005 +
1006 +<H3><A NAME="Define">Define</A></H3>
1007 +<A
1008 + HREF="directive-dict.html#Syntax"
1009 + REL="Help"
1010 +><STRONG>Syntax:</STRONG></A>
1011 +    <CODE>Define</CODE> <EM>variable</EM> <EM>value</EM><BR>
1012 +<A
1013 + HREF="directive-dict.html#Default"
1014 + REL="Help"
1015 +><STRONG>Default:</STRONG></A>
1016 +    <EM>none</EM><BR>
1017 +<A
1018 + HREF="directive-dict.html#Context"
1019 + REL="Help"
1020 +><STRONG>Context:</STRONG></A>
1021 +    server config, virtual host, directory, .htaccess<BR>
1022 +<A
1023 + HREF="directive-dict.html#Override"
1024 + REL="Help"
1025 +><STRONG>Override:</STRONG></A> none<BR>
1026 +<A
1027 + HREF="directive-dict.html#Status"
1028 + REL="Help"
1029 +><STRONG>Status:</STRONG></A> Extension<BR>
1030 +<A
1031 + HREF="directive-dict.html#Module"
1032 + REL="Help"
1033 +><STRONG>Module:</STRONG></A> mod_define.c<BR>
1034 +<A
1035 + HREF="directive-dict.html#Compatibility"
1036 + REL="Help"
1037 +><STRONG>Compatibility:</STRONG></A> Apache+EAPI<BR>
1038 +
1039 +<P>
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).
1054 +
1055 +<P>
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:
1060 +
1061 +<BLOCKQUOTE>
1062 +<PRE>
1063 +Define mod_define::escape "\\"
1064 +Define mod_define::dollar "$"
1065 +Define mod_define::open   "{"
1066 +Define mod_define::close  "}"
1067 +</PRE>
1068 +</BLOCKQUOTE>
1069 +
1070 +<P>
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.
1074 +
1075 +<P>
1076 +<STRONG>Example:</STRONG>
1077 +<BLOCKQUOTE>
1078 +<PRE>
1079 +Define master     "Joe Average &lt;joe@average.dom&gt;"
1080 +Define docroot    /usr/local/apache/htdocs
1081 +Define hostname   foo
1082 +Define domainname bar.dom
1083 +Define portnumber 80
1084 +  :
1085 +&lt;VirtualHost $hostname.$domainname:$portnumber&gt;
1086 +SetEnv       SERVER_MASTER "$master"
1087 +ServerName   $hostname.$domainname
1088 +ServerAlias  $hostname
1089 +Port         $portnumber
1090 +DocumentRoot $docroot
1091 +&lt;Directory $docroot&gt;
1092 +  :
1093 +&lt;Directory&gt;
1094 +</PRE>
1095 +</BLOCKQUOTE>
1096 +
1097 +<!--#include virtual="footer.html" -->
1098 +</BLOCKQUOTE><!-- page indentation -->
1099 +</BODY>
1100 +</HTML>
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
1105 @@ -0,0 +1,155 @@
1106 +/* ====================================================================
1107 + * Copyright (c) 1998-2000 The Apache Group.  All rights reserved.
1108 + *
1109 + * Redistribution and use in source and binary forms, with or without
1110 + * modification, are permitted provided that the following conditions
1111 + * are met:
1112 + *
1113 + * 1. Redistributions of source code must retain the above copyright
1114 + *    notice, this list of conditions and the following disclaimer. 
1115 + *
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
1119 + *    distribution.
1120 + *
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/)."
1125 + *
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.
1130 + *
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.
1134 + *
1135 + * 6. Redistributions of any form whatsoever must retain the following
1136 + *    acknowledgment:
1137 + *    "This product includes software developed by the Apache Group
1138 + *    for use in the Apache HTTP server project (http://www.apache.org/)."
1139 + *
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 + * ====================================================================
1153 + *
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/>.
1160 + *
1161 + */
1162 +
1163 +/*
1164 +**  Generic Context Interface for Apache
1165 +**  Written by Ralf S. Engelschall <rse@engelschall.com> 
1166 +*/
1167 +
1168 +#ifdef EAPI
1169 +
1170 +#include "httpd.h"
1171 +#include "ap_config.h"
1172 +#include "ap_ctx.h"
1173 +
1174 +API_EXPORT(ap_ctx *) ap_ctx_new(pool *p)
1175 +{
1176 +    ap_ctx *ctx;
1177 +    int i;
1178 +
1179 +    if (p != NULL) {
1180 +        ctx = (ap_ctx *)ap_palloc(p, sizeof(ap_ctx_rec));
1181 +        ctx->cr_pool = p;
1182 +        ctx->cr_entry = (ap_ctx_entry **)
1183 +            ap_palloc(p, sizeof(ap_ctx_entry *)*(AP_CTX_MAX_ENTRIES+1));
1184 +    }
1185 +    else {
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));
1190 +    }
1191 +    for (i = 0; i < AP_CTX_MAX_ENTRIES+1; i++) 
1192 +        ctx->cr_entry[i] = NULL;
1193 +    return ctx;
1194 +}
1195 +
1196 +API_EXPORT(void) ap_ctx_set(ap_ctx *ctx, char *key, void *val)
1197 +{
1198 +    int i;
1199 +    ap_ctx_entry *ce;
1200 +
1201 +    ce = NULL;
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];
1205 +            break;
1206 +        }
1207 +    }
1208 +    if (ce == NULL) {
1209 +        if (i == AP_CTX_MAX_ENTRIES)
1210 +            return;
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);
1214 +        }
1215 +        else {
1216 +            ce = (ap_ctx_entry *)malloc(sizeof(ap_ctx_entry));
1217 +            ce->ce_key = strdup(key);
1218 +        }
1219 +        ctx->cr_entry[i] = ce;
1220 +        ctx->cr_entry[i+1] = NULL;
1221 +    }
1222 +    ce->ce_val = val;
1223 +    return;
1224 +}
1225 +
1226 +API_EXPORT(void *) ap_ctx_get(ap_ctx *ctx, char *key)
1227 +{
1228 +    int i;
1229 +
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;
1233 +    return NULL;
1234 +}
1235 +
1236 +API_EXPORT(ap_ctx *) ap_ctx_overlay(pool *p, ap_ctx *over, ap_ctx *base)
1237 +{
1238 +    ap_ctx *new;
1239 +    int i;
1240 +
1241 +#ifdef POOL_DEBUG
1242 +    if (p != NULL) {
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__);
1249 +    }
1250 +#endif
1251 +    if ((new = ap_ctx_new(p)) == NULL)
1252 +        return 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);
1257 +    return new;
1258 +}
1259 +
1260 +#endif /* EAPI */
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
1264 @@ -0,0 +1,930 @@
1265 +#if 0
1266 +=pod
1267 +#endif
1268 +/* ====================================================================
1269 + * Copyright (c) 1998-2000 The Apache Group.  All rights reserved.
1270 + *
1271 + * Redistribution and use in source and binary forms, with or without
1272 + * modification, are permitted provided that the following conditions
1273 + * are met:
1274 + *
1275 + * 1. Redistributions of source code must retain the above copyright
1276 + *    notice, this list of conditions and the following disclaimer. 
1277 + *
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
1281 + *    distribution.
1282 + *
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/)."
1287 + *
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.
1292 + *
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.
1296 + *
1297 + * 6. Redistributions of any form whatsoever must retain the following
1298 + *    acknowledgment:
1299 + *    "This product includes software developed by the Apache Group
1300 + *    for use in the Apache HTTP server project (http://www.apache.org/)."
1301 + *
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 + * ====================================================================
1315 + *
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/>.
1322 + *
1323 + */
1324 +
1325 +/*
1326 +**  Implementation of a Generic Hook Interface for Apache
1327 +**  Written by Ralf S. Engelschall <rse@engelschall.com> 
1328 +**
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''
1331 +**
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.
1337 +*/
1338 +
1339 +                                      /*
1340 +                                       * Premature optimization is 
1341 +                                       * the root of all evil.
1342 +                                       *       -- D. E. Knuth
1343 +                                       */
1344 +
1345 +#ifdef EAPI
1346 +
1347 +#include "httpd.h"
1348 +#include "http_log.h"
1349 +#include "ap_config.h"
1350 +#include "ap_hook.h"
1351 +
1352 +/* 
1353 + * the internal hook pool
1354 + */
1355 +static ap_hook_entry **ap_hook_pool = NULL;
1356 +
1357 +/* 
1358 + * forward prototypes for internal functions
1359 + */
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);
1364 +
1365 +/*
1366 + * Initialize the hook mechanism
1367 + */
1368 +API_EXPORT(void) ap_hook_init(void)
1369 +{
1370 +    int i;
1371 +
1372 +    if (ap_hook_pool != NULL)
1373 +        return;
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;
1378 +    return;
1379 +}
1380 +
1381 +/*
1382 + * Kill the hook mechanism
1383 + */
1384 +API_EXPORT(void) ap_hook_kill(void)
1385 +{
1386 +    int i;
1387 +
1388 +    if (ap_hook_pool == NULL)
1389 +        return;
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;
1394 +    return;
1395 +}
1396 +    
1397 +/*
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)
1400 + */
1401 +static ap_hook_entry *ap_hook_create(char *hook)
1402 +{
1403 +    int i;
1404 +    ap_hook_entry *he;
1405 +
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];
1409 +
1410 +    if (i >= AP_HOOK_MAX_ENTRIES)
1411 +        return NULL;
1412 +
1413 +    if ((he = (ap_hook_entry *)malloc(sizeof(ap_hook_entry))) == NULL)
1414 +        return NULL;
1415 +    ap_hook_pool[i] = he;
1416 +
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;
1421 +
1422 +    he->he_func = (ap_hook_func **)malloc(sizeof(ap_hook_func *)
1423 +                                          *(AP_HOOK_MAX_FUNCS+1));
1424 +    if (he->he_func == NULL)
1425 +        return FALSE;
1426 +
1427 +    for (i = 0; i < AP_HOOK_MAX_FUNCS; i++)
1428 +        he->he_func[i] = NULL;
1429 +    return he;
1430 +}
1431 +
1432 +/*
1433 + * Find a particular hook
1434 + */
1435 +static ap_hook_entry *ap_hook_find(char *hook)
1436 +{
1437 +    int i;
1438 +
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];
1442 +    return NULL;
1443 +}
1444 +
1445 +/*
1446 + * Destroy a particular hook
1447 + */
1448 +static void ap_hook_destroy(ap_hook_entry *he)
1449 +{
1450 +    int i;
1451 +
1452 +    if (he == NULL)
1453 +        return;
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);
1458 +    free(he);
1459 +    return;
1460 +}
1461 +
1462 +/*
1463 + * Configure a particular hook, 
1464 + * i.e. remember its signature and return value mode
1465 + */
1466 +API_EXPORT(int) ap_hook_configure(char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...)
1467 +{
1468 +    ap_hook_entry *he;
1469 +    va_list ap;
1470 +    int rc;
1471 +
1472 +    va_start(ap, modeid);
1473 +    if ((he = ap_hook_create(hook)) == NULL)
1474 +        rc = FALSE;
1475 +    else {
1476 +        he->he_sig = sig;
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));
1491 +        }
1492 +        rc = TRUE;
1493 +    }
1494 +    va_end(ap);
1495 +    return rc;
1496 +}
1497 +
1498 +/*
1499 + * Register a function to call for a hook
1500 + */
1501 +API_EXPORT(int) ap_hook_register_I(char *hook, void *func, void *ctx)
1502 +{
1503 +    int i, j;
1504 +    ap_hook_entry *he;
1505 +    ap_hook_func *hf;
1506 +
1507 +    if ((he = ap_hook_create(hook)) == NULL)
1508 +        return FALSE;
1509 +
1510 +    for (i = 0; he->he_func[i] != NULL; i++)
1511 +        if (he->he_func[i]->hf_ptr == func)
1512 +            return FALSE;
1513 +
1514 +    if (i == AP_HOOK_MAX_FUNCS)
1515 +        return FALSE;
1516 +
1517 +    if ((hf = (ap_hook_func *)malloc(sizeof(ap_hook_func))) == NULL)
1518 +        return FALSE;
1519 +
1520 +    for (j = i; j >= 0; j--)
1521 +        he->he_func[j+1] = he->he_func[j];
1522 +    he->he_func[0] = hf;
1523 +
1524 +    hf->hf_ptr = func;
1525 +    hf->hf_ctx = ctx;
1526 +
1527 +    return TRUE;
1528 +}
1529 +
1530 +/*
1531 + * Unregister a function to call for a hook
1532 + */
1533 +API_EXPORT(int) ap_hook_unregister_I(char *hook, void *func)
1534 +{
1535 +    int i, j;
1536 +    ap_hook_entry *he;
1537 +
1538 +    if ((he = ap_hook_find(hook)) == NULL)
1539 +        return FALSE;
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];
1545 +            return TRUE;
1546 +        }
1547 +    }
1548 +    return FALSE;
1549 +}
1550 +
1551 +/*
1552 + * Retrieve the status of a particular hook
1553 + */
1554 +API_EXPORT(ap_hook_state) ap_hook_status(char *hook)
1555 +{
1556 +    ap_hook_entry *he;
1557 +
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;
1568 +}
1569 +
1570 +/*
1571 + * Use a hook, i.e. optional on-the-fly configure it before calling it
1572 + */
1573 +API_EXPORT(int) ap_hook_use(char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...)
1574 +{
1575 +    int i;
1576 +    ap_hook_value modeval;
1577 +    ap_hook_entry *he;
1578 +    va_list ap;
1579 +    int rc;
1580 +
1581 +    va_start(ap, modeid);
1582 +
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));
1596 +    }
1597 +
1598 +    if ((he = ap_hook_create(hook)) == NULL)
1599 +        return FALSE;
1600 +
1601 +    if (he->he_sig == AP_HOOK_SIG_UNKNOWN)
1602 +        he->he_sig = sig;
1603 +    if (he->he_modeid == AP_HOOK_MODE_UNKNOWN) {
1604 +        he->he_modeid  = modeid;
1605 +        he->he_modeval = modeval;
1606 +    }
1607 +
1608 +    for (i = 0; he->he_func[i] != NULL; i++)
1609 +        if (ap_hook_call_func(ap, he, he->he_func[i]))
1610 +            break;
1611 +
1612 +    if (i > 0 && he->he_modeid == AP_HOOK_MODE_ALL)
1613 +        rc = TRUE;
1614 +    else if (i == AP_HOOK_MAX_FUNCS || he->he_func[i] == NULL)
1615 +        rc = FALSE;
1616 +    else
1617 +        rc = TRUE;
1618 +
1619 +    va_end(ap);
1620 +    return rc;
1621 +}
1622 +
1623 +/*
1624 + * Call a hook
1625 + */
1626 +API_EXPORT(int) ap_hook_call(char *hook, ...)
1627 +{
1628 +    int i;
1629 +    ap_hook_entry *he;
1630 +    va_list ap;
1631 +    int rc;
1632 +    
1633 +    va_start(ap, hook);
1634 +
1635 +    if ((he = ap_hook_find(hook)) == NULL) {
1636 +        va_end(ap);
1637 +        return FALSE;
1638 +    }
1639 +    if (   he->he_sig == AP_HOOK_SIG_UNKNOWN
1640 +        || he->he_modeid == AP_HOOK_MODE_UNKNOWN) {
1641 +        va_end(ap);
1642 +        return FALSE;
1643 +    }
1644 +
1645 +    for (i = 0; he->he_func[i] != NULL; i++)
1646 +        if (ap_hook_call_func(ap, he, he->he_func[i]))
1647 +            break;
1648 +
1649 +    if (i > 0 && he->he_modeid == AP_HOOK_MODE_ALL)
1650 +        rc = TRUE;
1651 +    else if (i == AP_HOOK_MAX_FUNCS || he->he_func[i] == NULL)
1652 +        rc = FALSE;
1653 +    else
1654 +        rc = TRUE;
1655 +
1656 +    va_end(ap);
1657 +    return rc;
1658 +}
1659 +
1660 +static int ap_hook_call_func(va_list ap, ap_hook_entry *he, ap_hook_func *hf)
1661 +{
1662 +    void *v_rc;
1663 +    ap_hook_value v_tmp;
1664 +    int rc;
1665 +
1666 +    /*
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):
1673 +     *
1674 +     * 1. `The basic hook'.
1675 +     *
1676 +     *    void func()
1677 +     *
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.
1681 +     *
1682 +     *    int func()
1683 +     *    ptr func()
1684 +     *    int func(int)
1685 +     *    int func(ptr)
1686 +     *    ptr func(int)
1687 +     *    ptr func(ptr)
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)
1712 +     *
1713 +     * 3. Actually currently used hooks.
1714 +     *
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]
1729 +     *
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
1735 +     *
1736 +     *     $ perl ap_hook.c
1737 +     *
1738 +     * This automatically updates the above code.
1739 +     */
1740 +
1741 +    rc = TRUE;
1742 +    v_rc = NULL;
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;
1758 +        }
1759 +        else {
1760 +            /* the return variable is provided by caller */ 
1761 +            v_rc = va_arg(ap, void *);
1762 +        }
1763 +    }
1764 +
1765 +    /* ----BEGIN GENERATED SECTION-------- */
1766 +    if (he->he_sig == AP_HOOK_SIG1(void)) {
1767 +        /* Call: void func() */
1768 +        ((void(*)())(hf->hf_ptr))();
1769 +    }
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);
1774 +    }
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);
1779 +    }
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);
1785 +    }
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);
1791 +    }
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);
1797 +    }
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);
1803 +    }
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);
1810 +    }
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);
1817 +    }
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);
1824 +    }
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);
1831 +    }
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);
1838 +    }
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);
1845 +    }
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);
1852 +    }
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);
1859 +    }
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);
1867 +    }
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);
1875 +    }
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);
1883 +    }
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);
1891 +    }
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);
1899 +    }
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);
1907 +    }
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);
1915 +    }
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);
1923 +    }
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);
1931 +    }
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);
1939 +    }
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);
1947 +    }
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);
1955 +    }
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);
1963 +    }
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);
1971 +    }
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);
1979 +    }
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);
1987 +    }
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);
1996 +    }
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);
2006 +    }
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);
2016 +    }
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);
2027 +    }
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);
2037 +    }
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);
2042 +    }
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);
2049 +    }
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);
2055 +    }
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);
2062 +    }
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);
2070 +    }
2071 +    /* ----END GENERATED SECTION---------- */
2072 +    else
2073 +        ap_log_assert("hook signature not implemented", __FILE__, __LINE__);
2074 +
2075 +    if (he->he_modeid == AP_HOOK_MODE_ALL)
2076 +        rc = FALSE;
2077 +    else if (he->he_modeid == AP_HOOK_MODE_TOPMOST)
2078 +        rc = TRUE;
2079 +
2080 +    return rc;
2081 +}
2082 +
2083 +#endif /* EAPI */
2084 +
2085 +/*
2086 +=cut
2087 +##
2088 +##  Embedded Perl script for generating the dispatch section
2089 +##
2090 +
2091 +require 5.003;
2092 +use strict;
2093 +
2094 +#   configuration
2095 +my $file  = $0;
2096 +my $begin = '----BEGIN GENERATED SECTION--------';
2097 +my $end   = '----END GENERATED SECTION----------';
2098 +
2099 +#   special command: find used signatures
2100 +if ($ARGV[0] eq 'used') {
2101 +    my @S = `find .. -type f -name "*.c" -print`;
2102 +    my $s;
2103 +    my %T = ();
2104 +    foreach $s (@S) {
2105 +        $s =~ s|\n$||;
2106 +        open(FP, "<$s") || die;
2107 +        my $source = '';
2108 +        $source .= $_ while (<FP>);
2109 +        close(FP);
2110 +        my %seen = ();
2111 +        sub printme {
2112 +            my ($src, $hook, $sig) = @_;
2113 +            return if ($seen{$hook} == 1);
2114 +            $seen{$hook} = 1;
2115 +            my ($rc, $args) = ($sig =~ m|^([^,]+)(.*)$|);
2116 +            $args =~ s|^,||;
2117 +            $src =~ s|^.+/||;
2118 +            my $sig = sprintf("%-6sfunc(%s)", $rc, $args);
2119 +            $T{$sig}++; 
2120 +        }
2121 +        $source =~ s|\("([^"]+)",\s*AP_HOOK_SIG[0-9]\((.+?)\)|&printme($s, $1, $2), ''|sge;
2122 +    }
2123 +    my $t;
2124 +    foreach $t (sort(keys(%T))) {
2125 +        printf("     *    %-40s [%dx]\n", $t, $T{$t});
2126 +    }
2127 +    exit(0);
2128 +}
2129 +
2130 +#   read ourself and keep a backup
2131 +open(FP, "<$file") || die;
2132 +my $source = '';
2133 +$source .= $_ while (<FP>);
2134 +close(FP);
2135 +open(FP, ">$file.bak") || die;
2136 +print FP $source;
2137 +close(FP);
2138 +
2139 +#   now parse the signature lines and update the code
2140 +my $o = '';
2141 +my $next = 0;
2142 +my $line;
2143 +my %seen = ();
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;
2148 +
2149 +    next if ($seen{$sig} == 1);
2150 +    $seen{$sig} = 1;
2151 +
2152 +    print "Generating code for `$sig'\n";
2153 +
2154 +    my @S = ($rc, split(/[\s,]+/, $param));
2155 +    my @RS = @S;
2156 +    my $i;
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');
2160 +    }
2161 +
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]);
2167 +    }
2168 +    $o .= "    ";
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]));
2171 +    $o .= "(";
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);
2176 +    }
2177 +    $o .= ");\n";
2178 +    $o .= sprintf("    rc = (*((%s *)v_rc) != he->he_modeval.v_%s);\n", 
2179 +                  $RS[0], $S[0]) if ($S[0] ne 'void');
2180 +    $o .= "}\n";
2181 +}
2182 +
2183 +#   insert the generated code at the target location
2184 +$o =~ s|^|    |mg;
2185 +$source =~ s|(\/\* $begin.+?\n).*\n(.*?\/\* $end)|$1$o$2|s;
2186 +
2187 +#   and update the source on disk
2188 +print "Updating file `$file'\n";
2189 +open(FP, ">$file") || die;
2190 +print FP $source;
2191 +close(FP);
2192 +
2193 +=pod
2194 +*/
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
2198 @@ -0,0 +1,178 @@
2199 +/* ====================================================================
2200 + * Copyright (c) 1999-2000 The Apache Group.  All rights reserved.
2201 + *
2202 + * Redistribution and use in source and binary forms, with or without
2203 + * modification, are permitted provided that the following conditions
2204 + * are met:
2205 + *
2206 + * 1. Redistributions of source code must retain the above copyright
2207 + *    notice, this list of conditions and the following disclaimer. 
2208 + *
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
2212 + *    distribution.
2213 + *
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/)."
2218 + *
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.
2223 + *
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.
2227 + *
2228 + * 6. Redistributions of any form whatsoever must retain the following
2229 + *    acknowledgment:
2230 + *    "This product includes software developed by the Apache Group
2231 + *    for use in the Apache HTTP server project (http://www.apache.org/)."
2232 + *
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 + * ====================================================================
2246 + *
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/>.
2253 + */
2254 +
2255 +/*
2256 +**  ap_mm.c -- wrapper for MM shared memory library
2257 +**
2258 +**  This file has two reason:
2259 +**
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.
2263 +**
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
2268 +**     the MM stuff.
2269 +*/
2270 +                                       /*
2271 +                                        * "What you see is all you get."
2272 +                                        *     -- Brian Kernighan
2273 +                                        */
2274 +#ifdef EAPI
2275 +
2276 +#include "httpd.h"
2277 +#include "ap_mm.h"
2278 +
2279 +#ifdef EAPI_MM
2280 +#include "mm.h"
2281 +API_EXPORT(int) ap_mm_useable(void) { return TRUE;  }
2282 +#define STUB(val,nul)               { return val;   }
2283 +#define STUB_STMT(stmt)             { stmt; return; }
2284 +#else
2285 +API_EXPORT(int) ap_mm_useable(void) { return FALSE; }
2286 +#define STUB(val,nul)               { return nul;   }
2287 +#define STUB_STMT(stmt)             { return;       }
2288 +#endif
2289 +
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)
2318 +
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))
2349 +
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)
2368 +
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)
2375 +
2376 +#endif /* EAPI */
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
2380 @@ -0,0 +1,416 @@
2381 +/*
2382 +**  mod_define.c - Apache module for configuration defines ($xxx)
2383 +**
2384 +**  Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
2385 +**  Copyright (c) 1998-2000 Christian Reiber <chrei@en.muc.de>
2386 +**
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
2390 +**  copies.
2391 +**
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
2403 +**  SUCH DAMAGE.
2404 +*/
2405 +
2406 +/*
2407 + *  HISTORY
2408 + *
2409 + *  v1.0: Originally written in December 1998 by
2410 + *        Ralf S. Engelschall <rse@engelschall.com> and
2411 + *        Christian Reiber <chrei@en.muc.de>
2412 + *
2413 + *  v1.1: Completely Overhauled in August 1999 by
2414 + *        Ralf S. Engelschall <rse@engelschall.com>
2415 + */
2416 +
2417 +#include "ap_config.h"
2418 +#include "ap_ctype.h"
2419 +#include "httpd.h"
2420 +#include "http_config.h"
2421 +#include "http_conf_globals.h"
2422 +#include "http_core.h"
2423 +#include "http_log.h"
2424 +
2425 +#ifndef EAPI
2426 +#error "This module requires the Extended API (EAPI) facilities."
2427 +#endif
2428 +
2429 +/*
2430 + * The global table of defines
2431 + */
2432 +
2433 +static table *tDefines         = NULL;   /* global table of defines */
2434 +static int    bOnceSeenADefine = FALSE;  /* optimization flag */
2435 +
2436 +/*
2437 + * Forward declaration
2438 + */
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 *);
2445 +
2446 +/*
2447 + * Character classes for scanner function
2448 + */
2449 +typedef enum {
2450 +    CC_ESCAPE, CC_DOLLAR, CC_BRACEOPEN, CC_BRACECLOSE,
2451 +    CC_IDCHAR1, CC_IDCHAR, CC_OTHER, CC_EOS
2452 +} CharClass;
2453 +
2454 +/*
2455 + * Scanner states for scanner function
2456 + */
2457 +typedef enum {
2458 +    SS_NONE, SS_SKIP, SS_DOLLAR, SS_TOKEN_BRACED,
2459 +    SS_TOKEN_UNBRACED, SS_ERROR, SS_FOUND
2460 +} ScanState;
2461 +
2462 +/*
2463 + * Default meta characters
2464 + */
2465 +#define DEFAULT_MC_ESCAPE      "\\"
2466 +#define DEFAULT_MC_DOLLAR      "$"
2467 +#define DEFAULT_MC_BRACEOPEN   "{"
2468 +#define DEFAULT_MC_BRACECLOSE  "}"
2469 +
2470 +/*
2471 + * Scanner for variable constructs $xxx and ${xxx}
2472 + */
2473 +static int DefineIndex(pool *p, char *cpLine, int *pos, int *len, char **cpVar)
2474 +{
2475 +    int rc;
2476 +    char *cp;
2477 +    char *cp2;
2478 +    CharClass cc;
2479 +    char cEscape;
2480 +    char cDefine;
2481 +    char cBraceOpen;
2482 +    char cBraceClose;
2483 +    char *cpError;
2484 +    ScanState s;
2485 +
2486 +    cEscape = DEFAULT_MC_ESCAPE[0];
2487 +    if ((cp = DefineFetch(p, "mod_define::escape")) != NULL)
2488 +        cEscape = cp[0];
2489 +    cDefine = DEFAULT_MC_DOLLAR[0];
2490 +    if ((cp = DefineFetch(p, "mod_define::dollar")) != NULL)
2491 +        cDefine = cp[0];
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];
2498 +
2499 +    rc = 0;
2500 +    *len = 0;
2501 +    cc = CC_OTHER;
2502 +    s = SS_NONE;
2503 +    for (cp = cpLine+(*pos); cc != CC_EOS; cp++) {
2504 +        if (*cp == cEscape)
2505 +            cc = CC_ESCAPE;
2506 +        else if (*cp == cDefine)
2507 +            cc = CC_DOLLAR;
2508 +        else if (*cp == cBraceOpen)
2509 +            cc = CC_BRACEOPEN;
2510 +        else if (*cp == cBraceClose)
2511 +            cc = CC_BRACECLOSE;
2512 +        else if (ap_isalpha(*cp))
2513 +            cc = CC_IDCHAR1;
2514 +        else if (ap_isdigit(*cp) || *cp == '_' || *cp == ':')
2515 +            cc = CC_IDCHAR;
2516 +        else if (*cp == '\0')
2517 +            cc = CC_EOS;
2518 +        else
2519 +            cc = CC_OTHER;
2520 +        switch (s) {
2521 +            case SS_NONE:
2522 +                switch (cc) {
2523 +                    case CC_ESCAPE:
2524 +                        s = SS_SKIP;
2525 +                        break;
2526 +                    case CC_DOLLAR:
2527 +                        s = SS_DOLLAR;
2528 +                        break;
2529 +                    default:
2530 +                        break;
2531 +                }
2532 +                break;
2533 +            case SS_SKIP:
2534 +                s = SS_NONE;
2535 +                continue;
2536 +                break;
2537 +            case SS_DOLLAR:
2538 +                switch (cc) {
2539 +                    case CC_BRACEOPEN:
2540 +                        s = SS_TOKEN_BRACED;
2541 +                        *pos = cp-cpLine-1;
2542 +                        (*len) = 2;
2543 +                        *cpVar = cp+1;
2544 +                        break;
2545 +                    case CC_IDCHAR1:
2546 +                        s = SS_TOKEN_UNBRACED;
2547 +                        *pos = cp-cpLine-1;
2548 +                        (*len) = 2;
2549 +                        *cpVar = cp;
2550 +                        break;
2551 +                    case CC_ESCAPE:
2552 +                        s = SS_SKIP;
2553 +                        break;
2554 +                    default:
2555 +                        s = SS_NONE;
2556 +                        break;
2557 +                }
2558 +                break;
2559 +            case SS_TOKEN_BRACED:
2560 +                switch (cc) {
2561 +                    case CC_IDCHAR1:
2562 +                    case CC_IDCHAR:
2563 +                        (*len)++;
2564 +                        break;
2565 +                    case CC_BRACECLOSE:
2566 +                        (*len)++;
2567 +                        cp2 = ap_palloc(p, cp-*cpVar+1);
2568 +                        ap_cpystrn(cp2, *cpVar, cp-*cpVar+1);
2569 +                        *cpVar = cp2;
2570 +                        s = SS_FOUND;
2571 +                        break;
2572 +                    default:
2573 +                        cpError = ap_psprintf(p, "Illegal character '%c' in identifier", *cp);
2574 +                        s = SS_ERROR;
2575 +                        break;
2576 +                }
2577 +                break;
2578 +            case SS_TOKEN_UNBRACED:
2579 +                switch (cc) {
2580 +                    case CC_IDCHAR1:
2581 +                    case CC_IDCHAR:
2582 +                        (*len)++;
2583 +                        break;
2584 +                    default:
2585 +                        cp2 = ap_palloc(p, cp-*cpVar+1);
2586 +                        ap_cpystrn(cp2, *cpVar, cp-*cpVar+1);
2587 +                        *cpVar = cp2;
2588 +                        s = SS_FOUND;
2589 +                        break;
2590 +                }
2591 +                break;
2592 +            case SS_FOUND:
2593 +            case SS_ERROR:
2594 +                break;
2595 +        }
2596 +        if (s == SS_ERROR) {
2597 +            fprintf(stderr, "Error\n");
2598 +            break;
2599 +        }
2600 +        else if (s == SS_FOUND) {
2601 +            rc = 1;
2602 +            break;
2603 +        }
2604 +    }
2605 +    return rc;
2606 +}
2607 +
2608 +/*
2609 + * Determine the value of a variable
2610 + */
2611 +static char *DefineFetch(pool *p, char *cpVar)
2612 +{
2613 +    char *cpVal;
2614 +
2615 +    /* first try out table */
2616 +    if ((cpVal = (char *)ap_table_get(tDefines, (char *)cpVar)) != NULL)
2617 +        return cpVal;
2618 +    /* second try the environment */
2619 +    if ((cpVal = getenv(cpVar)) != NULL)
2620 +        return cpVal;
2621 +    return NULL;
2622 +}
2623 +
2624 +/*
2625 + * Expand a variable
2626 + */
2627 +static char *DefineExpand(pool *p, char *cpToken, int tok_len, char *cpVal)
2628 +{
2629 +    char *cp;
2630 +    int val_len, rest_len;
2631 +
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);
2640 +    return NULL;
2641 +}
2642 +
2643 +/*
2644 + * The EAPI hook which is called after Apache has read a
2645 + * configuration line and before it's actually processed
2646 + */
2647 +static char *DefineRewriteHook(cmd_parms *cmd, void *config, const char *line)
2648 +{
2649 +    pool *p;
2650 +    char *cpBuf;
2651 +    char *cpLine;
2652 +    int pos;
2653 +    int len;
2654 +    char *cpError;
2655 +    char *cpVar;
2656 +    char *cpVal;
2657 +    server_rec *s;
2658 +
2659 +    /* runtime optimization */
2660 +    if (!bOnceSeenADefine)
2661 +        return NULL;
2662 +
2663 +    p  = cmd->pool;
2664 +    s  = cmd->server;
2665 +
2666 +    /*
2667 +     * Search for:
2668 +     *  ....\$[a-zA-Z][:_a-zA-Z0-9]*....
2669 +     *  ....\${[a-zA-Z][:_a-zA-Z0-9]*}....
2670 +     */
2671 +    cpBuf = NULL;
2672 +    cpLine = (char *)line;
2673 +    pos = 0;
2674 +    while (DefineIndex(p, cpLine, &pos, &len, &cpVar)) {
2675 +#ifdef DEFINE_DEBUG
2676 +        {
2677 +        char prefix[1024];
2678 +        char marker[1024];
2679 +        int i;
2680 +        for (i = 0; i < pos; i++)
2681 +            prefix[i] = ' ';
2682 +        prefix[i] = '\0';
2683 +        for (i = 0; i < len; i++)
2684 +            marker[i] = '^';
2685 +        marker[i] = '\0';
2686 +        fprintf(stderr,
2687 +                "Found variable `%s' (pos: %d, len: %d)\n"
2688 +                "  %s\n"
2689 +                "  %s%s\n",
2690 +                cpVar, pos, len, cpLine, prefix, marker);
2691 +        }
2692 +#endif
2693 +        if (cpBuf == NULL) {
2694 +            cpBuf = ap_palloc(p, MAX_STRING_LEN);
2695 +            ap_cpystrn(cpBuf, line, MAX_STRING_LEN);
2696 +            cpLine = cpBuf;
2697 +        }
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);
2703 +            cpBuf = NULL;
2704 +            break;
2705 +        }
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);
2711 +            cpBuf = NULL;
2712 +            break;
2713 +        }
2714 +    }
2715 +    return cpBuf;
2716 +}
2717 +
2718 +/*
2719 + * Implementation of the `Define' configuration directive
2720 + */
2721 +static const char *cmd_define(cmd_parms *cmd, void *config,
2722 +                              char *cpVar, char *cpVal)
2723 +{
2724 +    if (tDefines == NULL)
2725 +        DefineInit(cmd->pool);
2726 +    ap_table_set(tDefines, cpVar, cpVal);
2727 +    bOnceSeenADefine = TRUE;
2728 +    return NULL;
2729 +}
2730 +
2731 +/*
2732 + * Module Initialization
2733 + */
2734 +
2735 +static void DefineInit(pool *p)
2736 +{
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);
2744 +    return;
2745 +}
2746 +
2747 +/*
2748 + * Module Cleanup
2749 + */
2750 +
2751 +static void DefineCleanup(void *data)
2752 +{
2753 +    /* reset private variables when config pool is cleared */
2754 +    tDefines         = NULL;
2755 +    bOnceSeenADefine = FALSE;
2756 +    return;
2757 +}
2758 +
2759 +/*
2760 + * Module Directive lists
2761 + */
2762 +static const command_rec DefineDirectives[] = {
2763 +    { "Define", cmd_define, NULL, RSRC_CONF|ACCESS_CONF, TAKE2,
2764 +      "Define a configuration variable" },
2765 +    { NULL }
2766 +};
2767 +
2768 +/*
2769 + * Module API dispatch list
2770 + */
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                */
2795 +};
2796 +
This page took 0.435189 seconds and 3 git commands to generate.