]> git.pld-linux.org Git - packages/apache.git/blob - apache-mod_ssl-eapi.patch
- SECURITY update to 1.3.27
[packages/apache.git] / apache-mod_ssl-eapi.patch
1 ##  _____   _    ____ ___ 
2 ## | ____| / \  |  _ \_ _|
3 ## |  _|  / _ \ | |_) | | 
4 ## | |__ / ___ \|  __/| | 
5 ## |____/_/   \_\_|  |___|  Extended API for Apache
6 ## ____________________________________________________________________________
7 ## 
8 ## Annotated patch file: eapi.patch
9 ## Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved. 
10 ## Created on: 19-Jun-2002
11 ##
12 ## This file assembles changes to existing Apache source files
13 ## between the original Apache and the patched variant. It can be
14 ## automatically applied to a vanilla Apache source tree with the
15 ## 'patch' tool to upgrade those files.  Each patch snippet is
16 ## annotated with a short description.
17 ##
18 ## This file contains all patches to the Apache source
19 ## tree which add the Extended API (EAPI) support.
20 ##
21
22 # updated for apache 1.3.27 on 04-Oct-2002
23
24 +---------------------------------------------------------------------------
25 | Add the EAPI and EAPI_MM configuration entries which triggers the EAPI
26 | patches and configured the shared memory support via the MM library.
27 +---------------------------------------------------------------------------
28 Index: src/Configuration.tmpl
29 --- src/Configuration.tmpl      28 Jan 2002 19:21:21 -0000      1.1.1.7
30 +++ src/Configuration.tmpl      28 Jan 2002 19:40:56 -0000      1.23
31 @@ -68,6 +105,24 @@
32  #TARGET=
33  
34  ################################################################
35 +# Extended API (EAPI) support:
36 +#
37 +# EAPI:
38 +#   The EAPI rule enables more module hooks, a generic low-level hook
39 +#   mechanism, a generic context mechanism and shared memory based pools. 
40 +#
41 +# EAPI_MM:
42 +#   Set the EAPI_MM variable to either the directory of a MM Shared Memory
43 +#   Library source tree or the installation tree of MM. Alternatively you can
44 +#   also use the value 'SYSTEM' which then indicates that MM is installed
45 +#   under various system locations. When the MM library files cannot be found
46 +#   the EAPI still can be built, but without shared memory pool support, of
47 +#   course.
48 +
49 +Rule EAPI=no
50 +#EAPI_MM=SYSTEM
51 +
52 +################################################################
53  # Dynamic Shared Object (DSO) support
54  #
55  # There is experimental support for compiling the Apache core and
56
57 +---------------------------------------------------------------------------
58 | Patch in implementation of the EAPI rule.
59 +---------------------------------------------------------------------------
60 Index: src/Configure
61 --- src/Configure       19 Jun 2002 07:20:22 -0000      1.1.1.19
62 +++ src/Configure       19 Jun 2002 07:29:08 -0000      1.22
63 @@ -1869,6 +1869,72 @@
64  fi
65  
66  ####################################################################
67 +## Extended API (EAPI) support:
68 +##
69 +if [ "x$RULE_EAPI" = "x" ]; then
70 +    RULE_EAPI=`./helpers/CutRule EAPI $file`
71 +fi
72 +if [ "x$RULE_EAPI" = "xyes" ]; then
73 +    echo " + enabling Extended API (EAPI)"
74 +    CFLAGS="$CFLAGS -DEAPI"
75 +    #   some vendor compilers are too restrictive
76 +    #   for our ap_hook and ap_ctx sources.
77 +    case "$OS:$CC" in
78 +        *IRIX-32*:*/cc|*IRIX-32*:cc )
79 +            CFLAGS="$CFLAGS -woff 1048,1110,1164"
80 +            ;;
81 +    esac
82 +    #   MM Shared Memory Library support for EAPI
83 +    if [ "x$EAPI_MM" = "x" ]; then
84 +        EAPI_MM=`egrep '^EAPI_MM=' $file | sed -n -e '$p' | awk -F= '{print $2}'`
85 +    fi
86 +    if [ "x$EAPI_MM" != "x" ]; then
87 +        case $EAPI_MM in
88 +            SYSTEM|/* ) ;;
89 +            * ) for p in . .. ../..; do
90 +                    if [ -d "$p/$EAPI_MM" ]; then
91 +                        EAPI_MM="`echo $p/$EAPI_MM | sed -e 's;/\./;/;g'`" 
92 +                        break
93 +                    fi
94 +                done
95 +                ;;
96 +        esac
97 +        if [ "x$EAPI_MM" = "xSYSTEM" ]; then
98 +            echo "   using MM library for EAPI: (system-wide)"
99 +            CFLAGS="$CFLAGS -DEAPI_MM"
100 +            __INCLUDES="`mm-config --cflags`"
101 +            if [ "x$__INCLUDES" != "x-I/usr/include" ]; then
102 +                INCLUDES="$INCLUDES $__INCLUDES"
103 +            fi
104 +            LDFLAGS="$LDFLAGS `mm-config --ldflags`"
105 +            LIBS="$LIBS `mm-config --libs`"
106 +        else
107 +            if [ -f "$EAPI_MM/.libs/libmm.a" -a -f "$EAPI_MM/mm.h" ]; then
108 +                echo "   using MM library: $EAPI_MM (source-tree only)"
109 +                case $EAPI_MM in
110 +                    /* ) ;;
111 +                    *  ) EAPI_MM="\$(SRCDIR)/$EAPI_MM" ;;
112 +                esac
113 +                CFLAGS="$CFLAGS -DEAPI_MM"
114 +                INCLUDES="$INCLUDES -I$EAPI_MM"
115 +                LDFLAGS="$LDFLAGS -L$EAPI_MM/.libs"
116 +                LIBS="$LIBS -lmm"
117 +            elif [ -f "$EAPI_MM/bin/mm-config" ]; then
118 +                echo "   using MM library: $EAPI_MM (installed)"
119 +                CFLAGS="$CFLAGS -DEAPI_MM"
120 +                INCLUDES="$INCLUDES `$EAPI_MM/bin/mm-config --cflags`"
121 +                LDFLAGS="$LDFLAGS `$EAPI_MM/bin/mm-config --ldflags`"
122 +                LIBS="$LIBS `$EAPI_MM/bin/mm-config --libs`"
123 +            else
124 +                echo "Configure:Error: Cannot find MM library under $EAPI_MM" 1>&2
125 +                exit 1
126 +            fi
127 +        fi
128 +    fi
129 +fi
130 +
131 +
132 +####################################################################
133  ## Add in the Expat library if needed/wanted.
134  ##
135  
136
137 +---------------------------------------------------------------------------
138 | Add the build support for the ap_hook.c and ap_ctx.c sources (Unix)
139 +---------------------------------------------------------------------------
140 Index: src/ap/Makefile.tmpl
141 --- src/ap/Makefile.tmpl        19 Jun 2002 07:20:22 -0000      1.1.1.8
142 +++ src/ap/Makefile.tmpl        19 Jun 2002 07:29:08 -0000      1.8
143 @@ -7,7 +7,7 @@
144  
145  OBJS=ap_cpystrn.o ap_execve.o ap_fnmatch.o ap_getpass.o ap_md5c.o ap_signal.o \
146       ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o ap_ebcdic.o \
147 -     ap_strtol.o
148 +     ap_strtol.o ap_hook.o ap_ctx.o ap_mm.o
149  
150  .c.o:
151         $(CC) -c $(INCLUDES) $(CFLAGS) $<
152
153 +---------------------------------------------------------------------------
154 | Add the build support for the ap_hook.c and ap_ctx.c sources (Win32)
155 +---------------------------------------------------------------------------
156 Index: src/ap/ap.mak
157 --- src/ap/ap.mak       16 Oct 2001 11:47:06 -0000      1.1.1.9
158 +++ src/ap/ap.mak       16 Oct 2001 11:57:38 -0000      1.9
159 @@ -50,6 +50,9 @@
160         -@erase "$(INTDIR)\ap_cpystrn.obj"
161         -@erase "$(INTDIR)\ap_fnmatch.obj"
162         -@erase "$(INTDIR)\ap_md5c.obj"
163 +       -@erase "$(INTDIR)\ap_hook.obj"
164 +       -@erase "$(INTDIR)\ap_ctx.obj"
165 +       -@erase "$(INTDIR)\ap_mm.obj"
166         -@erase "$(INTDIR)\ap_sha1.obj"
167         -@erase "$(INTDIR)\ap_signal.obj"
168         -@erase "$(INTDIR)\ap_slack.obj"
169 @@ -108,6 +111,9 @@
170         "$(INTDIR)\ap_cpystrn.obj" \
171         "$(INTDIR)\ap_fnmatch.obj" \
172         "$(INTDIR)\ap_md5c.obj" \
173 +       "$(INTDIR)\ap_hook.obj" \
174 +       "$(INTDIR)\ap_ctx.obj" \
175 +       "$(INTDIR)\ap_mm.obj" \
176         "$(INTDIR)\ap_sha1.obj" \
177         "$(INTDIR)\ap_signal.obj" \
178         "$(INTDIR)\ap_slack.obj" \
179 @@ -144,6 +150,9 @@
180         -@erase "$(INTDIR)\ap_cpystrn.obj"
181         -@erase "$(INTDIR)\ap_fnmatch.obj"
182         -@erase "$(INTDIR)\ap_md5c.obj"
183 +       -@erase "$(INTDIR)\ap_hook.obj"
184 +       -@erase "$(INTDIR)\ap_ctx.obj"
185 +       -@erase "$(INTDIR)\ap_mm.obj"
186         -@erase "$(INTDIR)\ap_sha1.obj"
187         -@erase "$(INTDIR)\ap_signal.obj"
188         -@erase "$(INTDIR)\ap_slack.obj"
189 @@ -202,6 +211,9 @@
190         "$(INTDIR)\ap_cpystrn.obj" \
191         "$(INTDIR)\ap_fnmatch.obj" \
192         "$(INTDIR)\ap_md5c.obj" \
193 +       "$(INTDIR)\ap_hook.obj" \
194 +       "$(INTDIR)\ap_ctx.obj" \
195 +       "$(INTDIR)\ap_mm.obj" \
196         "$(INTDIR)\ap_sha1.obj" \
197         "$(INTDIR)\ap_signal.obj" \
198         "$(INTDIR)\ap_slack.obj" \
199
200 +---------------------------------------------------------------------------
201 | Replace the MODULE_MAGIC_COOKIE to allow us to distinguish between
202 | EAPI-aware modules and standard modules.
203 +---------------------------------------------------------------------------
204 Index: src/include/ap_mmn.h
205 --- src/include/ap_mmn.h        19 Jun 2002 07:20:24 -0000      1.1.1.11
206 +++ src/include/ap_mmn.h        19 Jun 2002 07:29:08 -0000      1.11
207 @@ -239,7 +239,23 @@
208   * 19990320.13          - add ap_strtol()
209   */
210  
211 +/* 
212 + * Under Extended API situations we replace the magic cookie "AP13" with
213 + * "EAPI" to let us distinguish between the EAPI module structure (which
214 + * contain additional pointers at the end) and standard module structures
215 + * (which lack at least NULL's for the pointers at the end).  This is
216 + * important because standard ("AP13") modules would dump core when we
217 + * dispatch over the additional hooks because NULL's are missing at the end of
218 + * the module structure. See also the code in mod_so for details on loading
219 + * (we accept both "AP13" and "EAPI").
220 + */
221 +#ifdef EAPI
222 +#define MODULE_MAGIC_COOKIE_AP13 0x41503133UL /* "AP13" */
223 +#define MODULE_MAGIC_COOKIE_EAPI 0x45415049UL /* "EAPI" */
224 +#define MODULE_MAGIC_COOKIE      MODULE_MAGIC_COOKIE_EAPI 
225 +#else
226  #define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */
227 +#endif
228  
229  #ifndef MODULE_MAGIC_NUMBER_MAJOR
230  #define MODULE_MAGIC_NUMBER_MAJOR 19990320
231
232 +---------------------------------------------------------------------------
233 | Add the additional prototypes and defines for the 
234 | shared memory pools.
235 +---------------------------------------------------------------------------
236 Index: src/include/ap_alloc.h
237 --- src/include/ap_alloc.h      27 Mar 2002 15:22:56 -0000      1.1.1.5
238 +++ src/include/ap_alloc.h      27 Mar 2002 15:30:02 -0000      1.6
239 @@ -95,6 +95,15 @@
240  API_EXPORT(pool *) ap_init_alloc(void);                /* Set up everything */
241  void ap_cleanup_alloc(void);
242  API_EXPORT(pool *) ap_make_sub_pool(pool *);   /* All pools are subpools of permanent_pool */
243 +#if defined(EAPI)
244 +typedef enum { AP_POOL_RD, AP_POOL_RW } ap_pool_lock_mode;
245 +int ap_shared_pool_possible(void);
246 +void ap_init_alloc_shared(int);
247 +void ap_kill_alloc_shared(void);
248 +API_EXPORT(pool *) ap_make_shared_sub_pool(pool *);
249 +API_EXPORT(int) ap_acquire_pool(pool *, ap_pool_lock_mode);
250 +API_EXPORT(int) ap_release_pool(pool *);
251 +#endif
252  API_EXPORT(void) ap_destroy_pool(pool *);
253  
254  /* pools have nested lifetimes -- sub_pools are destroyed when the
255
256 +---------------------------------------------------------------------------
257 | Add the additional context variable `ctx' for BUFF structures.
258 +---------------------------------------------------------------------------
259 Index: src/include/buff.h
260 --- src/include/buff.h  27 Mar 2002 15:22:57 -0000      1.1.1.6
261 +++ src/include/buff.h  27 Mar 2002 15:30:02 -0000      1.10
262 @@ -125,6 +125,10 @@
263      /* transport handle, for RPC binding handle or some such */
264      void *t_handle;
265  
266 +#ifdef EAPI
267 +    ap_ctx *ctx;
268 +#endif /* EAPI */
269 +
270  #ifdef B_SFIO
271      Sfio_t *sf_in;
272      Sfio_t *sf_out;
273 @@ -180,6 +184,10 @@
274  /* Internal routines */
275  API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb);
276  API_EXPORT(int) ap_bfilbuf(BUFF *fb);
277 +
278 +#ifdef EAPI
279 +#define ap_bpeekc(fb) ( ((fb)->incnt == 0) ? EOF : *((fb)->inptr) )
280 +#endif
281  
282  #ifndef CHARSET_EBCDIC
283  
284
285 +---------------------------------------------------------------------------
286 | Add the four additional Apache API module hooks.
287 +---------------------------------------------------------------------------
288 Index: src/include/http_config.h
289 --- src/include/http_config.h   27 Mar 2002 15:22:57 -0000      1.1.1.10
290 +++ src/include/http_config.h   27 Mar 2002 15:30:02 -0000      1.12
291 @@ -276,6 +276,65 @@
292      void (*child_exit) (server_rec *, pool *);
293  #endif
294      int (*post_read_request) (request_rec *);
295 +
296 +#ifdef EAPI
297 +    /*
298 +     * ANSI C guarantees us that we can at least _extend_ the module structure
299 +     * with additional hooks without the need to change all existing modules.
300 +     * Because: ``If there are fewer initializers in the list than members of
301 +     * the structure, the trailing members are initialized with 0.'' (The C
302 +     * Programming Language, 2nd Ed., A8.7 Initialization). So we just
303 +     * have to put our additional hooks here:
304 +     *
305 +     * add_module: 
306 +     *     Called from within ap_add_module() right after the module structure
307 +     *     was linked into the Apache internal module list.  It is mainly
308 +     *     intended to be used to define configuration defines (<IfDefine>)
309 +     *     which have to be available directly after a LoadModule/AddModule.
310 +     *     Actually this is the earliest possible hook a module can use.
311 +     *
312 +     * remove_module: 
313 +     *     Called from within ap_remove_module() right before the module
314 +     *     structure is kicked out from the Apache internal module list.
315 +     *     Actually this is last possible hook a module can use and exists for
316 +     *     consistency with the add_module hook.
317 +     *
318 +     * rewrite_command:
319 +     *     Called right after a configuration directive line was read and
320 +     *     before it is processed. It is mainly intended to be used for
321 +     *     rewriting directives in order to provide backward compatibility to
322 +     *     old directive variants.
323 +     *
324 +     * new_connection:
325 +     *     Called from within the internal new_connection() function, right
326 +     *     after the conn_rec structure for the new established connection was
327 +     *     created and before Apache starts processing the request with
328 +     *     ap_read_request().  It is mainly intended to be used to setup/run
329 +     *     connection dependent things like sending start headers for
330 +     *     on-the-fly compression, etc.
331 +     *
332 +     * close_connection:
333 +     *     Called from within the Apache dispatching loop just before any
334 +     *     ap_bclose() is performed on the socket connection, but a long time
335 +     *     before any pool cleanups are done for the connection (which can be
336 +     *     too late for some applications).  It is mainly intended to be used
337 +     *     to close/finalize connection dependent things like sending end
338 +     *     headers for on-the-fly compression, etc.
339 +     */
340 +#ifdef ULTRIX_BRAIN_DEATH
341 +    void  (*add_module) ();
342 +    void  (*remove_module) ();
343 +    char *(*rewrite_command) ();
344 +    void  (*new_connection) ();
345 +    void  (*close_connection) ();
346 +#else
347 +    void  (*add_module) (struct module_struct *);
348 +    void  (*remove_module) (struct module_struct *);
349 +    char *(*rewrite_command) (cmd_parms *, void *config, const char *);
350 +    void  (*new_connection) (conn_rec *);
351 +    void  (*close_connection) (conn_rec *);
352 +#endif
353 +#endif /* EAPI */
354  } module;
355  
356  /* Initializer for the first few module slots, which are only
357
358 +---------------------------------------------------------------------------
359 | Add the additional variable `ap_global_ctx' for holding
360 | global module context.
361 +---------------------------------------------------------------------------
362 Index: src/include/http_conf_globals.h
363 --- src/include/http_conf_globals.h     27 Mar 2002 15:22:57 -0000      1.1.1.11
364 +++ src/include/http_conf_globals.h     27 Mar 2002 15:30:02 -0000      1.12
365 @@ -95,6 +95,9 @@
366  #endif
367  extern int ap_dump_settings;
368  extern API_VAR_EXPORT int ap_extended_status;
369 +#ifdef EAPI
370 +extern API_VAR_EXPORT ap_ctx *ap_global_ctx;
371 +#endif /* EAPI */
372  
373  extern API_VAR_EXPORT char *ap_pid_fname;
374  extern API_VAR_EXPORT char *ap_scoreboard_fname;
375
376 +---------------------------------------------------------------------------
377 | Export the ap_set_callback_and_alarm() function because this
378 | first is a useful thing and second we need it because all
379 | other API/timeout functions deal with a request_rec while
380 | some modules need a generic timeout mechanism.
381 +---------------------------------------------------------------------------
382 Index: src/include/http_main.h
383
384 +---------------------------------------------------------------------------
385 | First add support for the HTTPS protocol scheme via hooks,
386 | second add the additional context variable `ctx' for the
387 | conn_rec, server_rec and request_rec structures. And third
388 | add a prototype for the additional ap_add_config_define()
389 | function.
390 +---------------------------------------------------------------------------
391 Index: src/include/httpd.h
392 --- src/include/httpd.h 19 Jun 2002 07:20:24 -0000      1.1.1.19
393 +++ src/include/httpd.h 19 Jun 2002 07:29:08 -0000      1.29
394 @@ -70,7 +70,19 @@
395  /* Headers in which EVERYONE has an interest... */
396  
397  #include "ap_config.h"
398 +#ifdef EAPI
399 +#include "ap_mm.h"
400 +#endif
401  #include "ap_alloc.h"
402 +/*
403 + * Include the Extended API headers.
404 + * Don't move the position. It has to be after ap_alloc.h because it uses the
405 + * pool stuff but before buff.h because the buffer stuff uses the EAPI, too. 
406 + */
407 +#ifdef EAPI
408 +#include "ap_hook.h"
409 +#include "ap_ctx.h"
410 +#endif /* EAPI */
411  #include "buff.h"
412  #include "ap.h"
413  
414 @@ -141,12 +153,17 @@
415  #define DEFAULT_HTTP_PORT      80
416  #define DEFAULT_HTTPS_PORT     443
417  #define ap_is_default_port(port,r)     ((port) == ap_default_port(r))
418 +#ifdef EAPI
419 +#define ap_http_method(r)   (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::http::method") != NULL) ? ((char *)ap_ctx_get((r)->ctx, "ap::http::method")) : "http")
420 +#define ap_default_port(r)  (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::default::port") != NULL) ? atoi((char *)ap_ctx_get((r)->ctx, "ap::default::port")) : DEFAULT_HTTP_PORT)
421 +#else /* EAPI */
422  #ifdef NETWARE
423  #define ap_http_method(r) ap_os_http_method(r)
424  #else
425  #define ap_http_method(r)      "http"
426  #endif
427  #define ap_default_port(r)     DEFAULT_HTTP_PORT
428 +#endif /* EAPI */
429  
430  /* --------- Default user name and group name running standalone ---------- */
431  /* --- These may be specified as numbers by placing a # before a number --- */
432 @@ -351,6 +368,19 @@
433  #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
434  #endif
435  
436 +/*
437 + * Unix only:
438 + * Path to Shared Memory Files 
439 + */
440 +#ifdef EAPI
441 +#ifndef EAPI_MM_CORE_PATH
442 +#define EAPI_MM_CORE_PATH "logs/mm"
443 +#endif
444 +#ifndef EAPI_MM_CORE_MAXSIZE
445 +#define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */
446 +#endif
447 +#endif
448 +
449  /* Number of requests to try to handle in a single process.  If <= 0,
450   * the children don't die off.  That's the default here, since I'm still
451   * interested in finding and stanching leaks.
452 @@ -443,6 +473,9 @@
453  API_EXPORT(const char *) ap_get_server_version(void);
454  API_EXPORT(void) ap_add_version_component(const char *component);
455  API_EXPORT(const char *) ap_get_server_built(void);
456 +#ifdef EAPI
457 +API_EXPORT(void) ap_add_config_define(const char *define);
458 +#endif /* EAPI */
459  
460  /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
461   * Always increases along the same track as the source branch.
462 @@ -846,6 +879,10 @@
463   * record to improve 64bit alignment the next time we need to break
464   * binary compatibility for some other reason.
465   */
466 +
467 +#ifdef EAPI
468 +    ap_ctx *ctx;
469 +#endif /* EAPI */
470  };
471  
472  
473 @@ -894,6 +931,9 @@
474      char *local_host;          /* used for ap_get_server_name when
475                                  * UseCanonicalName is set to DNS
476                                  * (ignores setting of HostnameLookups) */
477 +#ifdef EAPI
478 +    ap_ctx *ctx;
479 +#endif /* EAPI */
480  };
481  
482  /* Per-vhost config... */
483 @@ -966,6 +1006,10 @@
484      int limit_req_line;      /* limit on size of the HTTP request line    */
485      int limit_req_fieldsize; /* limit on size of any request header field */
486      int limit_req_fields;    /* limit on number of request header fields  */
487 +
488 +#ifdef EAPI
489 +    ap_ctx *ctx;
490 +#endif /* EAPI */
491  };
492  
493  /* These are more like real hosts than virtual hosts */
494
495 +---------------------------------------------------------------------------
496 | Patch the shared memory pool support into the Apache pool facility.
497 +---------------------------------------------------------------------------
498 Index: src/main/alloc.c
499 --- src/main/alloc.c    27 Mar 2002 15:23:00 -0000      1.1.1.12
500 +++ src/main/alloc.c    27 Mar 2002 15:30:02 -0000      1.19
501 @@ -64,6 +64,10 @@
502   */
503  
504  #include "httpd.h"
505 +#ifdef EAPI
506 +#include "http_config.h"
507 +#include "http_conf_globals.h"
508 +#endif
509  #include "multithread.h"
510  #include "http_log.h"
511  
512 @@ -138,6 +142,10 @@
513  #define BLOCK_MINALLOC 0
514  #endif
515  
516 +#if defined(EAPI) && defined(EAPI_MM)
517 +static AP_MM *mm = NULL;
518 +#endif
519 +
520  /*****************************************************************
521   *
522   * Managing free storage blocks...
523 @@ -166,6 +174,9 @@
524         char *endp;
525         union block_hdr *next;
526         char *first_avail;
527 +#if defined(EAPI) && defined(EAPI_MM)
528 +       int is_shm;
529 +#endif
530  #ifdef POOL_DEBUG
531         union block_hdr *global_next;
532         struct pool *owning_pool;
533 @@ -216,7 +227,11 @@
534  /* Get a completely new block from the system pool. Note that we rely on
535     malloc() to provide aligned memory. */
536  
537 +#if defined(EAPI) && defined(EAPI_MM)
538 +static union block_hdr *malloc_block(int size, int is_shm)
539 +#else
540  static union block_hdr *malloc_block(int size)
541 +#endif
542  {
543      union block_hdr *blok;
544  
545 @@ -230,12 +245,20 @@
546      ++num_malloc_calls;
547      num_malloc_bytes += size + sizeof(union block_hdr);
548  #endif
549 +#if defined(EAPI) && defined(EAPI_MM)
550 +    if (is_shm)
551 +        blok = (union block_hdr *)ap_mm_malloc(mm, size + sizeof(union block_hdr));
552 +    else
553 +#endif
554      blok = (union block_hdr *) malloc(size + sizeof(union block_hdr));
555      if (blok == NULL) {
556         fprintf(stderr, "Ouch!  malloc failed in malloc_block()\n");
557         exit(1);
558      }
559      debug_fill(blok, size + sizeof(union block_hdr));
560 +#if defined(EAPI) && defined(EAPI_MM)
561 +    blok->h.is_shm = is_shm;
562 +#endif
563      blok->h.next = NULL;
564      blok->h.first_avail = (char *) (blok + 1);
565      blok->h.endp = size + blok->h.first_avail;
566 @@ -296,6 +319,10 @@
567      if (blok == NULL)
568         return;                 /* Sanity check --- freeing empty pool? */
569  
570 +#if defined(EAPI) && defined(EAPI_MM)
571 +    if (blok->h.is_shm)
572 +        (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
573 +#endif
574      (void) ap_acquire_mutex(alloc_mutex);
575      old_free_list = block_freelist;
576      block_freelist = blok;
577 @@ -342,6 +369,10 @@
578  #endif
579  
580      (void) ap_release_mutex(alloc_mutex);
581 +#if defined(EAPI) && defined(EAPI_MM)
582 +    if (blok->h.is_shm)
583 +        (void)ap_mm_unlock(mm);
584 +#endif
585  #endif
586  }
587  
588 @@ -350,7 +381,11 @@
589   * if necessary.  Must be called with alarms blocked.
590   */
591  
592 +#if defined(EAPI) && defined(EAPI_MM)
593 +static union block_hdr *new_block(int min_size, int is_shm)
594 +#else
595  static union block_hdr *new_block(int min_size)
596 +#endif
597  {
598      union block_hdr **lastptr = &block_freelist;
599      union block_hdr *blok = block_freelist;
600 @@ -360,7 +395,12 @@
601       */
602  
603      while (blok != NULL) {
604 +#if defined(EAPI) && defined(EAPI_MM)
605 +    if (blok->h.is_shm == is_shm &&
606 +        min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
607 +#else
608         if (min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) {
609 +#endif
610             *lastptr = blok->h.next;
611             blok->h.next = NULL;
612             debug_verify_filled(blok->h.first_avail, blok->h.endp,
613 @@ -376,7 +416,11 @@
614      /* Nope. */
615  
616      min_size += BLOCK_MINFREE;
617 +#if defined(EAPI) && defined(EAPI_MM)
618 +    blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm);
619 +#else
620      blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC);
621 +#endif
622      return blok;
623  }
624  
625 @@ -426,6 +470,9 @@
626  #ifdef POOL_DEBUG
627      struct pool *joined;
628  #endif
629 +#if defined(EAPI) && defined(EAPI_MM)
630 +    int is_shm;
631 +#endif
632  };
633  
634  static pool *permanent_pool;
635 @@ -440,16 +487,28 @@
636  #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ))
637  #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ)
638  
639 +#if defined(EAPI) && defined(EAPI_MM)
640 +static struct pool *make_sub_pool_internal(struct pool *p, int is_shm)
641 +#else
642  API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
643 +#endif
644  {
645      union block_hdr *blok;
646      pool *new_pool;
647  
648      ap_block_alarms();
649  
650 +#if defined(EAPI) && defined(EAPI_MM)
651 +    if (is_shm)
652 +        (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
653 +#endif
654      (void) ap_acquire_mutex(alloc_mutex);
655  
656 +#if defined(EAPI) && defined(EAPI_MM)
657 +    blok = new_block(POOL_HDR_BYTES, is_shm);
658 +#else
659      blok = new_block(POOL_HDR_BYTES);
660 +#endif
661      new_pool = (pool *) blok->h.first_avail;
662      blok->h.first_avail += POOL_HDR_BYTES;
663  #ifdef POOL_DEBUG
664 @@ -468,12 +527,38 @@
665         p->sub_pools = new_pool;
666      }
667  
668 +#if defined(EAPI) && defined(EAPI_MM)
669 +    new_pool->is_shm = is_shm;
670 +#endif
671 +
672      (void) ap_release_mutex(alloc_mutex);
673 +#if defined(EAPI) && defined(EAPI_MM)
674 +    if (is_shm)
675 +       (void)ap_mm_unlock(mm);
676 +#endif
677      ap_unblock_alarms();
678  
679      return new_pool;
680  }
681  
682 +#if defined(EAPI)
683 +#if defined(EAPI_MM)
684 +API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p)
685 +{
686 +    return make_sub_pool_internal(p, 0);
687 +}
688 +API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
689 +{
690 +    return make_sub_pool_internal(p, 1);
691 +}
692 +#else
693 +API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p)
694 +{
695 +    return NULL;
696 +}
697 +#endif
698 +#endif
699 +
700  #ifdef POOL_DEBUG
701  static void stack_var_init(char *s)
702  {
703 @@ -488,6 +573,13 @@
704  }
705  #endif
706  
707 +#if defined(EAPI)
708 +int ap_shared_pool_possible(void)
709 +{
710 +    return ap_mm_useable();
711 +}
712 +#endif
713 +
714  #ifdef ALLOC_STATS
715  static void dump_stats(void)
716  {
717 @@ -520,6 +612,58 @@
718      return permanent_pool;
719  }
720  
721 +#if defined(EAPI)
722 +void ap_init_alloc_shared(int early)
723 +{
724 +#if defined(EAPI_MM)
725 +    int mm_size;
726 +    char *mm_path;
727 +    char *err1, *err2;
728 +
729 +    if (early) {
730 +        /* process very early on startup */
731 +        mm_size = ap_mm_maxsize();
732 +        if (mm_size > EAPI_MM_CORE_MAXSIZE)
733 +            mm_size = EAPI_MM_CORE_MAXSIZE;
734 +        mm_path = ap_server_root_relative(permanent_pool, 
735 +                  ap_psprintf(permanent_pool, "%s.%ld", 
736 +                              EAPI_MM_CORE_PATH, (long)getpid()));
737 +        if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) {
738 +            fprintf(stderr, "Ouch! ap_mm_create(%d, \"%s\") failed\n", mm_size, mm_path);
739 +            err1 = ap_mm_error();
740 +            if (err1 == NULL)
741 +                err1 = "-unknown-";
742 +            err2 = strerror(errno);
743 +            if (err2 == NULL)
744 +                err2 = "-unknown-";
745 +            fprintf(stderr, "Error: MM: %s: OS: %s\n", err1, err2);
746 +            exit(1);
747 +        }
748 +    }
749 +    else {
750 +        /* process a lot later on startup */
751 +#ifdef WIN32
752 +        ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1);
753 +#else
754 +        ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1);
755 +#endif
756 +    }
757 +#endif /* EAPI_MM */
758 +    return; 
759 +}
760 +
761 +void ap_kill_alloc_shared(void)
762 +{
763 +#if defined(EAPI_MM)
764 +    if (mm != NULL) {
765 +        ap_mm_destroy(mm);
766 +        mm = NULL;
767 +    }
768 +#endif /* EAPI_MM */
769 +    return;
770 +}
771 +#endif /* EAPI */
772 +
773  void ap_cleanup_alloc(void)
774  {
775      ap_destroy_mutex(alloc_mutex);
776 @@ -530,10 +674,18 @@
777  {
778      ap_block_alarms();
779  
780 +#if defined(EAPI) && defined(EAPI_MM)
781 +    if (a->is_shm)
782 +        (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
783 +#endif
784      (void) ap_acquire_mutex(alloc_mutex);
785      while (a->sub_pools)
786         ap_destroy_pool(a->sub_pools);
787      (void) ap_release_mutex(alloc_mutex);
788 +#if defined(EAPI) && defined(EAPI_MM)
789 +    if (a->is_shm)
790 +           (void)ap_mm_unlock(mm);
791 +#endif
792      /* Don't hold the mutex during cleanups. */
793      run_cleanups(a->cleanups);
794      a->cleanups = NULL;
795 @@ -567,6 +719,10 @@
796      ap_block_alarms();
797      ap_clear_pool(a);
798  
799 +#if defined(EAPI) && defined(EAPI_MM)
800 +    if (a->is_shm)
801 +       (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
802 +#endif
803      (void) ap_acquire_mutex(alloc_mutex);
804      if (a->parent) {
805         if (a->parent->sub_pools == a)
806 @@ -577,6 +733,10 @@
807             a->sub_next->sub_prev = a->sub_prev;
808      }
809      (void) ap_release_mutex(alloc_mutex);
810 +#if defined(EAPI) && defined(EAPI_MM)
811 +    if (a->is_shm)
812 +       (void)ap_mm_unlock(mm);
813 +#endif
814  
815      free_blocks(a->first);
816      ap_unblock_alarms();
817 @@ -591,6 +751,30 @@
818      return bytes_in_block_list(block_freelist);
819  }
820  
821 +#if defined(EAPI)
822 +API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode)
823 +{
824 +#if defined(EAPI_MM)
825 +    if (!p->is_shm)
826 +        return 1;
827 +    return ap_mm_lock(mm, mode == AP_POOL_RD ? AP_MM_LOCK_RD : AP_MM_LOCK_RW);
828 +#else
829 +       return 1;
830 +#endif
831 +}
832 +
833 +API_EXPORT(int) ap_release_pool(pool *p)
834 +{
835 +#if defined(EAPI_MM)
836 +    if (!p->is_shm)
837 +        return 1;
838 +    return ap_mm_unlock(mm);
839 +#else
840 +       return 1;
841 +#endif
842 +}
843 +#endif /* EAPI */
844 +
845  /*****************************************************************
846   * POOL_DEBUG support
847   */
848 @@ -756,16 +940,31 @@
849  
850      ap_block_alarms();
851  
852 +#if defined(EAPI) && defined(EAPI_MM)
853 +    if (a->is_shm)
854 +       (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
855 +#endif
856      (void) ap_acquire_mutex(alloc_mutex);
857  
858 +#if defined(EAPI) && defined(EAPI_MM)
859 +    blok = new_block(size, a->is_shm);
860 +#else
861      blok = new_block(size);
862 +#endif
863      a->last->h.next = blok;
864      a->last = blok;
865  #ifdef POOL_DEBUG
866      blok->h.owning_pool = a;
867  #endif
868 +#if defined(EAPI) && defined(EAPI_MM)
869 +    blok->h.is_shm = a->is_shm;
870 +#endif
871  
872      (void) ap_release_mutex(alloc_mutex);
873 +#if defined(EAPI) && defined(EAPI_MM)
874 +    if (a->is_shm)
875 +       (void)ap_mm_unlock(mm);
876 +#endif
877  
878      ap_unblock_alarms();
879  
880 @@ -877,6 +1076,11 @@
881      size = cur_len << 1;
882      if (size < AP_PSPRINTF_MIN_SIZE)
883          size = AP_PSPRINTF_MIN_SIZE;
884 +#if defined(EAPI) && defined(EAPI_MM)
885 +    if (ps->block->h.is_shm)
886 +        ptr = ap_mm_realloc(ps->base, size);
887 +    else
888 +#endif
889      ptr = realloc(ps->base, size);
890      if (ptr == NULL) {
891         fputs("Ouch!  Out of memory!\n", stderr);
892 @@ -897,9 +1101,21 @@
893          size = AP_PSPRINTF_MIN_SIZE;
894  
895      /* must try another blok */
896 +#if defined(EAPI) && defined(EAPI_MM)
897 +    if (blok->h.is_shm)
898 +       (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
899 +#endif
900      (void) ap_acquire_mutex(alloc_mutex);
901 +#if defined(EAPI) && defined(EAPI_MM)
902 +    nblok = new_block(size, blok->h.is_shm);
903 +#else
904      nblok = new_block(size);
905 +#endif
906      (void) ap_release_mutex(alloc_mutex);
907 +#if defined(EAPI) && defined(EAPI_MM)
908 +    if (blok->h.is_shm)
909 +       (void)ap_mm_unlock(mm);
910 +#endif
911      memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
912      ps->vbuff.curpos = nblok->h.first_avail + cur_len;
913      /* save a byte for the NUL terminator */
914 @@ -908,10 +1124,18 @@
915      /* did we allocate the current blok? if so free it up */
916      if (ps->got_a_new_block) {
917         debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
918 +#if defined(EAPI) && defined(EAPI_MM)
919 +    if (blok->h.is_shm)
920 +       (void)ap_mm_lock(mm, AP_MM_LOCK_RW);
921 +#endif
922         (void) ap_acquire_mutex(alloc_mutex);
923         blok->h.next = block_freelist;
924         block_freelist = blok;
925         (void) ap_release_mutex(alloc_mutex);
926 +#if defined(EAPI) && defined(EAPI_MM)
927 +    if (blok->h.is_shm)
928 +       (void)ap_mm_unlock(mm);
929 +#endif
930      }
931      ps->blok = nblok;
932      ps->got_a_new_block = 1;
933 @@ -930,6 +1154,11 @@
934      void *ptr;
935  
936      ap_block_alarms();
937 +#if defined(EAPI) && defined(EAPI_MM)
938 +    if (p->is_shm)
939 +        ps.base = ap_mm_malloc(mm, 512);
940 +    else
941 +#endif
942      ps.base = malloc(512);
943      if (ps.base == NULL) {
944         fputs("Ouch!  Out of memory!\n", stderr);
945 @@ -942,6 +1171,11 @@
946      *ps.vbuff.curpos++ = '\0';
947      ptr = ps.base;
948      /* shrink */
949 +#if defined(EAPI) && defined(EAPI_MM)
950 +    if (p->is_shm)
951 +        ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
952 +    else
953 +#endif
954      ptr = realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr);
955      if (ptr == NULL) {
956         fputs("Ouch!  Out of memory!\n", stderr);
957
958 +---------------------------------------------------------------------------
959 | Patch the low-level buffer routines to additionally allow
960 | modules to intercept the I/O processing via hooks.
961 +---------------------------------------------------------------------------
962 Index: src/main/buff.c
963 --- src/main/buff.c     27 Mar 2002 15:23:00 -0000      1.1.1.12
964 +++ src/main/buff.c     27 Mar 2002 15:30:02 -0000      1.20
965 @@ -293,6 +293,9 @@
966      }
967      else
968  #endif
969 +#ifdef EAPI
970 +       if (!ap_hook_call("ap::buff::read", &rv, fb, buf, nbyte))
971 +#endif /* EAPI */
972         rv = read(fb->fd_in, buf, nbyte);
973      
974      return rv;
975 @@ -304,6 +307,9 @@
976  
977  #if defined (WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) 
978      if (fb->flags & B_SOCKET) {
979 +#ifdef EAPI
980 +       if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte))
981 +#endif /* EAPI */
982         rv = ap_recvwithtimeout(fb->fd_in, buf, nbyte, 0);
983         if (rv == SOCKET_ERROR)
984             errno = WSAGetLastError();
985 @@ -351,6 +357,9 @@
986      }
987      else
988  #endif
989 +#ifdef EAPI
990 +       if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte))
991 +#endif /* EAPI */
992  #if defined (B_SFIO)
993         rv = sfwrite(fb->sf_out, buf, nbyte);
994  #else
995 @@ -381,6 +390,9 @@
996     
997  #if defined(WIN32) || defined(NETWARE)
998      if (fb->flags & B_SOCKET) {
999 +#ifdef EAPI
1000 +       if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte))
1001 +#endif /* EAPI */
1002         rv = ap_sendwithtimeout(fb->fd, buf, nbyte, 0);
1003         if (rv == SOCKET_ERROR)
1004             errno = WSAGetLastError();
1005 @@ -464,6 +476,10 @@
1006      fb->callback_data = NULL;
1007      fb->filter_callback = NULL;
1008  
1009 +#ifdef EAPI
1010 +    fb->ctx = ap_ctx_new(p);
1011 +#endif /* EAPI */
1012 +
1013      return fb;
1014  }
1015  
1016 @@ -1116,6 +1132,9 @@
1017      i = 0;
1018      while (i < nvec) {
1019         do
1020 +#ifdef EAPI
1021 +           if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i))
1022 +#endif /* EAPI */
1023             rv = writev(fb->fd, &vec[i], nvec - i);
1024         while (rv == -1 && (errno == EINTR || errno == EAGAIN)
1025                && !(fb->flags & B_EOUT));
1026
1027 +---------------------------------------------------------------------------
1028 | Add the implementation of the additional `add_module' and
1029 | `rewrite_command' module hooks. Additionally the `ctx'
1030 | variables are initialized.
1031 +---------------------------------------------------------------------------
1032 Index: src/main/http_config.c
1033 --- src/main/http_config.c      27 Mar 2002 15:23:00 -0000      1.1.1.14
1034 +++ src/main/http_config.c      27 Mar 2002 15:30:02 -0000      1.17
1035 @@ -599,6 +599,20 @@
1036         m->name = tmp;
1037      }
1038  #endif /*_OSD_POSIX*/
1039 +
1040 +#ifdef EAPI
1041 +    /*
1042 +     * Invoke the `add_module' hook inside the now existing set
1043 +     * of modules to let them all now that this module was added.
1044 +     */
1045 +    {
1046 +        module *m2;
1047 +        for (m2 = top_module; m2 != NULL; m2 = m2->next)
1048 +            if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1049 +                if (m2->add_module != NULL)
1050 +                    (*m2->add_module)(m);
1051 +    }
1052 +#endif /* EAPI */
1053  }
1054  
1055  /* 
1056 @@ -613,6 +627,21 @@
1057  {
1058      module *modp;
1059  
1060 +#ifdef EAPI
1061 +    /*
1062 +     * Invoke the `remove_module' hook inside the now existing
1063 +     * set of modules to let them all now that this module is
1064 +     * beeing removed.
1065 +     */
1066 +    {
1067 +        module *m2;
1068 +        for (m2 = top_module; m2 != NULL; m2 = m2->next)
1069 +            if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)
1070 +                if (m2->remove_module != NULL)
1071 +                    (*m2->remove_module)(m);
1072 +    }
1073 +#endif /* EAPI */
1074 +
1075      modp = top_module;
1076      if (modp == m) {
1077         /* We are the top module, special case */
1078 @@ -1006,6 +1035,27 @@
1079      const command_rec *cmd;
1080      module *mod = top_module;
1081  
1082 +#ifdef EAPI
1083 +    /*
1084 +     * Invoke the `rewrite_command' of modules to allow
1085 +     * they to rewrite the directive line before we
1086 +     * process it.
1087 +     */
1088 +    {
1089 +        module *m;
1090 +        char *cp;
1091 +        for (m = top_module; m != NULL; m = m->next) {
1092 +            if (m->magic == MODULE_MAGIC_COOKIE_EAPI) {
1093 +                if (m->rewrite_command != NULL) {
1094 +                    cp = (m->rewrite_command)(parms, config, l);
1095 +                    if (cp != NULL)
1096 +                        l = cp;
1097 +                }
1098 +            }
1099 +        }
1100 +    }
1101 +#endif /* EAPI */
1102 +
1103      if ((l[0] == '#') || (!l[0]))
1104         return NULL;
1105  
1106 @@ -1440,6 +1490,10 @@
1107      s->limit_req_fieldsize = main_server->limit_req_fieldsize;
1108      s->limit_req_fields = main_server->limit_req_fields;
1109  
1110 +#ifdef EAPI
1111 +    s->ctx = ap_ctx_new(p);
1112 +#endif /* EAPI */
1113 +
1114      *ps = s;
1115  
1116      return ap_parse_vhost_addrs(p, hostname, s);
1117 @@ -1550,6 +1604,10 @@
1118  
1119      s->module_config = create_server_config(p, s);
1120      s->lookup_defaults = create_default_per_dir_config(p);
1121 +
1122 +#ifdef EAPI
1123 +    s->ctx = ap_ctx_new(p);
1124 +#endif /* EAPI */
1125  
1126      return s;
1127  }
1128
1129 +---------------------------------------------------------------------------
1130 | Add the ap_global_ctx variable and the new
1131 | ap_add_config_define() function. Additionally the
1132 | implementation of the additional `new_connection' module hook
1133 | is added plus the initialization of one more `ctx' variable.
1134 +---------------------------------------------------------------------------
1135 Index: src/main/http_main.c
1136 --- src/main/http_main.c        19 Jun 2002 07:20:25 -0000      1.1.1.18
1137 +++ src/main/http_main.c        19 Jun 2002 07:29:08 -0000      1.40
1138 @@ -279,6 +279,9 @@
1139  
1140  int ap_dump_settings = 0;
1141  API_VAR_EXPORT int ap_extended_status = 0;
1142 +#ifdef EAPI
1143 +API_VAR_EXPORT ap_ctx *ap_global_ctx;
1144 +#endif /* EAPI */
1145  
1146  /*
1147   * The max child slot ever assigned, preserved across restarts.  Necessary
1148 @@ -463,6 +466,30 @@
1149      }
1150  }
1151  
1152 +#ifdef EAPI
1153 +API_EXPORT(void) ap_add_config_define(const char *define)
1154 +{
1155 +    char **var;
1156 +    var = (char **)ap_push_array(ap_server_config_defines);
1157 +    *var = ap_pstrdup(pcommands, define);
1158 +    return;
1159 +}
1160 +
1161 +/*
1162 + * Invoke the `close_connection' hook of modules to let them do
1163 + * some connection dependent actions before we close it.
1164 + */
1165 +static void ap_call_close_connection_hook(conn_rec *c)
1166 +{
1167 +    module *m;
1168 +    for (m = top_module; m != NULL; m = m->next)
1169 +        if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1170 +            if (m->close_connection != NULL)
1171 +                (*m->close_connection)(c);
1172 +    return;
1173 +}
1174 +#endif /* EAPI */
1175 +
1176  #ifndef NETWARE
1177  static APACHE_TLS int volatile exit_after_unblock = 0;
1178  #endif
1179 @@ -1518,6 +1545,10 @@
1180             ap_log_transaction(log_req);
1181         }
1182  
1183 +#ifdef EAPI
1184 +       ap_call_close_connection_hook(save_req->connection);
1185 +#endif /* EAPI */
1186 +
1187         ap_bsetflag(save_req->connection->client, B_EOUT, 1);
1188         ap_bclose(save_req->connection->client);
1189         
1190 @@ -1526,6 +1557,9 @@
1191          ap_longjmp(jmpbuffer, 1);
1192      }
1193      else {                     /* abort the connection */
1194 +#ifdef EAPI
1195 +       ap_call_close_connection_hook(current_conn);
1196 +#endif /* EAPI */
1197         ap_bsetflag(current_conn->client, B_EOUT, 1);
1198         ap_bclose(current_conn->client);
1199         current_conn->aborted = 1;
1200 @@ -1828,10 +1862,16 @@
1201      /* Send any leftover data to the client, but never try to again */
1202  
1203      if (ap_bflush(r->connection->client) == -1) {
1204 +#ifdef EAPI
1205 +       ap_call_close_connection_hook(r->connection);
1206 +#endif /* EAPI */
1207         ap_kill_timeout(r);
1208         ap_bclose(r->connection->client);
1209         return;
1210      }
1211 +#ifdef EAPI
1212 +    ap_call_close_connection_hook(r->connection);
1213 +#endif /* EAPI */
1214      ap_bsetflag(r->connection->client, B_EOUT, 1);
1215  
1216      /* Close our half of the connection --- send the client a FIN */
1217 @@ -2559,6 +2599,9 @@
1218      /* Clear the pool - including any registered cleanups */
1219      ap_destroy_pool(pglobal);
1220  #endif
1221 +#ifdef EAPI
1222 +    ap_kill_alloc_shared();
1223 +#endif
1224      exit(code);
1225  }
1226  
1227 @@ -3570,6 +3613,24 @@
1228      conn->remote_addr = *remaddr;
1229      conn->remote_ip = ap_pstrdup(conn->pool,
1230                               inet_ntoa(conn->remote_addr.sin_addr));
1231 +#ifdef EAPI
1232 +    conn->ctx = ap_ctx_new(conn->pool);
1233 +#endif /* EAPI */
1234 +
1235 +#ifdef EAPI
1236 +    /*
1237 +     * Invoke the `new_connection' hook of modules to let them do
1238 +     * some connection dependent actions before we go on with
1239 +     * processing the request on this connection.
1240 +     */
1241 +    {
1242 +        module *m;
1243 +        for (m = top_module; m != NULL; m = m->next)
1244 +            if (m->magic == MODULE_MAGIC_COOKIE_EAPI)
1245 +                if (m->new_connection != NULL)
1246 +                    (*m->new_connection)(conn);
1247 +    }
1248 +#endif /* EAPI */
1249  
1250      return conn;
1251  }
1252 @@ -3998,6 +4059,15 @@
1253      printf("Server's Module Magic Number: %u:%u\n",
1254            MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
1255      printf("Server compiled with....\n");
1256 +#ifdef EAPI
1257 +    printf(" -D EAPI\n");
1258 +#endif
1259 +#ifdef EAPI_MM
1260 +    printf(" -D EAPI_MM\n");
1261 +#ifdef EAPI_MM_CORE_PATH
1262 +    printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n");
1263 +#endif
1264 +#endif
1265  #ifdef TPF
1266      show_os_specific_compile_settings();
1267  #endif
1268 @@ -4167,6 +4237,22 @@
1269      ap_server_pre_read_config  = ap_make_array(pcommands, 1, sizeof(char *));
1270      ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
1271      ap_server_config_defines   = ap_make_array(pcommands, 1, sizeof(char *));
1272 +
1273 +#ifdef EAPI
1274 +    ap_hook_init();
1275 +    ap_hook_configure("ap::buff::read", 
1276 +                      AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1277 +    ap_hook_configure("ap::buff::write",  
1278 +                      AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1279 +    ap_hook_configure("ap::buff::writev",  
1280 +                      AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1281 +    ap_hook_configure("ap::buff::sendwithtimeout", 
1282 +                      AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1283 +    ap_hook_configure("ap::buff::recvwithtimeout", 
1284 +                      AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);
1285 +
1286 +    ap_global_ctx = ap_ctx_new(NULL);
1287 +#endif /* EAPI */
1288  }
1289  
1290  #ifndef MULTITHREAD
1291 @@ -4617,6 +4703,9 @@
1292  
1293             ap_sync_scoreboard_image();
1294             if (ap_scoreboard_image->global.running_generation != ap_my_generation) {
1295 +#ifdef EAPI
1296 +               ap_call_close_connection_hook(current_conn);
1297 +#endif /* EAPI */
1298                 ap_bclose(conn_io);
1299                 clean_child_exit(0);
1300             }
1301 @@ -4645,6 +4734,9 @@
1302          */
1303  
1304  #ifdef NO_LINGCLOSE
1305 +#ifdef EAPI
1306 +       ap_call_close_connection_hook(current_conn);
1307 +#endif /* EAPI */
1308         ap_bclose(conn_io);     /* just close it */
1309  #else
1310         if (r && r->connection
1311 @@ -4655,6 +4747,9 @@
1312             lingering_close(r);
1313         }
1314         else {
1315 +#ifdef EAPI
1316 +           ap_call_close_connection_hook(current_conn);
1317 +#endif /* EAPI */
1318             ap_bsetflag(conn_io, B_EOUT, 1);
1319             ap_bclose(conn_io);
1320         }
1321 @@ -5420,16 +5515,31 @@
1322             usage(argv[0]);
1323         }
1324      }
1325 +#ifdef EAPI
1326 +    ap_init_alloc_shared(TRUE);
1327 +#endif
1328  
1329      ap_suexec_enabled = init_suexec();
1330      server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1331  
1332 +#ifdef EAPI
1333 +    ap_init_alloc_shared(FALSE);
1334 +#endif
1335 +
1336      if (ap_configtestonly) {
1337          fprintf(stderr, "Syntax OK\n");
1338 +#ifdef EAPI
1339 +        clean_parent_exit(0);
1340 +#else
1341          exit(0);
1342 +#endif
1343      }
1344      if (ap_dump_settings) {
1345 +#ifdef EAPI
1346 +        clean_parent_exit(0);
1347 +#else
1348          exit(0);
1349 +#endif
1350      }
1351  
1352      child_timeouts = !ap_standalone || one_process;
1353 @@ -5576,6 +5686,10 @@
1354             ap_destroy_pool(r->pool);
1355         }
1356  
1357 +#ifdef EAPI
1358 +       ap_call_close_connection_hook(conn);
1359 +#endif /* EAPI */
1360 +
1361         ap_bclose(cio);
1362      }
1363      exit(0);
1364 @@ -5952,6 +6066,9 @@
1365         ap_kill_cleanups_for_socket(ptrans, csd);
1366  
1367  #ifdef NO_LINGCLOSE
1368 +#ifdef EAPI
1369 +       ap_call_close_connection_hook(current_conn);
1370 +#endif /* EAPI */
1371         ap_bclose(conn_io);     /* just close it */
1372  #else
1373         if (r && r->connection
1374 @@ -5962,6 +6079,9 @@
1375             lingering_close(r);
1376         }
1377         else {
1378 +#ifdef EAPI
1379 +           ap_call_close_connection_hook(current_conn);
1380 +#endif /* EAPI */
1381             ap_bsetflag(conn_io, B_EOUT, 1);
1382             ap_bclose(conn_io);
1383         }
1384 @@ -7530,6 +7650,10 @@
1385      if (!conf_specified)
1386          ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname));
1387  
1388 +#ifdef EAPI
1389 +    ap_init_alloc_shared(TRUE);
1390 +#endif
1391 +
1392      if (!ap_os_is_path_absolute(ap_server_confname))
1393          ap_cpystrn(ap_server_confname,
1394                     ap_server_root_relative(pcommands, ap_server_confname),
1395 @@ -7569,6 +7693,9 @@
1396      }
1397  #else /* ndef WIN32 */
1398      server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
1399 +#endif
1400 +#ifdef EAPI
1401 +    ap_init_alloc_shared(FALSE);
1402  #endif
1403  
1404      if (ap_configtestonly) {
1405
1406 +---------------------------------------------------------------------------
1407 | Just add the initialization of the `ctx' variable for
1408 | conn_rec structures.
1409 +---------------------------------------------------------------------------
1410 Index: src/main/http_request.c
1411 --- src/main/http_request.c     19 Jun 2002 07:20:26 -0000      1.1.1.15
1412 +++ src/main/http_request.c     19 Jun 2002 07:29:09 -0000      1.15
1413 @@ -1375,6 +1375,10 @@
1414  
1415      new->method          = r->method;
1416      new->method_number   = r->method_number;
1417 +#ifdef EAPI
1418 +    /* initialize context _BEFORE_ ap_parse_uri() call */
1419 +    new->ctx             = r->ctx;
1420 +#endif /* EAPI */
1421      ap_parse_uri(new, new_uri);
1422      new->request_config = ap_create_request_config(r->pool);
1423      new->per_dir_config = r->server->lookup_defaults;
1424
1425 +---------------------------------------------------------------------------
1426 | Just add the initialization of the `ctx' variable for
1427 | request_rec structures.
1428 +---------------------------------------------------------------------------
1429 Index: src/main/http_protocol.c
1430 --- src/main/http_protocol.c    19 Jun 2002 07:20:26 -0000      1.1.1.17
1431 +++ src/main/http_protocol.c    19 Jun 2002 07:29:09 -0000      1.17
1432 @@ -1167,6 +1167,10 @@
1433      r->status          = HTTP_REQUEST_TIME_OUT;  /* Until we get a request */
1434      r->the_request     = NULL;
1435  
1436 +#ifdef EAPI
1437 +    r->ctx = ap_ctx_new(r->pool);
1438 +#endif /* EAPI */
1439 +
1440  #ifdef CHARSET_EBCDIC
1441      ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in  = 1);
1442      ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
1443 @@ -1323,6 +1327,11 @@
1444      rnew->read_body       = REQUEST_NO_BODY;
1445  
1446      rnew->main = (request_rec *) r;
1447 +
1448 +#ifdef EAPI
1449 +    rnew->ctx = r->ctx;
1450 +#endif /* EAPI */
1451 +
1452  }
1453  
1454  API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub)
1455
1456 +---------------------------------------------------------------------------
1457 | Add support for loading both EAPI and AP13 modules.
1458 +---------------------------------------------------------------------------
1459 Index: src/modules/standard/mod_so.c
1460 --- src/modules/standard/mod_so.c       27 Mar 2002 15:23:06 -0000      1.1.1.9
1461 +++ src/modules/standard/mod_so.c       27 Mar 2002 15:30:03 -0000      1.10
1462 @@ -269,11 +269,24 @@
1463       * Make sure the found module structure is really a module structure
1464       * 
1465       */
1466 +#ifdef EAPI
1467 +    if (   modp->magic != MODULE_MAGIC_COOKIE_AP13 
1468 +        && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {
1469 +#else
1470      if (modp->magic != MODULE_MAGIC_COOKIE) {
1471 +#endif
1472          return ap_pstrcat(cmd->pool, "API module structure `", modname,
1473                            "' in file ", szModuleFile, " is garbled -"
1474                            " perhaps this is not an Apache module DSO?", NULL);
1475      }
1476 +#ifdef EAPI
1477 +    if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {
1478 +        ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,
1479 +                     "Loaded DSO %s uses plain Apache 1.3 API, "
1480 +                     "this module might crash under EAPI! "
1481 +                     "(please recompile it with -DEAPI)", filename);
1482 +    }
1483 +#endif
1484  
1485      /* 
1486       * Add this module to the Apache core structures
1487
1488 +---------------------------------------------------------------------------
1489 | Add additional logging functions to the CustomLog directive
1490 | which can be used by other modules to create additional
1491 | logfile tags. Actually we add two types of hooks: One hook
1492 | for intercepting the new and generic %x (eXtension) tag and
1493 | one hook for creating new %x tags at all.
1494 +---------------------------------------------------------------------------
1495 Index: src/modules/standard/mod_log_config.c
1496 --- src/modules/standard/mod_log_config.c       19 Jun 2002 07:20:30 -0000      1.1.1.13
1497 +++ src/modules/standard/mod_log_config.c       19 Jun 2002 07:29:09 -0000      1.26
1498 @@ -262,6 +262,9 @@
1499  typedef const char *(*item_key_func) (request_rec *, char *);
1500  
1501  typedef struct {
1502 +#ifdef EAPI
1503 +    char ch;
1504 +#endif
1505      item_key_func func;
1506      char *arg;
1507      int condition_sense;
1508 @@ -580,15 +583,36 @@
1509      }
1510  };
1511  
1512 +#ifdef EAPI
1513 +static struct log_item_list *find_log_func(pool *p, char k)
1514 +#else /* EAPI */
1515  static struct log_item_list *find_log_func(char k)
1516 +#endif /* EAPI */
1517  {
1518      int i;
1519 +#ifdef EAPI
1520 +    struct log_item_list *lil;
1521 +#endif /* EAPI */
1522  
1523      for (i = 0; log_item_keys[i].ch; ++i)
1524          if (k == log_item_keys[i].ch) {
1525              return &log_item_keys[i];
1526          }
1527  
1528 +#ifdef EAPI
1529 +    if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k)) 
1530 +        != AP_HOOK_STATE_NOTEXISTANT) {
1531 +        lil = (struct log_item_list *)
1532 +              ap_pcalloc(p, sizeof(struct log_item_list));
1533 +        if (lil == NULL)
1534 +            return NULL;
1535 +        lil->ch = k;
1536 +        lil->func = NULL;
1537 +        lil->want_orig_default = 0;
1538 +        return lil;
1539 +    }
1540 +#endif /* EAPI */
1541 +
1542      return NULL;
1543  }
1544  
1545 @@ -714,7 +738,11 @@
1546              break;
1547  
1548          default:
1549 +#ifdef EAPI
1550 +            l = find_log_func(p, *s++);
1551 +#else /* EAPI */
1552              l = find_log_func(*s++);
1553 +#endif /* EAPI */
1554              if (!l) {
1555                  char dummy[2];
1556  
1557 @@ -723,6 +751,9 @@
1558                  return ap_pstrcat(p, "Unrecognized LogFormat directive %",
1559                                 dummy, NULL);
1560              }
1561 +#ifdef EAPI
1562 +            it->ch = s[-1];
1563 +#endif
1564              it->func = l->func;
1565              if (it->want_orig == -1) {
1566                  it->want_orig = l->want_orig_default;
1567 @@ -784,6 +815,15 @@
1568  
1569      /* We do.  Do it... */
1570  
1571 +#ifdef EAPI
1572 +    if (item->func == NULL) {
1573 +        cp = NULL;
1574 +        ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),
1575 +                    AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),
1576 +                    &cp, r, item->arg);
1577 +    }
1578 +    else
1579 +#endif
1580      cp = (*item->func) (item->want_orig ? orig : r, item->arg);
1581      return cp ? cp : "-";
1582  }
1583
1584 +---------------------------------------------------------------------------
1585 | Allow RewriteCond and RewriteRule directives to lookup 
1586 | variables from other modules.
1587 +---------------------------------------------------------------------------
1588 Index: src/modules/standard/mod_rewrite.c
1589 --- src/modules/standard/mod_rewrite.c  19 Jun 2002 07:20:30 -0000      1.1.1.15
1590 +++ src/modules/standard/mod_rewrite.c  19 Jun 2002 07:29:09 -0000      1.13
1591 @@ -3678,6 +3678,15 @@
1592      }
1593  #endif /* ndef WIN32 && NETWARE*/
1594  
1595 +#ifdef EAPI
1596 +    else {
1597 +        ap_hook_use("ap::mod_rewrite::lookup_variable",
1598 +                    AP_HOOK_SIG3(ptr,ptr,ptr), 
1599 +                    AP_HOOK_DECLINE(NULL),
1600 +                    &result, r, var);
1601 +    }
1602 +#endif
1603 +
1604      if (result == NULL) {
1605          return ap_pstrdup(r->pool, "");
1606      }
1607
1608 +---------------------------------------------------------------------------
1609 | Add an EAPI hook to allow other modules to add content to 
1610 | the status HTML page.
1611 +---------------------------------------------------------------------------
1612 Index: src/modules/standard/mod_status.c
1613 --- src/modules/standard/mod_status.c   27 Mar 2002 15:23:06 -0000      1.1.1.14
1614 +++ src/modules/standard/mod_status.c   27 Mar 2002 15:30:03 -0000      1.11
1615 @@ -717,6 +754,12 @@
1616  </table>\n", r);
1617  #endif
1618         }
1619 +
1620 +#ifdef EAPI
1621 +    ap_hook_use("ap::mod_status::display",
1622 +                AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL,
1623 +                r, no_table_report, short_report);
1624 +#endif
1625  
1626      } else {
1627  
1628
1629 +---------------------------------------------------------------------------
1630 | Add hooks to the scheme processing to allow other modules to
1631 | recognize more schemes by intercepting this processing.
1632 +---------------------------------------------------------------------------
1633 Index: src/modules/proxy/mod_proxy.c
1634 --- src/modules/proxy/mod_proxy.c       19 Jun 2002 07:20:27 -0000      1.1.1.12
1635 +++ src/modules/proxy/mod_proxy.c       19 Jun 2002 07:29:09 -0000      1.19
1636 @@ -218,6 +218,9 @@
1637  static int proxy_fixup(request_rec *r)
1638  {
1639      char *url, *p;
1640 +#ifdef EAPI
1641 +    int rc;
1642 +#endif /* EAPI */
1643  
1644      if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0)
1645          return DECLINED;
1646 @@ -225,6 +228,14 @@
1647      url = &r->filename[6];
1648  
1649  /* canonicalise each specific scheme */
1650 +#ifdef EAPI
1651 +    if (ap_hook_use("ap::mod_proxy::canon",
1652 +                    AP_HOOK_SIG3(int,ptr,ptr),
1653 +                    AP_HOOK_DECLINE(DECLINED),
1654 +                    &rc, r, url) && rc != DECLINED)
1655 +        return rc;  
1656 +    else
1657 +#endif /* EAPI */
1658      if (strncasecmp(url, "http:", 5) == 0)
1659          return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
1660      else if (strncasecmp(url, "ftp:", 4) == 0)
1661 @@ -240,9 +251,44 @@
1662  static void proxy_init(server_rec *r, pool *p)
1663  {
1664      ap_proxy_garbage_init(r, p);
1665 +#ifdef EAPI
1666 +    ap_hook_use("ap::mod_proxy::init", 
1667 +                AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);
1668 +#endif
1669  }
1670  
1671 -
1672 +#ifdef EAPI
1673 +static void proxy_addmod(module *m)
1674 +{
1675 +    /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */
1676 +    ap_hook_configure("ap::mod_proxy::http::canon", 
1677 +                      AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1678 +    ap_hook_register("ap::mod_proxy::http::canon", 
1679 +                     ap_proxy_http_canon, AP_HOOK_NOCTX);
1680 +
1681 +    /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */
1682 +    ap_hook_configure("ap::mod_proxy::http::handler", 
1683 +                      AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);
1684 +    ap_hook_register("ap::mod_proxy::http::handler", 
1685 +                     ap_proxy_http_handler, AP_HOOK_NOCTX);
1686 +
1687 +    /* export: ap_proxyerror() as `ap::mod_proxy::error' */
1688 +    ap_hook_configure("ap::mod_proxy::error", 
1689 +                      AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);
1690 +    ap_hook_register("ap::mod_proxy::error", 
1691 +                     ap_proxyerror, AP_HOOK_NOCTX);
1692 +    return;
1693 +}
1694 +
1695 +static void proxy_remmod(module *m)
1696 +{
1697 +       /* remove the hook references */
1698 +    ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);
1699 +    ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);
1700 +    ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);
1701 +    return;
1702 +}
1703 +#endif /* EAPI */
1704  
1705  /* Send a redirection if the request contains a hostname which is not */
1706  /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
1707 @@ -374,6 +420,14 @@
1708                   * CONNECT is a special method that bypasses the normal proxy
1709                   * code.
1710                   */
1711 +#ifdef EAPI
1712 +               if (!ap_hook_use("ap::mod_proxy::handler",
1713 +                                AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1714 +                                AP_HOOK_DECLINE(DECLINED),
1715 +                                &rc, r, cr, url, 
1716 +                                ents[i].hostname, ents[i].port, 
1717 +                                ents[i].protocol) || rc == DECLINED) {
1718 +#endif /* EAPI */
1719                  if (r->method_number == M_CONNECT)
1720                      rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
1721                                                    ents[i].port);
1722 @@ -383,6 +437,9 @@
1723                                                 ents[i].port);
1724                  else
1725                      rc = DECLINED;
1726 +#ifdef EAPI
1727 +               }
1728 +#endif /* EAPI */
1729  
1730                  /* an error or success */
1731                  if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
1732 @@ -397,6 +454,14 @@
1733       */
1734  
1735      /* handle the scheme */
1736 +#ifdef EAPI
1737 +    if (ap_hook_use("ap::mod_proxy::handler",
1738 +                   AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),
1739 +                   AP_HOOK_DECLINE(DECLINED),
1740 +                   &rc, r, cr, url, 
1741 +                    NULL, 0, scheme) && rc != DECLINED)
1742 +        return rc;
1743 +#endif /* EAPI */
1744      if (r->method_number == M_CONNECT) {
1745          return ap_proxy_connect_handler(r, cr, url, NULL, 0);
1746      }
1747 @@ -994,4 +1059,10 @@
1748      NULL,                       /* child_init */
1749      NULL,                       /* child_exit */
1750      proxy_detect                /* post read-request */
1751 +#ifdef EAPI
1752 +   ,proxy_addmod,              /* EAPI: add_module */
1753 +    proxy_remmod,              /* EAPI: remove_module */
1754 +    NULL,                      /* EAPI: rewrite_command */
1755 +    NULL                       /* EAPI: new_connection  */
1756 +#endif
1757  };
1758
1759 +---------------------------------------------------------------------------
1760 | Add hooks to the HTTP processing to allow other modules
1761 | to enhance it by intercepting this processing.
1762 +---------------------------------------------------------------------------
1763 Index: src/modules/proxy/proxy_http.c
1764 --- src/modules/proxy/proxy_http.c      19 Jun 2002 07:20:27 -0000      1.1.1.14
1765 +++ src/modules/proxy/proxy_http.c      19 Jun 2002 07:29:09 -0000      1.22
1766 @@ -170,6 +170,9 @@
1767      const char *datestr, *urlstr;
1768      int result, major, minor;
1769      const char *content_length;
1770 +#ifdef EAPI
1771 +    char *peer;
1772 +#endif
1773  
1774      void *sconf = r->server->module_config;
1775      proxy_server_conf *conf =
1776 @@ -191,6 +194,12 @@
1777          return HTTP_BAD_REQUEST;
1778      urlptr += 3;
1779      destport = DEFAULT_HTTP_PORT;
1780 +#ifdef EAPI
1781 +    ap_hook_use("ap::mod_proxy::http::handler::set_destport", 
1782 +                AP_HOOK_SIG2(int,ptr), 
1783 +                AP_HOOK_TOPMOST,
1784 +                &destport, r);
1785 +#endif /* EAPI */
1786      strp = strchr(urlptr, '/');
1787      if (strp == NULL) {
1788          desthost = ap_pstrdup(p, urlptr);
1789 @@ -228,12 +237,18 @@
1790          err = ap_proxy_host2addr(proxyhost, &server_hp);
1791          if (err != NULL)
1792              return DECLINED;    /* try another */
1793 +#ifdef EAPI
1794 +       peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport);  
1795 +#endif
1796      }
1797      else {
1798          server.sin_port = htons((unsigned short)destport);
1799          err = ap_proxy_host2addr(desthost, &server_hp);
1800          if (err != NULL)
1801              return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
1802 +#ifdef EAPI
1803 +       peer =  ap_psprintf(p, "%s:%u", desthost, destport);  
1804 +#endif
1805      }
1806  
1807  
1808 @@ -308,14 +323,42 @@
1809      f = ap_bcreate(p, B_RDWR | B_SOCKET);
1810      ap_bpushfd(f, sock, sock);
1811  
1812 +#ifdef EAPI
1813 +    {
1814 +        char *errmsg = NULL;
1815 +        ap_hook_use("ap::mod_proxy::http::handler::new_connection", 
1816 +                    AP_HOOK_SIG4(ptr,ptr,ptr,ptr), 
1817 +                    AP_HOOK_DECLINE(NULL),
1818 +                    &errmsg, r, f, peer);
1819 +        if (errmsg != NULL)
1820 +            return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);
1821 +    }
1822 +#endif /* EAPI */
1823 +
1824      ap_hard_timeout("proxy send", r);
1825      ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF,
1826                NULL);
1827 +#ifdef EAPI
1828 +    {
1829 +       int rc = DECLINED;
1830 +       ap_hook_use("ap::mod_proxy::http::handler::write_host_header", 
1831 +                   AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr), 
1832 +                   AP_HOOK_DECLINE(DECLINED),
1833 +                   &rc, r, f, desthost, destport, destportstr);
1834 +        if (rc == DECLINED) {
1835 +           if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
1836 +               ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
1837 +           else
1838 +               ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
1839 +        }
1840 +    }
1841 +#else /* EAPI */
1842      /* Send Host: now, adding it to req_hdrs wouldn't be much better */
1843      if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
1844          ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
1845      else
1846          ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
1847 +#endif /* EAPI */
1848  
1849      if (conf->viaopt == via_block) {
1850          /* Block all outgoing Via: headers */
1851
1852 +---------------------------------------------------------------------------
1853 | Add EAPI hooks in module structure for APXS generated samples.
1854 +---------------------------------------------------------------------------
1855 Index: src/support/apxs.pl
1856 --- src/support/apxs.pl 19 Jun 2002 07:20:34 -0000      1.1.1.12
1857 +++ src/support/apxs.pl 19 Jun 2002 07:29:09 -0000      1.12
1858 @@ -711,5 +711,11 @@
1859      NULL,                  /* child_init                          */
1860      NULL,                  /* child_exit                          */
1861      NULL                   /* [#0] post read-request              */
1862 +#ifdef EAPI
1863 +   ,NULL,                  /* EAPI: add_module                    */
1864 +    NULL,                  /* EAPI: remove_module                 */
1865 +    NULL,                  /* EAPI: rewrite_command               */
1866 +    NULL                   /* EAPI: new_connection                */
1867 +#endif
1868  };
1869  
1870
1871 +---------------------------------------------------------------------------
1872 | Add the EAPI functions, so the stuff can be built under AIX
1873 | and similar braindead platforms as DSO.
1874 +---------------------------------------------------------------------------
1875 Index: src/support/httpd.exp
1876 --- src/support/httpd.exp       19 Jun 2002 07:20:34 -0000      1.1.1.11
1877 +++ src/support/httpd.exp       19 Jun 2002 07:29:09 -0000      1.13
1878 @@ -427,3 +427,59 @@
1879  XML_SetUnparsedEntityDeclHandler
1880  XML_SetUserData
1881  XML_UseParserAsHandlerArg
1882 +ap_add_config_define
1883 +ap_make_shared_sub_pool
1884 +ap_global_ctx
1885 +ap_ctx_new
1886 +ap_ctx_get
1887 +ap_ctx_set
1888 +ap_hook_init
1889 +ap_hook_kill
1890 +ap_hook_configure
1891 +ap_hook_register_I
1892 +ap_hook_unregister_I
1893 +ap_hook_status
1894 +ap_hook_use
1895 +ap_hook_call
1896 +ap_mm_useable
1897 +ap_MM_create
1898 +ap_MM_permission
1899 +ap_MM_destroy
1900 +ap_MM_lock
1901 +ap_MM_unlock
1902 +ap_MM_malloc
1903 +ap_MM_realloc
1904 +ap_MM_free
1905 +ap_MM_calloc
1906 +ap_MM_strdup
1907 +ap_MM_sizeof
1908 +ap_MM_maxsize
1909 +ap_MM_available
1910 +ap_MM_error
1911 +ap_mm_create
1912 +ap_mm_permission
1913 +ap_mm_destroy
1914 +ap_mm_lock
1915 +ap_mm_unlock
1916 +ap_mm_malloc
1917 +ap_mm_realloc
1918 +ap_mm_free
1919 +ap_mm_calloc
1920 +ap_mm_strdup
1921 +ap_mm_sizeof
1922 +ap_mm_maxsize
1923 +ap_mm_available
1924 +ap_mm_error
1925 +ap_mm_display_info
1926 +ap_mm_core_create
1927 +ap_mm_core_permission
1928 +ap_mm_core_delete
1929 +ap_mm_core_size
1930 +ap_mm_core_lock
1931 +ap_mm_core_unlock
1932 +ap_mm_core_maxsegsize
1933 +ap_mm_core_align2page
1934 +ap_mm_core_align2word
1935 +ap_mm_lib_error_set
1936 +ap_mm_lib_error_get
1937 +ap_mm_lib_version
1938
1939 +---------------------------------------------------------------------------
1940 | Add the EAPI functions, so the stuff can be built under
1941 | Windows 95 and similar braindead platforms as DDL.
1942 +---------------------------------------------------------------------------
1943 Index: src/ApacheCore.def
1944 --- src/ApacheCore.def  19 Jun 2002 07:20:21 -0000      1.1.1.10
1945 +++ src/ApacheCore.def  19 Jun 2002 07:29:08 -0000      1.14
1946 @@ -447,3 +447,67 @@
1947          ap_getline @439
1948          ap_get_chunk_size @440
1949          ap_escape_logitem @441
1950 +       
1951 +       ; EAPI extended symbols
1952 +       ; note; no ID's, so these all bind by name rather than ordinal since 
1953 +       ; their ordinals would change with symbol changes in the distribution
1954 +       ap_add_config_define
1955 +       ap_global_ctx  DATA
1956 +       ap_ctx_new
1957 +       ap_ctx_get
1958 +       ap_ctx_overlay
1959 +       ap_ctx_set
1960 +       ap_hook_init
1961 +       ap_hook_kill
1962 +       ap_hook_configure
1963 +       ap_hook_register_I
1964 +       ap_hook_unregister_I
1965 +       ap_hook_status
1966 +       ap_hook_use
1967 +       ap_hook_call
1968 +       ap_set_callback_and_alarm
1969 +       ap_acquire_pool
1970 +       ap_make_shared_sub_pool
1971 +       ap_release_pool
1972 +       ap_mm_useable
1973 +       ap_MM_create
1974 +       ap_MM_permission
1975 +       ap_MM_destroy
1976 +       ap_MM_lock
1977 +       ap_MM_unlock
1978 +       ap_MM_malloc
1979 +       ap_MM_realloc
1980 +       ap_MM_free
1981 +       ap_MM_calloc
1982 +       ap_MM_strdup
1983 +       ap_MM_sizeof
1984 +       ap_MM_maxsize
1985 +       ap_MM_available
1986 +       ap_MM_error
1987 +       ap_mm_create
1988 +       ap_mm_permission
1989 +       ap_mm_destroy
1990 +       ap_mm_lock
1991 +       ap_mm_unlock
1992 +       ap_mm_malloc
1993 +       ap_mm_realloc
1994 +       ap_mm_free
1995 +       ap_mm_calloc
1996 +       ap_mm_strdup
1997 +       ap_mm_sizeof
1998 +       ap_mm_maxsize
1999 +       ap_mm_available
2000 +       ap_mm_error
2001 +       ap_mm_display_info
2002 +       ap_mm_core_create
2003 +       ap_mm_core_permission
2004 +       ap_mm_core_delete
2005 +       ap_mm_core_size
2006 +       ap_mm_core_lock
2007 +       ap_mm_core_unlock
2008 +       ap_mm_core_align2page
2009 +       ap_mm_core_align2word
2010 +       ap_mm_lib_error_set
2011 +       ap_mm_lib_error_get
2012 +       ap_mm_lib_version
2013 +
This page took 0.24091 seconds and 3 git commands to generate.