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