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