]>
Commit | Line | Data |
---|---|---|
5d6773a4 | 1 | diff -Nru apache_1.3.9/README.EAPI apache_1.3.9.EAPI/README.EAPI |
2 | --- apache_1.3.9/README.EAPI Thu Jan 1 01:00:00 1970 | |
3 | +++ apache_1.3.9.EAPI/README.EAPI Wed Dec 29 21:25:55 1999 | |
4 | @@ -0,0 +1,340 @@ | |
5 | + | |
6 | + Extended API (EAPI) | |
7 | + =================== | |
8 | + | |
9 | + What is EAPI | |
10 | + ============ | |
11 | + | |
12 | + Extended API (EAPI) is a comprehensive API addition which can be _OPTIONALLY_ | |
13 | + enabled with ``Rule EAPI=yes'' in src/Configuration or ``--enable-rule=EAPI'' | |
14 | + on the APACI configure command line. This then defines a -DEAPI and this way | |
15 | + the EAPI code is compiled into Apache. When this define is not present _NO_ | |
16 | + EAPI code is compiled into Apache at all, because all(!) EAPI patches are | |
17 | + encapsulated in #ifdef EAPI...#endif. | |
18 | + | |
19 | + What is provided by EAPI? | |
20 | + ========================= | |
21 | + | |
22 | + EAPI's additions to the Apache API fall into the following categories: | |
23 | + | |
24 | + o Context Attachment Support for Data Structures | |
25 | + o Loosly-coupled Hook Interface for Inter-Module Communication | |
26 | + o Direct and Pool-based Shared Memory Support | |
27 | + o Additional Apache Module Hooks | |
28 | + o Specialized EAPI Goodies | |
29 | + | |
30 | + They are discussed in details now.... | |
31 | + | |
32 | + Context Attachment Support for Data Structures | |
33 | + ---------------------------------------------- | |
34 | + | |
35 | + Attaching private information to a request_rec, conn_rec, server_rec or even | |
36 | + BUFF structure is for a lot of modules the most elegant solution to keep | |
37 | + states between API phases without the need for any global variables. That's | |
38 | + especially true for modules which operate on lower I/O levels (where no | |
39 | + per-module configuration structure is available) or have to deal with various | |
40 | + callback functions of third-party libraries (where one need to find the | |
41 | + private context which can be hard without global variables). | |
42 | + | |
43 | + The EAPI way to solve this situation is: | |
44 | + | |
45 | + 1. A generic context library was written which allows one | |
46 | + to create a context and later store and retrieve context variables | |
47 | + identified by a unique key. | |
48 | + | |
49 | + 2. The Apache kernel was extended to provide contexts for all standard data | |
50 | + structures like request_rec, server_rec, conn_rec, BUFF, etc. This way | |
51 | + modules can easily attach information to all these structures with the | |
52 | + help of the context API. | |
53 | + | |
54 | + Point 1 is implemented by new src/ap/ap_ctx.c and src/include/ap_ctx.h source | |
55 | + files. Point 2 is implemented by EAPI patches to various src/main/*.c and | |
56 | + src/include/*.h files. | |
57 | + | |
58 | + Example: | |
59 | + | |
60 | + | /* a module implements on-the-fly compression for | |
61 | + | the buffer code and for this uses a third-party library which | |
62 | + | don't uses a filedescriptor. Instead a CLIB* is used. The module has to | |
63 | + | attach this CLIB* to the BUFF in oder to have it available whenever a | |
64 | + | BUFF is used somewhere. */ | |
65 | + | BUFF *buff; | |
66 | + | CLIB *comp; | |
67 | + | comp = CLIB_new_from_fd(buff->fd); | |
68 | + | ap_ctx_set(buff->ctx, "CLIB", comp); | |
69 | + | : | |
70 | + | | |
71 | + | /* later when it deals with a BUFF, it can easily find back the | |
72 | + | CLIB* via the BUFF* */ | |
73 | + | comp = (CLIB *)ap_ctx_get(buff->ctx, "CLIB"); | |
74 | + | : | |
75 | + | |
76 | + Possible use cases from practice are: | |
77 | + | |
78 | + o attaching third-party structures to Apache structures | |
79 | + o replacing global module variables with clean context variables | |
80 | + o custom attachments for complex modules like mod_php, mod_php, etc. | |
81 | + o companion support for the hook interface (see below) | |
82 | + o etc. pp. | |
83 | + | |
84 | + Loosly-coupled Hook Interface for Inter-Module Communication | |
85 | + ------------------------------------------------------------ | |
86 | + | |
87 | + Apache is structured into modules which is a nice idea. With the Dynamic | |
88 | + Shared Object (DSO) facility it gets even nicer because then modules are then | |
89 | + really stand-alone objects. The drawback is that DSO restricts modules. The | |
90 | + most popular problem is that no inter-module symbol references are allowed. | |
91 | + The classical problem: Module A implements some nice functions module B would | |
92 | + like to use to avoid reimplementing the wheel. But B cannot call A's | |
93 | + functions because this violates both the design idea of stand-alone modules | |
94 | + and the DSO restrictions. Additionally a module C could exists which also | |
95 | + provides a variant of the functionality of A's function. Then B should get | |
96 | + the variant (either A's or C's) which is best or available at all. | |
97 | + | |
98 | + Real Life Example: | |
99 | + | |
100 | + mod_rewrite provides %{XXXX} constructs to lookup variables. The available | |
101 | + variables are (and have to be) hard-coded into mod_rewrite. Now our mod_clib | |
102 | + which does on-the-fly compression provides a variable CLIB_FACTOR which gives | |
103 | + information about the shrink factor of the compression and a user wants to | |
104 | + use this shrink factor to make an URL-rewriting decision (<grin>). No chance | |
105 | + without EAPI. With EAPI it's easy: Inside the if-cascade for the various | |
106 | + variables in mod_rewrite one replaces: | |
107 | + | |
108 | + | char *result; | |
109 | + | request_rec *r; | |
110 | + | : | |
111 | + | if (strcasecmp(var, "...") == 0) { | |
112 | + | : | |
113 | + | else if (strcasecmp(var, "SCRIPT_GROUP") == 0) { | |
114 | + | result = ... | |
115 | + | } | |
116 | + | else { | |
117 | + | if (result == NULL) { | |
118 | + | ...complain... | |
119 | + | } | |
120 | + | } | |
121 | + | : | |
122 | + | |
123 | + with | |
124 | + | |
125 | + | char *result; | |
126 | + | request_rec *r; | |
127 | + | : | |
128 | + | if (strcasecmp(var, "...") == 0) { | |
129 | + | : | |
130 | + | else if (strcasecmp(var, "SCRIPT_GROUP") == 0) { | |
131 | + | result = ... | |
132 | + | } | |
133 | + | else { | |
134 | + | ap_hook_use("ap::lookup_variable", | |
135 | + | AP_HOOK_SIG4(ptr,ptr,ptr,ctx), | |
136 | + | AP_HOOK_DECLINE(NULL), | |
137 | + | &result, r, var); | |
138 | + | if (result == NULL) { | |
139 | + | ...complain... | |
140 | + | } | |
141 | + | } | |
142 | + | : | |
143 | + | |
144 | + What this does is that when XXXX of %{XXXX} isn't known, a hook named | |
145 | + ap::lookup_variable is called with the request_rec and the var ("XXX") and | |
146 | + the result variable. When no one has registered for this hook, nothing | |
147 | + happens. ap_hook_use() immediately returns and nothing was changed. | |
148 | + | |
149 | + But now let's assume mod_clib is additionally loaded as a DSO. And without | |
150 | + changing anything now magically mod_rewrite implements %{CLIB_FACTOR}. How? | |
151 | + Look inside mod_clib.c: | |
152 | + | |
153 | + | /* mod_clib registeres for the ap::lookup_variable hook | |
154 | + | inside it's init phase */ | |
155 | + | CLIB *comp; | |
156 | + | ap_hook_register("ap::lookup_variable", | |
157 | + | my_lookup_variable, AP_HOOK_CTX(comp)); | |
158 | + | | |
159 | + | /* and implements the my_lookup_variable() function */ | |
160 | + | char *my_lookup_variable(request_rec *r, char *name, CLIB *comp) | |
161 | + | { | |
162 | + | if (strcmp(name, "CLIB_FACTOR") == 0) | |
163 | + | return ap_psrintf(r->pool, "%d", comp->factor); | |
164 | + | return NULL; | |
165 | + | } | |
166 | + | |
167 | + What happens? When mod_rewrite calls the ap_hook_use() function internally | |
168 | + the hook facility knows that mod_clib has registered for this hook and calls | |
169 | + the equivalent of | |
170 | + | |
171 | + | result = my_lookup_variable(r, var, <comp>); | |
172 | + | |
173 | + where <comp> is the CLIB* context variable mod_clib has registered for | |
174 | + itself. Now assume a second module exists which also provides variables and | |
175 | + want to allow mod_rewrite to lookup them. It registers after mod_clib with | |
176 | + | |
177 | + | ap_hook_register("ap::lookup_variable", | |
178 | + | my_lookup_variable2, AP_HOOK_CTX(whatever)); | |
179 | + | | |
180 | + | |
181 | + and then the following happens: The hook facility does for mod_rewrite the | |
182 | + equivalent of: | |
183 | + | |
184 | + | result = my_lookup_variable(r, var, <comp>); | |
185 | + | if (result == NULL) | |
186 | + | result = my_lookup_variable2(r, var, <whatever>); | |
187 | + | |
188 | + As you can see the hook functions decline in this example with NULL. That's | |
189 | + the NULL from AP_HOOK_DECLINE(NULL) and can be any value of any type, of | |
190 | + course. | |
191 | + | |
192 | + The same idea can be also used by mod_log_config and every other module which | |
193 | + wants to lookup a variable inside Apache. Which variables are available | |
194 | + depend on the available modules which implement them. And this all works | |
195 | + nicely with the DSO facility, because the ap_hook_xxx() API is part of the | |
196 | + Apache kernel code. And nothing has to be changed inside Apache when another | |
197 | + modules wants to create a new hook, because the mechanism is totally generic. | |
198 | + | |
199 | + So when our module A wants to let other modules to use it's function it just | |
200 | + has to configure a hook for this. Then other modules call this hook. Is | |
201 | + module A not there the boolean return value of the hook call will indicate | |
202 | + this. When module A is there the function is called. | |
203 | + | |
204 | + Direct and Pool-based Shared Memory Support | |
205 | + ------------------------------------------- | |
206 | + | |
207 | + Since years it was annoying that Apache's pre-forked process model basically | |
208 | + means that every server lives it's own life (= address space) and this way | |
209 | + module authors cannot easily spread module configuration or other data | |
210 | + accross the processes. The most elegant solution is to use shared memory | |
211 | + segments. The drawback is that there is no portable API for shared memory | |
212 | + handling and there is no convinient memory allocation API for working inside | |
213 | + shared memory segments. | |
214 | + | |
215 | + The EAPI way to solve this situation is: | |
216 | + | |
217 | + 1. A stand-alone and resuable library was written (named MM from "memory | |
218 | + mapped" and available from http://www.engelschall.com/sw/mm/) which | |
219 | + abstracts the shared memory and memory mutex fiddling into a low-level | |
220 | + API. Internally the shared memory and mutex functionality is implemented | |
221 | + in various platform-depended ways: 4.4BSD or POSIX.1 anonymous memory | |
222 | + mapping, /dev/zero-based memory mapping, temporary file memory mapping, or | |
223 | + SysV IPC shared memory for allocating the shared memory areas and POSIX.1 | |
224 | + fcntl(2), BSD flock(2) or SysV IPC semaphores for implementing mutual | |
225 | + exclusion capabilities. | |
226 | + | |
227 | + Additionally MM provides a high-level malloc()-style API based on this | |
228 | + abstracted shared memory low-level API. The idea is just to allocate the | |
229 | + requested memory chunks from shared memory segments instead of the heap. | |
230 | + | |
231 | + 2. EAPI now provides an easy method (with the EAPI_MM configuration | |
232 | + variable) to build Apache against this MM library. For this the whole MM | |
233 | + API (mm_xxx() functions) is encapsulated in an Apache API subpart | |
234 | + (ap_mm_xxx() functions). This way the API is fixed and always present (no | |
235 | + #ifdef EAPI stuff in modules!), but useable only when EAPI was used in | |
236 | + conjunction with MM. A simple ``EAPI_MM=/path/to/mm ./configure | |
237 | + --enable-rule=EAPI ...'' is enough to put MM under the ap_mm_xxx() API. | |
238 | + This way modules can use a consistent, powerful and abstracted ap_mm_xxx() | |
239 | + API for dealing with shared memory. | |
240 | + | |
241 | + 3. Because inside Apache mostly all memory handling is done via the | |
242 | + pool facility, additional support for ``shared memory pools'' is provided. | |
243 | + This way modules can use all ap_pxxx() functions in combination with | |
244 | + shared memory. | |
245 | + | |
246 | + Point 1 is implemented inside the MM package. Point 2 is implemented by the | |
247 | + new src/ap/ap_mm.c and src/include/ap_mm.h source files. Point 3 is | |
248 | + implemented by EAPI patches to src/main/alloc.c and src/include/alloc.h. | |
249 | + | |
250 | + Example: | |
251 | + | |
252 | + | /* inside a module init function (before the forking!) | |
253 | + | for instance a module allocates a structure with a counter | |
254 | + | in a shared memory segment */ | |
255 | + | pool *p; | |
256 | + | pool *sp; | |
257 | + | struct mystuff { int cnt } *my; | |
258 | + | sp = ap_make_shared_sub_pool(p); | |
259 | + | my = (struct mystuff *)ap_palloc(sp, sizeof(struct mystuff)); | |
260 | + | my->cnt = 0; | |
261 | + | | |
262 | + | : | |
263 | + | /* then under request processing time it's changed by one process */ | |
264 | + | ap_acquire_pool(sp, AP_POOL_RW); | |
265 | + | my->cnt++; | |
266 | + | ap_release_pool(sp); | |
267 | + | : | |
268 | + | | |
269 | + | /* and at the same time read by other processes */ | |
270 | + | ap_acquire_pool(sp, AP_POOL_RD); | |
271 | + | ap_rprintf(r, "The counter is %d\n", my->cnt); | |
272 | + | ap_release_pool(sp); | |
273 | + | |
274 | + Possible use cases from practice are: | |
275 | + | |
276 | + o assembling traffic or other accounting details | |
277 | + o establishing of high-performance inter-process caches | |
278 | + o inter-process wide keeping of session state information | |
279 | + o shared memory support for mod_perl, mod_php, etc. | |
280 | + o etc. pp. | |
281 | + | |
282 | + Additional Apache Module Hooks | |
283 | + ------------------------------ | |
284 | + | |
285 | + The above three EAPI additions are all very generic facilities. But there | |
286 | + were also specialized things which were missing in Apache (and needed by | |
287 | + modules). Mostly additional API phases. EAPI adds the following additional | |
288 | + hook pointers to the module structure: | |
289 | + | |
290 | + add_module: | |
291 | + Called from within ap_add_module() right after the module structure | |
292 | + was linked into the Apache internal module list. It is mainly | |
293 | + intended to be used to define configuration defines (<IfDefine>) | |
294 | + which have to be available directly after a LoadModule/AddModule. | |
295 | + Actually this is the earliest possible hook a module can use. It's | |
296 | + especially important for the modules when they use the hook facility. | |
297 | + | |
298 | + remove_module: | |
299 | + Called from within ap_remove_module() right before the module | |
300 | + structure is kicked out from the Apache internal module list. | |
301 | + Actually this is last possible hook a module can use and exists for | |
302 | + consistency with the add_module hook. | |
303 | + | |
304 | + rewrite_command: | |
305 | + Called right after a configuration directive line was read and | |
306 | + before it is processed. It is mainly intended to be used for | |
307 | + rewriting directives in order to provide backward compatibility to | |
308 | + old directive variants. | |
309 | + | |
310 | + new_connection: | |
311 | + Called from within the internal new_connection() function, right | |
312 | + after the conn_rec structure for the new established connection was | |
313 | + created and before Apache starts processing the request with | |
314 | + ap_read_request(). It is mainly intended to be used to setup/run | |
315 | + connection dependent things like sending start headers for | |
316 | + on-the-fly compression, etc. | |
317 | + | |
318 | + close_connection: | |
319 | + Called from within the Apache dispatching loop just before any | |
320 | + ap_bclose() is performed on the socket connection, but a long time | |
321 | + before any pool cleanups are done for the connection (which can be | |
322 | + too late for some applications). It is mainly intended to be used | |
323 | + to close/finalize connection dependent things like sending end | |
324 | + headers for on-the-fly compression, etc. | |
325 | + | |
326 | + Specialized EAPI Goodies | |
327 | + ------------------------ | |
328 | + | |
329 | + And finally EAPI now uses some of the new functionality to add a few new | |
330 | + EAPI-based goodies to mod_rewrite, mod_status and mod_proxy: | |
331 | + | |
332 | + mod_rewrite: | |
333 | + The above presented example of lookup hooks is implemented which allows | |
334 | + mod_rewrite to lookup arbitrary variables provides by not known modules. | |
335 | + | |
336 | + mod_status: | |
337 | + Any module now can register to an EAPI hook of mod_status which | |
338 | + allows it to put additional text on the /status webpages. | |
339 | + | |
340 | + mod_proxy: | |
341 | + Some EAPI hooks are provided to allow other modules to control the HTTP | |
342 | + client processing inside mod_proxy. This can be used for a lot of | |
343 | + tricks. | |
344 | + | |
345 | diff -Nru apache_1.3.9/htdocs/manual/mod/directives.html apache_1.3.9.EAPI/htdocs/manual/mod/directives.html | |
346 | --- apache_1.3.9/htdocs/manual/mod/directives.html Wed Dec 29 22:03:42 1999 | |
347 | +++ apache_1.3.9.EAPI/htdocs/manual/mod/directives.html Wed Dec 29 21:25:55 1999 | |
348 | @@ -96,6 +96,7 @@ | |
349 | <LI><A HREF="mod_autoindex.html#defaulticon">DefaultIcon</A> | |
350 | <LI><A HREF="mod_mime.html#defaultlanguage">DefaultLanguage</A> | |
351 | <LI><A HREF="core.html#defaulttype">DefaultType</A> | |
352 | +<LI><A HREF="mod_define.html#define">Define</A> | |
353 | <LI><A HREF="mod_access.html#deny">deny</A> | |
354 | <LI><A HREF="core.html#directory"><Directory></A> | |
355 | <LI><A HREF="core.html#directorymatch"><DirectoryMatch></A> | |
356 | diff -Nru apache_1.3.9/htdocs/manual/mod/index.html apache_1.3.9.EAPI/htdocs/manual/mod/index.html | |
357 | --- apache_1.3.9/htdocs/manual/mod/index.html Wed Dec 29 22:03:42 1999 | |
358 | +++ apache_1.3.9.EAPI/htdocs/manual/mod/index.html Wed Dec 29 21:25:55 1999 | |
359 | @@ -62,6 +62,8 @@ | |
360 | <DT><A HREF="mod_cookies.html">mod_cookies</A> up to Apache 1.1.1 | |
361 | <DD>Support for Netscape-like cookies. Replaced in Apache 1.2 by | |
362 | mod_usertrack | |
363 | +<DT><A HREF="mod_define.html">mod_define</A> | |
364 | +<DD>Variable Definition for Arbitrary Directives | |
365 | <DT><A HREF="mod_digest.html">mod_digest</A> | |
366 | <DD>MD5 authentication | |
367 | <DT><A HREF="mod_dir.html">mod_dir</A> | |
368 | diff -Nru apache_1.3.9/htdocs/manual/mod/mod_define.html apache_1.3.9.EAPI/htdocs/manual/mod/mod_define.html | |
369 | --- apache_1.3.9/htdocs/manual/mod/mod_define.html Thu Jan 1 01:00:00 1970 | |
370 | +++ apache_1.3.9.EAPI/htdocs/manual/mod/mod_define.html Wed Dec 29 21:25:55 1999 | |
371 | @@ -0,0 +1,135 @@ | |
372 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> | |
373 | +<!--%hypertext --> | |
374 | +<!-- mod_define.html --> | |
375 | +<!-- Documentation for the mod_define Apache module --> | |
376 | +<HTML> | |
377 | +<HEAD> | |
378 | +<TITLE>Apache module mod_define</TITLE> | |
379 | +</HEAD> | |
380 | + | |
381 | +<!-- Background white, links blue (unvisited), navy (visited), red (active) --> | |
382 | +<BODY | |
383 | + BGCOLOR="#FFFFFF" | |
384 | + TEXT="#000000" | |
385 | + LINK="#0000FF" | |
386 | + VLINK="#000080" | |
387 | + ALINK="#FF0000" | |
388 | +> | |
389 | +<BLOCKQUOTE><!-- page indentation --> | |
390 | +<!--#include virtual="header.html" --> | |
391 | + | |
392 | +<BR> | |
393 | +<H1 ALIGN="CENTER">Module mod_define</H1> | |
394 | +<H2 ALIGN="CENTER">Variable Definition For Arbitrary Directives</H2> | |
395 | + | |
396 | +This module is contained in the <CODE>mod_define.c</CODE> file. It provides | |
397 | +the definition variables for arbitrary directives, i.e. variables which can be | |
398 | +expanded on any(!) directive line. It needs Extended API (EAPI). It is not | |
399 | +compiled into the server by default. To use <CODE>mod_define</CODE> you have | |
400 | +to enable the following line in the server build <CODE>Configuration</CODE> | |
401 | +file: | |
402 | + | |
403 | +<P> | |
404 | +<PRE> | |
405 | + AddModule modules/extra/mod_define.o | |
406 | +</PRE> | |
407 | + | |
408 | +<P> | |
409 | +<HR NOSHADE SIZE=1> | |
410 | + | |
411 | +<H3><A NAME="Define">Define</A></H3> | |
412 | +<A | |
413 | + HREF="directive-dict.html#Syntax" | |
414 | + REL="Help" | |
415 | +><STRONG>Syntax:</STRONG></A> | |
416 | + <CODE>Define</CODE> <EM>variable</EM> <EM>value</EM><BR> | |
417 | +<A | |
418 | + HREF="directive-dict.html#Default" | |
419 | + REL="Help" | |
420 | +><STRONG>Default:</STRONG></A> | |
421 | + <EM>none</EM><BR> | |
422 | +<A | |
423 | + HREF="directive-dict.html#Context" | |
424 | + REL="Help" | |
425 | +><STRONG>Context:</STRONG></A> | |
426 | + server config, virtual host, directory, .htaccess<BR> | |
427 | +<A | |
428 | + HREF="directive-dict.html#Override" | |
429 | + REL="Help" | |
430 | +><STRONG>Override:</STRONG></A> none<BR> | |
431 | +<A | |
432 | + HREF="directive-dict.html#Status" | |
433 | + REL="Help" | |
434 | +><STRONG>Status:</STRONG></A> Extension<BR> | |
435 | +<A | |
436 | + HREF="directive-dict.html#Module" | |
437 | + REL="Help" | |
438 | +><STRONG>Module:</STRONG></A> mod_define.c<BR> | |
439 | +<A | |
440 | + HREF="directive-dict.html#Compatibility" | |
441 | + REL="Help" | |
442 | +><STRONG>Compatibility:</STRONG></A> Apache+EAPI<BR> | |
443 | + | |
444 | +<P> | |
445 | +The <CODE>Define</CODE> directive defines a variable which later can be | |
446 | +expanded with the unsafe but short construct | |
447 | +``<CODE>$</CODE><EM>variable</EM>'' or the safe but longer construct | |
448 | +``<CODE>${</CODE><EM>variable</EM><CODE>}</CODE>'' on any configuration line. | |
449 | +Do not intermix this with the third-party module <CODE>mod_macro</CODE>. The | |
450 | +<CODE>mod_define</CODE> module doesn't provide a general macro mechanism, | |
451 | +although one can consider variable substitutions as a special form of macros. | |
452 | +Because the value of to which ``<CODE>$</CODE><EM>variable</EM>'' expands has | |
453 | +to fit into one line. When you need macros which can span more lines, you've | |
454 | +to use <CODE>mod_macro</CODE>. OTOH <CODE>mod_macro</CODE> cannot be used to | |
455 | +expand a variable/macro on an arbitrary directive line. So, the typical use | |
456 | +case of <CODE>mod_define</CODE> is to make strings <EM>variable</EM> (and this | |
457 | +way easily changeable at one location) and not to <EM>bundle</EM> things | |
458 | +together (as it's the typical use case for macros). | |
459 | + | |
460 | +<P> | |
461 | +The syntax of the expansion construct ( | |
462 | +``<CODE>${</CODE><EM>variable</EM><CODE>}</CODE>'') follows the Perl and Shell | |
463 | +syntax, but can be changed via the <CODE>Define</CODE> directive, too. Four | |
464 | +internal variables can be used for this. The default is: | |
465 | + | |
466 | +<BLOCKQUOTE> | |
467 | +<PRE> | |
468 | +Define mod_define::escape "\\" | |
469 | +Define mod_define::dollar "$" | |
470 | +Define mod_define::open "{" | |
471 | +Define mod_define::close "}" | |
472 | +</PRE> | |
473 | +</BLOCKQUOTE> | |
474 | + | |
475 | +<P> | |
476 | +When you need to escape some of the expansion constructs you place the | |
477 | +mod_define::escape character in front of it. The default is the backslash as | |
478 | +in Perl or the Shell. | |
479 | + | |
480 | +<P> | |
481 | +<STRONG>Example:</STRONG> | |
482 | +<BLOCKQUOTE> | |
483 | +<PRE> | |
484 | +Define master "Joe Average <joe@average.dom>" | |
485 | +Define docroot /usr/local/apache/htdocs | |
486 | +Define hostname foo | |
487 | +Define domainname bar.dom | |
488 | +Define portnumber 80 | |
489 | + : | |
490 | +<VirtualHost $hostname.$domainname:$portnumber> | |
491 | +SetEnv SERVER_MASTER "$master" | |
492 | +ServerName $hostname.$domainname | |
493 | +ServerAlias $hostname | |
494 | +Port $portnumber | |
495 | +DocumentRoot $docroot | |
496 | +<Directory $docroot> | |
497 | + : | |
498 | +<Directory> | |
499 | +</PRE> | |
500 | +</BLOCKQUOTE> | |
501 | + | |
502 | +<!--#include virtual="footer.html" --> | |
503 | +</BLOCKQUOTE><!-- page indentation --> | |
504 | +</BODY> | |
505 | +</HTML> | |
506 | +<!--/%hypertext --> | |
507 | diff -Nru apache_1.3.9/src/ApacheCore.def apache_1.3.9.EAPI/src/ApacheCore.def | |
508 | --- apache_1.3.9/src/ApacheCore.def Wed Dec 29 22:03:42 1999 | |
509 | +++ apache_1.3.9.EAPI/src/ApacheCore.def Wed Dec 29 21:25:55 1999 | |
510 | @@ -359,4 +359,17 @@ | |
511 | ap_SHA1Update @354 | |
512 | ap_SHA1Final @355 | |
513 | ap_sha1_base64 @356 | |
514 | + ap_add_config_define @357 | |
515 | + ap_global_ctx @358 | |
516 | + ap_ctx_new @359 | |
517 | + ap_ctx_get @360 | |
518 | + ap_ctx_set @361 | |
519 | + ap_hook_init @362 | |
520 | + ap_hook_kill @363 | |
521 | + ap_hook_configure @364 | |
522 | + ap_hook_register_I @365 | |
523 | + ap_hook_unregister_I @366 | |
524 | + ap_hook_status @367 | |
525 | + ap_hook_use @368 | |
526 | + ap_hook_call @369 | |
527 | ||
528 | diff -Nru apache_1.3.9/src/Configuration.tmpl apache_1.3.9.EAPI/src/Configuration.tmpl | |
529 | --- apache_1.3.9/src/Configuration.tmpl Wed Dec 29 22:03:42 1999 | |
530 | +++ apache_1.3.9.EAPI/src/Configuration.tmpl Wed Dec 29 21:27:21 1999 | |
531 | @@ -68,6 +68,24 @@ | |
532 | #TARGET= | |
533 | ||
534 | ################################################################ | |
535 | +# Extended API (EAPI) support: | |
536 | +# | |
537 | +# EAPI: | |
538 | +# The EAPI rule enables more module hooks, a generic low-level hook | |
539 | +# mechanism, a generic context mechanism and shared memory based pools. | |
540 | +# | |
541 | +# EAPI_MM: | |
542 | +# Set the EAPI_MM variable to either the directory of a MM Shared Memory | |
543 | +# Library source tree or the installation tree of MM. Alternatively you can | |
544 | +# also use the value 'SYSTEM' which then indicates that MM is installed | |
545 | +# under various system locations. When the MM library files cannot be found | |
546 | +# the EAPI still can be built, but without shared memory pool support, of | |
547 | +# course. | |
548 | + | |
549 | +Rule EAPI=no | |
550 | +EAPI_MM=SYSTEM | |
551 | + | |
552 | +################################################################ | |
553 | # Dynamic Shared Object (DSO) support | |
554 | # | |
555 | # There is experimental support for compiling the Apache core and | |
556 | @@ -246,6 +265,11 @@ | |
557 | ## it does not do per-request stuff. | |
558 | ||
559 | AddModule modules/standard/mod_env.o | |
560 | + | |
561 | +## mod_define expands variables on arbitrary directive lines. | |
562 | +## It requires Extended API (EAPI). | |
563 | + | |
564 | +# AddModule modules/extra/mod_define.o | |
565 | ||
566 | ## | |
567 | ## Request logging modules | |
568 | diff -Nru apache_1.3.9/src/Configure apache_1.3.9.EAPI/src/Configure | |
569 | --- apache_1.3.9/src/Configure Wed Dec 29 22:03:42 1999 | |
570 | +++ apache_1.3.9.EAPI/src/Configure Wed Dec 29 21:42:17 1999 | |
571 | @@ -1725,6 +1732,72 @@ | |
572 | SUBDIRS="regex $SUBDIRS" | |
573 | CFLAGS="$CFLAGS -DUSE_HSREGEX" | |
574 | fi | |
575 | + | |
576 | +#################################################################### | |
577 | +## Extended API (EAPI) support: | |
578 | +## | |
579 | +if [ "x$RULE_EAPI" = "x" ]; then | |
580 | + RULE_EAPI=`./helpers/CutRule EAPI $file` | |
581 | +fi | |
582 | +if [ "x$RULE_EAPI" = "xyes" ]; then | |
583 | + echo " + enabling Extended API (EAPI)" | |
584 | + CFLAGS="$CFLAGS -DEAPI" | |
585 | + # some vendor compilers are too restrictive | |
586 | + # for our ap_hook and ap_ctx sources. | |
587 | + case "$OS:$CC" in | |
588 | + *IRIX-32*:*/cc|*IRIX-32*:cc ) | |
589 | + CFLAGS="$CFLAGS -woff 1048,1110,1164" | |
590 | + ;; | |
591 | + esac | |
592 | + # MM Shared Memory Library support for EAPI | |
593 | + if [ "x$EAPI_MM" = "x" ]; then | |
594 | + EAPI_MM=`egrep '^EAPI_MM=' $file | tail -1 | awk -F= '{print $2}'` | |
595 | + fi | |
596 | + if [ "x$EAPI_MM" != "x" ]; then | |
597 | + case $EAPI_MM in | |
598 | + SYSTEM|/* ) ;; | |
599 | + * ) for p in . .. ../..; do | |
600 | + if [ -d "$p/$EAPI_MM" ]; then | |
601 | + EAPI_MM="`echo $p/$EAPI_MM | sed -e 's;/\./;/;g'`" | |
602 | + break | |
603 | + fi | |
604 | + done | |
605 | + ;; | |
606 | + esac | |
607 | + if [ "x$EAPI_MM" = "xSYSTEM" ]; then | |
608 | + echo " using MM library for EAPI: (system-wide)" | |
609 | + CFLAGS="$CFLAGS -DEAPI_MM" | |
610 | + __INCLUDES="`mm-config --cflags`" | |
611 | + if [ "x$__INCLUDES" != "x-I/usr/include" ]; then | |
612 | + INCLUDES="$INCLUDES $__INCLUDES" | |
613 | + fi | |
614 | + LDFLAGS="$LDFLAGS `mm-config --ldflags`" | |
615 | + LIBS="$LIBS `mm-config --libs`" | |
616 | + else | |
617 | + if [ -f "$EAPI_MM/.libs/libmm.a" -a -f "$EAPI_MM/mm.h" ]; then | |
618 | + echo " using MM library: $EAPI_MM (source-tree only)" | |
619 | + case $EAPI_MM in | |
620 | + /* ) ;; | |
621 | + * ) EAPI_MM="\$(SRCDIR)/$EAPI_MM" ;; | |
622 | + esac | |
623 | + CFLAGS="$CFLAGS -DEAPI_MM" | |
624 | + INCLUDES="$INCLUDES -I$EAPI_MM" | |
625 | + LDFLAGS="$LDFLAGS -L$EAPI_MM/.libs" | |
626 | + LIBS="$LIBS -lmm" | |
627 | + elif [ -f "$EAPI_MM/bin/mm-config" ]; then | |
628 | + echo " using MM library: $EAPI_MM (installed)" | |
629 | + CFLAGS="$CFLAGS -DEAPI_MM" | |
630 | + INCLUDES="$INCLUDES `$EAPI_MM/bin/mm-config --cflags`" | |
631 | + LDFLAGS="$LDFLAGS `$EAPI_MM/bin/mm-config --ldflags`" | |
632 | + LIBS="$LIBS `$EAPI_MM/bin/mm-config --libs`" | |
633 | + else | |
634 | + echo "Configure:Error: Cannot find MM library under $EAPI_MM" 1>&2 | |
635 | + exit 1 | |
636 | + fi | |
637 | + fi | |
638 | + fi | |
639 | +fi | |
640 | + | |
641 | ||
642 | #################################################################### | |
643 | ## Add in the Expat library if needed/wanted. | |
644 | diff -Nru apache_1.3.9/src/ap/Makefile.tmpl apache_1.3.9.EAPI/src/ap/Makefile.tmpl | |
645 | --- apache_1.3.9/src/ap/Makefile.tmpl Wed Dec 29 22:03:42 1999 | |
646 | +++ apache_1.3.9.EAPI/src/ap/Makefile.tmpl Wed Dec 29 21:25:56 1999 | |
647 | @@ -6,7 +6,8 @@ | |
648 | LIB=libap.a | |
649 | ||
650 | OBJS=ap_cpystrn.o ap_execve.o ap_fnmatch.o ap_getpass.o ap_md5c.o ap_signal.o \ | |
651 | - ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o | |
652 | + ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o \ | |
653 | + ap_hook.o ap_ctx.o ap_mm.o | |
654 | ||
655 | .c.o: | |
656 | $(CC) -c $(INCLUDES) $(CFLAGS) $< | |
657 | diff -Nru apache_1.3.9/src/ap/ap.mak apache_1.3.9.EAPI/src/ap/ap.mak | |
658 | --- apache_1.3.9/src/ap/ap.mak Wed Dec 29 22:03:42 1999 | |
659 | +++ apache_1.3.9.EAPI/src/ap/ap.mak Wed Dec 29 21:25:56 1999 | |
660 | @@ -47,6 +47,9 @@ | |
661 | -@erase "$(INTDIR)\ap_cpystrn.obj" | |
662 | -@erase "$(INTDIR)\ap_fnmatch.obj" | |
663 | -@erase "$(INTDIR)\ap_md5c.obj" | |
664 | + -@erase "$(INTDIR)\ap_hook.obj" | |
665 | + -@erase "$(INTDIR)\ap_ctx.obj" | |
666 | + -@erase "$(INTDIR)\ap_mm.obj" | |
667 | -@erase "$(INTDIR)\ap_signal.obj" | |
668 | -@erase "$(INTDIR)\ap_slack.obj" | |
669 | -@erase "$(INTDIR)\ap_snprintf.obj" | |
670 | @@ -105,6 +108,9 @@ | |
671 | "$(INTDIR)\ap_cpystrn.obj" \ | |
672 | "$(INTDIR)\ap_fnmatch.obj" \ | |
673 | "$(INTDIR)\ap_md5c.obj" \ | |
674 | + "$(INTDIR)\ap_hook.obj" \ | |
675 | + "$(INTDIR)\ap_ctx.obj" \ | |
676 | + "$(INTDIR)\ap_mm.obj" \ | |
677 | "$(INTDIR)\ap_signal.obj" \ | |
678 | "$(INTDIR)\ap_slack.obj" \ | |
679 | "$(INTDIR)\ap_snprintf.obj" \ | |
680 | @@ -139,6 +145,9 @@ | |
681 | -@erase "$(INTDIR)\ap_cpystrn.obj" | |
682 | -@erase "$(INTDIR)\ap_fnmatch.obj" | |
683 | -@erase "$(INTDIR)\ap_md5c.obj" | |
684 | + -@erase "$(INTDIR)\ap_hook.obj" | |
685 | + -@erase "$(INTDIR)\ap_ctx.obj" | |
686 | + -@erase "$(INTDIR)\ap_mm.obj" | |
687 | -@erase "$(INTDIR)\ap_signal.obj" | |
688 | -@erase "$(INTDIR)\ap_slack.obj" | |
689 | -@erase "$(INTDIR)\ap_snprintf.obj" | |
690 | @@ -197,6 +206,9 @@ | |
691 | "$(INTDIR)\ap_cpystrn.obj" \ | |
692 | "$(INTDIR)\ap_fnmatch.obj" \ | |
693 | "$(INTDIR)\ap_md5c.obj" \ | |
694 | + "$(INTDIR)\ap_hook.obj" \ | |
695 | + "$(INTDIR)\ap_ctx.obj" \ | |
696 | + "$(INTDIR)\ap_mm.obj" \ | |
697 | "$(INTDIR)\ap_signal.obj" \ | |
698 | "$(INTDIR)\ap_slack.obj" \ | |
699 | "$(INTDIR)\ap_snprintf.obj" \ | |
700 | diff -Nru apache_1.3.9/src/ap/ap_ctx.c apache_1.3.9.EAPI/src/ap/ap_ctx.c | |
701 | --- apache_1.3.9/src/ap/ap_ctx.c Thu Jan 1 01:00:00 1970 | |
702 | +++ apache_1.3.9.EAPI/src/ap/ap_ctx.c Wed Dec 29 21:25:56 1999 | |
703 | @@ -0,0 +1,155 @@ | |
704 | +/* ==================================================================== | |
705 | + * Copyright (c) 1998 The Apache Group. All rights reserved. | |
706 | + * | |
707 | + * Redistribution and use in source and binary forms, with or without | |
708 | + * modification, are permitted provided that the following conditions | |
709 | + * are met: | |
710 | + * | |
711 | + * 1. Redistributions of source code must retain the above copyright | |
712 | + * notice, this list of conditions and the following disclaimer. | |
713 | + * | |
714 | + * 2. Redistributions in binary form must reproduce the above copyright | |
715 | + * notice, this list of conditions and the following disclaimer in | |
716 | + * the documentation and/or other materials provided with the | |
717 | + * distribution. | |
718 | + * | |
719 | + * 3. All advertising materials mentioning features or use of this | |
720 | + * software must display the following acknowledgment: | |
721 | + * "This product includes software developed by the Apache Group | |
722 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
723 | + * | |
724 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
725 | + * endorse or promote products derived from this software without | |
726 | + * prior written permission. For written permission, please contact | |
727 | + * apache@apache.org. | |
728 | + * | |
729 | + * 5. Products derived from this software may not be called "Apache" | |
730 | + * nor may "Apache" appear in their names without prior written | |
731 | + * permission of the Apache Group. | |
732 | + * | |
733 | + * 6. Redistributions of any form whatsoever must retain the following | |
734 | + * acknowledgment: | |
735 | + * "This product includes software developed by the Apache Group | |
736 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
737 | + * | |
738 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
739 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
740 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
741 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
742 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
743 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
744 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
745 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
746 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
747 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
748 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
749 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
750 | + * ==================================================================== | |
751 | + * | |
752 | + * This software consists of voluntary contributions made by many | |
753 | + * individuals on behalf of the Apache Group and was originally based | |
754 | + * on public domain software written at the National Center for | |
755 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
756 | + * For more information on the Apache Group and the Apache HTTP server | |
757 | + * project, please see <http://www.apache.org/>. | |
758 | + * | |
759 | + */ | |
760 | + | |
761 | +/* | |
762 | +** Generic Context Interface for Apache | |
763 | +** Written by Ralf S. Engelschall <rse@engelschall.com> | |
764 | +*/ | |
765 | + | |
766 | +#ifdef EAPI | |
767 | + | |
768 | +#include "httpd.h" | |
769 | +#include "ap_config.h" | |
770 | +#include "ap_ctx.h" | |
771 | + | |
772 | +API_EXPORT(ap_ctx *) ap_ctx_new(pool *p) | |
773 | +{ | |
774 | + ap_ctx *ctx; | |
775 | + int i; | |
776 | + | |
777 | + if (p != NULL) { | |
778 | + ctx = (ap_ctx *)ap_palloc(p, sizeof(ap_ctx_rec)); | |
779 | + ctx->cr_pool = p; | |
780 | + ctx->cr_entry = (ap_ctx_entry **) | |
781 | + ap_palloc(p, sizeof(ap_ctx_entry *)*(AP_CTX_MAX_ENTRIES+1)); | |
782 | + } | |
783 | + else { | |
784 | + ctx = (ap_ctx *)malloc(sizeof(ap_ctx_rec)); | |
785 | + ctx->cr_pool = NULL; | |
786 | + ctx->cr_entry = (ap_ctx_entry **) | |
787 | + malloc(sizeof(ap_ctx_entry *)*(AP_CTX_MAX_ENTRIES+1)); | |
788 | + } | |
789 | + for (i = 0; i < AP_CTX_MAX_ENTRIES+1; i++) | |
790 | + ctx->cr_entry[i] = NULL; | |
791 | + return ctx; | |
792 | +} | |
793 | + | |
794 | +API_EXPORT(void) ap_ctx_set(ap_ctx *ctx, char *key, void *val) | |
795 | +{ | |
796 | + int i; | |
797 | + ap_ctx_entry *ce; | |
798 | + | |
799 | + ce = NULL; | |
800 | + for (i = 0; ctx->cr_entry[i] != NULL; i++) { | |
801 | + if (strcmp(ctx->cr_entry[i]->ce_key, key) == 0) { | |
802 | + ce = ctx->cr_entry[i]; | |
803 | + break; | |
804 | + } | |
805 | + } | |
806 | + if (ce == NULL) { | |
807 | + if (i == AP_CTX_MAX_ENTRIES) | |
808 | + return; | |
809 | + if (ctx->cr_pool != NULL) { | |
810 | + ce = (ap_ctx_entry *)ap_palloc(ctx->cr_pool, sizeof(ap_ctx_entry)); | |
811 | + ce->ce_key = ap_pstrdup(ctx->cr_pool, key); | |
812 | + } | |
813 | + else { | |
814 | + ce = (ap_ctx_entry *)malloc(sizeof(ap_ctx_entry)); | |
815 | + ce->ce_key = strdup(key); | |
816 | + } | |
817 | + ctx->cr_entry[i] = ce; | |
818 | + ctx->cr_entry[i+1] = NULL; | |
819 | + } | |
820 | + ce->ce_val = val; | |
821 | + return; | |
822 | +} | |
823 | + | |
824 | +API_EXPORT(void *) ap_ctx_get(ap_ctx *ctx, char *key) | |
825 | +{ | |
826 | + int i; | |
827 | + | |
828 | + for (i = 0; ctx->cr_entry[i] != NULL; i++) | |
829 | + if (strcmp(ctx->cr_entry[i]->ce_key, key) == 0) | |
830 | + return ctx->cr_entry[i]->ce_val; | |
831 | + return NULL; | |
832 | +} | |
833 | + | |
834 | +API_EXPORT(ap_ctx *) ap_ctx_overlay(pool *p, ap_ctx *over, ap_ctx *base) | |
835 | +{ | |
836 | + ap_ctx *new; | |
837 | + int i; | |
838 | + | |
839 | +#ifdef POOL_DEBUG | |
840 | + if (p != NULL) { | |
841 | + if (!ap_pool_is_ancestor(over->cr_pool, p)) | |
842 | + ap_log_assert("ap_ctx_overlay: overlay's pool is not an ancestor of p", | |
843 | + __FILE__, __LINE__); | |
844 | + if (!ap_pool_is_ancestor(base->cr_pool, p)) | |
845 | + ap_log_assert("ap_ctx_overlay: base's pool is not an ancestor of p", | |
846 | + __FILE__, __LINE__); | |
847 | + } | |
848 | +#endif | |
849 | + if ((new = ap_ctx_new(p)) == NULL) | |
850 | + return NULL; | |
851 | + memcpy(new->cr_entry, base->cr_entry, | |
852 | + sizeof(ap_ctx_entry *)*(AP_CTX_MAX_ENTRIES+1)); | |
853 | + for (i = 0; over->cr_entry[i] != NULL; i++) | |
854 | + ap_ctx_set(new, over->cr_entry[i]->ce_key, over->cr_entry[i]->ce_val); | |
855 | + return new; | |
856 | +} | |
857 | + | |
858 | +#endif /* EAPI */ | |
859 | diff -Nru apache_1.3.9/src/ap/ap_hook.c apache_1.3.9.EAPI/src/ap/ap_hook.c | |
860 | --- apache_1.3.9/src/ap/ap_hook.c Thu Jan 1 01:00:00 1970 | |
861 | +++ apache_1.3.9.EAPI/src/ap/ap_hook.c Wed Dec 29 21:25:56 1999 | |
862 | @@ -0,0 +1,930 @@ | |
863 | +#if 0 | |
864 | +=pod | |
865 | +#endif | |
866 | +/* ==================================================================== | |
867 | + * Copyright (c) 1998 The Apache Group. All rights reserved. | |
868 | + * | |
869 | + * Redistribution and use in source and binary forms, with or without | |
870 | + * modification, are permitted provided that the following conditions | |
871 | + * are met: | |
872 | + * | |
873 | + * 1. Redistributions of source code must retain the above copyright | |
874 | + * notice, this list of conditions and the following disclaimer. | |
875 | + * | |
876 | + * 2. Redistributions in binary form must reproduce the above copyright | |
877 | + * notice, this list of conditions and the following disclaimer in | |
878 | + * the documentation and/or other materials provided with the | |
879 | + * distribution. | |
880 | + * | |
881 | + * 3. All advertising materials mentioning features or use of this | |
882 | + * software must display the following acknowledgment: | |
883 | + * "This product includes software developed by the Apache Group | |
884 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
885 | + * | |
886 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
887 | + * endorse or promote products derived from this software without | |
888 | + * prior written permission. For written permission, please contact | |
889 | + * apache@apache.org. | |
890 | + * | |
891 | + * 5. Products derived from this software may not be called "Apache" | |
892 | + * nor may "Apache" appear in their names without prior written | |
893 | + * permission of the Apache Group. | |
894 | + * | |
895 | + * 6. Redistributions of any form whatsoever must retain the following | |
896 | + * acknowledgment: | |
897 | + * "This product includes software developed by the Apache Group | |
898 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
899 | + * | |
900 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
901 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
902 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
903 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
904 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
905 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
906 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
907 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
908 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
909 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
910 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
911 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
912 | + * ==================================================================== | |
913 | + * | |
914 | + * This software consists of voluntary contributions made by many | |
915 | + * individuals on behalf of the Apache Group and was originally based | |
916 | + * on public domain software written at the National Center for | |
917 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
918 | + * For more information on the Apache Group and the Apache HTTP server | |
919 | + * project, please see <http://www.apache.org/>. | |
920 | + * | |
921 | + */ | |
922 | + | |
923 | +/* | |
924 | +** Implementation of a Generic Hook Interface for Apache | |
925 | +** Written by Ralf S. Engelschall <rse@engelschall.com> | |
926 | +** | |
927 | +** See POD document at end of ap_hook.h for description. | |
928 | +** View it with the command ``pod2man ap_hook.h | nroff -man | more'' | |
929 | +** | |
930 | +** Attention: This source file is a little bit tricky. | |
931 | +** It's a combination of a C source and an embedded Perl script | |
932 | +** (which updates the C source). The purpose of this is to have | |
933 | +** both things together at one place. So you can both pass | |
934 | +** this file to the C compiler and the Perl interpreter. | |
935 | +*/ | |
936 | + | |
937 | + /* | |
938 | + * Premature optimization is | |
939 | + * the root of all evil. | |
940 | + * -- D. E. Knuth | |
941 | + */ | |
942 | + | |
943 | +#ifdef EAPI | |
944 | + | |
945 | +#include "httpd.h" | |
946 | +#include "http_log.h" | |
947 | +#include "ap_config.h" | |
948 | +#include "ap_hook.h" | |
949 | + | |
950 | +/* | |
951 | + * the internal hook pool | |
952 | + */ | |
953 | +static ap_hook_entry **ap_hook_pool = NULL; | |
954 | + | |
955 | +/* | |
956 | + * forward prototypes for internal functions | |
957 | + */ | |
958 | +static int ap_hook_call_func(va_list ap, ap_hook_entry *he, ap_hook_func *hf); | |
959 | +static ap_hook_entry *ap_hook_create(char *hook); | |
960 | +static ap_hook_entry *ap_hook_find(char *hook); | |
961 | +static void ap_hook_destroy(ap_hook_entry *he); | |
962 | + | |
963 | +/* | |
964 | + * Initialize the hook mechanism | |
965 | + */ | |
966 | +API_EXPORT(void) ap_hook_init(void) | |
967 | +{ | |
968 | + int i; | |
969 | + | |
970 | + if (ap_hook_pool != NULL) | |
971 | + return; | |
972 | + ap_hook_pool = (ap_hook_entry **)malloc(sizeof(ap_hook_entry *) | |
973 | + *(AP_HOOK_MAX_ENTRIES+1)); | |
974 | + for (i = 0; i < AP_HOOK_MAX_ENTRIES; i++) | |
975 | + ap_hook_pool[i] = NULL; | |
976 | + return; | |
977 | +} | |
978 | + | |
979 | +/* | |
980 | + * Kill the hook mechanism | |
981 | + */ | |
982 | +API_EXPORT(void) ap_hook_kill(void) | |
983 | +{ | |
984 | + int i; | |
985 | + | |
986 | + if (ap_hook_pool == NULL) | |
987 | + return; | |
988 | + for (i = 0; ap_hook_pool[i] != NULL; i++) | |
989 | + ap_hook_destroy(ap_hook_pool[i]); | |
990 | + free(ap_hook_pool); | |
991 | + ap_hook_pool = NULL; | |
992 | + return; | |
993 | +} | |
994 | + | |
995 | +/* | |
996 | + * Smart creation of a hook (when it exist this is the same as | |
997 | + * ap_hook_find, when it doesn't exists it is created) | |
998 | + */ | |
999 | +static ap_hook_entry *ap_hook_create(char *hook) | |
1000 | +{ | |
1001 | + int i; | |
1002 | + ap_hook_entry *he; | |
1003 | + | |
1004 | + for (i = 0; ap_hook_pool[i] != NULL; i++) | |
1005 | + if (strcmp(ap_hook_pool[i]->he_hook, hook) == 0) | |
1006 | + return ap_hook_pool[i]; | |
1007 | + | |
1008 | + if (i >= AP_HOOK_MAX_ENTRIES) | |
1009 | + return NULL; | |
1010 | + | |
1011 | + if ((he = (ap_hook_entry *)malloc(sizeof(ap_hook_entry))) == NULL) | |
1012 | + return NULL; | |
1013 | + ap_hook_pool[i] = he; | |
1014 | + | |
1015 | + he->he_hook = strdup(hook); | |
1016 | + he->he_sig = AP_HOOK_SIG_UNKNOWN; | |
1017 | + he->he_modeid = AP_HOOK_MODE_UNKNOWN; | |
1018 | + he->he_modeval.v_int = 0; | |
1019 | + | |
1020 | + he->he_func = (ap_hook_func **)malloc(sizeof(ap_hook_func *) | |
1021 | + *(AP_HOOK_MAX_FUNCS+1)); | |
1022 | + if (he->he_func == NULL) | |
1023 | + return FALSE; | |
1024 | + | |
1025 | + for (i = 0; i < AP_HOOK_MAX_FUNCS; i++) | |
1026 | + he->he_func[i] = NULL; | |
1027 | + return he; | |
1028 | +} | |
1029 | + | |
1030 | +/* | |
1031 | + * Find a particular hook | |
1032 | + */ | |
1033 | +static ap_hook_entry *ap_hook_find(char *hook) | |
1034 | +{ | |
1035 | + int i; | |
1036 | + | |
1037 | + for (i = 0; ap_hook_pool[i] != NULL; i++) | |
1038 | + if (strcmp(ap_hook_pool[i]->he_hook, hook) == 0) | |
1039 | + return ap_hook_pool[i]; | |
1040 | + return NULL; | |
1041 | +} | |
1042 | + | |
1043 | +/* | |
1044 | + * Destroy a particular hook | |
1045 | + */ | |
1046 | +static void ap_hook_destroy(ap_hook_entry *he) | |
1047 | +{ | |
1048 | + int i; | |
1049 | + | |
1050 | + if (he == NULL) | |
1051 | + return; | |
1052 | + free(he->he_hook); | |
1053 | + for (i = 0; he->he_func[i] != NULL; i++) | |
1054 | + free(he->he_func[i]); | |
1055 | + free(he->he_func); | |
1056 | + free(he); | |
1057 | + return; | |
1058 | +} | |
1059 | + | |
1060 | +/* | |
1061 | + * Configure a particular hook, | |
1062 | + * i.e. remember its signature and return value mode | |
1063 | + */ | |
1064 | +API_EXPORT(int) ap_hook_configure(char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...) | |
1065 | +{ | |
1066 | + ap_hook_entry *he; | |
1067 | + va_list ap; | |
1068 | + int rc; | |
1069 | + | |
1070 | + va_start(ap, modeid); | |
1071 | + if ((he = ap_hook_create(hook)) == NULL) | |
1072 | + rc = FALSE; | |
1073 | + else { | |
1074 | + he->he_sig = sig; | |
1075 | + he->he_modeid = modeid; | |
1076 | + if (modeid == AP_HOOK_MODE_DECLINE || modeid == AP_HOOK_MODE_DECLTMP) { | |
1077 | + if (AP_HOOK_SIG_HAS(sig, RC, char)) | |
1078 | + he->he_modeval.v_char = va_arg(ap, va_type(char)); | |
1079 | + else if (AP_HOOK_SIG_HAS(sig, RC, int)) | |
1080 | + he->he_modeval.v_int = va_arg(ap, va_type(int)); | |
1081 | + else if (AP_HOOK_SIG_HAS(sig, RC, long)) | |
1082 | + he->he_modeval.v_long = va_arg(ap, va_type(long)); | |
1083 | + else if (AP_HOOK_SIG_HAS(sig, RC, float)) | |
1084 | + he->he_modeval.v_float = va_arg(ap, va_type(float)); | |
1085 | + else if (AP_HOOK_SIG_HAS(sig, RC, double)) | |
1086 | + he->he_modeval.v_double = va_arg(ap, va_type(double)); | |
1087 | + else if (AP_HOOK_SIG_HAS(sig, RC, ptr)) | |
1088 | + he->he_modeval.v_ptr = va_arg(ap, va_type(ptr)); | |
1089 | + } | |
1090 | + rc = TRUE; | |
1091 | + } | |
1092 | + va_end(ap); | |
1093 | + return rc; | |
1094 | +} | |
1095 | + | |
1096 | +/* | |
1097 | + * Register a function to call for a hook | |
1098 | + */ | |
1099 | +API_EXPORT(int) ap_hook_register_I(char *hook, void *func, void *ctx) | |
1100 | +{ | |
1101 | + int i, j; | |
1102 | + ap_hook_entry *he; | |
1103 | + ap_hook_func *hf; | |
1104 | + | |
1105 | + if ((he = ap_hook_create(hook)) == NULL) | |
1106 | + return FALSE; | |
1107 | + | |
1108 | + for (i = 0; he->he_func[i] != NULL; i++) | |
1109 | + if (he->he_func[i]->hf_ptr == func) | |
1110 | + return FALSE; | |
1111 | + | |
1112 | + if (i == AP_HOOK_MAX_FUNCS) | |
1113 | + return FALSE; | |
1114 | + | |
1115 | + if ((hf = (ap_hook_func *)malloc(sizeof(ap_hook_func))) == NULL) | |
1116 | + return FALSE; | |
1117 | + | |
1118 | + for (j = i; j >= 0; j--) | |
1119 | + he->he_func[j+1] = he->he_func[j]; | |
1120 | + he->he_func[0] = hf; | |
1121 | + | |
1122 | + hf->hf_ptr = func; | |
1123 | + hf->hf_ctx = ctx; | |
1124 | + | |
1125 | + return TRUE; | |
1126 | +} | |
1127 | + | |
1128 | +/* | |
1129 | + * Unregister a function to call for a hook | |
1130 | + */ | |
1131 | +API_EXPORT(int) ap_hook_unregister_I(char *hook, void *func) | |
1132 | +{ | |
1133 | + int i, j; | |
1134 | + ap_hook_entry *he; | |
1135 | + | |
1136 | + if ((he = ap_hook_find(hook)) == NULL) | |
1137 | + return FALSE; | |
1138 | + for (i = 0; he->he_func[i] != NULL; i++) { | |
1139 | + if (he->he_func[i]->hf_ptr == func) { | |
1140 | + free(he->he_func[i]); | |
1141 | + for (j = i; he->he_func[j] != NULL; j++) | |
1142 | + he->he_func[j] = he->he_func[j+1]; | |
1143 | + return TRUE; | |
1144 | + } | |
1145 | + } | |
1146 | + return FALSE; | |
1147 | +} | |
1148 | + | |
1149 | +/* | |
1150 | + * Retrieve the status of a particular hook | |
1151 | + */ | |
1152 | +API_EXPORT(ap_hook_state) ap_hook_status(char *hook) | |
1153 | +{ | |
1154 | + ap_hook_entry *he; | |
1155 | + | |
1156 | + if ((he = ap_hook_find(hook)) == NULL) | |
1157 | + return AP_HOOK_STATE_NOTEXISTANT; | |
1158 | + if ( he->he_func[0] != NULL | |
1159 | + && he->he_sig != AP_HOOK_SIG_UNKNOWN | |
1160 | + && he->he_modeid != AP_HOOK_MODE_UNKNOWN) | |
1161 | + return AP_HOOK_STATE_REGISTERED; | |
1162 | + if ( he->he_sig != AP_HOOK_SIG_UNKNOWN | |
1163 | + && he->he_modeid != AP_HOOK_MODE_UNKNOWN) | |
1164 | + return AP_HOOK_STATE_CONFIGURED; | |
1165 | + return AP_HOOK_STATE_ESTABLISHED; | |
1166 | +} | |
1167 | + | |
1168 | +/* | |
1169 | + * Use a hook, i.e. optional on-the-fly configure it before calling it | |
1170 | + */ | |
1171 | +API_EXPORT(int) ap_hook_use(char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...) | |
1172 | +{ | |
1173 | + int i; | |
1174 | + ap_hook_value modeval; | |
1175 | + ap_hook_entry *he; | |
1176 | + va_list ap; | |
1177 | + int rc; | |
1178 | + | |
1179 | + va_start(ap, modeid); | |
1180 | + | |
1181 | + if (modeid == AP_HOOK_MODE_DECLINE || modeid == AP_HOOK_MODE_DECLTMP) { | |
1182 | + if (AP_HOOK_SIG_HAS(sig, RC, char)) | |
1183 | + modeval.v_char = va_arg(ap, va_type(char)); | |
1184 | + else if (AP_HOOK_SIG_HAS(sig, RC, int)) | |
1185 | + modeval.v_int = va_arg(ap, va_type(int)); | |
1186 | + else if (AP_HOOK_SIG_HAS(sig, RC, long)) | |
1187 | + modeval.v_long = va_arg(ap, va_type(long)); | |
1188 | + else if (AP_HOOK_SIG_HAS(sig, RC, float)) | |
1189 | + modeval.v_float = va_arg(ap, va_type(float)); | |
1190 | + else if (AP_HOOK_SIG_HAS(sig, RC, double)) | |
1191 | + modeval.v_double = va_arg(ap, va_type(double)); | |
1192 | + else if (AP_HOOK_SIG_HAS(sig, RC, ptr)) | |
1193 | + modeval.v_ptr = va_arg(ap, va_type(ptr)); | |
1194 | + } | |
1195 | + | |
1196 | + if ((he = ap_hook_create(hook)) == NULL) | |
1197 | + return FALSE; | |
1198 | + | |
1199 | + if (he->he_sig == AP_HOOK_SIG_UNKNOWN) | |
1200 | + he->he_sig = sig; | |
1201 | + if (he->he_modeid == AP_HOOK_MODE_UNKNOWN) { | |
1202 | + he->he_modeid = modeid; | |
1203 | + he->he_modeval = modeval; | |
1204 | + } | |
1205 | + | |
1206 | + for (i = 0; he->he_func[i] != NULL; i++) | |
1207 | + if (ap_hook_call_func(ap, he, he->he_func[i])) | |
1208 | + break; | |
1209 | + | |
1210 | + if (i > 0 && he->he_modeid == AP_HOOK_MODE_ALL) | |
1211 | + rc = TRUE; | |
1212 | + else if (i == AP_HOOK_MAX_FUNCS || he->he_func[i] == NULL) | |
1213 | + rc = FALSE; | |
1214 | + else | |
1215 | + rc = TRUE; | |
1216 | + | |
1217 | + va_end(ap); | |
1218 | + return rc; | |
1219 | +} | |
1220 | + | |
1221 | +/* | |
1222 | + * Call a hook | |
1223 | + */ | |
1224 | +API_EXPORT(int) ap_hook_call(char *hook, ...) | |
1225 | +{ | |
1226 | + int i; | |
1227 | + ap_hook_entry *he; | |
1228 | + va_list ap; | |
1229 | + int rc; | |
1230 | + | |
1231 | + va_start(ap, hook); | |
1232 | + | |
1233 | + if ((he = ap_hook_find(hook)) == NULL) { | |
1234 | + va_end(ap); | |
1235 | + return FALSE; | |
1236 | + } | |
1237 | + if ( he->he_sig == AP_HOOK_SIG_UNKNOWN | |
1238 | + || he->he_modeid == AP_HOOK_MODE_UNKNOWN) { | |
1239 | + va_end(ap); | |
1240 | + return FALSE; | |
1241 | + } | |
1242 | + | |
1243 | + for (i = 0; he->he_func[i] != NULL; i++) | |
1244 | + if (ap_hook_call_func(ap, he, he->he_func[i])) | |
1245 | + break; | |
1246 | + | |
1247 | + if (i > 0 && he->he_modeid == AP_HOOK_MODE_ALL) | |
1248 | + rc = TRUE; | |
1249 | + else if (i == AP_HOOK_MAX_FUNCS || he->he_func[i] == NULL) | |
1250 | + rc = FALSE; | |
1251 | + else | |
1252 | + rc = TRUE; | |
1253 | + | |
1254 | + va_end(ap); | |
1255 | + return rc; | |
1256 | +} | |
1257 | + | |
1258 | +static int ap_hook_call_func(va_list ap, ap_hook_entry *he, ap_hook_func *hf) | |
1259 | +{ | |
1260 | + void *v_rc; | |
1261 | + ap_hook_value v_tmp; | |
1262 | + int rc; | |
1263 | + | |
1264 | + /* | |
1265 | + * Now we dispatch the various function calls. We support function | |
1266 | + * signatures with up to 9 types (1 return type, 8 argument types) where | |
1267 | + * each argument can have 7 different types (ctx, char, int, long, float, | |
1268 | + * double, ptr), so theoretically there are 9^7 (=4782969) combinations | |
1269 | + * possible. But because we don't need all of them, of course, we | |
1270 | + * implement only the following well chosen subset (duplicates are ok): | |
1271 | + * | |
1272 | + * 1. `The basic hook'. | |
1273 | + * | |
1274 | + * void func() | |
1275 | + * | |
1276 | + * 2. The standard set of signatures which form all combinations of | |
1277 | + * int&ptr based signatures for up to 3 arguments. We provide | |
1278 | + * them per default for module authors. | |
1279 | + * | |
1280 | + * int func() | |
1281 | + * ptr func() | |
1282 | + * int func(int) | |
1283 | + * int func(ptr) | |
1284 | + * ptr func(int) | |
1285 | + * ptr func(ptr) | |
1286 | + * int func(int,int) | |
1287 | + * int func(int,ptr) | |
1288 | + * int func(ptr,int) | |
1289 | + * int func(ptr,ptr) | |
1290 | + * ptr func(int,int) | |
1291 | + * ptr func(int,ptr) | |
1292 | + * ptr func(ptr,int) | |
1293 | + * ptr func(ptr,ptr) | |
1294 | + * int func(int,int,int) | |
1295 | + * int func(int,int,ptr) | |
1296 | + * int func(int,ptr,int) | |
1297 | + * int func(int,ptr,ptr) | |
1298 | + * int func(ptr,int,int) | |
1299 | + * int func(ptr,int,ptr) | |
1300 | + * int func(ptr,ptr,int) | |
1301 | + * int func(ptr,ptr,ptr) | |
1302 | + * ptr func(int,int,int) | |
1303 | + * ptr func(int,int,ptr) | |
1304 | + * ptr func(int,ptr,int) | |
1305 | + * ptr func(int,ptr,ptr) | |
1306 | + * ptr func(ptr,int,int) | |
1307 | + * ptr func(ptr,int,ptr) | |
1308 | + * ptr func(ptr,ptr,int) | |
1309 | + * ptr func(ptr,ptr,ptr) | |
1310 | + * | |
1311 | + * 3. Actually currently used hooks. | |
1312 | + * | |
1313 | + * int func(ptr) [2x] | |
1314 | + * int func(ptr,ptr) [2x] | |
1315 | + * int func(ptr,ptr,int) [5x] | |
1316 | + * int func(ptr,ptr,ptr,int) [1x] | |
1317 | + * int func(ptr,ptr,ptr,int,ptr) [1x] | |
1318 | + * int func(ptr,ptr,ptr,ptr,int) [1x] | |
1319 | + * int func(ptr,ptr,ptr,ptr,int,ptr) [1x] | |
1320 | + * ptr func(ptr,ptr) [3x] | |
1321 | + * ptr func(ptr,ptr,ptr,ptr,ptr) [1x] | |
1322 | + * void func(ptr) [2x] | |
1323 | + * void func(ptr,int,int) [1x] | |
1324 | + * void func(ptr,ptr) [5x] | |
1325 | + * void func(ptr,ptr,ptr) [3x] | |
1326 | + * void func(ptr,ptr,ptr,ptr) [2x] | |
1327 | + * | |
1328 | + * To simplify the programming task we generate the actual dispatch code | |
1329 | + * for these calls via the embedded Perl script at the end of this source | |
1330 | + * file. This script parses the above lines and generates the section | |
1331 | + * below. So, when you need more signature variants just add them to the | |
1332 | + * above list and run | |
1333 | + * | |
1334 | + * $ perl ap_hook.c | |
1335 | + * | |
1336 | + * This automatically updates the above code. | |
1337 | + */ | |
1338 | + | |
1339 | + rc = TRUE; | |
1340 | + v_rc = NULL; | |
1341 | + if (!AP_HOOK_SIG_HAS(he->he_sig, RC, void)) { | |
1342 | + if (he->he_modeid == AP_HOOK_MODE_DECLTMP) { | |
1343 | + /* the return variable is a temporary one */ | |
1344 | + if (AP_HOOK_SIG_HAS(he->he_sig, RC, char)) | |
1345 | + v_rc = &v_tmp.v_char; | |
1346 | + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, int)) | |
1347 | + v_rc = &v_tmp.v_int; | |
1348 | + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, long)) | |
1349 | + v_rc = &v_tmp.v_long; | |
1350 | + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, float)) | |
1351 | + v_rc = &v_tmp.v_float; | |
1352 | + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, double)) | |
1353 | + v_rc = &v_tmp.v_double; | |
1354 | + else if (AP_HOOK_SIG_HAS(he->he_sig, RC, ptr)) | |
1355 | + v_rc = &v_tmp.v_ptr; | |
1356 | + } | |
1357 | + else { | |
1358 | + /* the return variable is provided by caller */ | |
1359 | + v_rc = va_arg(ap, void *); | |
1360 | + } | |
1361 | + } | |
1362 | + | |
1363 | + /* ----BEGIN GENERATED SECTION-------- */ | |
1364 | + if (he->he_sig == AP_HOOK_SIG1(void)) { | |
1365 | + /* Call: void func() */ | |
1366 | + ((void(*)())(hf->hf_ptr))(); | |
1367 | + } | |
1368 | + else if (he->he_sig == AP_HOOK_SIG1(int)) { | |
1369 | + /* Call: int func() */ | |
1370 | + *((int *)v_rc) = ((int(*)())(hf->hf_ptr))(); | |
1371 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1372 | + } | |
1373 | + else if (he->he_sig == AP_HOOK_SIG1(ptr)) { | |
1374 | + /* Call: ptr func() */ | |
1375 | + *((void * *)v_rc) = ((void *(*)())(hf->hf_ptr))(); | |
1376 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1377 | + } | |
1378 | + else if (he->he_sig == AP_HOOK_SIG2(int, int)) { | |
1379 | + /* Call: int func(int) */ | |
1380 | + int v1 = va_arg(ap, va_type(int)); | |
1381 | + *((int *)v_rc) = ((int(*)(int))(hf->hf_ptr))(v1); | |
1382 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1383 | + } | |
1384 | + else if (he->he_sig == AP_HOOK_SIG2(int, ptr)) { | |
1385 | + /* Call: int func(ptr) */ | |
1386 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1387 | + *((int *)v_rc) = ((int(*)(void *))(hf->hf_ptr))(v1); | |
1388 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1389 | + } | |
1390 | + else if (he->he_sig == AP_HOOK_SIG2(ptr, int)) { | |
1391 | + /* Call: ptr func(int) */ | |
1392 | + int v1 = va_arg(ap, va_type(int)); | |
1393 | + *((void * *)v_rc) = ((void *(*)(int))(hf->hf_ptr))(v1); | |
1394 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1395 | + } | |
1396 | + else if (he->he_sig == AP_HOOK_SIG2(ptr, ptr)) { | |
1397 | + /* Call: ptr func(ptr) */ | |
1398 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1399 | + *((void * *)v_rc) = ((void *(*)(void *))(hf->hf_ptr))(v1); | |
1400 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1401 | + } | |
1402 | + else if (he->he_sig == AP_HOOK_SIG3(int, int, int)) { | |
1403 | + /* Call: int func(int,int) */ | |
1404 | + int v1 = va_arg(ap, va_type(int)); | |
1405 | + int v2 = va_arg(ap, va_type(int)); | |
1406 | + *((int *)v_rc) = ((int(*)(int, int))(hf->hf_ptr))(v1, v2); | |
1407 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1408 | + } | |
1409 | + else if (he->he_sig == AP_HOOK_SIG3(int, int, ptr)) { | |
1410 | + /* Call: int func(int,ptr) */ | |
1411 | + int v1 = va_arg(ap, va_type(int)); | |
1412 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1413 | + *((int *)v_rc) = ((int(*)(int, void *))(hf->hf_ptr))(v1, v2); | |
1414 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1415 | + } | |
1416 | + else if (he->he_sig == AP_HOOK_SIG3(int, ptr, int)) { | |
1417 | + /* Call: int func(ptr,int) */ | |
1418 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1419 | + int v2 = va_arg(ap, va_type(int)); | |
1420 | + *((int *)v_rc) = ((int(*)(void *, int))(hf->hf_ptr))(v1, v2); | |
1421 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1422 | + } | |
1423 | + else if (he->he_sig == AP_HOOK_SIG3(int, ptr, ptr)) { | |
1424 | + /* Call: int func(ptr,ptr) */ | |
1425 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1426 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1427 | + *((int *)v_rc) = ((int(*)(void *, void *))(hf->hf_ptr))(v1, v2); | |
1428 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1429 | + } | |
1430 | + else if (he->he_sig == AP_HOOK_SIG3(ptr, int, int)) { | |
1431 | + /* Call: ptr func(int,int) */ | |
1432 | + int v1 = va_arg(ap, va_type(int)); | |
1433 | + int v2 = va_arg(ap, va_type(int)); | |
1434 | + *((void * *)v_rc) = ((void *(*)(int, int))(hf->hf_ptr))(v1, v2); | |
1435 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1436 | + } | |
1437 | + else if (he->he_sig == AP_HOOK_SIG3(ptr, int, ptr)) { | |
1438 | + /* Call: ptr func(int,ptr) */ | |
1439 | + int v1 = va_arg(ap, va_type(int)); | |
1440 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1441 | + *((void * *)v_rc) = ((void *(*)(int, void *))(hf->hf_ptr))(v1, v2); | |
1442 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1443 | + } | |
1444 | + else if (he->he_sig == AP_HOOK_SIG3(ptr, ptr, int)) { | |
1445 | + /* Call: ptr func(ptr,int) */ | |
1446 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1447 | + int v2 = va_arg(ap, va_type(int)); | |
1448 | + *((void * *)v_rc) = ((void *(*)(void *, int))(hf->hf_ptr))(v1, v2); | |
1449 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1450 | + } | |
1451 | + else if (he->he_sig == AP_HOOK_SIG3(ptr, ptr, ptr)) { | |
1452 | + /* Call: ptr func(ptr,ptr) */ | |
1453 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1454 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1455 | + *((void * *)v_rc) = ((void *(*)(void *, void *))(hf->hf_ptr))(v1, v2); | |
1456 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1457 | + } | |
1458 | + else if (he->he_sig == AP_HOOK_SIG4(int, int, int, int)) { | |
1459 | + /* Call: int func(int,int,int) */ | |
1460 | + int v1 = va_arg(ap, va_type(int)); | |
1461 | + int v2 = va_arg(ap, va_type(int)); | |
1462 | + int v3 = va_arg(ap, va_type(int)); | |
1463 | + *((int *)v_rc) = ((int(*)(int, int, int))(hf->hf_ptr))(v1, v2, v3); | |
1464 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1465 | + } | |
1466 | + else if (he->he_sig == AP_HOOK_SIG4(int, int, int, ptr)) { | |
1467 | + /* Call: int func(int,int,ptr) */ | |
1468 | + int v1 = va_arg(ap, va_type(int)); | |
1469 | + int v2 = va_arg(ap, va_type(int)); | |
1470 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1471 | + *((int *)v_rc) = ((int(*)(int, int, void *))(hf->hf_ptr))(v1, v2, v3); | |
1472 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1473 | + } | |
1474 | + else if (he->he_sig == AP_HOOK_SIG4(int, int, ptr, int)) { | |
1475 | + /* Call: int func(int,ptr,int) */ | |
1476 | + int v1 = va_arg(ap, va_type(int)); | |
1477 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1478 | + int v3 = va_arg(ap, va_type(int)); | |
1479 | + *((int *)v_rc) = ((int(*)(int, void *, int))(hf->hf_ptr))(v1, v2, v3); | |
1480 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1481 | + } | |
1482 | + else if (he->he_sig == AP_HOOK_SIG4(int, int, ptr, ptr)) { | |
1483 | + /* Call: int func(int,ptr,ptr) */ | |
1484 | + int v1 = va_arg(ap, va_type(int)); | |
1485 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1486 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1487 | + *((int *)v_rc) = ((int(*)(int, void *, void *))(hf->hf_ptr))(v1, v2, v3); | |
1488 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1489 | + } | |
1490 | + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, int, int)) { | |
1491 | + /* Call: int func(ptr,int,int) */ | |
1492 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1493 | + int v2 = va_arg(ap, va_type(int)); | |
1494 | + int v3 = va_arg(ap, va_type(int)); | |
1495 | + *((int *)v_rc) = ((int(*)(void *, int, int))(hf->hf_ptr))(v1, v2, v3); | |
1496 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1497 | + } | |
1498 | + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, int, ptr)) { | |
1499 | + /* Call: int func(ptr,int,ptr) */ | |
1500 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1501 | + int v2 = va_arg(ap, va_type(int)); | |
1502 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1503 | + *((int *)v_rc) = ((int(*)(void *, int, void *))(hf->hf_ptr))(v1, v2, v3); | |
1504 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1505 | + } | |
1506 | + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, ptr, int)) { | |
1507 | + /* Call: int func(ptr,ptr,int) */ | |
1508 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1509 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1510 | + int v3 = va_arg(ap, va_type(int)); | |
1511 | + *((int *)v_rc) = ((int(*)(void *, void *, int))(hf->hf_ptr))(v1, v2, v3); | |
1512 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1513 | + } | |
1514 | + else if (he->he_sig == AP_HOOK_SIG4(int, ptr, ptr, ptr)) { | |
1515 | + /* Call: int func(ptr,ptr,ptr) */ | |
1516 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1517 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1518 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1519 | + *((int *)v_rc) = ((int(*)(void *, void *, void *))(hf->hf_ptr))(v1, v2, v3); | |
1520 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1521 | + } | |
1522 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, int, int)) { | |
1523 | + /* Call: ptr func(int,int,int) */ | |
1524 | + int v1 = va_arg(ap, va_type(int)); | |
1525 | + int v2 = va_arg(ap, va_type(int)); | |
1526 | + int v3 = va_arg(ap, va_type(int)); | |
1527 | + *((void * *)v_rc) = ((void *(*)(int, int, int))(hf->hf_ptr))(v1, v2, v3); | |
1528 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1529 | + } | |
1530 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, int, ptr)) { | |
1531 | + /* Call: ptr func(int,int,ptr) */ | |
1532 | + int v1 = va_arg(ap, va_type(int)); | |
1533 | + int v2 = va_arg(ap, va_type(int)); | |
1534 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1535 | + *((void * *)v_rc) = ((void *(*)(int, int, void *))(hf->hf_ptr))(v1, v2, v3); | |
1536 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1537 | + } | |
1538 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, ptr, int)) { | |
1539 | + /* Call: ptr func(int,ptr,int) */ | |
1540 | + int v1 = va_arg(ap, va_type(int)); | |
1541 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1542 | + int v3 = va_arg(ap, va_type(int)); | |
1543 | + *((void * *)v_rc) = ((void *(*)(int, void *, int))(hf->hf_ptr))(v1, v2, v3); | |
1544 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1545 | + } | |
1546 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, int, ptr, ptr)) { | |
1547 | + /* Call: ptr func(int,ptr,ptr) */ | |
1548 | + int v1 = va_arg(ap, va_type(int)); | |
1549 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1550 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1551 | + *((void * *)v_rc) = ((void *(*)(int, void *, void *))(hf->hf_ptr))(v1, v2, v3); | |
1552 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1553 | + } | |
1554 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, int, int)) { | |
1555 | + /* Call: ptr func(ptr,int,int) */ | |
1556 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1557 | + int v2 = va_arg(ap, va_type(int)); | |
1558 | + int v3 = va_arg(ap, va_type(int)); | |
1559 | + *((void * *)v_rc) = ((void *(*)(void *, int, int))(hf->hf_ptr))(v1, v2, v3); | |
1560 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1561 | + } | |
1562 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, int, ptr)) { | |
1563 | + /* Call: ptr func(ptr,int,ptr) */ | |
1564 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1565 | + int v2 = va_arg(ap, va_type(int)); | |
1566 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1567 | + *((void * *)v_rc) = ((void *(*)(void *, int, void *))(hf->hf_ptr))(v1, v2, v3); | |
1568 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1569 | + } | |
1570 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, ptr, int)) { | |
1571 | + /* Call: ptr func(ptr,ptr,int) */ | |
1572 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1573 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1574 | + int v3 = va_arg(ap, va_type(int)); | |
1575 | + *((void * *)v_rc) = ((void *(*)(void *, void *, int))(hf->hf_ptr))(v1, v2, v3); | |
1576 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1577 | + } | |
1578 | + else if (he->he_sig == AP_HOOK_SIG4(ptr, ptr, ptr, ptr)) { | |
1579 | + /* Call: ptr func(ptr,ptr,ptr) */ | |
1580 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1581 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1582 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1583 | + *((void * *)v_rc) = ((void *(*)(void *, void *, void *))(hf->hf_ptr))(v1, v2, v3); | |
1584 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1585 | + } | |
1586 | + else if (he->he_sig == AP_HOOK_SIG5(int, ptr, ptr, ptr, int)) { | |
1587 | + /* Call: int func(ptr,ptr,ptr,int) */ | |
1588 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1589 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1590 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1591 | + int v4 = va_arg(ap, va_type(int)); | |
1592 | + *((int *)v_rc) = ((int(*)(void *, void *, void *, int))(hf->hf_ptr))(v1, v2, v3, v4); | |
1593 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1594 | + } | |
1595 | + else if (he->he_sig == AP_HOOK_SIG6(int, ptr, ptr, ptr, int, ptr)) { | |
1596 | + /* Call: int func(ptr,ptr,ptr,int,ptr) */ | |
1597 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1598 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1599 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1600 | + int v4 = va_arg(ap, va_type(int)); | |
1601 | + void *v5 = va_arg(ap, va_type(ptr)); | |
1602 | + *((int *)v_rc) = ((int(*)(void *, void *, void *, int, void *))(hf->hf_ptr))(v1, v2, v3, v4, v5); | |
1603 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1604 | + } | |
1605 | + else if (he->he_sig == AP_HOOK_SIG6(int, ptr, ptr, ptr, ptr, int)) { | |
1606 | + /* Call: int func(ptr,ptr,ptr,ptr,int) */ | |
1607 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1608 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1609 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1610 | + void *v4 = va_arg(ap, va_type(ptr)); | |
1611 | + int v5 = va_arg(ap, va_type(int)); | |
1612 | + *((int *)v_rc) = ((int(*)(void *, void *, void *, void *, int))(hf->hf_ptr))(v1, v2, v3, v4, v5); | |
1613 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1614 | + } | |
1615 | + else if (he->he_sig == AP_HOOK_SIG7(int, ptr, ptr, ptr, ptr, int, ptr)) { | |
1616 | + /* Call: int func(ptr,ptr,ptr,ptr,int,ptr) */ | |
1617 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1618 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1619 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1620 | + void *v4 = va_arg(ap, va_type(ptr)); | |
1621 | + int v5 = va_arg(ap, va_type(int)); | |
1622 | + void *v6 = va_arg(ap, va_type(ptr)); | |
1623 | + *((int *)v_rc) = ((int(*)(void *, void *, void *, void *, int, void *))(hf->hf_ptr))(v1, v2, v3, v4, v5, v6); | |
1624 | + rc = (*((int *)v_rc) != he->he_modeval.v_int); | |
1625 | + } | |
1626 | + else if (he->he_sig == AP_HOOK_SIG6(ptr, ptr, ptr, ptr, ptr, ptr)) { | |
1627 | + /* Call: ptr func(ptr,ptr,ptr,ptr,ptr) */ | |
1628 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1629 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1630 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1631 | + void *v4 = va_arg(ap, va_type(ptr)); | |
1632 | + void *v5 = va_arg(ap, va_type(ptr)); | |
1633 | + *((void * *)v_rc) = ((void *(*)(void *, void *, void *, void *, void *))(hf->hf_ptr))(v1, v2, v3, v4, v5); | |
1634 | + rc = (*((void * *)v_rc) != he->he_modeval.v_ptr); | |
1635 | + } | |
1636 | + else if (he->he_sig == AP_HOOK_SIG2(void, ptr)) { | |
1637 | + /* Call: void func(ptr) */ | |
1638 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1639 | + ((void(*)(void *))(hf->hf_ptr))(v1); | |
1640 | + } | |
1641 | + else if (he->he_sig == AP_HOOK_SIG4(void, ptr, int, int)) { | |
1642 | + /* Call: void func(ptr,int,int) */ | |
1643 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1644 | + int v2 = va_arg(ap, va_type(int)); | |
1645 | + int v3 = va_arg(ap, va_type(int)); | |
1646 | + ((void(*)(void *, int, int))(hf->hf_ptr))(v1, v2, v3); | |
1647 | + } | |
1648 | + else if (he->he_sig == AP_HOOK_SIG3(void, ptr, ptr)) { | |
1649 | + /* Call: void func(ptr,ptr) */ | |
1650 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1651 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1652 | + ((void(*)(void *, void *))(hf->hf_ptr))(v1, v2); | |
1653 | + } | |
1654 | + else if (he->he_sig == AP_HOOK_SIG4(void, ptr, ptr, ptr)) { | |
1655 | + /* Call: void func(ptr,ptr,ptr) */ | |
1656 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1657 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1658 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1659 | + ((void(*)(void *, void *, void *))(hf->hf_ptr))(v1, v2, v3); | |
1660 | + } | |
1661 | + else if (he->he_sig == AP_HOOK_SIG5(void, ptr, ptr, ptr, ptr)) { | |
1662 | + /* Call: void func(ptr,ptr,ptr,ptr) */ | |
1663 | + void *v1 = va_arg(ap, va_type(ptr)); | |
1664 | + void *v2 = va_arg(ap, va_type(ptr)); | |
1665 | + void *v3 = va_arg(ap, va_type(ptr)); | |
1666 | + void *v4 = va_arg(ap, va_type(ptr)); | |
1667 | + ((void(*)(void *, void *, void *, void *))(hf->hf_ptr))(v1, v2, v3, v4); | |
1668 | + } | |
1669 | + /* ----END GENERATED SECTION---------- */ | |
1670 | + else | |
1671 | + ap_log_assert("hook signature not implemented", __FILE__, __LINE__); | |
1672 | + | |
1673 | + if (he->he_modeid == AP_HOOK_MODE_ALL) | |
1674 | + rc = FALSE; | |
1675 | + else if (he->he_modeid == AP_HOOK_MODE_TOPMOST) | |
1676 | + rc = TRUE; | |
1677 | + | |
1678 | + return rc; | |
1679 | +} | |
1680 | + | |
1681 | +#endif /* EAPI */ | |
1682 | + | |
1683 | +/* | |
1684 | +=cut | |
1685 | +## | |
1686 | +## Embedded Perl script for generating the dispatch section | |
1687 | +## | |
1688 | + | |
1689 | +require 5.003; | |
1690 | +use strict; | |
1691 | + | |
1692 | +# configuration | |
1693 | +my $file = $0; | |
1694 | +my $begin = '----BEGIN GENERATED SECTION--------'; | |
1695 | +my $end = '----END GENERATED SECTION----------'; | |
1696 | + | |
1697 | +# special command: find used signatures | |
1698 | +if ($ARGV[0] eq 'used') { | |
1699 | + my @S = `find .. -type f -name "*.c" -print`; | |
1700 | + my $s; | |
1701 | + my %T = (); | |
1702 | + foreach $s (@S) { | |
1703 | + $s =~ s|\n$||; | |
1704 | + open(FP, "<$s") || die; | |
1705 | + my $source = ''; | |
1706 | + $source .= $_ while (<FP>); | |
1707 | + close(FP); | |
1708 | + my %seen = (); | |
1709 | + sub printme { | |
1710 | + my ($src, $hook, $sig) = @_; | |
1711 | + return if ($seen{$hook} == 1); | |
1712 | + $seen{$hook} = 1; | |
1713 | + my ($rc, $args) = ($sig =~ m|^([^,]+)(.*)$|); | |
1714 | + $args =~ s|^,||; | |
1715 | + $src =~ s|^.+/||; | |
1716 | + my $sig = sprintf("%-6sfunc(%s)", $rc, $args); | |
1717 | + $T{$sig}++; | |
1718 | + } | |
1719 | + $source =~ s|\("([^"]+)",\s*AP_HOOK_SIG[0-9]\((.+?)\)|&printme($s, $1, $2), ''|sge; | |
1720 | + } | |
1721 | + my $t; | |
1722 | + foreach $t (sort(keys(%T))) { | |
1723 | + printf(" * %-40s [%dx]\n", $t, $T{$t}); | |
1724 | + } | |
1725 | + exit(0); | |
1726 | +} | |
1727 | + | |
1728 | +# read ourself and keep a backup | |
1729 | +open(FP, "<$file") || die; | |
1730 | +my $source = ''; | |
1731 | +$source .= $_ while (<FP>); | |
1732 | +close(FP); | |
1733 | +open(FP, ">$file.bak") || die; | |
1734 | +print FP $source; | |
1735 | +close(FP); | |
1736 | + | |
1737 | +# now parse the signature lines and update the code | |
1738 | +my $o = ''; | |
1739 | +my $next = 0; | |
1740 | +my $line; | |
1741 | +my %seen = (); | |
1742 | +foreach $line (split(/\n/, $source)) { | |
1743 | + next if (not $line =~ m|\*\s+\S+\s+func\(.*\)|); | |
1744 | + my ($sig, $rc, $param) = ($line =~ m|\*\s+((\S+)\s+func\((.*?)\))|); | |
1745 | + $sig =~ s|\s+| |g; | |
1746 | + | |
1747 | + next if ($seen{$sig} == 1); | |
1748 | + $seen{$sig} = 1; | |
1749 | + | |
1750 | + print "Generating code for `$sig'\n"; | |
1751 | + | |
1752 | + my @S = ($rc, split(/[\s,]+/, $param)); | |
1753 | + my @RS = @S; | |
1754 | + my $i; | |
1755 | + for ($i = 0; $i <= $#RS; $i++) { | |
1756 | + $RS[$i] = 'void *' if ($RS[$i] eq 'ptr'); | |
1757 | + $RS[$i] = 'void *' if ($RS[$i] eq 'ctx'); | |
1758 | + } | |
1759 | + | |
1760 | + $o .= "else " if ($next); $next++; | |
1761 | + $o .= sprintf("if (he->he_sig == AP_HOOK_SIG%d(%s)) {\n", $#S+1, join(', ',@S)); | |
1762 | + $o .= sprintf(" \/\* Call: %s \*\/\n", $sig); | |
1763 | + for ($i = 1; $i <= $#S; $i++) { | |
1764 | + $o .= sprintf(" %-6sv%d = va_arg(ap, va_type(%s));\n", $RS[$i], $i, $S[$i]); | |
1765 | + } | |
1766 | + $o .= " "; | |
1767 | + $o .= sprintf("*((%s *)v_rc) = ", $RS[0]) if ($S[0] ne 'void'); | |
1768 | + $o .= sprintf("((%s(*)(%s))(hf->hf_ptr))", $RS[0], join(', ', @RS[1..$#RS])); | |
1769 | + $o .= "("; | |
1770 | + for ($i = 1; $i <= $#S; $i++) { | |
1771 | + $o .= "hf->hf_ctx" if ($S[$i] eq 'ctx'); | |
1772 | + $o .= sprintf("v%d", $i) if ($S[$i] ne 'ctx'); | |
1773 | + $o .= ", " if ($i < $#S); | |
1774 | + } | |
1775 | + $o .= ");\n"; | |
1776 | + $o .= sprintf(" rc = (*((%s *)v_rc) != he->he_modeval.v_%s);\n", | |
1777 | + $RS[0], $S[0]) if ($S[0] ne 'void'); | |
1778 | + $o .= "}\n"; | |
1779 | +} | |
1780 | + | |
1781 | +# insert the generated code at the target location | |
1782 | +$o =~ s|^| |mg; | |
1783 | +$source =~ s|(\/\* $begin.+?\n).*\n(.*?\/\* $end)|$1$o$2|s; | |
1784 | + | |
1785 | +# and update the source on disk | |
1786 | +print "Updating file `$file'\n"; | |
1787 | +open(FP, ">$file") || die; | |
1788 | +print FP $source; | |
1789 | +close(FP); | |
1790 | + | |
1791 | +=pod | |
1792 | +*/ | |
1793 | diff -Nru apache_1.3.9/src/ap/ap_mm.c apache_1.3.9.EAPI/src/ap/ap_mm.c | |
1794 | --- apache_1.3.9/src/ap/ap_mm.c Thu Jan 1 01:00:00 1970 | |
1795 | +++ apache_1.3.9.EAPI/src/ap/ap_mm.c Wed Dec 29 21:25:56 1999 | |
1796 | @@ -0,0 +1,178 @@ | |
1797 | +/* ==================================================================== | |
1798 | + * Copyright (c) 1999 The Apache Group. All rights reserved. | |
1799 | + * | |
1800 | + * Redistribution and use in source and binary forms, with or without | |
1801 | + * modification, are permitted provided that the following conditions | |
1802 | + * are met: | |
1803 | + * | |
1804 | + * 1. Redistributions of source code must retain the above copyright | |
1805 | + * notice, this list of conditions and the following disclaimer. | |
1806 | + * | |
1807 | + * 2. Redistributions in binary form must reproduce the above copyright | |
1808 | + * notice, this list of conditions and the following disclaimer in | |
1809 | + * the documentation and/or other materials provided with the | |
1810 | + * distribution. | |
1811 | + * | |
1812 | + * 3. All advertising materials mentioning features or use of this | |
1813 | + * software must display the following acknowledgment: | |
1814 | + * "This product includes software developed by the Apache Group | |
1815 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
1816 | + * | |
1817 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
1818 | + * endorse or promote products derived from this software without | |
1819 | + * prior written permission. For written permission, please contact | |
1820 | + * apache@apache.org. | |
1821 | + * | |
1822 | + * 5. Products derived from this software may not be called "Apache" | |
1823 | + * nor may "Apache" appear in their names without prior written | |
1824 | + * permission of the Apache Group. | |
1825 | + * | |
1826 | + * 6. Redistributions of any form whatsoever must retain the following | |
1827 | + * acknowledgment: | |
1828 | + * "This product includes software developed by the Apache Group | |
1829 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
1830 | + * | |
1831 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
1832 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
1833 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
1834 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
1835 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
1836 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
1837 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
1838 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
1839 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
1840 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
1841 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
1842 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
1843 | + * ==================================================================== | |
1844 | + * | |
1845 | + * This software consists of voluntary contributions made by many | |
1846 | + * individuals on behalf of the Apache Group and was originally based | |
1847 | + * on public domain software written at the National Center for | |
1848 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
1849 | + * For more information on the Apache Group and the Apache HTTP server | |
1850 | + * project, please see <http://www.apache.org/>. | |
1851 | + */ | |
1852 | + | |
1853 | +/* | |
1854 | +** ap_mm.c -- wrapper for MM shared memory library | |
1855 | +** | |
1856 | +** This file has two reason: | |
1857 | +** | |
1858 | +** 1. Under DSO context we need stubs inside the Apache core code | |
1859 | +** to make sure the MM library's code is actually available | |
1860 | +** to the module DSOs. | |
1861 | +** | |
1862 | +** 2. When the MM library cannot be built on the current platform | |
1863 | +** still provide dummy stubs so modules using the ap_mm_xxx() | |
1864 | +** functions can be still built. But modules should use | |
1865 | +** ap_mm_useable() to find out whether they really can use | |
1866 | +** the MM stuff. | |
1867 | +*/ | |
1868 | + /* | |
1869 | + * "What you see is all you get." | |
1870 | + * -- Brian Kernighan | |
1871 | + */ | |
1872 | +#ifdef EAPI | |
1873 | + | |
1874 | +#include "httpd.h" | |
1875 | +#include "ap_mm.h" | |
1876 | + | |
1877 | +#ifdef EAPI_MM | |
1878 | +#include "mm.h" | |
1879 | +API_EXPORT(int) ap_mm_useable(void) { return TRUE; } | |
1880 | +#define STUB(val,nul) { return val; } | |
1881 | +#define STUB_STMT(stmt) { stmt; return; } | |
1882 | +#else | |
1883 | +API_EXPORT(int) ap_mm_useable(void) { return FALSE; } | |
1884 | +#define STUB(val,nul) { return nul; } | |
1885 | +#define STUB_STMT(stmt) { return; } | |
1886 | +#endif | |
1887 | + | |
1888 | +API_EXPORT(int) ap_MM_create(size_t size, char *file) | |
1889 | + STUB(MM_create(size, file), FALSE) | |
1890 | +API_EXPORT(int) ap_MM_permission(mode_t mode, uid_t owner, gid_t group) | |
1891 | + STUB(MM_permission(mode, owner, group), -1) | |
1892 | +API_EXPORT(void) ap_MM_destroy(void) | |
1893 | + STUB_STMT(MM_destroy()) | |
1894 | +API_EXPORT(int) ap_MM_lock(ap_mm_lock_mode mode) | |
1895 | + STUB(MM_lock(mode), FALSE) | |
1896 | +API_EXPORT(int) ap_MM_unlock(void) | |
1897 | + STUB(MM_unlock(), FALSE) | |
1898 | +API_EXPORT(void *) ap_MM_malloc(size_t size) | |
1899 | + STUB(MM_malloc(size), NULL) | |
1900 | +API_EXPORT(void *) ap_MM_realloc(void *ptr, size_t size) | |
1901 | + STUB(MM_realloc(ptr, size), NULL) | |
1902 | +API_EXPORT(void) ap_MM_free(void *ptr) | |
1903 | + STUB_STMT(MM_free(ptr)) | |
1904 | +API_EXPORT(void *) ap_MM_calloc(size_t number, size_t size) | |
1905 | + STUB(MM_calloc(number, size), NULL) | |
1906 | +API_EXPORT(char *) ap_MM_strdup(const char *str) | |
1907 | + STUB(MM_strdup(str), NULL) | |
1908 | +API_EXPORT(size_t) ap_MM_sizeof(void *ptr) | |
1909 | + STUB(MM_sizeof(ptr), 0) | |
1910 | +API_EXPORT(size_t) ap_MM_maxsize(void) | |
1911 | + STUB(MM_maxsize(), 0) | |
1912 | +API_EXPORT(size_t) ap_MM_available(void) | |
1913 | + STUB(MM_available(), 0) | |
1914 | +API_EXPORT(char *) ap_MM_error(void) | |
1915 | + STUB(MM_error(), NULL) | |
1916 | + | |
1917 | +API_EXPORT(AP_MM *) ap_mm_create(size_t size, char *file) | |
1918 | + STUB(mm_create(size, file), NULL) | |
1919 | +API_EXPORT(int) ap_mm_permission(AP_MM *mm, mode_t mode, uid_t owner, gid_t group) | |
1920 | + STUB(mm_permission(mm, mode, owner, group), -1) | |
1921 | +API_EXPORT(void) ap_mm_destroy(AP_MM *mm) | |
1922 | + STUB_STMT(mm_destroy(mm)) | |
1923 | +API_EXPORT(int) ap_mm_lock(AP_MM *mm, ap_mm_lock_mode mode) | |
1924 | + STUB(mm_lock(mm, mode), FALSE) | |
1925 | +API_EXPORT(int) ap_mm_unlock(AP_MM *mm) | |
1926 | + STUB(mm_unlock(mm), FALSE) | |
1927 | +API_EXPORT(void *) ap_mm_malloc(AP_MM *mm, size_t size) | |
1928 | + STUB(mm_malloc(mm, size), NULL) | |
1929 | +API_EXPORT(void *) ap_mm_realloc(AP_MM *mm, void *ptr, size_t size) | |
1930 | + STUB(mm_realloc(mm, ptr, size), NULL) | |
1931 | +API_EXPORT(void) ap_mm_free(AP_MM *mm, void *ptr) | |
1932 | + STUB_STMT(mm_free(mm, ptr)) | |
1933 | +API_EXPORT(void *) ap_mm_calloc(AP_MM *mm, size_t number, size_t size) | |
1934 | + STUB(mm_calloc(mm, number, size), NULL) | |
1935 | +API_EXPORT(char *) ap_mm_strdup(AP_MM *mm, const char *str) | |
1936 | + STUB(mm_strdup(mm, str), NULL) | |
1937 | +API_EXPORT(size_t) ap_mm_sizeof(AP_MM *mm, void *ptr) | |
1938 | + STUB(mm_sizeof(mm, ptr), 0) | |
1939 | +API_EXPORT(size_t) ap_mm_maxsize(void) | |
1940 | + STUB(mm_maxsize(), 0) | |
1941 | +API_EXPORT(size_t) ap_mm_available(AP_MM *mm) | |
1942 | + STUB(mm_available(mm), 0) | |
1943 | +API_EXPORT(char *) ap_mm_error(void) | |
1944 | + STUB(mm_error(), NULL) | |
1945 | +API_EXPORT(void) ap_mm_display_info(AP_MM *mm) | |
1946 | + STUB_STMT(mm_display_info(mm)) | |
1947 | + | |
1948 | +API_EXPORT(void *) ap_mm_core_create(size_t size, char *file) | |
1949 | + STUB(mm_core_create(size, file), NULL) | |
1950 | +API_EXPORT(int) ap_mm_core_permission(void *core, mode_t mode, uid_t owner, gid_t group) | |
1951 | + STUB(mm_core_permission(core, mode, owner, group), -1) | |
1952 | +API_EXPORT(void) ap_mm_core_delete(void *core) | |
1953 | + STUB_STMT(mm_core_delete(core)) | |
1954 | +API_EXPORT(size_t) ap_mm_core_size(void *core) | |
1955 | + STUB(mm_core_size(core), 0) | |
1956 | +API_EXPORT(int) ap_mm_core_lock(void *core, ap_mm_lock_mode mode) | |
1957 | + STUB(mm_core_lock(core, mode), FALSE) | |
1958 | +API_EXPORT(int) ap_mm_core_unlock(void *core) | |
1959 | + STUB(mm_core_unlock(core), FALSE) | |
1960 | +API_EXPORT(size_t) ap_mm_core_maxsegsize(void) | |
1961 | + STUB(mm_core_maxsegsize(), 0) | |
1962 | +API_EXPORT(size_t) ap_mm_core_align2page(size_t size) | |
1963 | + STUB(mm_core_align2page(size), 0) | |
1964 | +API_EXPORT(size_t) ap_mm_core_align2word(size_t size) | |
1965 | + STUB(mm_core_align2word(size), 0) | |
1966 | + | |
1967 | +API_EXPORT(void) ap_mm_lib_error_set(unsigned int type, const char *str) | |
1968 | + STUB_STMT(mm_lib_error_set(type, str)) | |
1969 | +API_EXPORT(char *) ap_mm_lib_error_get(void) | |
1970 | + STUB(mm_lib_error_get(), NULL) | |
1971 | +API_EXPORT(int) ap_mm_lib_version(void) | |
1972 | + STUB(mm_lib_version(), 0) | |
1973 | + | |
1974 | +#endif /* EAPI */ | |
1975 | diff -Nru apache_1.3.9/src/include/alloc.h apache_1.3.9.EAPI/src/include/alloc.h | |
1976 | --- apache_1.3.9/src/include/alloc.h Wed Dec 29 22:03:42 1999 | |
1977 | +++ apache_1.3.9.EAPI/src/include/alloc.h Wed Dec 29 21:25:56 1999 | |
1978 | @@ -93,6 +93,15 @@ | |
1979 | ||
1980 | pool * ap_init_alloc(void); /* Set up everything */ | |
1981 | API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ | |
1982 | +#if defined(EAPI) | |
1983 | +typedef enum { AP_POOL_RD, AP_POOL_RW } ap_pool_lock_mode; | |
1984 | +int ap_shared_pool_possible(void); | |
1985 | +void ap_init_alloc_shared(int); | |
1986 | +void ap_kill_alloc_shared(void); | |
1987 | +API_EXPORT(pool *) ap_make_shared_sub_pool(pool *); | |
1988 | +API_EXPORT(int) ap_acquire_pool(pool *, ap_pool_lock_mode); | |
1989 | +API_EXPORT(int) ap_release_pool(pool *); | |
1990 | +#endif | |
1991 | API_EXPORT(void) ap_destroy_pool(pool *); | |
1992 | ||
1993 | /* pools have nested lifetimes -- sub_pools are destroyed when the | |
1994 | diff -Nru apache_1.3.9/src/include/ap_ctx.h apache_1.3.9.EAPI/src/include/ap_ctx.h | |
1995 | --- apache_1.3.9/src/include/ap_ctx.h Thu Jan 1 01:00:00 1970 | |
1996 | +++ apache_1.3.9.EAPI/src/include/ap_ctx.h Wed Dec 29 21:25:56 1999 | |
1997 | @@ -0,0 +1,110 @@ | |
1998 | +/* ==================================================================== | |
1999 | + * Copyright (c) 1998 The Apache Group. All rights reserved. | |
2000 | + * | |
2001 | + * Redistribution and use in source and binary forms, with or without | |
2002 | + * modification, are permitted provided that the following conditions | |
2003 | + * are met: | |
2004 | + * | |
2005 | + * 1. Redistributions of source code must retain the above copyright | |
2006 | + * notice, this list of conditions and the following disclaimer. | |
2007 | + * | |
2008 | + * 2. Redistributions in binary form must reproduce the above copyright | |
2009 | + * notice, this list of conditions and the following disclaimer in | |
2010 | + * the documentation and/or other materials provided with the | |
2011 | + * distribution. | |
2012 | + * | |
2013 | + * 3. All advertising materials mentioning features or use of this | |
2014 | + * software must display the following acknowledgment: | |
2015 | + * "This product includes software developed by the Apache Group | |
2016 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
2017 | + * | |
2018 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
2019 | + * endorse or promote products derived from this software without | |
2020 | + * prior written permission. For written permission, please contact | |
2021 | + * apache@apache.org. | |
2022 | + * | |
2023 | + * 5. Products derived from this software may not be called "Apache" | |
2024 | + * nor may "Apache" appear in their names without prior written | |
2025 | + * permission of the Apache Group. | |
2026 | + * | |
2027 | + * 6. Redistributions of any form whatsoever must retain the following | |
2028 | + * acknowledgment: | |
2029 | + * "This product includes software developed by the Apache Group | |
2030 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
2031 | + * | |
2032 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
2033 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
2034 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
2035 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
2036 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
2037 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
2038 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
2039 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
2040 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
2041 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
2042 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
2043 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
2044 | + * ==================================================================== | |
2045 | + * | |
2046 | + * This software consists of voluntary contributions made by many | |
2047 | + * individuals on behalf of the Apache Group and was originally based | |
2048 | + * on public domain software written at the National Center for | |
2049 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
2050 | + * For more information on the Apache Group and the Apache HTTP server | |
2051 | + * project, please see <http://www.apache.org/>. | |
2052 | + * | |
2053 | + */ | |
2054 | + | |
2055 | +/* | |
2056 | +** Generic Context Interface for Apache | |
2057 | +** Written by Ralf S. Engelschall <rse@engelschall.com> | |
2058 | +*/ | |
2059 | + | |
2060 | +#ifdef EAPI | |
2061 | + | |
2062 | +#ifndef AP_CTX_H | |
2063 | +#define AP_CTX_H | |
2064 | + | |
2065 | +#ifndef FALSE | |
2066 | +#define FALSE 0 | |
2067 | +#define TRUE !FALSE | |
2068 | +#endif | |
2069 | + | |
2070 | +/* | |
2071 | + * Internal Context Record Definition | |
2072 | + */ | |
2073 | + | |
2074 | +#define AP_CTX_MAX_ENTRIES 1024 | |
2075 | + | |
2076 | +typedef struct { | |
2077 | + char *ce_key; | |
2078 | + void *ce_val; | |
2079 | +} ap_ctx_entry; | |
2080 | + | |
2081 | +typedef struct { | |
2082 | + pool *cr_pool; | |
2083 | + ap_ctx_entry **cr_entry; | |
2084 | +} ap_ctx_rec; | |
2085 | + | |
2086 | +typedef ap_ctx_rec ap_ctx; | |
2087 | + | |
2088 | +/* | |
2089 | + * Some convinience macros for storing _numbers_ 0...n in contexts, i.e. | |
2090 | + * treating numbers as pointers but keeping track of the NULL return code of | |
2091 | + * ap_ctx_get. | |
2092 | + */ | |
2093 | +#define AP_CTX_NUM2PTR(n) (void *)((unsigned int)(n)+1) | |
2094 | +#define AP_CTX_PTR2NUM(p) (unsigned int)(((char *)(p))-1) | |
2095 | + | |
2096 | +/* | |
2097 | + * Prototypes for Context Handling Functions | |
2098 | + */ | |
2099 | + | |
2100 | +API_EXPORT(ap_ctx *)ap_ctx_new(pool *p); | |
2101 | +API_EXPORT(void) ap_ctx_set(ap_ctx *ctx, char *key, void *val); | |
2102 | +API_EXPORT(void *) ap_ctx_get(ap_ctx *ctx, char *key); | |
2103 | +API_EXPORT(ap_ctx *)ap_ctx_overlay(pool *p, ap_ctx *over, ap_ctx *base); | |
2104 | + | |
2105 | +#endif /* AP_CTX_H */ | |
2106 | + | |
2107 | +#endif /* EAPI */ | |
2108 | diff -Nru apache_1.3.9/src/include/ap_hook.h apache_1.3.9.EAPI/src/include/ap_hook.h | |
2109 | --- apache_1.3.9/src/include/ap_hook.h Thu Jan 1 01:00:00 1970 | |
2110 | +++ apache_1.3.9.EAPI/src/include/ap_hook.h Wed Dec 29 21:25:56 1999 | |
2111 | @@ -0,0 +1,710 @@ | |
2112 | +#if 0 | |
2113 | +=cut | |
2114 | +#endif | |
2115 | +/* ==================================================================== | |
2116 | + * Copyright (c) 1998 The Apache Group. All rights reserved. | |
2117 | + * | |
2118 | + * Redistribution and use in source and binary forms, with or without | |
2119 | + * modification, are permitted provided that the following conditions | |
2120 | + * are met: | |
2121 | + * | |
2122 | + * 1. Redistributions of source code must retain the above copyright | |
2123 | + * notice, this list of conditions and the following disclaimer. | |
2124 | + * | |
2125 | + * 2. Redistributions in binary form must reproduce the above copyright | |
2126 | + * notice, this list of conditions and the following disclaimer in | |
2127 | + * the documentation and/or other materials provided with the | |
2128 | + * distribution. | |
2129 | + * | |
2130 | + * 3. All advertising materials mentioning features or use of this | |
2131 | + * software must display the following acknowledgment: | |
2132 | + * "This product includes software developed by the Apache Group | |
2133 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
2134 | + * | |
2135 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
2136 | + * endorse or promote products derived from this software without | |
2137 | + * prior written permission. For written permission, please contact | |
2138 | + * apache@apache.org. | |
2139 | + * | |
2140 | + * 5. Products derived from this software may not be called "Apache" | |
2141 | + * nor may "Apache" appear in their names without prior written | |
2142 | + * permission of the Apache Group. | |
2143 | + * | |
2144 | + * 6. Redistributions of any form whatsoever must retain the following | |
2145 | + * acknowledgment: | |
2146 | + * "This product includes software developed by the Apache Group | |
2147 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
2148 | + * | |
2149 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
2150 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
2151 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
2152 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
2153 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
2154 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
2155 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
2156 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
2157 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
2158 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
2159 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
2160 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
2161 | + * ==================================================================== | |
2162 | + * | |
2163 | + * This software consists of voluntary contributions made by many | |
2164 | + * individuals on behalf of the Apache Group and was originally based | |
2165 | + * on public domain software written at the National Center for | |
2166 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
2167 | + * For more information on the Apache Group and the Apache HTTP server | |
2168 | + * project, please see <http://www.apache.org/>. | |
2169 | + * | |
2170 | + */ | |
2171 | + | |
2172 | +/* | |
2173 | +** Implementation of a Generic Hook Interface for Apache | |
2174 | +** Written by Ralf S. Engelschall <rse@engelschall.com> | |
2175 | +** | |
2176 | +** See POD document at end of this file for description. | |
2177 | +** View it with the command ``pod2man ap_hook.h | nroff -man | more'' | |
2178 | +** | |
2179 | +** Attention: This header file is a little bit tricky. | |
2180 | +** It's a combination of a C source and an embedded POD document | |
2181 | +** The purpose of this is to have both things together at one | |
2182 | +** place. So you can both pass this file to the C compiler and | |
2183 | +** the pod2man translater. | |
2184 | +*/ | |
2185 | + | |
2186 | +#ifdef EAPI | |
2187 | + | |
2188 | +#ifndef AP_HOOK_H | |
2189 | +#define AP_HOOK_H | |
2190 | + | |
2191 | +/* | |
2192 | + * Function Signature Specification: | |
2193 | + * | |
2194 | + * We encode the complete signature ingredients as a bitfield | |
2195 | + * stored in a single unsigned long integer value, which can be | |
2196 | + * constructed with AP_HOOK_SIGx(...) | |
2197 | + */ | |
2198 | + | |
2199 | +/* the type of the signature bitfield */ | |
2200 | +typedef unsigned long int ap_hook_sig; | |
2201 | + | |
2202 | +/* the mask (bin) 111 (hex 0x7) for the triples in the bitfield */ | |
2203 | +#define AP_HOOK_SIG_TRIPLE_MASK 0x7 | |
2204 | + | |
2205 | +/* the position of the triple */ | |
2206 | +#define AP_HOOK_SIG_TRIPLE_POS(n) ((n)*3) | |
2207 | + | |
2208 | +/* the constructor for triple #n with value v */ | |
2209 | +#define AP_HOOK_SIG_TRIPLE(n,v) \ | |
2210 | + (((ap_hook_sig)(v))<<((AP_HOOK_##n)*3)) | |
2211 | + | |
2212 | +/* the check whether triple #n in sig contains value v */ | |
2213 | +#define AP_HOOK_SIG_HAS(sig,n,v) \ | |
2214 | + ((((ap_hook_sig)(sig))&AP_HOOK_SIG_TRIPLE(n, AP_HOOK_SIG_TRIPLE_MASK)) == (AP_HOOK_##n##_##v)) | |
2215 | + | |
2216 | +/* utility function to get triple #n in sig */ | |
2217 | +#define AP_HOOK_SIG_TRIPLE_GET(sig,n) \ | |
2218 | + ((((ap_hook_sig)(sig))>>AP_HOOK_SIG_TRIPLE_POS(n))&(AP_HOOK_SIG_TRIPLE_MASK)) | |
2219 | + | |
2220 | +/* utility function to set triple #n in sig to value v */ | |
2221 | +#define AP_HOOK_SIG_TRIPLE_SET(sig,n,v) \ | |
2222 | + ((((ap_hook_sig)(sig))&~(AP_HOOK_SIG_TRIPLE_MASK<<AP_HOOK_SIG_TRIPLE_POS(n)))|((v)<<AP_HOOK_SIG_TRIPLE_POS(n))) | |
2223 | + | |
2224 | +/* define the ingredients for the triple #0: id stuff */ | |
2225 | +#define AP_HOOK_ID 0 | |
2226 | +#define AP_HOOK_ID_ok AP_HOOK_SIG_TRIPLE(ID,0) | |
2227 | +#define AP_HOOK_ID_undef AP_HOOK_SIG_TRIPLE(ID,1) | |
2228 | + | |
2229 | +/* define the ingredients for the triple #1: return code */ | |
2230 | +#define AP_HOOK_RC 1 | |
2231 | +#define AP_HOOK_RC_void AP_HOOK_SIG_TRIPLE(RC,0) | |
2232 | +#define AP_HOOK_RC_char AP_HOOK_SIG_TRIPLE(RC,1) | |
2233 | +#define AP_HOOK_RC_int AP_HOOK_SIG_TRIPLE(RC,2) | |
2234 | +#define AP_HOOK_RC_long AP_HOOK_SIG_TRIPLE(RC,3) | |
2235 | +#define AP_HOOK_RC_float AP_HOOK_SIG_TRIPLE(RC,4) | |
2236 | +#define AP_HOOK_RC_double AP_HOOK_SIG_TRIPLE(RC,5) | |
2237 | +#define AP_HOOK_RC_ptr AP_HOOK_SIG_TRIPLE(RC,6) | |
2238 | + | |
2239 | +/* define the ingredients for the triple #2: argument 1 */ | |
2240 | +#define AP_HOOK_A1 2 | |
2241 | +#define AP_HOOK_A1_ctx AP_HOOK_SIG_TRIPLE(A1,0) | |
2242 | +#define AP_HOOK_A1_char AP_HOOK_SIG_TRIPLE(A1,1) | |
2243 | +#define AP_HOOK_A1_int AP_HOOK_SIG_TRIPLE(A1,2) | |
2244 | +#define AP_HOOK_A1_long AP_HOOK_SIG_TRIPLE(A1,3) | |
2245 | +#define AP_HOOK_A1_float AP_HOOK_SIG_TRIPLE(A1,4) | |
2246 | +#define AP_HOOK_A1_double AP_HOOK_SIG_TRIPLE(A1,5) | |
2247 | +#define AP_HOOK_A1_ptr AP_HOOK_SIG_TRIPLE(A1,6) | |
2248 | + | |
2249 | +/* define the ingredients for the triple #3: argument 2 */ | |
2250 | +#define AP_HOOK_A2 3 | |
2251 | +#define AP_HOOK_A2_ctx AP_HOOK_SIG_TRIPLE(A2,0) | |
2252 | +#define AP_HOOK_A2_char AP_HOOK_SIG_TRIPLE(A2,1) | |
2253 | +#define AP_HOOK_A2_int AP_HOOK_SIG_TRIPLE(A2,2) | |
2254 | +#define AP_HOOK_A2_long AP_HOOK_SIG_TRIPLE(A2,3) | |
2255 | +#define AP_HOOK_A2_float AP_HOOK_SIG_TRIPLE(A2,4) | |
2256 | +#define AP_HOOK_A2_double AP_HOOK_SIG_TRIPLE(A2,5) | |
2257 | +#define AP_HOOK_A2_ptr AP_HOOK_SIG_TRIPLE(A2,6) | |
2258 | + | |
2259 | +/* define the ingredients for the triple #4: argument 3 */ | |
2260 | +#define AP_HOOK_A3 4 | |
2261 | +#define AP_HOOK_A3_ctx AP_HOOK_SIG_TRIPLE(A3,0) | |
2262 | +#define AP_HOOK_A3_char AP_HOOK_SIG_TRIPLE(A3,1) | |
2263 | +#define AP_HOOK_A3_int AP_HOOK_SIG_TRIPLE(A3,2) | |
2264 | +#define AP_HOOK_A3_long AP_HOOK_SIG_TRIPLE(A3,3) | |
2265 | +#define AP_HOOK_A3_float AP_HOOK_SIG_TRIPLE(A3,4) | |
2266 | +#define AP_HOOK_A3_double AP_HOOK_SIG_TRIPLE(A3,5) | |
2267 | +#define AP_HOOK_A3_ptr AP_HOOK_SIG_TRIPLE(A3,6) | |
2268 | + | |
2269 | +/* define the ingredients for the triple #5: argument 4 */ | |
2270 | +#define AP_HOOK_A4 5 | |
2271 | +#define AP_HOOK_A4_ctx AP_HOOK_SIG_TRIPLE(A4,0) | |
2272 | +#define AP_HOOK_A4_char AP_HOOK_SIG_TRIPLE(A4,1) | |
2273 | +#define AP_HOOK_A4_int AP_HOOK_SIG_TRIPLE(A4,2) | |
2274 | +#define AP_HOOK_A4_long AP_HOOK_SIG_TRIPLE(A4,3) | |
2275 | +#define AP_HOOK_A4_float AP_HOOK_SIG_TRIPLE(A4,4) | |
2276 | +#define AP_HOOK_A4_double AP_HOOK_SIG_TRIPLE(A4,5) | |
2277 | +#define AP_HOOK_A4_ptr AP_HOOK_SIG_TRIPLE(A4,6) | |
2278 | + | |
2279 | +/* define the ingredients for the triple #6: argument 5 */ | |
2280 | +#define AP_HOOK_A5 6 | |
2281 | +#define AP_HOOK_A5_ctx AP_HOOK_SIG_TRIPLE(A5,0) | |
2282 | +#define AP_HOOK_A5_char AP_HOOK_SIG_TRIPLE(A5,1) | |
2283 | +#define AP_HOOK_A5_int AP_HOOK_SIG_TRIPLE(A5,2) | |
2284 | +#define AP_HOOK_A5_long AP_HOOK_SIG_TRIPLE(A5,3) | |
2285 | +#define AP_HOOK_A5_float AP_HOOK_SIG_TRIPLE(A5,4) | |
2286 | +#define AP_HOOK_A5_double AP_HOOK_SIG_TRIPLE(A5,5) | |
2287 | +#define AP_HOOK_A5_ptr AP_HOOK_SIG_TRIPLE(A5,6) | |
2288 | + | |
2289 | +/* define the ingredients for the triple #7: argument 6 */ | |
2290 | +#define AP_HOOK_A6 7 | |
2291 | +#define AP_HOOK_A6_ctx AP_HOOK_SIG_TRIPLE(A6,0) | |
2292 | +#define AP_HOOK_A6_char AP_HOOK_SIG_TRIPLE(A6,1) | |
2293 | +#define AP_HOOK_A6_int AP_HOOK_SIG_TRIPLE(A6,2) | |
2294 | +#define AP_HOOK_A6_long AP_HOOK_SIG_TRIPLE(A6,3) | |
2295 | +#define AP_HOOK_A6_float AP_HOOK_SIG_TRIPLE(A6,4) | |
2296 | +#define AP_HOOK_A6_double AP_HOOK_SIG_TRIPLE(A6,5) | |
2297 | +#define AP_HOOK_A6_ptr AP_HOOK_SIG_TRIPLE(A6,6) | |
2298 | + | |
2299 | +/* define the ingredients for the triple #8: argument 7 */ | |
2300 | +#define AP_HOOK_A7 8 | |
2301 | +#define AP_HOOK_A7_ctx AP_HOOK_SIG_TRIPLE(A7,0) | |
2302 | +#define AP_HOOK_A7_char AP_HOOK_SIG_TRIPLE(A7,1) | |
2303 | +#define AP_HOOK_A7_int AP_HOOK_SIG_TRIPLE(A7,2) | |
2304 | +#define AP_HOOK_A7_long AP_HOOK_SIG_TRIPLE(A7,3) | |
2305 | +#define AP_HOOK_A7_float AP_HOOK_SIG_TRIPLE(A7,4) | |
2306 | +#define AP_HOOK_A7_double AP_HOOK_SIG_TRIPLE(A7,5) | |
2307 | +#define AP_HOOK_A7_ptr AP_HOOK_SIG_TRIPLE(A7,6) | |
2308 | + | |
2309 | +/* define the ingredients for the triple #9: argument 8 */ | |
2310 | +#define AP_HOOK_A8 9 | |
2311 | +#define AP_HOOK_A8_ctx AP_HOOK_SIG_TRIPLE(9,0) | |
2312 | +#define AP_HOOK_A8_char AP_HOOK_SIG_TRIPLE(9,1) | |
2313 | +#define AP_HOOK_A8_int AP_HOOK_SIG_TRIPLE(9,2) | |
2314 | +#define AP_HOOK_A8_long AP_HOOK_SIG_TRIPLE(9,3) | |
2315 | +#define AP_HOOK_A8_float AP_HOOK_SIG_TRIPLE(9,4) | |
2316 | +#define AP_HOOK_A8_double AP_HOOK_SIG_TRIPLE(9,5) | |
2317 | +#define AP_HOOK_A8_ptr AP_HOOK_SIG_TRIPLE(9,6) | |
2318 | + | |
2319 | +/* the constructor for unknown signatures */ | |
2320 | +#define AP_HOOK_SIG_UNKNOWN AP_HOOK_ID_undef | |
2321 | + | |
2322 | +/* the constructor for signatures with 1 type */ | |
2323 | +#define AP_HOOK_SIG1(rc) \ | |
2324 | + (AP_HOOK_RC_##rc) | |
2325 | + | |
2326 | +/* the constructor for signatures with 2 types */ | |
2327 | +#define AP_HOOK_SIG2(rc,a1) \ | |
2328 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1) | |
2329 | + | |
2330 | +/* the constructor for signatures with 3 types */ | |
2331 | +#define AP_HOOK_SIG3(rc,a1,a2) \ | |
2332 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2) | |
2333 | + | |
2334 | +/* the constructor for signatures with 4 types */ | |
2335 | +#define AP_HOOK_SIG4(rc,a1,a2,a3) \ | |
2336 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3) | |
2337 | + | |
2338 | +/* the constructor for signatures with 5 types */ | |
2339 | +#define AP_HOOK_SIG5(rc,a1,a2,a3,a4) \ | |
2340 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4) | |
2341 | + | |
2342 | +/* the constructor for signatures with 6 types */ | |
2343 | +#define AP_HOOK_SIG6(rc,a1,a2,a3,a4,a5) \ | |
2344 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5) | |
2345 | + | |
2346 | +/* the constructor for signatures with 7 types */ | |
2347 | +#define AP_HOOK_SIG7(rc,a1,a2,a3,a4,a5,a6) \ | |
2348 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5|AP_HOOK_A6_##a6) | |
2349 | + | |
2350 | +/* the constructor for signatures with 8 types */ | |
2351 | +#define AP_HOOK_SIG8(rc,a1,a2,a3,a4,a5,a6,a7) \ | |
2352 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5|AP_HOOK_A6_##a6|AP_HOOK_A7_##a7) | |
2353 | + | |
2354 | +/* the constructor for signatures with 9 types */ | |
2355 | +#define AP_HOOK_SIG9(rc,a1,a2,a3,a4,a5,a6,a7,a8) \ | |
2356 | + (AP_HOOK_RC_##rc|AP_HOOK_A1_##a1|AP_HOOK_A2_##a2|AP_HOOK_A3_##a3|AP_HOOK_A4_##a4|AP_HOOK_A5_##a5|AP_HOOK_A6_##a6|AP_HOOK_A7_##a7|AP_HOOK_A8_##a8) | |
2357 | + | |
2358 | +/* | |
2359 | + * Return Value Mode Identification | |
2360 | + */ | |
2361 | + | |
2362 | +/* the type of the return value modes */ | |
2363 | +typedef unsigned int ap_hook_mode; | |
2364 | + | |
2365 | +/* the mode of the return value */ | |
2366 | +#define AP_HOOK_MODE_UNKNOWN 0 | |
2367 | +#define AP_HOOK_MODE_TOPMOST 1 | |
2368 | +#define AP_HOOK_MODE_DECLINE 2 | |
2369 | +#define AP_HOOK_MODE_DECLTMP 3 | |
2370 | +#define AP_HOOK_MODE_ALL 4 | |
2371 | + | |
2372 | +/* the constructors for the return value modes */ | |
2373 | +#define AP_HOOK_TOPMOST AP_HOOK_MODE_TOPMOST | |
2374 | +#define AP_HOOK_DECLINE(val) AP_HOOK_MODE_DECLINE, (val) | |
2375 | +#define AP_HOOK_DECLTMP(val) AP_HOOK_MODE_DECLTMP, (val) | |
2376 | +#define AP_HOOK_ALL AP_HOOK_MODE_ALL | |
2377 | + | |
2378 | +/* | |
2379 | + * Hook State Identification | |
2380 | + */ | |
2381 | + | |
2382 | +/* the type of the hook state */ | |
2383 | +typedef unsigned short int ap_hook_state; | |
2384 | + | |
2385 | +/* the values of the hook state */ | |
2386 | +#define AP_HOOK_STATE_UNDEF 0 | |
2387 | +#define AP_HOOK_STATE_NOTEXISTANT 1 | |
2388 | +#define AP_HOOK_STATE_ESTABLISHED 2 | |
2389 | +#define AP_HOOK_STATE_CONFIGURED 3 | |
2390 | +#define AP_HOOK_STATE_REGISTERED 4 | |
2391 | + | |
2392 | +/* | |
2393 | + * Hook Context Identification | |
2394 | + * | |
2395 | + * Notice: Null is ok here, because AP_HOOK_NOCTX is just a dummy argument | |
2396 | + * because we know from the signature whether the argument is a | |
2397 | + * context value or just the dummy value. | |
2398 | + */ | |
2399 | + | |
2400 | +#define AP_HOOK_NOCTX (void *)(0) | |
2401 | +#define AP_HOOK_CTX(v) (void *)(v) | |
2402 | + | |
2403 | +/* | |
2404 | + * Internal Hook Record Definition | |
2405 | + */ | |
2406 | + | |
2407 | +/* the union holding the arbitrary decline values */ | |
2408 | +typedef union { | |
2409 | + char v_char; | |
2410 | + int v_int; | |
2411 | + long v_long; | |
2412 | + float v_float; | |
2413 | + double v_double; | |
2414 | + void *v_ptr; | |
2415 | +} ap_hook_value; | |
2416 | + | |
2417 | +/* the structure holding one hook function and its context */ | |
2418 | +typedef struct { | |
2419 | + void *hf_ptr; /* function pointer */ | |
2420 | + void *hf_ctx; /* function context */ | |
2421 | +} ap_hook_func; | |
2422 | + | |
2423 | +/* the structure holding one hook entry with all its registered functions */ | |
2424 | +typedef struct { | |
2425 | + char *he_hook; /* hook name (=unique id) */ | |
2426 | + ap_hook_sig he_sig; /* hook signature */ | |
2427 | + int he_modeid; /* hook mode id */ | |
2428 | + ap_hook_value he_modeval; /* hook mode value */ | |
2429 | + ap_hook_func **he_func; /* hook registered funcs */ | |
2430 | +} ap_hook_entry; | |
2431 | + | |
2432 | +/* the maximum number of hooks and functions per hook */ | |
2433 | +#define AP_HOOK_MAX_ENTRIES 512 | |
2434 | +#define AP_HOOK_MAX_FUNCS 128 | |
2435 | + | |
2436 | +/* | |
2437 | + * Extended Variable Argument (vararg) Support | |
2438 | + * | |
2439 | + * In ANSI C varargs exists, but because the prototypes of function with | |
2440 | + * varargs cannot reflect the types of the varargs, K&R argument passing | |
2441 | + * conventions have to apply for the compiler. This means mainly a conversion | |
2442 | + * of shorter type variants to the maximum variant (according to sizeof). The | |
2443 | + * above va_type() macro provides this mapping from the wanted types to the | |
2444 | + * physically used ones. | |
2445 | + */ | |
2446 | + | |
2447 | +/* the mapping */ | |
2448 | +#define VA_TYPE_char int | |
2449 | +#define VA_TYPE_short int | |
2450 | +#define VA_TYPE_int int | |
2451 | +#define VA_TYPE_long long | |
2452 | +#define VA_TYPE_float double | |
2453 | +#define VA_TYPE_double double | |
2454 | +#define VA_TYPE_ptr void * | |
2455 | +#define VA_TYPE_ctx void * | |
2456 | + | |
2457 | +/* the constructor */ | |
2458 | +#ifdef va_type | |
2459 | +#undef va_type | |
2460 | +#endif | |
2461 | +#define va_type(type) VA_TYPE_ ## type | |
2462 | + | |
2463 | +/* | |
2464 | + * Miscellaneous stuff | |
2465 | + */ | |
2466 | + | |
2467 | +#ifndef FALSE | |
2468 | +#define FALSE 0 | |
2469 | +#define TRUE !FALSE | |
2470 | +#endif | |
2471 | + | |
2472 | +/* | |
2473 | + * Wrapper macros for the callback-function register/unregister calls. | |
2474 | + * | |
2475 | + * Background: Strict ANSI C doesn't allow a function pointer to be treated as | |
2476 | + * a void pointer on argument passing, but we cannot declare the argument as a | |
2477 | + * function prototype, because the functions can have arbitrary signatures. So | |
2478 | + * we have to use a void pointer here. But to not require explicit casts on | |
2479 | + * function pointers for every register/unregister call, we smooth the API a | |
2480 | + * little bit by providing these macros. | |
2481 | + */ | |
2482 | + | |
2483 | +#define ap_hook_register(hook,func,ctx) ap_hook_register_I(hook,(void *)(func),ctx) | |
2484 | +#define ap_hook_unregister(hook,func) ap_hook_unregister_I(hook,(void *)(func)) | |
2485 | + | |
2486 | +/* | |
2487 | + * Prototypes for the hook API functions | |
2488 | + */ | |
2489 | + | |
2490 | +API_EXPORT(void) ap_hook_init (void); | |
2491 | +API_EXPORT(void) ap_hook_kill (void); | |
2492 | +API_EXPORT(int) ap_hook_configure (char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...); | |
2493 | +API_EXPORT(int) ap_hook_register_I (char *hook, void *func, void *ctx); | |
2494 | +API_EXPORT(int) ap_hook_unregister_I (char *hook, void *func); | |
2495 | +API_EXPORT(ap_hook_state) ap_hook_status (char *hook); | |
2496 | +API_EXPORT(int) ap_hook_use (char *hook, ap_hook_sig sig, ap_hook_mode modeid, ...); | |
2497 | +API_EXPORT(int) ap_hook_call (char *hook, ...); | |
2498 | + | |
2499 | +#endif /* AP_HOOK_H */ | |
2500 | + | |
2501 | +#endif /* EAPI */ | |
2502 | +/* | |
2503 | +=pod | |
2504 | +## | |
2505 | +## Embedded POD document | |
2506 | +## | |
2507 | + | |
2508 | +=head1 NAME | |
2509 | + | |
2510 | +B<ap_hook> - B<Generic Hook Interface for Apache> | |
2511 | + | |
2512 | +=head1 SYNOPSIS | |
2513 | + | |
2514 | +B<Hook Library Setup:> | |
2515 | + | |
2516 | + void ap_hook_init(void); | |
2517 | + void ap_hook_kill(void); | |
2518 | + | |
2519 | +B<Hook Configuration and Registration:> | |
2520 | + | |
2521 | + int ap_hook_configure(char *hook, ap_hook_sig sig, ap_hook_mode mode); | |
2522 | + int ap_hook_register(char *hook, void *func, void *ctx); | |
2523 | + int ap_hook_unregister(char *hook, void *func); | |
2524 | + | |
2525 | +B<Hook Usage:> | |
2526 | + | |
2527 | + ap_hook_state ap_hook_status(char *hook); | |
2528 | + int ap_hook_use(char *hook, ap_hook_sig sig, ap_hook_mode mode, ...); | |
2529 | + int ap_hook_call(char *hook, ...); | |
2530 | + | |
2531 | +B<Hook Signature Constructors> (ap_hook_sig): | |
2532 | + | |
2533 | + AP_HOOK_SIG1(rc) | |
2534 | + AP_HOOK_SIG2(rc,a1) | |
2535 | + AP_HOOK_SIG3(rc,a1,a2) | |
2536 | + AP_HOOK_SIG4(rc,a1,a2,a3) | |
2537 | + AP_HOOK_SIG5(rc,a1,a2,a3,a4) | |
2538 | + AP_HOOK_SIG6(rc,a1,a2,a3,a4,a5) | |
2539 | + AP_HOOK_SIG7(rc,a1,a2,a3,a4,a5,a6) | |
2540 | + AP_HOOK_SIG8(rc,a1,a2,a3,a4,a5,a6,a7) | |
2541 | + | |
2542 | +B<Hook Modes Constructors> (ap_hook_mode): | |
2543 | + | |
2544 | + AP_HOOK_TOPMOST | |
2545 | + AP_HOOK_DECLINE(value) | |
2546 | + AP_HOOK_DECLTMP(value) | |
2547 | + AP_HOOK_ALL | |
2548 | + | |
2549 | +B<Hook States> (ap_hook_state): | |
2550 | + | |
2551 | + AP_HOOK_STATE_UNDEF | |
2552 | + AP_HOOK_STATE_NOTEXISTANT | |
2553 | + AP_HOOK_STATE_ESTABLISHED | |
2554 | + AP_HOOK_STATE_CONFIGURED | |
2555 | + AP_HOOK_STATE_REGISTERED | |
2556 | + | |
2557 | +=head1 DESCRIPTION | |
2558 | + | |
2559 | +This library implements a generic hook interface for Apache which can be used | |
2560 | +to loosely couple code through arbitrary hooks. There are two use cases for | |
2561 | +this mechanism: | |
2562 | + | |
2563 | +=over 3 | |
2564 | + | |
2565 | +=item B<1. Extension and Overrides> | |
2566 | + | |
2567 | +Inside a specific code section you want to perform a specific function call | |
2568 | +for extension reasons. But you want to allow one or more modules to implement | |
2569 | +this function by registering hooks. Those hooks are registered on a stack and | |
2570 | +can be even configured to have a I<decline> return value. As long as there are | |
2571 | +functions which return the decline value the next function on the stack is | |
2572 | +tried. When the first function doesn't return the decline value the hook call | |
2573 | +stops. | |
2574 | + | |
2575 | +The original intent of this use case is to provide a flexible extension | |
2576 | +mechanism where modules can override functionality. | |
2577 | + | |
2578 | +=item B<2. Intercommunication> | |
2579 | + | |
2580 | +Inside a specific code you have a function you want to export. But you first | |
2581 | +want to allow other code to override this function. And second you want to | |
2582 | +export this function without real object file symbol references. Instead you | |
2583 | +want to register the function and let the users call this function by name. | |
2584 | + | |
2585 | +The original intent of this use case is to allow inter-module communication | |
2586 | +without direct symbol references, which are a big I<no-no> for the I<Dynamic | |
2587 | +Shared Object> (DSO) situation. | |
2588 | + | |
2589 | +=back | |
2590 | + | |
2591 | +And the following design goals existed: | |
2592 | + | |
2593 | +=over 3 | |
2594 | + | |
2595 | +=item B<1. Minimum code changes> | |
2596 | + | |
2597 | +The hook calls should look very similar to the corresponding direct function | |
2598 | +call to allow one to easily translate it. And the total amount of changes for | |
2599 | +the hook registration, hook configuration and hook usage should be as small as | |
2600 | +possible to minimize the total code changes. Additionally a shorthand API | |
2601 | +function (ap_hook_use) should be provided which lets one trivially add a hook | |
2602 | +by just changing the code at a single location. | |
2603 | + | |
2604 | +=item B<2. The hook call has to be maximum flexible> | |
2605 | + | |
2606 | +In order to avoid nasty hacks, maximum flexiblity for the hook calls is | |
2607 | +needed, i.e. any function signature (the set of types for the return value and | |
2608 | +the arguments) should be supported. And it should be possible to | |
2609 | +register always a context (ctx) variable with a function which is passed to | |
2610 | +the corresponding function when the hook call is performed. | |
2611 | + | |
2612 | +=back | |
2613 | + | |
2614 | +The implementation of this library directly followed these two design goals. | |
2615 | + | |
2616 | +=head1 USAGE | |
2617 | + | |
2618 | +Using this hook API is a four-step process: | |
2619 | + | |
2620 | +=over 3 | |
2621 | + | |
2622 | +=item B<1. Initialization> | |
2623 | + | |
2624 | +Initialize or destroy the hook mechanism inside your application program: | |
2625 | + | |
2626 | + ap_hook_init(); | |
2627 | + : | |
2628 | + ap_hook_kill(); | |
2629 | + | |
2630 | +=item B<2. Configuration> | |
2631 | + | |
2632 | +Configure a particular hook by specifing its name, signature and return type | |
2633 | +semantic: | |
2634 | + | |
2635 | + ap_hook_configure("lookup", AP_HOOK_SIG2(ptr,ptr,ctx), AP_HOOK_DECLINE(NULL)); | |
2636 | + ap_hook_configure("setup", AP_HOOK_SIG2(int,ptr,char), AP_HOOK_DECLTMP(FALSE)); | |
2637 | + ap_hook_configure("read", AP_HOOK_SIG2(void,ptr), AP_HOOK_TOPMOST); | |
2638 | + ap_hook_configure("logit", AP_HOOK_SIG2(void,ptr), AP_HOOK_ALL); | |
2639 | + | |
2640 | +This configures four hooks: | |
2641 | + | |
2642 | +A hook named C<lookup> with the signature C<void *lookup(void *, void *)> | |
2643 | +(where the second argument is C<NULL> or the private context pointer of the | |
2644 | +hook function which can be optionally provided at the registration step | |
2645 | +later) and a return code semantic which says: Proceed as long as the | |
2646 | +registered lookup functions return C<NULL> or no more registered functions | |
2647 | +exists. A call for this hook has to provide 2 argument only (a pointer to the | |
2648 | +return variable and the first argument), because the context is | |
2649 | +implicitly provided by the hook mechanism. Sample idea: I<The first function | |
2650 | +who was successful in looking up a variable provides the value>. | |
2651 | + | |
2652 | +A hook named C<setup> with the signature C<int setup(void *, char)" and a | |
2653 | +return code semantic equal to the one of the C<lookup> hook. But the decline | |
2654 | +return value is implemented by a temporay variable of the hook mechanism and | |
2655 | +only used for the decline decision. So a call to this hook has to provide 2 | |
2656 | +arguments only (the first and second argument, but no address to a return | |
2657 | +value). Sample idea: I<Any function can handle the setup and when one | |
2658 | +function handled it stops the processing by indicating this with the return | |
2659 | +value>. | |
2660 | + | |
2661 | +A hook named C<read> with the signature C<void read(void *)> and a return code | |
2662 | +semantic which says: Only the top most function on the registered function | |
2663 | +stack is tried (and independet of a possible return value in non-void | |
2664 | +context). A call to this hook has to provide exactly 1 argument (the | |
2665 | +single argument to the hook function). Sample idea: I<We want to | |
2666 | +use a read function and allow others to override it, but independent how much | |
2667 | +registered functions exists, only top most (= last registered) function | |
2668 | +overrides and is used>. | |
2669 | + | |
2670 | +A hook named C<logit> with the signature C<void logit(void *)> and a return | |
2671 | +code semantic which says: All registered functions on the hook functioin stack | |
2672 | +are tried. Sample idea: I<We pass a FILE pointer to the logging functions and | |
2673 | +any function can log whatever it wants>. | |
2674 | + | |
2675 | +=item B<3. Registration> | |
2676 | + | |
2677 | +Register the actual functions which should be used by the hook: | |
2678 | + | |
2679 | + ap_hook_register("lookup", mylookup, mycontext); | |
2680 | + ap_hook_register("setup", mysetup); | |
2681 | + ap_hook_register("read", myread); | |
2682 | + ap_hook_register("logit", mylogit); | |
2683 | + | |
2684 | +This registers the function C<mylookup()> under the C<lookup> hook with the | |
2685 | +private context given by the variable C<mycontext>. And it registers the | |
2686 | +function C<mysetup()> under the C<setup> hook without any context. Same for | |
2687 | +C<myread> and C<mylogit>. | |
2688 | + | |
2689 | +=item B<4. Usage> | |
2690 | + | |
2691 | +Finally use the hooks, i.e. instead of using direct function calls like | |
2692 | + | |
2693 | + rc = mylookup(a1, a2); | |
2694 | + rc = mysetup(a1, a2); | |
2695 | + myread(a1); | |
2696 | + mylogit(a1); | |
2697 | + | |
2698 | +you now use: | |
2699 | + | |
2700 | + ap_hook_call("lookup", &rc, a1, a2); | |
2701 | + ap_hook_call("setup", &rc, a1, a2); | |
2702 | + ap_hook_call("read", a1); | |
2703 | + ap_hook_call("logit", a1); | |
2704 | + | |
2705 | +which are internally translated to: | |
2706 | + | |
2707 | + rc = mylookup(a1, a2, mycontext); | |
2708 | + rc = mysetup(a1, a2); | |
2709 | + myread(a1); | |
2710 | + mylogit(a1); | |
2711 | + | |
2712 | +Notice two things here: First the context (C<mycontext>) for the C<mylookup()> | |
2713 | +function is automatically added by the hook mechanism. And it is a different | |
2714 | +(and not fixed) context for each registered function, of course. Second, | |
2715 | +return values always have to be pushed into variables and a pointer to them | |
2716 | +has to be given as the second argument to C<ap_hook_call> (except for | |
2717 | +functions which have a void return type, of course). | |
2718 | + | |
2719 | +BTW, the return value of C<ap_hook_call()> is always C<TRUE> or C<FALSE>. | |
2720 | +C<TRUE> when at least one function call was successful (always the case for | |
2721 | +C<AP_HOOK_TOPMOST> and C<AP_HOOK_ALL>). C<FALSE> when all functions | |
2722 | +returned the decline value or no functions are registered at all. | |
2723 | + | |
2724 | +=back | |
2725 | + | |
2726 | +=head1 RESTRICTIONS | |
2727 | + | |
2728 | +To make the hook implementation efficient and to not bloat up the code too | |
2729 | +much a few restrictions have to make: | |
2730 | + | |
2731 | +=over 3 | |
2732 | + | |
2733 | +=item 1. | |
2734 | + | |
2735 | +Only function calls with up to 4 arguments are implemented. When more are | |
2736 | +needed you can either extend the hook implementation by using more bits for | |
2737 | +the signature configuration or you can do a workaround when the function is | |
2738 | +your own one: Put the remaining (N-4-1) arguments into a structure and pass | |
2739 | +only a pointer (one argument) as the forth argument. | |
2740 | + | |
2741 | +=item 2. | |
2742 | + | |
2743 | +Only the following ANSI C variable types are supported: | |
2744 | + | |
2745 | + - For the return value: | |
2746 | + void (= none), char, int, float, double, ptr (= void *) | |
2747 | + - For the arguments: | |
2748 | + ctx (= context), char, int, float, double, ptr (= void *) | |
2749 | + | |
2750 | +This means in theory that 6^5 (=7776) signature combinations are possible. But | |
2751 | +because we don't need all of them inside Apache and it would bloat up the code | |
2752 | +too dramatically we implement only a subset of those combinations. The | |
2753 | +implemented signatures can be specified inside C<ap_hook.c> and the | |
2754 | +corresponding code can be automatically generated by running ``C<perl | |
2755 | +ap_hook.c>'' (yeah, no joke ;-). So when you need a hook with a different | |
2756 | +still not implemented signature you either have to again use a workaround as | |
2757 | +above (i.e. use a structure) or just add the signature to the C<ap_hook.c> | |
2758 | +file. | |
2759 | + | |
2760 | +=head1 EXAMPLE | |
2761 | + | |
2762 | +We want to call `C<ssize_t read(int, void *, size_t)>' through hooks in order | |
2763 | +to allow modules to override this call. So, somewhere we have a replacement | |
2764 | +function for C<read()> defined (same signature, of course): | |
2765 | + | |
2766 | + ssize_t my_read(int, void *, size_t); | |
2767 | + | |
2768 | +We now configure a C<read> hook. Here the C<AP_HOOK_SIGx()> macro defines the | |
2769 | +signature of the C<read()>-like callback functions and has to match the | |
2770 | +prototype of C<read()>. But we have to replace typedefs with the physical | |
2771 | +underlaying ANSI C types. And C<AP_HOOK_DECLINE()> sets the return value of | |
2772 | +the read()-like functions which forces the next hook to be called (here -1). | |
2773 | +And we register the original C<read()> function as the default hook. | |
2774 | + | |
2775 | + ap_hook_configure("read", | |
2776 | + AP_HOOK_SIG4(int,int,ptr,int), | |
2777 | + AP_HOOK_DECLINE(-1)); | |
2778 | + ap_hook_register("read", read); | |
2779 | + | |
2780 | +Now a module wants to override the C<read()> call and registers the | |
2781 | +C<my_read()> function: | |
2782 | + | |
2783 | + ap_hook_register("read", my_read); | |
2784 | + | |
2785 | +The function logically gets pushed onto a stack, so the execution order is the | |
2786 | +reverse registering order, i.e. I<last registered - first called>. Now we can | |
2787 | +replace the standard C<read()> call | |
2788 | + | |
2789 | + bytes = read(fd, buf, bufsize); | |
2790 | + if (bytes == -1) | |
2791 | + ...error... | |
2792 | + | |
2793 | +with the hook based call: | |
2794 | + | |
2795 | + rc = ap_hook_call("read", &bytes, fd, buf, bufsize); | |
2796 | + if (rc == FALSE) | |
2797 | + ...error... | |
2798 | + | |
2799 | +Now internally the following is done: The call `C<bytes = my_read(fd, buf, | |
2800 | +bufsize)>' is done. When it returns not -1 (the decline value) nothing | |
2801 | +more is done. But when C<my_read()> returns -1 the next function is tried: | |
2802 | +`C<bytes = read(fd, buf, bufsize)>'. When this one also returns -1 you get | |
2803 | +`rc == FALSE'. When it finally returns not -1 you get `rc == TRUE'. | |
2804 | + | |
2805 | +=head1 SEE ALSO | |
2806 | + | |
2807 | +ap_ctx(3) | |
2808 | + | |
2809 | +=head1 HISTORY | |
2810 | + | |
2811 | +The ap_hook(3) interface was originally designed and implemented in October | |
2812 | +1998 by Ralf S. Engelschall as part of the mod_ssl project. | |
2813 | + | |
2814 | +=head1 AUTHOR | |
2815 | + | |
2816 | + Ralf S. Engelschall | |
2817 | + rse@engelschall.com | |
2818 | + www.engelschall.com | |
2819 | + | |
2820 | +=cut | |
2821 | +*/ | |
2822 | diff -Nru apache_1.3.9/src/include/ap_mm.h apache_1.3.9.EAPI/src/include/ap_mm.h | |
2823 | --- apache_1.3.9/src/include/ap_mm.h Thu Jan 1 01:00:00 1970 | |
2824 | +++ apache_1.3.9.EAPI/src/include/ap_mm.h Wed Dec 29 21:25:56 1999 | |
2825 | @@ -0,0 +1,130 @@ | |
2826 | +/* ==================================================================== | |
2827 | + * Copyright (c) 1999 The Apache Group. All rights reserved. | |
2828 | + * | |
2829 | + * Redistribution and use in source and binary forms, with or without | |
2830 | + * modification, are permitted provided that the following conditions | |
2831 | + * are met: | |
2832 | + * | |
2833 | + * 1. Redistributions of source code must retain the above copyright | |
2834 | + * notice, this list of conditions and the following disclaimer. | |
2835 | + * | |
2836 | + * 2. Redistributions in binary form must reproduce the above copyright | |
2837 | + * notice, this list of conditions and the following disclaimer in | |
2838 | + * the documentation and/or other materials provided with the | |
2839 | + * distribution. | |
2840 | + * | |
2841 | + * 3. All advertising materials mentioning features or use of this | |
2842 | + * software must display the following acknowledgment: | |
2843 | + * "This product includes software developed by the Apache Group | |
2844 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
2845 | + * | |
2846 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
2847 | + * endorse or promote products derived from this software without | |
2848 | + * prior written permission. For written permission, please contact | |
2849 | + * apache@apache.org. | |
2850 | + * | |
2851 | + * 5. Products derived from this software may not be called "Apache" | |
2852 | + * nor may "Apache" appear in their names without prior written | |
2853 | + * permission of the Apache Group. | |
2854 | + * | |
2855 | + * 6. Redistributions of any form whatsoever must retain the following | |
2856 | + * acknowledgment: | |
2857 | + * "This product includes software developed by the Apache Group | |
2858 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
2859 | + * | |
2860 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
2861 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
2862 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
2863 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
2864 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
2865 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
2866 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
2867 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
2868 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
2869 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
2870 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
2871 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
2872 | + * ==================================================================== | |
2873 | + * | |
2874 | + * This software consists of voluntary contributions made by many | |
2875 | + * individuals on behalf of the Apache Group and was originally based | |
2876 | + * on public domain software written at the National Center for | |
2877 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
2878 | + * For more information on the Apache Group and the Apache HTTP server | |
2879 | + * project, please see <http://www.apache.org/>. | |
2880 | + */ | |
2881 | + | |
2882 | +/* | |
2883 | +** | |
2884 | +** ap_mm.h -- wrapper code for MM shared memory library | |
2885 | +** | |
2886 | +*/ | |
2887 | + | |
2888 | +#ifdef EAPI | |
2889 | + | |
2890 | +#ifndef AP_MM_H | |
2891 | +#define AP_MM_H 1 | |
2892 | + | |
2893 | +#ifndef FALSE | |
2894 | +#define FALSE 0 | |
2895 | +#define TRUE !FALSE | |
2896 | +#endif | |
2897 | + | |
2898 | +API_EXPORT(int) ap_mm_useable(void); | |
2899 | + | |
2900 | +typedef void AP_MM; | |
2901 | +typedef enum { AP_MM_LOCK_RD, AP_MM_LOCK_RW } ap_mm_lock_mode; | |
2902 | + | |
2903 | +/* Global Malloc-Replacement API */ | |
2904 | +API_EXPORT(int) ap_MM_create(size_t size, char *file); | |
2905 | +API_EXPORT(int) ap_MM_permission(mode_t mode, uid_t owner, gid_t group); | |
2906 | +API_EXPORT(void) ap_MM_destroy(void); | |
2907 | +API_EXPORT(int) ap_MM_lock(ap_mm_lock_mode mode); | |
2908 | +API_EXPORT(int) ap_MM_unlock(void); | |
2909 | +API_EXPORT(void *) ap_MM_malloc(size_t size); | |
2910 | +API_EXPORT(void *) ap_MM_realloc(void *ptr, size_t size); | |
2911 | +API_EXPORT(void) ap_MM_free(void *ptr); | |
2912 | +API_EXPORT(void *) ap_MM_calloc(size_t number, size_t size); | |
2913 | +API_EXPORT(char *) ap_MM_strdup(const char *str); | |
2914 | +API_EXPORT(size_t) ap_MM_sizeof(void *ptr); | |
2915 | +API_EXPORT(size_t) ap_MM_maxsize(void); | |
2916 | +API_EXPORT(size_t) ap_MM_available(void); | |
2917 | +API_EXPORT(char *) ap_MM_error(void); | |
2918 | + | |
2919 | +/* Standard Malloc-Style API */ | |
2920 | +API_EXPORT(AP_MM *) ap_mm_create(size_t size, char *file); | |
2921 | +API_EXPORT(int) ap_mm_permission(AP_MM *mm, mode_t mode, uid_t owner, gid_t group); | |
2922 | +API_EXPORT(void) ap_mm_destroy(AP_MM *mm); | |
2923 | +API_EXPORT(int) ap_mm_lock(AP_MM *mm, ap_mm_lock_mode mode); | |
2924 | +API_EXPORT(int) ap_mm_unlock(AP_MM *mm); | |
2925 | +API_EXPORT(void *) ap_mm_malloc(AP_MM *mm, size_t size); | |
2926 | +API_EXPORT(void *) ap_mm_realloc(AP_MM *mm, void *ptr, size_t size); | |
2927 | +API_EXPORT(void) ap_mm_free(AP_MM *mm, void *ptr); | |
2928 | +API_EXPORT(void *) ap_mm_calloc(AP_MM *mm, size_t number, size_t size); | |
2929 | +API_EXPORT(char *) ap_mm_strdup(AP_MM *mm, const char *str); | |
2930 | +API_EXPORT(size_t) ap_mm_sizeof(AP_MM *mm, void *ptr); | |
2931 | +API_EXPORT(size_t) ap_mm_maxsize(void); | |
2932 | +API_EXPORT(size_t) ap_mm_available(AP_MM *mm); | |
2933 | +API_EXPORT(char *) ap_mm_error(void); | |
2934 | +API_EXPORT(void) ap_mm_display_info(AP_MM *mm); | |
2935 | + | |
2936 | +/* Low-Level Shared Memory API */ | |
2937 | +API_EXPORT(void *) ap_mm_core_create(size_t size, char *file); | |
2938 | +API_EXPORT(int) ap_mm_core_permission(void *core, mode_t mode, uid_t owner, gid_t group); | |
2939 | +API_EXPORT(void) ap_mm_core_delete(void *core); | |
2940 | +API_EXPORT(size_t) ap_mm_core_size(void *core); | |
2941 | +API_EXPORT(int) ap_mm_core_lock(void *core, ap_mm_lock_mode mode); | |
2942 | +API_EXPORT(int) ap_mm_core_unlock(void *core); | |
2943 | +API_EXPORT(size_t) ap_mm_core_maxsegsize(void); | |
2944 | +API_EXPORT(size_t) ap_mm_core_align2page(size_t size); | |
2945 | +API_EXPORT(size_t) ap_mm_core_align2word(size_t size); | |
2946 | + | |
2947 | +/* Internal Library API */ | |
2948 | +API_EXPORT(void) ap_mm_lib_error_set(unsigned int, const char *str); | |
2949 | +API_EXPORT(char *) ap_mm_lib_error_get(void); | |
2950 | +API_EXPORT(int) ap_mm_lib_version(void); | |
2951 | + | |
2952 | +#endif /* AP_MM_H */ | |
2953 | + | |
2954 | +#endif /* EAPI */ | |
2955 | + | |
2956 | diff -Nru apache_1.3.9/src/include/ap_mmn.h apache_1.3.9.EAPI/src/include/ap_mmn.h | |
2957 | --- apache_1.3.9/src/include/ap_mmn.h Wed Dec 29 22:03:42 1999 | |
2958 | +++ apache_1.3.9.EAPI/src/include/ap_mmn.h Wed Dec 29 21:25:56 1999 | |
2959 | @@ -228,7 +228,23 @@ | |
2960 | * ap_pbase64decode(), ap_pbase64encode() | |
2961 | */ | |
2962 | ||
2963 | +/* | |
2964 | + * Under Extended API situations we replace the magic cookie "AP13" with | |
2965 | + * "EAPI" to let us distinguish between the EAPI module structure (which | |
2966 | + * contain additional pointers at the end) and standard module structures | |
2967 | + * (which lack at least NULL's for the pointers at the end). This is | |
2968 | + * important because standard ("AP13") modules would dump core when we | |
2969 | + * dispatch over the additional hooks because NULL's are missing at the end of | |
2970 | + * the module structure. See also the code in mod_so for details on loading | |
2971 | + * (we accept both "AP13" and "EAPI"). | |
2972 | + */ | |
2973 | +#ifdef EAPI | |
2974 | +#define MODULE_MAGIC_COOKIE_AP13 0x41503133UL /* "AP13" */ | |
2975 | +#define MODULE_MAGIC_COOKIE_EAPI 0x45415049UL /* "EAPI" */ | |
2976 | +#define MODULE_MAGIC_COOKIE MODULE_MAGIC_COOKIE_EAPI | |
2977 | +#else | |
2978 | #define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */ | |
2979 | +#endif | |
2980 | ||
2981 | #ifndef MODULE_MAGIC_NUMBER_MAJOR | |
2982 | #define MODULE_MAGIC_NUMBER_MAJOR 19990320 | |
2983 | diff -Nru apache_1.3.9/src/include/buff.h apache_1.3.9.EAPI/src/include/buff.h | |
2984 | --- apache_1.3.9/src/include/buff.h Wed Dec 29 22:03:42 1999 | |
2985 | +++ apache_1.3.9.EAPI/src/include/buff.h Wed Dec 29 21:25:56 1999 | |
2986 | @@ -124,6 +124,10 @@ | |
2987 | /* transport handle, for RPC binding handle or some such */ | |
2988 | void *t_handle; | |
2989 | ||
2990 | +#ifdef EAPI | |
2991 | + ap_ctx *ctx; | |
2992 | +#endif /* EAPI */ | |
2993 | + | |
2994 | #ifdef B_SFIO | |
2995 | Sfio_t *sf_in; | |
2996 | Sfio_t *sf_out; | |
2997 | @@ -175,6 +179,10 @@ | |
2998 | /* Internal routines */ | |
2999 | API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb); | |
3000 | API_EXPORT(int) ap_bfilbuf(BUFF *fb); | |
3001 | + | |
3002 | +#ifdef EAPI | |
3003 | +#define ap_bpeekc(fb) ( ((fb)->incnt == 0) ? EOF : *((fb)->inptr) ) | |
3004 | +#endif | |
3005 | ||
3006 | #ifndef CHARSET_EBCDIC | |
3007 | ||
3008 | diff -Nru apache_1.3.9/src/include/http_conf_globals.h apache_1.3.9.EAPI/src/include/http_conf_globals.h | |
3009 | --- apache_1.3.9/src/include/http_conf_globals.h Wed Dec 29 22:03:42 1999 | |
3010 | +++ apache_1.3.9.EAPI/src/include/http_conf_globals.h Wed Dec 29 21:25:56 1999 | |
3011 | @@ -89,6 +89,9 @@ | |
3012 | extern int ap_listenbacklog; | |
3013 | extern int ap_dump_settings; | |
3014 | extern API_VAR_EXPORT int ap_extended_status; | |
3015 | +#ifdef EAPI | |
3016 | +extern API_VAR_EXPORT ap_ctx *ap_global_ctx; | |
3017 | +#endif /* EAPI */ | |
3018 | ||
3019 | extern char *ap_pid_fname; | |
3020 | extern char *ap_scoreboard_fname; | |
3021 | diff -Nru apache_1.3.9/src/include/http_config.h apache_1.3.9.EAPI/src/include/http_config.h | |
3022 | --- apache_1.3.9/src/include/http_config.h Wed Dec 29 22:03:42 1999 | |
3023 | +++ apache_1.3.9.EAPI/src/include/http_config.h Wed Dec 29 21:25:56 1999 | |
3024 | @@ -275,6 +275,65 @@ | |
3025 | void (*child_exit) (server_rec *, pool *); | |
3026 | #endif | |
3027 | int (*post_read_request) (request_rec *); | |
3028 | + | |
3029 | +#ifdef EAPI | |
3030 | + /* | |
3031 | + * ANSI C guarantees us that we can at least _extend_ the module structure | |
3032 | + * with additional hooks without the need to change all existing modules. | |
3033 | + * Because: ``If there are fewer initializers in the list than members of | |
3034 | + * the structure, the trailing members are initialized with 0.'' (The C | |
3035 | + * Programming Language, 2nd Ed., A8.7 Initialization). So we just | |
3036 | + * have to put our additional hooks here: | |
3037 | + * | |
3038 | + * add_module: | |
3039 | + * Called from within ap_add_module() right after the module structure | |
3040 | + * was linked into the Apache internal module list. It is mainly | |
3041 | + * intended to be used to define configuration defines (<IfDefine>) | |
3042 | + * which have to be available directly after a LoadModule/AddModule. | |
3043 | + * Actually this is the earliest possible hook a module can use. | |
3044 | + * | |
3045 | + * remove_module: | |
3046 | + * Called from within ap_remove_module() right before the module | |
3047 | + * structure is kicked out from the Apache internal module list. | |
3048 | + * Actually this is last possible hook a module can use and exists for | |
3049 | + * consistency with the add_module hook. | |
3050 | + * | |
3051 | + * rewrite_command: | |
3052 | + * Called right after a configuration directive line was read and | |
3053 | + * before it is processed. It is mainly intended to be used for | |
3054 | + * rewriting directives in order to provide backward compatibility to | |
3055 | + * old directive variants. | |
3056 | + * | |
3057 | + * new_connection: | |
3058 | + * Called from within the internal new_connection() function, right | |
3059 | + * after the conn_rec structure for the new established connection was | |
3060 | + * created and before Apache starts processing the request with | |
3061 | + * ap_read_request(). It is mainly intended to be used to setup/run | |
3062 | + * connection dependent things like sending start headers for | |
3063 | + * on-the-fly compression, etc. | |
3064 | + * | |
3065 | + * close_connection: | |
3066 | + * Called from within the Apache dispatching loop just before any | |
3067 | + * ap_bclose() is performed on the socket connection, but a long time | |
3068 | + * before any pool cleanups are done for the connection (which can be | |
3069 | + * too late for some applications). It is mainly intended to be used | |
3070 | + * to close/finalize connection dependent things like sending end | |
3071 | + * headers for on-the-fly compression, etc. | |
3072 | + */ | |
3073 | +#ifdef ULTRIX_BRAIN_DEATH | |
3074 | + void (*add_module) (); | |
3075 | + void (*remove_module) (); | |
3076 | + char *(*rewrite_command) (); | |
3077 | + void (*new_connection) (); | |
3078 | + void (*close_connection) (); | |
3079 | +#else | |
3080 | + void (*add_module) (struct module_struct *); | |
3081 | + void (*remove_module) (struct module_struct *); | |
3082 | + char *(*rewrite_command) (cmd_parms *, void *config, const char *); | |
3083 | + void (*new_connection) (conn_rec *); | |
3084 | + void (*close_connection) (conn_rec *); | |
3085 | +#endif | |
3086 | +#endif /* EAPI */ | |
3087 | } module; | |
3088 | ||
3089 | /* Initializer for the first few module slots, which are only | |
3090 | diff -Nru apache_1.3.9/src/include/http_main.h apache_1.3.9.EAPI/src/include/http_main.h | |
3091 | --- apache_1.3.9/src/include/http_main.h Wed Dec 29 22:03:42 1999 | |
3092 | +++ apache_1.3.9.EAPI/src/include/http_main.h Wed Dec 29 21:25:56 1999 | |
3093 | @@ -124,7 +124,11 @@ | |
3094 | API_EXPORT(void) ap_sync_scoreboard_image(void); | |
3095 | int ap_update_child_status(int child_num, int status, request_rec *r); | |
3096 | void ap_time_process_request(int child_num, int status); | |
3097 | +#ifdef EAPI | |
3098 | +API_EXPORT(unsigned int) ap_set_callback_and_alarm(void (*fn) (int), int x); | |
3099 | +#else | |
3100 | unsigned int ap_set_callback_and_alarm(void (*fn) (int), int x); | |
3101 | +#endif | |
3102 | API_EXPORT(int) ap_check_alarm(void); | |
3103 | ||
3104 | #ifndef NO_OTHER_CHILD | |
3105 | diff -Nru apache_1.3.9/src/include/httpd.h apache_1.3.9.EAPI/src/include/httpd.h | |
3106 | --- apache_1.3.9/src/include/httpd.h Wed Dec 29 22:03:42 1999 | |
3107 | +++ apache_1.3.9.EAPI/src/include/httpd.h Wed Dec 29 21:25:56 1999 | |
3108 | @@ -69,7 +69,19 @@ | |
3109 | /* Headers in which EVERYONE has an interest... */ | |
3110 | ||
3111 | #include "ap_config.h" | |
3112 | +#ifdef EAPI | |
3113 | +#include "ap_mm.h" | |
3114 | +#endif | |
3115 | #include "alloc.h" | |
3116 | +/* | |
3117 | + * Include the Extended API headers. | |
3118 | + * Don't move the position. It has to be after alloc.h because it uses the | |
3119 | + * pool stuff but before buff.h because the buffer stuff uses the EAPI, too. | |
3120 | + */ | |
3121 | +#ifdef EAPI | |
3122 | +#include "ap_hook.h" | |
3123 | +#include "ap_ctx.h" | |
3124 | +#endif /* EAPI */ | |
3125 | #include "buff.h" | |
3126 | #include "ap.h" | |
3127 | ||
3128 | @@ -138,8 +150,13 @@ | |
3129 | #define DEFAULT_HTTP_PORT 80 | |
3130 | #define DEFAULT_HTTPS_PORT 443 | |
3131 | #define ap_is_default_port(port,r) ((port) == ap_default_port(r)) | |
3132 | +#ifdef EAPI | |
3133 | +#define ap_http_method(r) (ap_ctx_get((r)->ctx, "ap::http::method") != NULL ? ((char *)ap_ctx_get((r)->ctx, "ap::http::method")) : "http") | |
3134 | +#define ap_default_port(r) (ap_ctx_get((r)->ctx, "ap::default::port") != NULL ? atoi((char *)ap_ctx_get((r)->ctx, "ap::default::port")) : DEFAULT_HTTP_PORT) | |
3135 | +#else /* EAPI */ | |
3136 | #define ap_http_method(r) "http" | |
3137 | #define ap_default_port(r) DEFAULT_HTTP_PORT | |
3138 | +#endif /* EAPI */ | |
3139 | ||
3140 | /* --------- Default user name and group name running standalone ---------- */ | |
3141 | /* --- These may be specified as numbers by placing a # before a number --- */ | |
3142 | @@ -351,6 +368,19 @@ | |
3143 | #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000 | |
3144 | #endif | |
3145 | ||
3146 | +/* | |
3147 | + * Unix only: | |
3148 | + * Path to Shared Memory Files | |
3149 | + */ | |
3150 | +#ifdef EAPI | |
3151 | +#ifndef EAPI_MM_CORE_PATH | |
3152 | +#define EAPI_MM_CORE_PATH "logs/mm" | |
3153 | +#endif | |
3154 | +#ifndef EAPI_MM_CORE_MAXSIZE | |
3155 | +#define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */ | |
3156 | +#endif | |
3157 | +#endif | |
3158 | + | |
3159 | /* Number of requests to try to handle in a single process. If <= 0, | |
3160 | * the children don't die off. That's the default here, since I'm still | |
3161 | * interested in finding and stanching leaks. | |
3162 | @@ -430,6 +460,9 @@ | |
3163 | API_EXPORT(const char *) ap_get_server_version(void); | |
3164 | API_EXPORT(void) ap_add_version_component(const char *component); | |
3165 | API_EXPORT(const char *) ap_get_server_built(void); | |
3166 | +#ifdef EAPI | |
3167 | +API_EXPORT(void) ap_add_config_define(const char *define); | |
3168 | +#endif /* EAPI */ | |
3169 | ||
3170 | /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta | |
3171 | * Always increases along the same track as the source branch. | |
3172 | @@ -801,6 +834,10 @@ | |
3173 | * record to improve 64bit alignment the next time we need to break | |
3174 | * binary compatibility for some other reason. | |
3175 | */ | |
3176 | + | |
3177 | +#ifdef EAPI | |
3178 | + ap_ctx *ctx; | |
3179 | +#endif /* EAPI */ | |
3180 | }; | |
3181 | ||
3182 | ||
3183 | @@ -849,6 +886,9 @@ | |
3184 | char *local_host; /* used for ap_get_server_name when | |
3185 | * UseCanonicalName is set to DNS | |
3186 | * (ignores setting of HostnameLookups) */ | |
3187 | +#ifdef EAPI | |
3188 | + ap_ctx *ctx; | |
3189 | +#endif /* EAPI */ | |
3190 | }; | |
3191 | ||
3192 | /* Per-vhost config... */ | |
3193 | @@ -921,6 +961,10 @@ | |
3194 | int limit_req_line; /* limit on size of the HTTP request line */ | |
3195 | int limit_req_fieldsize; /* limit on size of any request header field */ | |
3196 | int limit_req_fields; /* limit on number of request header fields */ | |
3197 | + | |
3198 | +#ifdef EAPI | |
3199 | + ap_ctx *ctx; | |
3200 | +#endif /* EAPI */ | |
3201 | }; | |
3202 | ||
3203 | /* These are more like real hosts than virtual hosts */ | |
3204 | diff -Nru apache_1.3.9/src/main/alloc.c apache_1.3.9.EAPI/src/main/alloc.c | |
3205 | --- apache_1.3.9/src/main/alloc.c Wed Dec 29 22:03:42 1999 | |
3206 | +++ apache_1.3.9.EAPI/src/main/alloc.c Wed Dec 29 21:25:56 1999 | |
3207 | @@ -63,6 +63,10 @@ | |
3208 | */ | |
3209 | ||
3210 | #include "httpd.h" | |
3211 | +#ifdef EAPI | |
3212 | +#include "http_config.h" | |
3213 | +#include "http_conf_globals.h" | |
3214 | +#endif | |
3215 | #include "multithread.h" | |
3216 | #include "http_log.h" | |
3217 | ||
3218 | @@ -137,6 +141,10 @@ | |
3219 | #define BLOCK_MINALLOC 0 | |
3220 | #endif | |
3221 | ||
3222 | +#if defined(EAPI) && defined(EAPI_MM) | |
3223 | +static AP_MM *mm = NULL; | |
3224 | +#endif | |
3225 | + | |
3226 | /***************************************************************** | |
3227 | * | |
3228 | * Managing free storage blocks... | |
3229 | @@ -165,6 +173,9 @@ | |
3230 | char *endp; | |
3231 | union block_hdr *next; | |
3232 | char *first_avail; | |
3233 | +#if defined(EAPI) && defined(EAPI_MM) | |
3234 | + int is_shm; | |
3235 | +#endif | |
3236 | #ifdef POOL_DEBUG | |
3237 | union block_hdr *global_next; | |
3238 | struct pool *owning_pool; | |
3239 | @@ -215,7 +226,11 @@ | |
3240 | /* Get a completely new block from the system pool. Note that we rely on | |
3241 | malloc() to provide aligned memory. */ | |
3242 | ||
3243 | +#if defined(EAPI) && defined(EAPI_MM) | |
3244 | +static union block_hdr *malloc_block(int size, int is_shm) | |
3245 | +#else | |
3246 | static union block_hdr *malloc_block(int size) | |
3247 | +#endif | |
3248 | { | |
3249 | union block_hdr *blok; | |
3250 | ||
3251 | @@ -229,12 +244,20 @@ | |
3252 | ++num_malloc_calls; | |
3253 | num_malloc_bytes += size + sizeof(union block_hdr); | |
3254 | #endif | |
3255 | +#if defined(EAPI) && defined(EAPI_MM) | |
3256 | + if (is_shm) | |
3257 | + blok = (union block_hdr *)ap_mm_malloc(mm, size + sizeof(union block_hdr)); | |
3258 | + else | |
3259 | +#endif | |
3260 | blok = (union block_hdr *) malloc(size + sizeof(union block_hdr)); | |
3261 | if (blok == NULL) { | |
3262 | fprintf(stderr, "Ouch! malloc failed in malloc_block()\n"); | |
3263 | exit(1); | |
3264 | } | |
3265 | debug_fill(blok, size + sizeof(union block_hdr)); | |
3266 | +#if defined(EAPI) && defined(EAPI_MM) | |
3267 | + blok->h.is_shm = is_shm; | |
3268 | +#endif | |
3269 | blok->h.next = NULL; | |
3270 | blok->h.first_avail = (char *) (blok + 1); | |
3271 | blok->h.endp = size + blok->h.first_avail; | |
3272 | @@ -295,6 +318,10 @@ | |
3273 | if (blok == NULL) | |
3274 | return; /* Sanity check --- freeing empty pool? */ | |
3275 | ||
3276 | +#if defined(EAPI) && defined(EAPI_MM) | |
3277 | + if (blok->h.is_shm) | |
3278 | + (void)ap_mm_lock(mm, AP_MM_LOCK_RW); | |
3279 | +#endif | |
3280 | (void) ap_acquire_mutex(alloc_mutex); | |
3281 | old_free_list = block_freelist; | |
3282 | block_freelist = blok; | |
3283 | @@ -341,6 +368,10 @@ | |
3284 | #endif | |
3285 | ||
3286 | (void) ap_release_mutex(alloc_mutex); | |
3287 | +#if defined(EAPI) && defined(EAPI_MM) | |
3288 | + if (blok->h.is_shm) | |
3289 | + (void)ap_mm_unlock(mm); | |
3290 | +#endif | |
3291 | #endif | |
3292 | } | |
3293 | ||
3294 | @@ -349,7 +380,11 @@ | |
3295 | * if necessary. Must be called with alarms blocked. | |
3296 | */ | |
3297 | ||
3298 | +#if defined(EAPI) && defined(EAPI_MM) | |
3299 | +static union block_hdr *new_block(int min_size, int is_shm) | |
3300 | +#else | |
3301 | static union block_hdr *new_block(int min_size) | |
3302 | +#endif | |
3303 | { | |
3304 | union block_hdr **lastptr = &block_freelist; | |
3305 | union block_hdr *blok = block_freelist; | |
3306 | @@ -359,7 +394,12 @@ | |
3307 | */ | |
3308 | ||
3309 | while (blok != NULL) { | |
3310 | +#if defined(EAPI) && defined(EAPI_MM) | |
3311 | + if (blok->h.is_shm == is_shm && | |
3312 | + min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) { | |
3313 | +#else | |
3314 | if (min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) { | |
3315 | +#endif | |
3316 | *lastptr = blok->h.next; | |
3317 | blok->h.next = NULL; | |
3318 | debug_verify_filled(blok->h.first_avail, blok->h.endp, | |
3319 | @@ -375,7 +415,11 @@ | |
3320 | /* Nope. */ | |
3321 | ||
3322 | min_size += BLOCK_MINFREE; | |
3323 | +#if defined(EAPI) && defined(EAPI_MM) | |
3324 | + blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm); | |
3325 | +#else | |
3326 | blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC); | |
3327 | +#endif | |
3328 | return blok; | |
3329 | } | |
3330 | ||
3331 | @@ -425,6 +469,9 @@ | |
3332 | #ifdef POOL_DEBUG | |
3333 | struct pool *joined; | |
3334 | #endif | |
3335 | +#if defined(EAPI) && defined(EAPI_MM) | |
3336 | + int is_shm; | |
3337 | +#endif | |
3338 | }; | |
3339 | ||
3340 | static pool *permanent_pool; | |
3341 | @@ -439,16 +486,28 @@ | |
3342 | #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ)) | |
3343 | #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ) | |
3344 | ||
3345 | +#if defined(EAPI) && defined(EAPI_MM) | |
3346 | +static struct pool *make_sub_pool_internal(struct pool *p, int is_shm) | |
3347 | +#else | |
3348 | API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p) | |
3349 | +#endif | |
3350 | { | |
3351 | union block_hdr *blok; | |
3352 | pool *new_pool; | |
3353 | ||
3354 | ap_block_alarms(); | |
3355 | ||
3356 | +#if defined(EAPI) && defined(EAPI_MM) | |
3357 | + if (is_shm) | |
3358 | + (void)ap_mm_lock(mm, AP_MM_LOCK_RW); | |
3359 | +#endif | |
3360 | (void) ap_acquire_mutex(alloc_mutex); | |
3361 | ||
3362 | +#if defined(EAPI) && defined(EAPI_MM) | |
3363 | + blok = new_block(POOL_HDR_BYTES, is_shm); | |
3364 | +#else | |
3365 | blok = new_block(POOL_HDR_BYTES); | |
3366 | +#endif | |
3367 | new_pool = (pool *) blok->h.first_avail; | |
3368 | blok->h.first_avail += POOL_HDR_BYTES; | |
3369 | #ifdef POOL_DEBUG | |
3370 | @@ -467,12 +526,38 @@ | |
3371 | p->sub_pools = new_pool; | |
3372 | } | |
3373 | ||
3374 | +#if defined(EAPI) && defined(EAPI_MM) | |
3375 | + new_pool->is_shm = is_shm; | |
3376 | +#endif | |
3377 | + | |
3378 | (void) ap_release_mutex(alloc_mutex); | |
3379 | +#if defined(EAPI) && defined(EAPI_MM) | |
3380 | + if (is_shm) | |
3381 | + (void)ap_mm_unlock(mm); | |
3382 | +#endif | |
3383 | ap_unblock_alarms(); | |
3384 | ||
3385 | return new_pool; | |
3386 | } | |
3387 | ||
3388 | +#if defined(EAPI) | |
3389 | +#if defined(EAPI_MM) | |
3390 | +API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p) | |
3391 | +{ | |
3392 | + return make_sub_pool_internal(p, 0); | |
3393 | +} | |
3394 | +API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p) | |
3395 | +{ | |
3396 | + return make_sub_pool_internal(p, 1); | |
3397 | +} | |
3398 | +#else | |
3399 | +API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p) | |
3400 | +{ | |
3401 | + return NULL; | |
3402 | +} | |
3403 | +#endif | |
3404 | +#endif | |
3405 | + | |
3406 | #ifdef POOL_DEBUG | |
3407 | static void stack_var_init(char *s) | |
3408 | { | |
3409 | @@ -487,6 +572,13 @@ | |
3410 | } | |
3411 | #endif | |
3412 | ||
3413 | +#if defined(EAPI) | |
3414 | +int ap_shared_pool_possible(void) | |
3415 | +{ | |
3416 | + return ap_mm_useable(); | |
3417 | +} | |
3418 | +#endif | |
3419 | + | |
3420 | #ifdef ALLOC_STATS | |
3421 | static void dump_stats(void) | |
3422 | { | |
3423 | @@ -519,14 +611,73 @@ | |
3424 | return permanent_pool; | |
3425 | } | |
3426 | ||
3427 | +#if defined(EAPI) | |
3428 | +void ap_init_alloc_shared(int early) | |
3429 | +{ | |
3430 | +#if defined(EAPI_MM) | |
3431 | + int mm_size; | |
3432 | + char *mm_path; | |
3433 | + char *err1, *err2; | |
3434 | + | |
3435 | + if (early) { | |
3436 | + /* process very early on startup */ | |
3437 | + mm_size = ap_mm_maxsize(); | |
3438 | + if (mm_size > EAPI_MM_CORE_MAXSIZE) | |
3439 | + mm_size = EAPI_MM_CORE_MAXSIZE; | |
3440 | + mm_path = ap_server_root_relative(permanent_pool, EAPI_MM_CORE_PATH); | |
3441 | + if ((mm = ap_mm_create(mm_size, mm_path)) == NULL) { | |
3442 | + fprintf(stderr, "Ouch! ap_mm_create(%d, \"%s\") failed\n", mm_size, mm_path); | |
3443 | + err1 = ap_mm_error(); | |
3444 | + if (err1 == NULL) | |
3445 | + err1 = "-unknown-"; | |
3446 | + err2 = strerror(errno); | |
3447 | + if (err2 == NULL) | |
3448 | + err2 = "-unknown-"; | |
3449 | + fprintf(stderr, "Error: MM: %s: OS: %s\n", err1, err2); | |
3450 | + abort(); | |
3451 | + exit(1); | |
3452 | + } | |
3453 | + } | |
3454 | + else { | |
3455 | + /* process a lot later on startup */ | |
3456 | +#ifdef WIN32 | |
3457 | + ap_mm_permission(mm, (_S_IREAD|_S_IWRITE), ap_user_id, -1); | |
3458 | +#else | |
3459 | + ap_mm_permission(mm, (S_IRUSR|S_IWUSR), ap_user_id, -1); | |
3460 | +#endif | |
3461 | + } | |
3462 | +#endif /* EAPI_MM */ | |
3463 | + return; | |
3464 | +} | |
3465 | + | |
3466 | +void ap_kill_alloc_shared(void) | |
3467 | +{ | |
3468 | +#if defined(EAPI_MM) | |
3469 | + if (mm != NULL) { | |
3470 | + ap_mm_destroy(mm); | |
3471 | + mm = NULL; | |
3472 | + } | |
3473 | +#endif /* EAPI_MM */ | |
3474 | + return; | |
3475 | +} | |
3476 | +#endif /* EAPI */ | |
3477 | + | |
3478 | API_EXPORT(void) ap_clear_pool(struct pool *a) | |
3479 | { | |
3480 | ap_block_alarms(); | |
3481 | ||
3482 | +#if defined(EAPI) && defined(EAPI_MM) | |
3483 | + if (a->is_shm) | |
3484 | + (void)ap_mm_lock(mm, AP_MM_LOCK_RW); | |
3485 | +#endif | |
3486 | (void) ap_acquire_mutex(alloc_mutex); | |
3487 | while (a->sub_pools) | |
3488 | ap_destroy_pool(a->sub_pools); | |
3489 | (void) ap_release_mutex(alloc_mutex); | |
3490 | +#if defined(EAPI) && defined(EAPI_MM) | |
3491 | + if (a->is_shm) | |
3492 | + (void)ap_mm_unlock(mm); | |
3493 | +#endif | |
3494 | /* Don't hold the mutex during cleanups. */ | |
3495 | run_cleanups(a->cleanups); | |
3496 | a->cleanups = NULL; | |
3497 | @@ -560,6 +711,10 @@ | |
3498 | ap_block_alarms(); | |
3499 | ap_clear_pool(a); | |
3500 | ||
3501 | +#if defined(EAPI) && defined(EAPI_MM) | |
3502 | + if (a->is_shm) | |
3503 | + (void)ap_mm_lock(mm, AP_MM_LOCK_RW); | |
3504 | +#endif | |
3505 | (void) ap_acquire_mutex(alloc_mutex); | |
3506 | if (a->parent) { | |
3507 | if (a->parent->sub_pools == a) | |
3508 | @@ -570,6 +725,10 @@ | |
3509 | a->sub_next->sub_prev = a->sub_prev; | |
3510 | } | |
3511 | (void) ap_release_mutex(alloc_mutex); | |
3512 | +#if defined(EAPI) && defined(EAPI_MM) | |
3513 | + if (a->is_shm) | |
3514 | + (void)ap_mm_unlock(mm); | |
3515 | +#endif | |
3516 | ||
3517 | free_blocks(a->first); | |
3518 | ap_unblock_alarms(); | |
3519 | @@ -584,6 +743,30 @@ | |
3520 | return bytes_in_block_list(block_freelist); | |
3521 | } | |
3522 | ||
3523 | +#if defined(EAPI) | |
3524 | +API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode) | |
3525 | +{ | |
3526 | +#if defined(EAPI_MM) | |
3527 | + if (!p->is_shm) | |
3528 | + return 1; | |
3529 | + return ap_mm_lock(mm, mode == AP_POOL_RD ? AP_MM_LOCK_RD : AP_MM_LOCK_RW); | |
3530 | +#else | |
3531 | + return 1; | |
3532 | +#endif | |
3533 | +} | |
3534 | + | |
3535 | +API_EXPORT(int) ap_release_pool(pool *p) | |
3536 | +{ | |
3537 | +#if defined(EAPI_MM) | |
3538 | + if (!p->is_shm) | |
3539 | + return 1; | |
3540 | + return ap_mm_unlock(mm); | |
3541 | +#else | |
3542 | + return 1; | |
3543 | +#endif | |
3544 | +} | |
3545 | +#endif /* EAPI */ | |
3546 | + | |
3547 | /***************************************************************** | |
3548 | * POOL_DEBUG support | |
3549 | */ | |
3550 | @@ -749,16 +932,31 @@ | |
3551 | ||
3552 | ap_block_alarms(); | |
3553 | ||
3554 | +#if defined(EAPI) && defined(EAPI_MM) | |
3555 | + if (a->is_shm) | |
3556 | + (void)ap_mm_lock(mm, AP_MM_LOCK_RW); | |
3557 | +#endif | |
3558 | (void) ap_acquire_mutex(alloc_mutex); | |
3559 | ||
3560 | +#if defined(EAPI) && defined(EAPI_MM) | |
3561 | + blok = new_block(size, a->is_shm); | |
3562 | +#else | |
3563 | blok = new_block(size); | |
3564 | +#endif | |
3565 | a->last->h.next = blok; | |
3566 | a->last = blok; | |
3567 | #ifdef POOL_DEBUG | |
3568 | blok->h.owning_pool = a; | |
3569 | #endif | |
3570 | +#if defined(EAPI) && defined(EAPI_MM) | |
3571 | + blok->h.is_shm = a->is_shm; | |
3572 | +#endif | |
3573 | ||
3574 | (void) ap_release_mutex(alloc_mutex); | |
3575 | +#if defined(EAPI) && defined(EAPI_MM) | |
3576 | + if (a->is_shm) | |
3577 | + (void)ap_mm_unlock(mm); | |
3578 | +#endif | |
3579 | ||
3580 | ap_unblock_alarms(); | |
3581 | ||
3582 | @@ -870,6 +1068,11 @@ | |
3583 | char *ptr; | |
3584 | ||
3585 | size = (char *)ps->vbuff.curpos - ps->base; | |
3586 | +#if defined(EAPI) && defined(EAPI_MM) | |
3587 | + if (ps->block->h.is_shm) | |
3588 | + ptr = ap_mm_realloc(ps->base, 2*size); | |
3589 | + else | |
3590 | +#endif | |
3591 | ptr = realloc(ps->base, 2*size); | |
3592 | if (ptr == NULL) { | |
3593 | fputs("Ouch! Out of memory!\n", stderr); | |
3594 | @@ -890,9 +1093,21 @@ | |
3595 | cur_len = strp - blok->h.first_avail; | |
3596 | ||
3597 | /* must try another blok */ | |
3598 | +#if defined(EAPI) && defined(EAPI_MM) | |
3599 | + if (blok->h.is_shm) | |
3600 | + (void)ap_mm_lock(mm, AP_MM_LOCK_RW); | |
3601 | +#endif | |
3602 | (void) ap_acquire_mutex(alloc_mutex); | |
3603 | +#if defined(EAPI) && defined(EAPI_MM) | |
3604 | + nblok = new_block(2 * cur_len, blok->h.is_shm); | |
3605 | +#else | |
3606 | nblok = new_block(2 * cur_len); | |
3607 | +#endif | |
3608 | (void) ap_release_mutex(alloc_mutex); | |
3609 | +#if defined(EAPI) && defined(EAPI_MM) | |
3610 | + if (blok->h.is_shm) | |
3611 | + (void)ap_mm_unlock(mm); | |
3612 | +#endif | |
3613 | memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len); | |
3614 | ps->vbuff.curpos = nblok->h.first_avail + cur_len; | |
3615 | /* save a byte for the NUL terminator */ | |
3616 | @@ -901,10 +1116,18 @@ | |
3617 | /* did we allocate the current blok? if so free it up */ | |
3618 | if (ps->got_a_new_block) { | |
3619 | debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail); | |
3620 | +#if defined(EAPI) && defined(EAPI_MM) | |
3621 | + if (blok->h.is_shm) | |
3622 | + (void)ap_mm_lock(mm, AP_MM_LOCK_RW); | |
3623 | +#endif | |
3624 | (void) ap_acquire_mutex(alloc_mutex); | |
3625 | blok->h.next = block_freelist; | |
3626 | block_freelist = blok; | |
3627 | (void) ap_release_mutex(alloc_mutex); | |
3628 | +#if defined(EAPI) && defined(EAPI_MM) | |
3629 | + if (blok->h.is_shm) | |
3630 | + (void)ap_mm_unlock(mm); | |
3631 | +#endif | |
3632 | } | |
3633 | ps->blok = nblok; | |
3634 | ps->got_a_new_block = 1; | |
3635 | @@ -923,6 +1146,11 @@ | |
3636 | void *ptr; | |
3637 | ||
3638 | ap_block_alarms(); | |
3639 | +#if defined(EAPI) && defined(EAPI_MM) | |
3640 | + if (p->is_shm) | |
3641 | + ps.base = ap_mm_malloc(mm, 512); | |
3642 | + else | |
3643 | +#endif | |
3644 | ps.base = malloc(512); | |
3645 | if (ps.base == NULL) { | |
3646 | fputs("Ouch! Out of memory!\n", stderr); | |
3647 | @@ -935,6 +1163,11 @@ | |
3648 | *ps.vbuff.curpos++ = '\0'; | |
3649 | ptr = ps.base; | |
3650 | /* shrink */ | |
3651 | +#if defined(EAPI) && defined(EAPI_MM) | |
3652 | + if (p->is_shm) | |
3653 | + ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr); | |
3654 | + else | |
3655 | +#endif | |
3656 | ptr = realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr); | |
3657 | if (ptr == NULL) { | |
3658 | fputs("Ouch! Out of memory!\n", stderr); | |
3659 | diff -Nru apache_1.3.9/src/main/buff.c apache_1.3.9.EAPI/src/main/buff.c | |
3660 | --- apache_1.3.9/src/main/buff.c Wed Dec 29 22:03:42 1999 | |
3661 | +++ apache_1.3.9.EAPI/src/main/buff.c Wed Dec 29 21:25:56 1999 | |
3662 | @@ -125,7 +125,11 @@ | |
3663 | select() sometimes returns 1 even though the write will block. We must work around this. | |
3664 | */ | |
3665 | ||
3666 | +#ifdef EAPI | |
3667 | +API_EXPORT(int) sendwithtimeout(int sock, const char *buf, int len, int flags) | |
3668 | +#else /* EAPI */ | |
3669 | int sendwithtimeout(int sock, const char *buf, int len, int flags) | |
3670 | +#endif /* EAPI */ | |
3671 | { | |
3672 | int iostate = 1; | |
3673 | fd_set fdset; | |
3674 | @@ -183,8 +187,11 @@ | |
3675 | return (rv); | |
3676 | } | |
3677 | ||
3678 | - | |
3679 | +#ifdef EAPI | |
3680 | +API_EXPORT(int) recvwithtimeout(int sock, char *buf, int len, int flags) | |
3681 | +#else /* EAPI */ | |
3682 | int recvwithtimeout(int sock, char *buf, int len, int flags) | |
3683 | +#endif /* EAPI */ | |
3684 | { | |
3685 | int iostate = 1; | |
3686 | fd_set fdset; | |
3687 | @@ -242,6 +249,9 @@ | |
3688 | } | |
3689 | else | |
3690 | #endif | |
3691 | +#ifdef EAPI | |
3692 | + if (!ap_hook_call("ap::buff::read", &rv, fb, buf, nbyte)) | |
3693 | +#endif /* EAPI */ | |
3694 | rv = read(fb->fd_in, buf, nbyte); | |
3695 | ||
3696 | return rv; | |
3697 | @@ -253,6 +263,9 @@ | |
3698 | ||
3699 | #if defined (WIN32) | |
3700 | if (fb->flags & B_SOCKET) { | |
3701 | +#ifdef EAPI | |
3702 | + if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte)) | |
3703 | +#endif /* EAPI */ | |
3704 | rv = recvwithtimeout(fb->fd_in, buf, nbyte, 0); | |
3705 | if (rv == SOCKET_ERROR) | |
3706 | errno = WSAGetLastError(); | |
3707 | @@ -299,6 +312,9 @@ | |
3708 | } | |
3709 | else | |
3710 | #endif | |
3711 | +#ifdef EAPI | |
3712 | + if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte)) | |
3713 | +#endif /* EAPI */ | |
3714 | #if defined (B_SFIO) | |
3715 | rv = sfwrite(fb->sf_out, buf, nbyte); | |
3716 | #else | |
3717 | @@ -314,6 +330,9 @@ | |
3718 | ||
3719 | #if defined(WIN32) | |
3720 | if (fb->flags & B_SOCKET) { | |
3721 | +#ifdef EAPI | |
3722 | + if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte)) | |
3723 | +#endif /* EAPI */ | |
3724 | rv = sendwithtimeout(fb->fd, buf, nbyte, 0); | |
3725 | if (rv == SOCKET_ERROR) | |
3726 | errno = WSAGetLastError(); | |
3727 | @@ -394,6 +413,10 @@ | |
3728 | (size_t) SF_UNBOUND, 1, SF_WRITE); | |
3729 | #endif | |
3730 | ||
3731 | +#ifdef EAPI | |
3732 | + fb->ctx = ap_ctx_new(p); | |
3733 | +#endif /* EAPI */ | |
3734 | + | |
3735 | return fb; | |
3736 | } | |
3737 | ||
3738 | @@ -1051,6 +1074,9 @@ | |
3739 | i = 0; | |
3740 | while (i < nvec) { | |
3741 | do | |
3742 | +#ifdef EAPI | |
3743 | + if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i)) | |
3744 | +#endif /* EAPI */ | |
3745 | rv = writev(fb->fd, &vec[i], nvec - i); | |
3746 | while (rv == -1 && (errno == EINTR || errno == EAGAIN) | |
3747 | && !(fb->flags & B_EOUT)); | |
3748 | diff -Nru apache_1.3.9/src/main/http_config.c apache_1.3.9.EAPI/src/main/http_config.c | |
3749 | --- apache_1.3.9/src/main/http_config.c Wed Dec 29 22:03:42 1999 | |
3750 | +++ apache_1.3.9.EAPI/src/main/http_config.c Wed Dec 29 21:25:56 1999 | |
3751 | @@ -583,6 +583,20 @@ | |
3752 | m->name = tmp; | |
3753 | } | |
3754 | #endif /*_OSD_POSIX*/ | |
3755 | + | |
3756 | +#ifdef EAPI | |
3757 | + /* | |
3758 | + * Invoke the `add_module' hook inside the now existing set | |
3759 | + * of modules to let them all now that this module was added. | |
3760 | + */ | |
3761 | + { | |
3762 | + module *m2; | |
3763 | + for (m2 = top_module; m2 != NULL; m2 = m2->next) | |
3764 | + if (m2->magic == MODULE_MAGIC_COOKIE_EAPI) | |
3765 | + if (m2->add_module != NULL) | |
3766 | + (*m2->add_module)(m); | |
3767 | + } | |
3768 | +#endif /* EAPI */ | |
3769 | } | |
3770 | ||
3771 | /* | |
3772 | @@ -597,6 +611,21 @@ | |
3773 | { | |
3774 | module *modp; | |
3775 | ||
3776 | +#ifdef EAPI | |
3777 | + /* | |
3778 | + * Invoke the `remove_module' hook inside the now existing | |
3779 | + * set of modules to let them all now that this module is | |
3780 | + * beeing removed. | |
3781 | + */ | |
3782 | + { | |
3783 | + module *m2; | |
3784 | + for (m2 = top_module; m2 != NULL; m2 = m2->next) | |
3785 | + if (m2->magic == MODULE_MAGIC_COOKIE_EAPI) | |
3786 | + if (m2->remove_module != NULL) | |
3787 | + (*m2->remove_module)(m); | |
3788 | + } | |
3789 | +#endif /* EAPI */ | |
3790 | + | |
3791 | modp = top_module; | |
3792 | if (modp == m) { | |
3793 | /* We are the top module, special case */ | |
3794 | @@ -985,6 +1014,27 @@ | |
3795 | const command_rec *cmd; | |
3796 | module *mod = top_module; | |
3797 | ||
3798 | +#ifdef EAPI | |
3799 | + /* | |
3800 | + * Invoke the `rewrite_command' of modules to allow | |
3801 | + * they to rewrite the directive line before we | |
3802 | + * process it. | |
3803 | + */ | |
3804 | + { | |
3805 | + module *m; | |
3806 | + char *cp; | |
3807 | + for (m = top_module; m != NULL; m = m->next) { | |
3808 | + if (m->magic == MODULE_MAGIC_COOKIE_EAPI) { | |
3809 | + if (m->rewrite_command != NULL) { | |
3810 | + cp = (m->rewrite_command)(parms, config, l); | |
3811 | + if (cp != NULL) | |
3812 | + l = cp; | |
3813 | + } | |
3814 | + } | |
3815 | + } | |
3816 | + } | |
3817 | +#endif /* EAPI */ | |
3818 | + | |
3819 | if ((l[0] == '#') || (!l[0])) | |
3820 | return NULL; | |
3821 | ||
3822 | @@ -1334,6 +1384,10 @@ | |
3823 | s->limit_req_fieldsize = main_server->limit_req_fieldsize; | |
3824 | s->limit_req_fields = main_server->limit_req_fields; | |
3825 | ||
3826 | +#ifdef EAPI | |
3827 | + s->ctx = ap_ctx_new(p); | |
3828 | +#endif /* EAPI */ | |
3829 | + | |
3830 | *ps = s; | |
3831 | ||
3832 | return ap_parse_vhost_addrs(p, hostname, s); | |
3833 | @@ -1483,6 +1537,10 @@ | |
3834 | ||
3835 | s->module_config = create_server_config(p, s); | |
3836 | s->lookup_defaults = create_default_per_dir_config(p); | |
3837 | + | |
3838 | +#ifdef EAPI | |
3839 | + s->ctx = ap_ctx_new(p); | |
3840 | +#endif /* EAPI */ | |
3841 | ||
3842 | return s; | |
3843 | } | |
3844 | diff -Nru apache_1.3.9/src/main/http_main.c apache_1.3.9.EAPI/src/main/http_main.c | |
3845 | --- apache_1.3.9/src/main/http_main.c Wed Dec 29 22:03:42 1999 | |
3846 | +++ apache_1.3.9.EAPI/src/main/http_main.c Wed Dec 29 21:25:56 1999 | |
3847 | @@ -256,6 +256,9 @@ | |
3848 | int ap_listenbacklog; | |
3849 | int ap_dump_settings = 0; | |
3850 | API_VAR_EXPORT int ap_extended_status = 0; | |
3851 | +#ifdef EAPI | |
3852 | +API_VAR_EXPORT ap_ctx *ap_global_ctx; | |
3853 | +#endif /* EAPI */ | |
3854 | ||
3855 | /* | |
3856 | * The max child slot ever assigned, preserved across restarts. Necessary | |
3857 | @@ -427,6 +430,30 @@ | |
3858 | } | |
3859 | } | |
3860 | ||
3861 | +#ifdef EAPI | |
3862 | +API_EXPORT(void) ap_add_config_define(const char *define) | |
3863 | +{ | |
3864 | + char **var; | |
3865 | + var = (char **)ap_push_array(ap_server_config_defines); | |
3866 | + *var = ap_pstrdup(pcommands, define); | |
3867 | + return; | |
3868 | +} | |
3869 | + | |
3870 | +/* | |
3871 | + * Invoke the `close_connection' hook of modules to let them do | |
3872 | + * some connection dependent actions before we close it. | |
3873 | + */ | |
3874 | +static void ap_call_close_connection_hook(conn_rec *c) | |
3875 | +{ | |
3876 | + module *m; | |
3877 | + for (m = top_module; m != NULL; m = m->next) | |
3878 | + if (m->magic == MODULE_MAGIC_COOKIE_EAPI) | |
3879 | + if (m->close_connection != NULL) | |
3880 | + (*m->close_connection)(c); | |
3881 | + return; | |
3882 | +} | |
3883 | +#endif /* EAPI */ | |
3884 | + | |
3885 | static APACHE_TLS int volatile exit_after_unblock = 0; | |
3886 | ||
3887 | #ifdef GPROF | |
3888 | @@ -1144,6 +1171,10 @@ | |
3889 | ap_log_transaction(log_req); | |
3890 | } | |
3891 | ||
3892 | +#ifdef EAPI | |
3893 | + ap_call_close_connection_hook(save_req->connection); | |
3894 | +#endif /* EAPI */ | |
3895 | + | |
3896 | ap_bsetflag(save_req->connection->client, B_EOUT, 1); | |
3897 | ap_bclose(save_req->connection->client); | |
3898 | ||
3899 | @@ -1153,6 +1184,9 @@ | |
3900 | ap_longjmp(jmpbuffer, 1); | |
3901 | } | |
3902 | else { /* abort the connection */ | |
3903 | +#ifdef EAPI | |
3904 | + ap_call_close_connection_hook(current_conn); | |
3905 | +#endif /* EAPI */ | |
3906 | ap_bsetflag(current_conn->client, B_EOUT, 1); | |
3907 | ap_bclose(current_conn->client); | |
3908 | current_conn->aborted = 1; | |
3909 | @@ -1209,7 +1243,11 @@ | |
3910 | } | |
3911 | #endif | |
3912 | ||
3913 | +#ifdef EAPI | |
3914 | +API_EXPORT(unsigned int) ap_set_callback_and_alarm(void (*fn) (int), int x) | |
3915 | +#else | |
3916 | unsigned int ap_set_callback_and_alarm(void (*fn) (int), int x) | |
3917 | +#endif | |
3918 | { | |
3919 | unsigned int old; | |
3920 | ||
3921 | @@ -1426,10 +1464,16 @@ | |
3922 | /* Send any leftover data to the client, but never try to again */ | |
3923 | ||
3924 | if (ap_bflush(r->connection->client) == -1) { | |
3925 | +#ifdef EAPI | |
3926 | + ap_call_close_connection_hook(r->connection); | |
3927 | +#endif /* EAPI */ | |
3928 | ap_kill_timeout(r); | |
3929 | ap_bclose(r->connection->client); | |
3930 | return; | |
3931 | } | |
3932 | +#ifdef EAPI | |
3933 | + ap_call_close_connection_hook(r->connection); | |
3934 | +#endif /* EAPI */ | |
3935 | ap_bsetflag(r->connection->client, B_EOUT, 1); | |
3936 | ||
3937 | /* Close our half of the connection --- send the client a FIN */ | |
3938 | @@ -2121,6 +2165,9 @@ | |
3939 | { | |
3940 | /* Clear the pool - including any registered cleanups */ | |
3941 | ap_destroy_pool(pglobal); | |
3942 | +#ifdef EAPI | |
3943 | + ap_kill_alloc_shared(); | |
3944 | +#endif | |
3945 | exit(code); | |
3946 | } | |
3947 | ||
3948 | @@ -3105,6 +3152,25 @@ | |
3949 | hostnamebuf, sizeof(hostnamebuf), NULL, 0, NI_NUMERICHOST); | |
3950 | conn->remote_ip = ap_pstrdup(conn->pool, hostnamebuf); | |
3951 | ||
3952 | +#ifdef EAPI | |
3953 | + conn->ctx = ap_ctx_new(conn->pool); | |
3954 | +#endif /* EAPI */ | |
3955 | + | |
3956 | +#ifdef EAPI | |
3957 | + /* | |
3958 | + * Invoke the `new_connection' hook of modules to let them do | |
3959 | + * some connection dependent actions before we go on with | |
3960 | + * processing the request on this connection. | |
3961 | + */ | |
3962 | + { | |
3963 | + module *m; | |
3964 | + for (m = top_module; m != NULL; m = m->next) | |
3965 | + if (m->magic == MODULE_MAGIC_COOKIE_EAPI) | |
3966 | + if (m->new_connection != NULL) | |
3967 | + (*m->new_connection)(conn); | |
3968 | + } | |
3969 | +#endif /* EAPI */ | |
3970 | + | |
3971 | return conn; | |
3972 | } | |
3973 | ||
3974 | @@ -3541,6 +3607,12 @@ | |
3975 | printf("Server's Module Magic Number: %u:%u\n", | |
3976 | MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); | |
3977 | printf("Server compiled with....\n"); | |
3978 | +#ifdef EAPI | |
3979 | + printf(" -D EAPI\n"); | |
3980 | +#endif | |
3981 | +#ifdef EAPI_MM | |
3982 | + printf(" -D EAPI_MM\n"); | |
3983 | +#endif | |
3984 | #ifdef BIG_SECURITY_HOLE | |
3985 | printf(" -D BIG_SECURITY_HOLE\n"); | |
3986 | #endif | |
3987 | @@ -3688,6 +3760,22 @@ | |
3988 | ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *)); | |
3989 | ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *)); | |
3990 | ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *)); | |
3991 | + | |
3992 | +#ifdef EAPI | |
3993 | + ap_hook_init(); | |
3994 | + ap_hook_configure("ap::buff::read", | |
3995 | + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST); | |
3996 | + ap_hook_configure("ap::buff::write", | |
3997 | + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST); | |
3998 | + ap_hook_configure("ap::buff::writev", | |
3999 | + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST); | |
4000 | + ap_hook_configure("ap::buff::sendwithtimeout", | |
4001 | + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST); | |
4002 | + ap_hook_configure("ap::buff::recvwithtimeout", | |
4003 | + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST); | |
4004 | + | |
4005 | + ap_global_ctx = ap_ctx_new(NULL); | |
4006 | +#endif /* EAPI */ | |
4007 | } | |
4008 | ||
4009 | #ifndef MULTITHREAD | |
4010 | @@ -4109,6 +4197,9 @@ | |
4011 | ||
4012 | ap_sync_scoreboard_image(); | |
4013 | if (ap_scoreboard_image->global.running_generation != ap_my_generation) { | |
4014 | +#ifdef EAPI | |
4015 | + ap_call_close_connection_hook(current_conn); | |
4016 | +#endif /* EAPI */ | |
4017 | ap_bclose(conn_io); | |
4018 | clean_child_exit(0); | |
4019 | } | |
4020 | @@ -4137,6 +4228,9 @@ | |
4021 | */ | |
4022 | ||
4023 | #ifdef NO_LINGCLOSE | |
4024 | +#ifdef EAPI | |
4025 | + ap_call_close_connection_hook(current_conn); | |
4026 | +#endif /* EAPI */ | |
4027 | ap_bclose(conn_io); /* just close it */ | |
4028 | #else | |
4029 | if (r && r->connection | |
4030 | @@ -4147,6 +4241,9 @@ | |
4031 | lingering_close(r); | |
4032 | } | |
4033 | else { | |
4034 | +#ifdef EAPI | |
4035 | + ap_call_close_connection_hook(current_conn); | |
4036 | +#endif /* EAPI */ | |
4037 | ap_bsetflag(conn_io, B_EOUT, 1); | |
4038 | ap_bclose(conn_io); | |
4039 | } | |
4040 | @@ -4879,10 +4976,17 @@ | |
4041 | usage(argv[0]); | |
4042 | } | |
4043 | } | |
4044 | +#ifdef EAPI | |
4045 | + ap_init_alloc_shared(TRUE); | |
4046 | +#endif | |
4047 | ||
4048 | ap_suexec_enabled = init_suexec(); | |
4049 | server_conf = ap_read_config(pconf, ptrans, ap_server_confname); | |
4050 | ||
4051 | +#ifdef EAPI | |
4052 | + ap_init_alloc_shared(FALSE); | |
4053 | +#endif | |
4054 | + | |
4055 | if (ap_configtestonly) { | |
4056 | fprintf(stderr, "Syntax OK\n"); | |
4057 | exit(0); | |
4058 | @@ -5033,6 +5137,10 @@ | |
4059 | ap_destroy_pool(r->pool); | |
4060 | } | |
4061 | ||
4062 | +#ifdef EAPI | |
4063 | + ap_call_close_connection_hook(conn); | |
4064 | +#endif /* EAPI */ | |
4065 | + | |
4066 | ap_bclose(cio); | |
4067 | } | |
4068 | exit(0); | |
4069 | @@ -5361,6 +5469,9 @@ | |
4070 | ap_kill_cleanups_for_socket(ptrans, csd); | |
4071 | ||
4072 | #ifdef NO_LINGCLOSE | |
4073 | +#ifdef EAPI | |
4074 | + ap_call_close_connection_hook(current_conn); | |
4075 | +#endif /* EAPI */ | |
4076 | ap_bclose(conn_io); /* just close it */ | |
4077 | #else | |
4078 | if (r && r->connection | |
4079 | @@ -5371,6 +5482,9 @@ | |
4080 | lingering_close(r); | |
4081 | } | |
4082 | else { | |
4083 | +#ifdef EAPI | |
4084 | + ap_call_close_connection_hook(current_conn); | |
4085 | +#endif /* EAPI */ | |
4086 | ap_bsetflag(conn_io, B_EOUT, 1); | |
4087 | ap_bclose(conn_io); | |
4088 | } | |
4089 | @@ -6490,6 +6604,10 @@ | |
4090 | } | |
4091 | } | |
4092 | ||
4093 | +#ifdef EAPI | |
4094 | + ap_init_alloc_shared(TRUE); | |
4095 | +#endif | |
4096 | + | |
4097 | if (!ap_os_is_path_absolute(ap_server_confname)) { | |
4098 | char *full_conf_path; | |
4099 | ||
4100 | @@ -6522,6 +6640,10 @@ | |
4101 | } | |
4102 | #endif | |
4103 | server_conf = ap_read_config(pconf, ptrans, ap_server_confname); | |
4104 | + | |
4105 | +#ifdef EAPI | |
4106 | + ap_init_alloc_shared(FALSE); | |
4107 | +#endif | |
4108 | ||
4109 | if (ap_configtestonly) { | |
4110 | fprintf(stderr, "%s: Syntax OK\n", ap_server_root_relative(pcommands, ap_server_confname)); | |
4111 | diff -Nru apache_1.3.9/src/main/http_protocol.c apache_1.3.9.EAPI/src/main/http_protocol.c | |
4112 | --- apache_1.3.9/src/main/http_protocol.c Wed Dec 29 22:03:42 1999 | |
4113 | +++ apache_1.3.9.EAPI/src/main/http_protocol.c Wed Dec 29 21:25:56 1999 | |
4114 | @@ -935,6 +935,10 @@ | |
4115 | r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */ | |
4116 | r->the_request = NULL; | |
4117 | ||
4118 | +#ifdef EAPI | |
4119 | + r->ctx = ap_ctx_new(r->pool); | |
4120 | +#endif /* EAPI */ | |
4121 | + | |
4122 | #ifdef CHARSET_EBCDIC | |
4123 | ap_bsetflag(r->connection->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 1); | |
4124 | #endif | |
4125 | @@ -1079,6 +1083,11 @@ | |
4126 | rnew->read_body = REQUEST_NO_BODY; | |
4127 | ||
4128 | rnew->main = (request_rec *) r; | |
4129 | + | |
4130 | +#ifdef EAPI | |
4131 | + rnew->ctx = r->ctx; | |
4132 | +#endif /* EAPI */ | |
4133 | + | |
4134 | } | |
4135 | ||
4136 | void ap_finalize_sub_req_protocol(request_rec *sub) | |
4137 | diff -Nru apache_1.3.9/src/main/http_request.c apache_1.3.9.EAPI/src/main/http_request.c | |
4138 | --- apache_1.3.9/src/main/http_request.c Wed Dec 29 22:03:42 1999 | |
4139 | +++ apache_1.3.9.EAPI/src/main/http_request.c Wed Dec 29 21:25:56 1999 | |
4140 | @@ -1315,6 +1315,9 @@ | |
4141 | new->no_local_copy = r->no_local_copy; | |
4142 | new->read_length = r->read_length; /* We can only read it once */ | |
4143 | new->vlist_validator = r->vlist_validator; | |
4144 | +#ifdef EAPI | |
4145 | + new->ctx = r->ctx; | |
4146 | +#endif /* EAPI */ | |
4147 | ||
4148 | ap_table_setn(new->subprocess_env, "REDIRECT_STATUS", | |
4149 | ap_psprintf(r->pool, "%d", r->status)); | |
4150 | diff -Nru apache_1.3.9/src/modules/extra/mod_define.c apache_1.3.9.EAPI/src/modules/extra/mod_define.c | |
4151 | --- apache_1.3.9/src/modules/extra/mod_define.c Thu Jan 1 01:00:00 1970 | |
4152 | +++ apache_1.3.9.EAPI/src/modules/extra/mod_define.c Wed Dec 29 21:25:56 1999 | |
4153 | @@ -0,0 +1,446 @@ | |
4154 | +/* ==================================================================== | |
4155 | + * Copyright (c) 1995-1998 The Apache Group. All rights reserved. | |
4156 | + * | |
4157 | + * Redistribution and use in source and binary forms, with or without | |
4158 | + * modification, are permitted provided that the following conditions | |
4159 | + * are met: | |
4160 | + * | |
4161 | + * 1. Redistributions of source code must retain the above copyright | |
4162 | + * notice, this list of conditions and the following disclaimer. | |
4163 | + * | |
4164 | + * 2. Redistributions in binary form must reproduce the above copyright | |
4165 | + * notice, this list of conditions and the following disclaimer in | |
4166 | + * the documentation and/or other materials provided with the | |
4167 | + * distribution. | |
4168 | + * | |
4169 | + * 3. All advertising materials mentioning features or use of this | |
4170 | + * software must display the following acknowledgment: | |
4171 | + * "This product includes software developed by the Apache Group | |
4172 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
4173 | + * | |
4174 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
4175 | + * endorse or promote products derived from this software without | |
4176 | + * prior written permission. For written permission, please contact | |
4177 | + * apache@apache.org. | |
4178 | + * | |
4179 | + * 5. Products derived from this software may not be called "Apache" | |
4180 | + * nor may "Apache" appear in their names without prior written | |
4181 | + * permission of the Apache Group. | |
4182 | + * | |
4183 | + * 6. Redistributions of any form whatsoever must retain the following | |
4184 | + * acknowledgment: | |
4185 | + * "This product includes software developed by the Apache Group | |
4186 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
4187 | + * | |
4188 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
4189 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
4190 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
4191 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
4192 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
4193 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
4194 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
4195 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
4196 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
4197 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
4198 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
4199 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
4200 | + * ==================================================================== | |
4201 | + * | |
4202 | + * This software consists of voluntary contributions made by many | |
4203 | + * individuals on behalf of the Apache Group and was originally based | |
4204 | + * on public domain software written at the National Center for | |
4205 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
4206 | + * For more information on the Apache Group and the Apache HTTP server | |
4207 | + * project, please see <http://www.apache.org/>. | |
4208 | + * | |
4209 | + */ | |
4210 | + | |
4211 | +/* | |
4212 | +** mod_define.c -- Apache module for configuration defines ($xxx) | |
4213 | +** v1.0: Originally written in December 1998 by | |
4214 | +** Ralf S. Engelschall <rse@engelschall.com> and | |
4215 | +** Christian Reiber <chrei@en.muc.de> | |
4216 | +** v1.1: Completely Overhauled in August 1999 by | |
4217 | +** Ralf S. Engelschall <rse@engelschall.com> | |
4218 | +*/ | |
4219 | + | |
4220 | +#include "ap_config.h" | |
4221 | +#include "ap_ctype.h" | |
4222 | +#include "httpd.h" | |
4223 | +#include "http_config.h" | |
4224 | +#include "http_conf_globals.h" | |
4225 | +#include "http_core.h" | |
4226 | +#include "http_log.h" | |
4227 | + | |
4228 | +#ifndef EAPI | |
4229 | +#error "This module requires the Extended API (EAPI) facilities." | |
4230 | +#endif | |
4231 | + | |
4232 | +/* | |
4233 | + * The global table of defines | |
4234 | + */ | |
4235 | + | |
4236 | +static table *tDefines = NULL; /* global table of defines */ | |
4237 | +static int bOnceSeenADefine = FALSE; /* optimization flag */ | |
4238 | + | |
4239 | +/* | |
4240 | + * Forward declaration | |
4241 | + */ | |
4242 | +static int DefineIndex (pool *, char *, int *, int *, char **); | |
4243 | +static char *DefineFetch (pool *, char *); | |
4244 | +static char *DefineExpand (pool *, char *, int, char *); | |
4245 | +static void DefineInit (pool *); | |
4246 | +static void DefineCleanup (void *); | |
4247 | +static char *DefineRewriteHook(cmd_parms *, void *, const char *); | |
4248 | + | |
4249 | +/* | |
4250 | + * Character classes for scanner function | |
4251 | + */ | |
4252 | +typedef enum { | |
4253 | + CC_ESCAPE, CC_DOLLAR, CC_BRACEOPEN, CC_BRACECLOSE, | |
4254 | + CC_IDCHAR1, CC_IDCHAR, CC_OTHER, CC_EOS | |
4255 | +} CharClass; | |
4256 | + | |
4257 | +/* | |
4258 | + * Scanner states for scanner function | |
4259 | + */ | |
4260 | +typedef enum { | |
4261 | + SS_NONE, SS_SKIP, SS_DOLLAR, SS_TOKEN_BRACED, | |
4262 | + SS_TOKEN_UNBRACED, SS_ERROR, SS_FOUND | |
4263 | +} ScanState; | |
4264 | + | |
4265 | +/* | |
4266 | + * Default meta characters | |
4267 | + */ | |
4268 | +#define DEFAULT_MC_ESCAPE "\\" | |
4269 | +#define DEFAULT_MC_DOLLAR "$" | |
4270 | +#define DEFAULT_MC_BRACEOPEN "{" | |
4271 | +#define DEFAULT_MC_BRACECLOSE "}" | |
4272 | + | |
4273 | +/* | |
4274 | + * Scanner for variable constructs $xxx and ${xxx} | |
4275 | + */ | |
4276 | +static int DefineIndex(pool *p, char *cpLine, int *pos, int *len, char **cpVar) | |
4277 | +{ | |
4278 | + int rc; | |
4279 | + char *cp; | |
4280 | + char *cp2; | |
4281 | + CharClass cc; | |
4282 | + char cEscape; | |
4283 | + char cDefine; | |
4284 | + char cBraceOpen; | |
4285 | + char cBraceClose; | |
4286 | + char *cpError; | |
4287 | + ScanState s; | |
4288 | + | |
4289 | + cEscape = DEFAULT_MC_ESCAPE[0]; | |
4290 | + if ((cp = DefineFetch(p, "mod_define::escape")) != NULL) | |
4291 | + cEscape = cp[0]; | |
4292 | + cDefine = DEFAULT_MC_DOLLAR[0]; | |
4293 | + if ((cp = DefineFetch(p, "mod_define::dollar")) != NULL) | |
4294 | + cDefine = cp[0]; | |
4295 | + cBraceOpen = DEFAULT_MC_BRACEOPEN[0]; | |
4296 | + if ((cp = DefineFetch(p, "mod_define::braceopen")) != NULL) | |
4297 | + cBraceOpen = cp[0]; | |
4298 | + cBraceClose = DEFAULT_MC_BRACECLOSE[0]; | |
4299 | + if ((cp = DefineFetch(p, "mod_define::braceclose")) != NULL) | |
4300 | + cBraceClose = cp[0]; | |
4301 | + | |
4302 | + rc = 0; | |
4303 | + *len = 0; | |
4304 | + cc = CC_OTHER; | |
4305 | + s = SS_NONE; | |
4306 | + for (cp = cpLine+(*pos); cc != CC_EOS; cp++) { | |
4307 | + if (*cp == cEscape) | |
4308 | + cc = CC_ESCAPE; | |
4309 | + else if (*cp == cDefine) | |
4310 | + cc = CC_DOLLAR; | |
4311 | + else if (*cp == cBraceOpen) | |
4312 | + cc = CC_BRACEOPEN; | |
4313 | + else if (*cp == cBraceClose) | |
4314 | + cc = CC_BRACECLOSE; | |
4315 | + else if (ap_isalpha(*cp)) | |
4316 | + cc = CC_IDCHAR1; | |
4317 | + else if (ap_isdigit(*cp) || *cp == '_' || *cp == ':') | |
4318 | + cc = CC_IDCHAR; | |
4319 | + else if (*cp == '\0') | |
4320 | + cc = CC_EOS; | |
4321 | + else | |
4322 | + cc = CC_OTHER; | |
4323 | + switch (s) { | |
4324 | + case SS_NONE: | |
4325 | + switch (cc) { | |
4326 | + case CC_ESCAPE: | |
4327 | + s = SS_SKIP; | |
4328 | + break; | |
4329 | + case CC_DOLLAR: | |
4330 | + s = SS_DOLLAR; | |
4331 | + break; | |
4332 | + default: | |
4333 | + break; | |
4334 | + } | |
4335 | + break; | |
4336 | + case SS_SKIP: | |
4337 | + s = SS_NONE; | |
4338 | + continue; | |
4339 | + break; | |
4340 | + case SS_DOLLAR: | |
4341 | + switch (cc) { | |
4342 | + case CC_BRACEOPEN: | |
4343 | + s = SS_TOKEN_BRACED; | |
4344 | + *pos = cp-cpLine-1; | |
4345 | + (*len) = 2; | |
4346 | + *cpVar = cp+1; | |
4347 | + break; | |
4348 | + case CC_IDCHAR1: | |
4349 | + s = SS_TOKEN_UNBRACED; | |
4350 | + *pos = cp-cpLine-1; | |
4351 | + (*len) = 2; | |
4352 | + *cpVar = cp; | |
4353 | + break; | |
4354 | + case CC_ESCAPE: | |
4355 | + s = SS_SKIP; | |
4356 | + break; | |
4357 | + default: | |
4358 | + s = SS_NONE; | |
4359 | + break; | |
4360 | + } | |
4361 | + break; | |
4362 | + case SS_TOKEN_BRACED: | |
4363 | + switch (cc) { | |
4364 | + case CC_IDCHAR1: | |
4365 | + case CC_IDCHAR: | |
4366 | + (*len)++; | |
4367 | + break; | |
4368 | + case CC_BRACECLOSE: | |
4369 | + (*len)++; | |
4370 | + cp2 = ap_palloc(p, cp-*cpVar+1); | |
4371 | + ap_cpystrn(cp2, *cpVar, cp-*cpVar+1); | |
4372 | + *cpVar = cp2; | |
4373 | + s = SS_FOUND; | |
4374 | + break; | |
4375 | + default: | |
4376 | + cpError = ap_psprintf(p, "Illegal character '%c' in identifier", *cp); | |
4377 | + s = SS_ERROR; | |
4378 | + break; | |
4379 | + } | |
4380 | + break; | |
4381 | + case SS_TOKEN_UNBRACED: | |
4382 | + switch (cc) { | |
4383 | + case CC_IDCHAR1: | |
4384 | + case CC_IDCHAR: | |
4385 | + (*len)++; | |
4386 | + break; | |
4387 | + default: | |
4388 | + cp2 = ap_palloc(p, cp-*cpVar+1); | |
4389 | + ap_cpystrn(cp2, *cpVar, cp-*cpVar+1); | |
4390 | + *cpVar = cp2; | |
4391 | + s = SS_FOUND; | |
4392 | + break; | |
4393 | + } | |
4394 | + break; | |
4395 | + case SS_FOUND: | |
4396 | + case SS_ERROR: | |
4397 | + break; | |
4398 | + } | |
4399 | + if (s == SS_ERROR) { | |
4400 | + fprintf(stderr, "Error\n"); | |
4401 | + break; | |
4402 | + } | |
4403 | + else if (s == SS_FOUND) { | |
4404 | + rc = 1; | |
4405 | + break; | |
4406 | + } | |
4407 | + } | |
4408 | + return rc; | |
4409 | +} | |
4410 | + | |
4411 | +/* | |
4412 | + * Determine the value of a variable | |
4413 | + */ | |
4414 | +static char *DefineFetch(pool *p, char *cpVar) | |
4415 | +{ | |
4416 | + char *cpVal; | |
4417 | + | |
4418 | + /* first try out table */ | |
4419 | + if ((cpVal = (char *)ap_table_get(tDefines, (char *)cpVar)) != NULL) | |
4420 | + return cpVal; | |
4421 | + /* second try the environment */ | |
4422 | + if ((cpVal = getenv(cpVar)) != NULL) | |
4423 | + return cpVal; | |
4424 | + return NULL; | |
4425 | +} | |
4426 | + | |
4427 | +/* | |
4428 | + * Expand a variable | |
4429 | + */ | |
4430 | +static char *DefineExpand(pool *p, char *cpToken, int tok_len, char *cpVal) | |
4431 | +{ | |
4432 | + char *cp; | |
4433 | + int val_len, rest_len; | |
4434 | + | |
4435 | + val_len = strlen(cpVal); | |
4436 | + rest_len = strlen(cpToken+tok_len); | |
4437 | + if (val_len < tok_len) | |
4438 | + memcpy(cpToken+val_len, cpToken+tok_len, rest_len+1); | |
4439 | + else if (val_len > tok_len) | |
4440 | + for (cp = cpToken+strlen(cpToken); cp > cpToken+tok_len-1; cp--) | |
4441 | + *(cp+(val_len-tok_len)) = *cp; | |
4442 | + memcpy(cpToken, cpVal, val_len); | |
4443 | + return NULL; | |
4444 | +} | |
4445 | + | |
4446 | +/* | |
4447 | + * The EAPI hook which is called after Apache has read a | |
4448 | + * configuration line and before it's actually processed | |
4449 | + */ | |
4450 | +static char *DefineRewriteHook(cmd_parms *cmd, void *config, const char *line) | |
4451 | +{ | |
4452 | + pool *p; | |
4453 | + char *cpBuf; | |
4454 | + char *cpLine; | |
4455 | + int pos; | |
4456 | + int len; | |
4457 | + char *cpError; | |
4458 | + char *cpVar; | |
4459 | + char *cpVal; | |
4460 | + server_rec *s; | |
4461 | + | |
4462 | + /* runtime optimization */ | |
4463 | + if (!bOnceSeenADefine) | |
4464 | + return NULL; | |
4465 | + | |
4466 | + p = cmd->pool; | |
4467 | + s = cmd->server; | |
4468 | + | |
4469 | + /* | |
4470 | + * Search for: | |
4471 | + * ....\$[a-zA-Z][:_a-zA-Z0-9]*.... | |
4472 | + * ....\${[a-zA-Z][:_a-zA-Z0-9]*}.... | |
4473 | + */ | |
4474 | + cpBuf = NULL; | |
4475 | + cpLine = (char *)line; | |
4476 | + pos = 0; | |
4477 | + while (DefineIndex(p, cpLine, &pos, &len, &cpVar)) { | |
4478 | +#ifdef DEFINE_DEBUG | |
4479 | + { | |
4480 | + char prefix[1024]; | |
4481 | + char marker[1024]; | |
4482 | + int i; | |
4483 | + for (i = 0; i < pos; i++) | |
4484 | + prefix[i] = ' '; | |
4485 | + prefix[i] = '\0'; | |
4486 | + for (i = 0; i < len; i++) | |
4487 | + marker[i] = '^'; | |
4488 | + marker[i] = '\0'; | |
4489 | + fprintf(stderr, | |
4490 | + "Found variable `%s' (pos: %d, len: %d)\n" | |
4491 | + " %s\n" | |
4492 | + " %s%s\n", | |
4493 | + cpVar, pos, len, cpLine, prefix, marker); | |
4494 | + } | |
4495 | +#endif | |
4496 | + if (cpBuf == NULL) { | |
4497 | + cpBuf = ap_palloc(p, MAX_STRING_LEN); | |
4498 | + ap_cpystrn(cpBuf, line, MAX_STRING_LEN); | |
4499 | + cpLine = cpBuf; | |
4500 | + } | |
4501 | + if ((cpVal = DefineFetch(p, cpVar)) == NULL) { | |
4502 | + ap_log_error(APLOG_MARK, APLOG_ERR, s, | |
4503 | + "mod_define: Variable '%s' not defined: file %s, line %d", | |
4504 | + cpVar, cmd->config_file->name, | |
4505 | + cmd->config_file->line_number); | |
4506 | + cpBuf = NULL; | |
4507 | + break; | |
4508 | + } | |
4509 | + if ((cpError = DefineExpand(p, cpLine+pos, len, cpVal)) != NULL) { | |
4510 | + ap_log_error(APLOG_MARK, APLOG_ERR, s, | |
4511 | + "mod_define: %s: file %s, line %d", | |
4512 | + cpError, cmd->config_file->name, | |
4513 | + cmd->config_file->line_number); | |
4514 | + cpBuf = NULL; | |
4515 | + break; | |
4516 | + } | |
4517 | + } | |
4518 | + return cpBuf; | |
4519 | +} | |
4520 | + | |
4521 | +/* | |
4522 | + * Implementation of the `Define' configuration directive | |
4523 | + */ | |
4524 | +static const char *cmd_define(cmd_parms *cmd, void *config, | |
4525 | + char *cpVar, char *cpVal) | |
4526 | +{ | |
4527 | + if (tDefines == NULL) | |
4528 | + DefineInit(cmd->pool); | |
4529 | + ap_table_set(tDefines, cpVar, cpVal); | |
4530 | + bOnceSeenADefine = TRUE; | |
4531 | + return NULL; | |
4532 | +} | |
4533 | + | |
4534 | +/* | |
4535 | + * Module Initialization | |
4536 | + */ | |
4537 | + | |
4538 | +static void DefineInit(pool *p) | |
4539 | +{ | |
4540 | + tDefines = ap_make_table(p, 10); | |
4541 | + /* predefine delimiters */ | |
4542 | + ap_table_set(tDefines, "mod_define::escape", DEFAULT_MC_ESCAPE); | |
4543 | + ap_table_set(tDefines, "mod_define::dollar", DEFAULT_MC_DOLLAR); | |
4544 | + ap_table_set(tDefines, "mod_define::open", DEFAULT_MC_BRACEOPEN); | |
4545 | + ap_table_set(tDefines, "mod_define::close", DEFAULT_MC_BRACECLOSE); | |
4546 | + ap_register_cleanup(p, NULL, DefineCleanup, ap_null_cleanup); | |
4547 | + return; | |
4548 | +} | |
4549 | + | |
4550 | +/* | |
4551 | + * Module Cleanup | |
4552 | + */ | |
4553 | + | |
4554 | +static void DefineCleanup(void *data) | |
4555 | +{ | |
4556 | + /* reset private variables when config pool is cleared */ | |
4557 | + tDefines = NULL; | |
4558 | + bOnceSeenADefine = FALSE; | |
4559 | + return; | |
4560 | +} | |
4561 | + | |
4562 | +/* | |
4563 | + * Module Directive lists | |
4564 | + */ | |
4565 | +static const command_rec DefineDirectives[] = { | |
4566 | + { "Define", cmd_define, NULL, RSRC_CONF|ACCESS_CONF, TAKE2, | |
4567 | + "Define a configuration variable" }, | |
4568 | + { NULL } | |
4569 | +}; | |
4570 | + | |
4571 | +/* | |
4572 | + * Module API dispatch list | |
4573 | + */ | |
4574 | +module MODULE_VAR_EXPORT define_module = { | |
4575 | + STANDARD_MODULE_STUFF, | |
4576 | + NULL, /* module initializer */ | |
4577 | + NULL, /* create per-dir config structures */ | |
4578 | + NULL, /* merge per-dir config structures */ | |
4579 | + NULL, /* create per-server config structures */ | |
4580 | + NULL, /* merge per-server config structures */ | |
4581 | + DefineDirectives, /* table of config file commands */ | |
4582 | + NULL, /* [#8] MIME-typed-dispatched handlers */ | |
4583 | + NULL, /* [#1] URI to filename translation */ | |
4584 | + NULL, /* [#4] validate user id from request */ | |
4585 | + NULL, /* [#5] check if the user is ok _here_ */ | |
4586 | + NULL, /* [#2] check access by host address */ | |
4587 | + NULL, /* [#6] determine MIME type */ | |
4588 | + NULL, /* [#7] pre-run fixups */ | |
4589 | + NULL, /* [#9] log a transaction */ | |
4590 | + NULL, /* [#3] header parser */ | |
4591 | + NULL, /* child_init */ | |
4592 | + NULL, /* child_exit */ | |
4593 | + NULL, /* [#0] post read-request */ | |
4594 | + NULL, /* EAPI: add_module */ | |
4595 | + NULL, /* EAPI: del_module */ | |
4596 | + DefineRewriteHook, /* EAPI: rewrite_command */ | |
4597 | + NULL /* EAPI: new_connection */ | |
4598 | +}; | |
4599 | + | |
4600 | diff -Nru apache_1.3.9/src/modules/proxy/mod_proxy.c apache_1.3.9.EAPI/src/modules/proxy/mod_proxy.c | |
4601 | --- apache_1.3.9/src/modules/proxy/mod_proxy.c Wed Dec 29 22:03:42 1999 | |
4602 | +++ apache_1.3.9.EAPI/src/modules/proxy/mod_proxy.c Wed Dec 29 21:25:56 1999 | |
4603 | @@ -214,6 +214,9 @@ | |
4604 | static int proxy_fixup(request_rec *r) | |
4605 | { | |
4606 | char *url, *p; | |
4607 | +#ifdef EAPI | |
4608 | + int rc; | |
4609 | +#endif /* EAPI */ | |
4610 | ||
4611 | if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0) | |
4612 | return DECLINED; | |
4613 | @@ -221,6 +224,14 @@ | |
4614 | url = &r->filename[6]; | |
4615 | ||
4616 | /* canonicalise each specific scheme */ | |
4617 | +#ifdef EAPI | |
4618 | + if (ap_hook_use("ap::mod_proxy::canon", | |
4619 | + AP_HOOK_SIG3(int,ptr,ptr), | |
4620 | + AP_HOOK_DECLINE(DECLINED), | |
4621 | + &rc, r, url) && rc != DECLINED) | |
4622 | + return rc; | |
4623 | + else | |
4624 | +#endif /* EAPI */ | |
4625 | if (strncasecmp(url, "http:", 5) == 0) | |
4626 | return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT); | |
4627 | else if (strncasecmp(url, "ftp:", 4) == 0) | |
4628 | @@ -238,7 +249,38 @@ | |
4629 | ap_proxy_garbage_init(r, p); | |
4630 | } | |
4631 | ||
4632 | - | |
4633 | +#ifdef EAPI | |
4634 | +static void proxy_addmod(module *m) | |
4635 | +{ | |
4636 | + /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */ | |
4637 | + ap_hook_configure("ap::mod_proxy::http::canon", | |
4638 | + AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST); | |
4639 | + ap_hook_register("ap::mod_proxy::http::canon", | |
4640 | + ap_proxy_http_canon, AP_HOOK_NOCTX); | |
4641 | + | |
4642 | + /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */ | |
4643 | + ap_hook_configure("ap::mod_proxy::http::handler", | |
4644 | + AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST); | |
4645 | + ap_hook_register("ap::mod_proxy::http::handler", | |
4646 | + ap_proxy_http_handler, AP_HOOK_NOCTX); | |
4647 | + | |
4648 | + /* export: ap_proxyerror() as `ap::mod_proxy::error' */ | |
4649 | + ap_hook_configure("ap::mod_proxy::error", | |
4650 | + AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST); | |
4651 | + ap_hook_register("ap::mod_proxy::error", | |
4652 | + ap_proxyerror, AP_HOOK_NOCTX); | |
4653 | + return; | |
4654 | +} | |
4655 | + | |
4656 | +static void proxy_remmod(module *m) | |
4657 | +{ | |
4658 | + /* remove the hook references */ | |
4659 | + ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon); | |
4660 | + ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler); | |
4661 | + ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror); | |
4662 | + return; | |
4663 | +} | |
4664 | +#endif /* EAPI */ | |
4665 | ||
4666 | /* Send a redirection if the request contains a hostname which is not */ | |
4667 | /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */ | |
4668 | @@ -368,6 +410,14 @@ | |
4669 | /* CONNECT is a special method that bypasses the normal | |
4670 | * proxy code. | |
4671 | */ | |
4672 | +#ifdef EAPI | |
4673 | + if (!ap_hook_use("ap::mod_proxy::handler", | |
4674 | + AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr), | |
4675 | + AP_HOOK_DECLINE(DECLINED), | |
4676 | + &rc, r, cr, url, | |
4677 | + ents[i].hostname, ents[i].port, | |
4678 | + ents[i].protocol) || rc == DECLINED) { | |
4679 | +#endif /* EAPI */ | |
4680 | if (r->method_number == M_CONNECT) | |
4681 | rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname, | |
4682 | ents[i].port); | |
4683 | @@ -377,6 +427,9 @@ | |
4684 | ents[i].port); | |
4685 | else | |
4686 | rc = DECLINED; | |
4687 | +#ifdef EAPI | |
4688 | + } | |
4689 | +#endif /* EAPI */ | |
4690 | ||
4691 | /* an error or success */ | |
4692 | if (rc != DECLINED && rc != HTTP_BAD_GATEWAY) | |
4693 | @@ -390,6 +443,14 @@ | |
4694 | * give up?? | |
4695 | */ | |
4696 | /* handle the scheme */ | |
4697 | +#ifdef EAPI | |
4698 | + if (ap_hook_use("ap::mod_proxy::handler", | |
4699 | + AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr), | |
4700 | + AP_HOOK_DECLINE(DECLINED), | |
4701 | + &rc, r, cr, url, | |
4702 | + NULL, 0, scheme) && rc != DECLINED) | |
4703 | + return rc; | |
4704 | +#endif /* EAPI */ | |
4705 | if (r->method_number == M_CONNECT) | |
4706 | return ap_proxy_connect_handler(r, cr, url, NULL, 0); | |
4707 | if (strcasecmp(scheme, "http") == 0) | |
4708 | @@ -895,4 +956,10 @@ | |
4709 | NULL, /* child_init */ | |
4710 | NULL, /* child_exit */ | |
4711 | proxy_detect /* post read-request */ | |
4712 | +#ifdef EAPI | |
4713 | + ,proxy_addmod, /* EAPI: add_module */ | |
4714 | + proxy_remmod, /* EAPI: remove_module */ | |
4715 | + NULL, /* EAPI: rewrite_command */ | |
4716 | + NULL /* EAPI: new_connection */ | |
4717 | +#endif | |
4718 | }; | |
4719 | diff -Nru apache_1.3.9/src/modules/proxy/proxy_http.c apache_1.3.9.EAPI/src/modules/proxy/proxy_http.c | |
4720 | --- apache_1.3.9/src/modules/proxy/proxy_http.c Wed Dec 29 22:03:42 1999 | |
4721 | +++ apache_1.3.9.EAPI/src/modules/proxy/proxy_http.c Wed Dec 29 22:02:34 1999 | |
4722 | @@ -181,8 +181,11 @@ | |
4723 | pool *p = r->pool; | |
4724 | const long int zero = 0L; | |
4725 | char *destportstr = NULL; | |
4726 | - const char *urlptr = NULL; | |
4727 | +#ifdef EAPI | |
4728 | + int destport = 0; | |
4729 | +#endif /* EAPI */ | |
4730 | const char *datestr; | |
4731 | + const char *urlptr = NULL; | |
4732 | struct tbl_do_args tdo; | |
4733 | struct addrinfo hints, *res, *tres; | |
4734 | int error; | |
4735 | @@ -202,6 +205,17 @@ | |
4736 | urlptr += 3; | |
4737 | ap_snprintf(portstr, sizeof(portstr), "%d", DEFAULT_HTTP_PORT); | |
4738 | destportstr = portstr; | |
4739 | + | |
4740 | +#ifdef EAPI | |
4741 | + | |
4742 | + ap_hook_use("ap::mod_proxy::http::handler::set_destport", | |
4743 | + AP_HOOK_SIG2(int,ptr), | |
4744 | + AP_HOOK_TOPMOST, | |
4745 | + &destport, r); | |
4746 | + ap_snprintf(portstr, sizeof(portstr), "%d", DEFAULT_HTTP_PORT); | |
4747 | + destportstr = portstr; | |
4748 | +#endif /* EAPI */ | |
4749 | + | |
4750 | strp = strchr(urlptr, '/'); | |
4751 | if (strp == NULL) { | |
4752 | desthost = ap_pstrdup(p, urlptr); | |
4753 | @@ -374,13 +388,41 @@ | |
4754 | f = ap_bcreate(p, B_RDWR | B_SOCKET); | |
4755 | ap_bpushfd(f, sock, sock); | |
4756 | ||
4757 | +#ifdef EAPI | |
4758 | + { | |
4759 | + char *errmsg = NULL; | |
4760 | + ap_hook_use("ap::mod_proxy::http::handler::new_connection", | |
4761 | + AP_HOOK_SIG3(ptr,ptr,ptr), | |
4762 | + AP_HOOK_DECLINE(NULL), | |
4763 | + &errmsg, r, f); | |
4764 | + if (errmsg != NULL) | |
4765 | + return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg); | |
4766 | + } | |
4767 | +#endif /* EAPI */ | |
4768 | + | |
4769 | ap_hard_timeout("proxy send", r); | |
4770 | ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF, | |
4771 | NULL); | |
4772 | +#ifdef EAPI | |
4773 | + { | |
4774 | + int rc = DECLINED; | |
4775 | + ap_hook_use("ap::mod_proxy::http::handler::write_host_header", | |
4776 | + AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr), | |
4777 | + AP_HOOK_DECLINE(DECLINED), | |
4778 | + &rc, r, f, desthost, destport, destportstr); | |
4779 | + if (rc == DECLINED) { | |
4780 | + if (destportstr != NULL && destport != DEFAULT_HTTP_PORT) | |
4781 | + ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL); | |
4782 | + else | |
4783 | + ap_bvputs(f, "Host: ", desthost, CRLF, NULL); | |
4784 | + } | |
4785 | + } | |
4786 | +#else /* EAPI */ | |
4787 | if (destportstr != NULL && atoi(destportstr) != DEFAULT_HTTP_PORT) | |
4788 | ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL); | |
4789 | else | |
4790 | ap_bvputs(f, "Host: ", desthost, CRLF, NULL); | |
4791 | +#endif /* EAPI */ | |
4792 | ||
4793 | if (conf->viaopt == via_block) { | |
4794 | /* Block all outgoing Via: headers */ | |
4795 | diff -Nru apache_1.3.9/src/modules/standard/mod_define.c apache_1.3.9.EAPI/src/modules/standard/mod_define.c | |
4796 | --- apache_1.3.9/src/modules/standard/mod_define.c Thu Jan 1 01:00:00 1970 | |
4797 | +++ apache_1.3.9.EAPI/src/modules/standard/mod_define.c Wed Dec 29 21:25:56 1999 | |
4798 | @@ -0,0 +1,446 @@ | |
4799 | +/* ==================================================================== | |
4800 | + * Copyright (c) 1995-1998 The Apache Group. All rights reserved. | |
4801 | + * | |
4802 | + * Redistribution and use in source and binary forms, with or without | |
4803 | + * modification, are permitted provided that the following conditions | |
4804 | + * are met: | |
4805 | + * | |
4806 | + * 1. Redistributions of source code must retain the above copyright | |
4807 | + * notice, this list of conditions and the following disclaimer. | |
4808 | + * | |
4809 | + * 2. Redistributions in binary form must reproduce the above copyright | |
4810 | + * notice, this list of conditions and the following disclaimer in | |
4811 | + * the documentation and/or other materials provided with the | |
4812 | + * distribution. | |
4813 | + * | |
4814 | + * 3. All advertising materials mentioning features or use of this | |
4815 | + * software must display the following acknowledgment: | |
4816 | + * "This product includes software developed by the Apache Group | |
4817 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
4818 | + * | |
4819 | + * 4. The names "Apache Server" and "Apache Group" must not be used to | |
4820 | + * endorse or promote products derived from this software without | |
4821 | + * prior written permission. For written permission, please contact | |
4822 | + * apache@apache.org. | |
4823 | + * | |
4824 | + * 5. Products derived from this software may not be called "Apache" | |
4825 | + * nor may "Apache" appear in their names without prior written | |
4826 | + * permission of the Apache Group. | |
4827 | + * | |
4828 | + * 6. Redistributions of any form whatsoever must retain the following | |
4829 | + * acknowledgment: | |
4830 | + * "This product includes software developed by the Apache Group | |
4831 | + * for use in the Apache HTTP server project (http://www.apache.org/)." | |
4832 | + * | |
4833 | + * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY | |
4834 | + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
4835 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
4836 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR | |
4837 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
4838 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
4839 | + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
4840 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
4841 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
4842 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
4843 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
4844 | + * OF THE POSSIBILITY OF SUCH DAMAGE. | |
4845 | + * ==================================================================== | |
4846 | + * | |
4847 | + * This software consists of voluntary contributions made by many | |
4848 | + * individuals on behalf of the Apache Group and was originally based | |
4849 | + * on public domain software written at the National Center for | |
4850 | + * Supercomputing Applications, University of Illinois, Urbana-Champaign. | |
4851 | + * For more information on the Apache Group and the Apache HTTP server | |
4852 | + * project, please see <http://www.apache.org/>. | |
4853 | + * | |
4854 | + */ | |
4855 | + | |
4856 | +/* | |
4857 | +** mod_define.c -- Apache module for configuration defines ($xxx) | |
4858 | +** v1.0: Originally written in December 1998 by | |
4859 | +** Ralf S. Engelschall <rse@engelschall.com> and | |
4860 | +** Christian Reiber <chrei@en.muc.de> | |
4861 | +** v1.1: Completely Overhauled in August 1999 by | |
4862 | +** Ralf S. Engelschall <rse@engelschall.com> | |
4863 | +*/ | |
4864 | + | |
4865 | +#include "ap_config.h" | |
4866 | +#include "ap_ctype.h" | |
4867 | +#include "httpd.h" | |
4868 | +#include "http_config.h" | |
4869 | +#include "http_conf_globals.h" | |
4870 | +#include "http_core.h" | |
4871 | +#include "http_log.h" | |
4872 | + | |
4873 | +#ifndef EAPI | |
4874 | +#error "This module requires the Extended API (EAPI) facilities." | |
4875 | +#endif | |
4876 | + | |
4877 | +/* | |
4878 | + * The global table of defines | |
4879 | + */ | |
4880 | + | |
4881 | +static table *tDefines = NULL; /* global table of defines */ | |
4882 | +static int bOnceSeenADefine = FALSE; /* optimization flag */ | |
4883 | + | |
4884 | +/* | |
4885 | + * Forward declaration | |
4886 | + */ | |
4887 | +static int DefineIndex (pool *, char *, int *, int *, char **); | |
4888 | +static char *DefineFetch (pool *, char *); | |
4889 | +static char *DefineExpand (pool *, char *, int, char *); | |
4890 | +static void DefineInit (pool *); | |
4891 | +static void DefineCleanup (void *); | |
4892 | +static char *DefineRewriteHook(cmd_parms *, void *, const char *); | |
4893 | + | |
4894 | +/* | |
4895 | + * Character classes for scanner function | |
4896 | + */ | |
4897 | +typedef enum { | |
4898 | + CC_ESCAPE, CC_DOLLAR, CC_BRACEOPEN, CC_BRACECLOSE, | |
4899 | + CC_IDCHAR1, CC_IDCHAR, CC_OTHER, CC_EOS | |
4900 | +} CharClass; | |
4901 | + | |
4902 | +/* | |
4903 | + * Scanner states for scanner function | |
4904 | + */ | |
4905 | +typedef enum { | |
4906 | + SS_NONE, SS_SKIP, SS_DOLLAR, SS_TOKEN_BRACED, | |
4907 | + SS_TOKEN_UNBRACED, SS_ERROR, SS_FOUND | |
4908 | +} ScanState; | |
4909 | + | |
4910 | +/* | |
4911 | + * Default meta characters | |
4912 | + */ | |
4913 | +#define DEFAULT_MC_ESCAPE "\\" | |
4914 | +#define DEFAULT_MC_DOLLAR "$" | |
4915 | +#define DEFAULT_MC_BRACEOPEN "{" | |
4916 | +#define DEFAULT_MC_BRACECLOSE "}" | |
4917 | + | |
4918 | +/* | |
4919 | + * Scanner for variable constructs $xxx and ${xxx} | |
4920 | + */ | |
4921 | +static int DefineIndex(pool *p, char *cpLine, int *pos, int *len, char **cpVar) | |
4922 | +{ | |
4923 | + int rc; | |
4924 | + char *cp; | |
4925 | + char *cp2; | |
4926 | + CharClass cc; | |
4927 | + char cEscape; | |
4928 | + char cDefine; | |
4929 | + char cBraceOpen; | |
4930 | + char cBraceClose; | |
4931 | + char *cpError; | |
4932 | + ScanState s; | |
4933 | + | |
4934 | + cEscape = DEFAULT_MC_ESCAPE[0]; | |
4935 | + if ((cp = DefineFetch(p, "mod_define::escape")) != NULL) | |
4936 | + cEscape = cp[0]; | |
4937 | + cDefine = DEFAULT_MC_DOLLAR[0]; | |
4938 | + if ((cp = DefineFetch(p, "mod_define::dollar")) != NULL) | |
4939 | + cDefine = cp[0]; | |
4940 | + cBraceOpen = DEFAULT_MC_BRACEOPEN[0]; | |
4941 | + if ((cp = DefineFetch(p, "mod_define::braceopen")) != NULL) | |
4942 | + cBraceOpen = cp[0]; | |
4943 | + cBraceClose = DEFAULT_MC_BRACECLOSE[0]; | |
4944 | + if ((cp = DefineFetch(p, "mod_define::braceclose")) != NULL) | |
4945 | + cBraceClose = cp[0]; | |
4946 | + | |
4947 | + rc = 0; | |
4948 | + *len = 0; | |
4949 | + cc = CC_OTHER; | |
4950 | + s = SS_NONE; | |
4951 | + for (cp = cpLine+(*pos); cc != CC_EOS; cp++) { | |
4952 | + if (*cp == cEscape) | |
4953 | + cc = CC_ESCAPE; | |
4954 | + else if (*cp == cDefine) | |
4955 | + cc = CC_DOLLAR; | |
4956 | + else if (*cp == cBraceOpen) | |
4957 | + cc = CC_BRACEOPEN; | |
4958 | + else if (*cp == cBraceClose) | |
4959 | + cc = CC_BRACECLOSE; | |
4960 | + else if (ap_isalpha(*cp)) | |
4961 | + cc = CC_IDCHAR1; | |
4962 | + else if (ap_isdigit(*cp) || *cp == '_' || *cp == ':') | |
4963 | + cc = CC_IDCHAR; | |
4964 | + else if (*cp == '\0') | |
4965 | + cc = CC_EOS; | |
4966 | + else | |
4967 | + cc = CC_OTHER; | |
4968 | + switch (s) { | |
4969 | + case SS_NONE: | |
4970 | + switch (cc) { | |
4971 | + case CC_ESCAPE: | |
4972 | + s = SS_SKIP; | |
4973 | + break; | |
4974 | + case CC_DOLLAR: | |
4975 | + s = SS_DOLLAR; | |
4976 | + break; | |
4977 | + default: | |
4978 | + break; | |
4979 | + } | |
4980 | + break; | |
4981 | + case SS_SKIP: | |
4982 | + s = SS_NONE; | |
4983 | + continue; | |
4984 | + break; | |
4985 | + case SS_DOLLAR: | |
4986 | + switch (cc) { | |
4987 | + case CC_BRACEOPEN: | |
4988 | + s = SS_TOKEN_BRACED; | |
4989 | + *pos = cp-cpLine-1; | |
4990 | + (*len) = 2; | |
4991 | + *cpVar = cp+1; | |
4992 | + break; | |
4993 | + case CC_IDCHAR1: | |
4994 | + s = SS_TOKEN_UNBRACED; | |
4995 | + *pos = cp-cpLine-1; | |
4996 | + (*len) = 2; | |
4997 | + *cpVar = cp; | |
4998 | + break; | |
4999 | + case CC_ESCAPE: | |
5000 | + s = SS_SKIP; | |
5001 | + break; | |
5002 | + default: | |
5003 | + s = SS_NONE; | |
5004 | + break; | |
5005 | + } | |
5006 | + break; | |
5007 | + case SS_TOKEN_BRACED: | |
5008 | + switch (cc) { | |
5009 | + case CC_IDCHAR1: | |
5010 | + case CC_IDCHAR: | |
5011 | + (*len)++; | |
5012 | + break; | |
5013 | + case CC_BRACECLOSE: | |
5014 | + (*len)++; | |
5015 | + cp2 = ap_palloc(p, cp-*cpVar+1); | |
5016 | + ap_cpystrn(cp2, *cpVar, cp-*cpVar+1); | |
5017 | + *cpVar = cp2; | |
5018 | + s = SS_FOUND; | |
5019 | + break; | |
5020 | + default: | |
5021 | + cpError = ap_psprintf(p, "Illegal character '%c' in identifier", *cp); | |
5022 | + s = SS_ERROR; | |
5023 | + break; | |
5024 | + } | |
5025 | + break; | |
5026 | + case SS_TOKEN_UNBRACED: | |
5027 | + switch (cc) { | |
5028 | + case CC_IDCHAR1: | |
5029 | + case CC_IDCHAR: | |
5030 | + (*len)++; | |
5031 | + break; | |
5032 | + default: | |
5033 | + cp2 = ap_palloc(p, cp-*cpVar+1); | |
5034 | + ap_cpystrn(cp2, *cpVar, cp-*cpVar+1); | |
5035 | + *cpVar = cp2; | |
5036 | + s = SS_FOUND; | |
5037 | + break; | |
5038 | + } | |
5039 | + break; | |
5040 | + case SS_FOUND: | |
5041 | + case SS_ERROR: | |
5042 | + break; | |
5043 | + } | |
5044 | + if (s == SS_ERROR) { | |
5045 | + fprintf(stderr, "Error\n"); | |
5046 | + break; | |
5047 | + } | |
5048 | + else if (s == SS_FOUND) { | |
5049 | + rc = 1; | |
5050 | + break; | |
5051 | + } | |
5052 | + } | |
5053 | + return rc; | |
5054 | +} | |
5055 | + | |
5056 | +/* | |
5057 | + * Determine the value of a variable | |
5058 | + */ | |
5059 | +static char *DefineFetch(pool *p, char *cpVar) | |
5060 | +{ | |
5061 | + char *cpVal; | |
5062 | + | |
5063 | + /* first try out table */ | |
5064 | + if ((cpVal = (char *)ap_table_get(tDefines, (char *)cpVar)) != NULL) | |
5065 | + return cpVal; | |
5066 | + /* second try the environment */ | |
5067 | + if ((cpVal = getenv(cpVar)) != NULL) | |
5068 | + return cpVal; | |
5069 | + return NULL; | |
5070 | +} | |
5071 | + | |
5072 | +/* | |
5073 | + * Expand a variable | |
5074 | + */ | |
5075 | +static char *DefineExpand(pool *p, char *cpToken, int tok_len, char *cpVal) | |
5076 | +{ | |
5077 | + char *cp; | |
5078 | + int val_len, rest_len; | |
5079 | + | |
5080 | + val_len = strlen(cpVal); | |
5081 | + rest_len = strlen(cpToken+tok_len); | |
5082 | + if (val_len < tok_len) | |
5083 | + memcpy(cpToken+val_len, cpToken+tok_len, rest_len+1); | |
5084 | + else if (val_len > tok_len) | |
5085 | + for (cp = cpToken+strlen(cpToken); cp > cpToken+tok_len-1; cp--) | |
5086 | + *(cp+(val_len-tok_len)) = *cp; | |
5087 | + memcpy(cpToken, cpVal, val_len); | |
5088 | + return NULL; | |
5089 | +} | |
5090 | + | |
5091 | +/* | |
5092 | + * The EAPI hook which is called after Apache has read a | |
5093 | + * configuration line and before it's actually processed | |
5094 | + */ | |
5095 | +static char *DefineRewriteHook(cmd_parms *cmd, void *config, const char *line) | |
5096 | +{ | |
5097 | + pool *p; | |
5098 | + char *cpBuf; | |
5099 | + char *cpLine; | |
5100 | + int pos; | |
5101 | + int len; | |
5102 | + char *cpError; | |
5103 | + char *cpVar; | |
5104 | + char *cpVal; | |
5105 | + server_rec *s; | |
5106 | + | |
5107 | + /* runtime optimization */ | |
5108 | + if (!bOnceSeenADefine) | |
5109 | + return NULL; | |
5110 | + | |
5111 | + p = cmd->pool; | |
5112 | + s = cmd->server; | |
5113 | + | |
5114 | + /* | |
5115 | + * Search for: | |
5116 | + * ....\$[a-zA-Z][:_a-zA-Z0-9]*.... | |
5117 | + * ....\${[a-zA-Z][:_a-zA-Z0-9]*}.... | |
5118 | + */ | |
5119 | + cpBuf = NULL; | |
5120 | + cpLine = (char *)line; | |
5121 | + pos = 0; | |
5122 | + while (DefineIndex(p, cpLine, &pos, &len, &cpVar)) { | |
5123 | +#ifdef DEFINE_DEBUG | |
5124 | + { | |
5125 | + char prefix[1024]; | |
5126 | + char marker[1024]; | |
5127 | + int i; | |
5128 | + for (i = 0; i < pos; i++) | |
5129 | + prefix[i] = ' '; | |
5130 | + prefix[i] = '\0'; | |
5131 | + for (i = 0; i < len; i++) | |
5132 | + marker[i] = '^'; | |
5133 | + marker[i] = '\0'; | |
5134 | + fprintf(stderr, | |
5135 | + "Found variable `%s' (pos: %d, len: %d)\n" | |
5136 | + " %s\n" | |
5137 | + " %s%s\n", | |
5138 | + cpVar, pos, len, cpLine, prefix, marker); | |
5139 | + } | |
5140 | +#endif | |
5141 | + if (cpBuf == NULL) { | |
5142 | + cpBuf = ap_palloc(p, MAX_STRING_LEN); | |
5143 | + ap_cpystrn(cpBuf, line, MAX_STRING_LEN); | |
5144 | + cpLine = cpBuf; | |
5145 | + } | |
5146 | + if ((cpVal = DefineFetch(p, cpVar)) == NULL) { | |
5147 | + ap_log_error(APLOG_MARK, APLOG_ERR, s, | |
5148 | + "mod_define: Variable '%s' not defined: file %s, line %d", | |
5149 | + cpVar, cmd->config_file->name, | |
5150 | + cmd->config_file->line_number); | |
5151 | + cpBuf = NULL; | |
5152 | + break; | |
5153 | + } | |
5154 | + if ((cpError = DefineExpand(p, cpLine+pos, len, cpVal)) != NULL) { | |
5155 | + ap_log_error(APLOG_MARK, APLOG_ERR, s, | |
5156 | + "mod_define: %s: file %s, line %d", | |
5157 | + cpError, cmd->config_file->name, | |
5158 | + cmd->config_file->line_number); | |
5159 | + cpBuf = NULL; | |
5160 | + break; | |
5161 | + } | |
5162 | + } | |
5163 | + return cpBuf; | |
5164 | +} | |
5165 | + | |
5166 | +/* | |
5167 | + * Implementation of the `Define' configuration directive | |
5168 | + */ | |
5169 | +static const char *cmd_define(cmd_parms *cmd, void *config, | |
5170 | + char *cpVar, char *cpVal) | |
5171 | +{ | |
5172 | + if (tDefines == NULL) | |
5173 | + DefineInit(cmd->pool); | |
5174 | + ap_table_set(tDefines, cpVar, cpVal); | |
5175 | + bOnceSeenADefine = TRUE; | |
5176 | + return NULL; | |
5177 | +} | |
5178 | + | |
5179 | +/* | |
5180 | + * Module Initialization | |
5181 | + */ | |
5182 | + | |
5183 | +static void DefineInit(pool *p) | |
5184 | +{ | |
5185 | + tDefines = ap_make_table(p, 10); | |
5186 | + /* predefine delimiters */ | |
5187 | + ap_table_set(tDefines, "mod_define::escape", DEFAULT_MC_ESCAPE); | |
5188 | + ap_table_set(tDefines, "mod_define::dollar", DEFAULT_MC_DOLLAR); | |
5189 | + ap_table_set(tDefines, "mod_define::open", DEFAULT_MC_BRACEOPEN); | |
5190 | + ap_table_set(tDefines, "mod_define::close", DEFAULT_MC_BRACECLOSE); | |
5191 | + ap_register_cleanup(p, NULL, DefineCleanup, ap_null_cleanup); | |
5192 | + return; | |
5193 | +} | |
5194 | + | |
5195 | +/* | |
5196 | + * Module Cleanup | |
5197 | + */ | |
5198 | + | |
5199 | +static void DefineCleanup(void *data) | |
5200 | +{ | |
5201 | + /* reset private variables when config pool is cleared */ | |
5202 | + tDefines = NULL; | |
5203 | + bOnceSeenADefine = FALSE; | |
5204 | + return; | |
5205 | +} | |
5206 | + | |
5207 | +/* | |
5208 | + * Module Directive lists | |
5209 | + */ | |
5210 | +static const command_rec DefineDirectives[] = { | |
5211 | + { "Define", cmd_define, NULL, RSRC_CONF|ACCESS_CONF, TAKE2, | |
5212 | + "Define a configuration variable" }, | |
5213 | + { NULL } | |
5214 | +}; | |
5215 | + | |
5216 | +/* | |
5217 | + * Module API dispatch list | |
5218 | + */ | |
5219 | +module MODULE_VAR_EXPORT define_module = { | |
5220 | + STANDARD_MODULE_STUFF, | |
5221 | + NULL, /* module initializer */ | |
5222 | + NULL, /* create per-dir config structures */ | |
5223 | + NULL, /* merge per-dir config structures */ | |
5224 | + NULL, /* create per-server config structures */ | |
5225 | + NULL, /* merge per-server config structures */ | |
5226 | + DefineDirectives, /* table of config file commands */ | |
5227 | + NULL, /* [#8] MIME-typed-dispatched handlers */ | |
5228 | + NULL, /* [#1] URI to filename translation */ | |
5229 | + NULL, /* [#4] validate user id from request */ | |
5230 | + NULL, /* [#5] check if the user is ok _here_ */ | |
5231 | + NULL, /* [#2] check access by host address */ | |
5232 | + NULL, /* [#6] determine MIME type */ | |
5233 | + NULL, /* [#7] pre-run fixups */ | |
5234 | + NULL, /* [#9] log a transaction */ | |
5235 | + NULL, /* [#3] header parser */ | |
5236 | + NULL, /* child_init */ | |
5237 | + NULL, /* child_exit */ | |
5238 | + NULL, /* [#0] post read-request */ | |
5239 | + NULL, /* EAPI: add_module */ | |
5240 | + NULL, /* EAPI: del_module */ | |
5241 | + DefineRewriteHook, /* EAPI: rewrite_command */ | |
5242 | + NULL /* EAPI: new_connection */ | |
5243 | +}; | |
5244 | + | |
5245 | diff -Nru apache_1.3.9/src/modules/standard/mod_log_config.c apache_1.3.9.EAPI/src/modules/standard/mod_log_config.c | |
5246 | --- apache_1.3.9/src/modules/standard/mod_log_config.c Wed Dec 29 22:03:42 1999 | |
5247 | +++ apache_1.3.9.EAPI/src/modules/standard/mod_log_config.c Wed Dec 29 21:25:56 1999 | |
5248 | @@ -252,6 +252,9 @@ | |
5249 | typedef const char *(*item_key_func) (request_rec *, char *); | |
5250 | ||
5251 | typedef struct { | |
5252 | +#ifdef EAPI | |
5253 | + char ch; | |
5254 | +#endif | |
5255 | item_key_func func; | |
5256 | char *arg; | |
5257 | int condition_sense; | |
5258 | @@ -511,15 +514,36 @@ | |
5259 | } | |
5260 | }; | |
5261 | ||
5262 | +#ifdef EAPI | |
5263 | +static struct log_item_list *find_log_func(pool *p, char k) | |
5264 | +#else /* EAPI */ | |
5265 | static struct log_item_list *find_log_func(char k) | |
5266 | +#endif /* EAPI */ | |
5267 | { | |
5268 | int i; | |
5269 | +#ifdef EAPI | |
5270 | + struct log_item_list *lil; | |
5271 | +#endif /* EAPI */ | |
5272 | ||
5273 | for (i = 0; log_item_keys[i].ch; ++i) | |
5274 | if (k == log_item_keys[i].ch) { | |
5275 | return &log_item_keys[i]; | |
5276 | } | |
5277 | ||
5278 | +#ifdef EAPI | |
5279 | + if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k)) | |
5280 | + != AP_HOOK_STATE_NOTEXISTANT) { | |
5281 | + lil = (struct log_item_list *) | |
5282 | + ap_pcalloc(p, sizeof(struct log_item_list)); | |
5283 | + if (lil == NULL) | |
5284 | + return NULL; | |
5285 | + lil->ch = k; | |
5286 | + lil->func = NULL; | |
5287 | + lil->want_orig_default = 0; | |
5288 | + return lil; | |
5289 | + } | |
5290 | +#endif /* EAPI */ | |
5291 | + | |
5292 | return NULL; | |
5293 | } | |
5294 | ||
5295 | @@ -645,7 +669,11 @@ | |
5296 | break; | |
5297 | ||
5298 | default: | |
5299 | +#ifdef EAPI | |
5300 | + l = find_log_func(p, *s++); | |
5301 | +#else /* EAPI */ | |
5302 | l = find_log_func(*s++); | |
5303 | +#endif /* EAPI */ | |
5304 | if (!l) { | |
5305 | char dummy[2]; | |
5306 | ||
5307 | @@ -654,6 +682,9 @@ | |
5308 | return ap_pstrcat(p, "Unrecognized LogFormat directive %", | |
5309 | dummy, NULL); | |
5310 | } | |
5311 | +#ifdef EAPI | |
5312 | + it->ch = s[-1]; | |
5313 | +#endif | |
5314 | it->func = l->func; | |
5315 | if (it->want_orig == -1) { | |
5316 | it->want_orig = l->want_orig_default; | |
5317 | @@ -715,6 +746,15 @@ | |
5318 | ||
5319 | /* We do. Do it... */ | |
5320 | ||
5321 | +#ifdef EAPI | |
5322 | + if (item->func == NULL) { | |
5323 | + cp = NULL; | |
5324 | + ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch), | |
5325 | + AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL), | |
5326 | + &cp, r, item->arg); | |
5327 | + } | |
5328 | + else | |
5329 | +#endif | |
5330 | cp = (*item->func) (item->want_orig ? orig : r, item->arg); | |
5331 | return cp ? cp : "-"; | |
5332 | } | |
5333 | diff -Nru apache_1.3.9/src/modules/standard/mod_rewrite.c apache_1.3.9.EAPI/src/modules/standard/mod_rewrite.c | |
5334 | --- apache_1.3.9/src/modules/standard/mod_rewrite.c Wed Dec 29 22:03:43 1999 | |
5335 | +++ apache_1.3.9.EAPI/src/modules/standard/mod_rewrite.c Wed Dec 29 21:25:56 1999 | |
5336 | @@ -3746,6 +3746,15 @@ | |
5337 | } | |
5338 | #endif /* ndef WIN32 */ | |
5339 | ||
5340 | +#ifdef EAPI | |
5341 | + else { | |
5342 | + ap_hook_use("ap::mod_rewrite::lookup_variable", | |
5343 | + AP_HOOK_SIG3(ptr,ptr,ptr), | |
5344 | + AP_HOOK_DECLINE(NULL), | |
5345 | + &result, r, var); | |
5346 | + } | |
5347 | +#endif | |
5348 | + | |
5349 | if (result == NULL) { | |
5350 | return ap_pstrdup(r->pool, ""); | |
5351 | } | |
5352 | diff -Nru apache_1.3.9/src/modules/standard/mod_so.c apache_1.3.9.EAPI/src/modules/standard/mod_so.c | |
5353 | --- apache_1.3.9/src/modules/standard/mod_so.c Wed Dec 29 22:03:43 1999 | |
5354 | +++ apache_1.3.9.EAPI/src/modules/standard/mod_so.c Wed Dec 29 21:25:56 1999 | |
5355 | @@ -257,7 +257,12 @@ | |
5356 | * Make sure the found module structure is really a module structure | |
5357 | * | |
5358 | */ | |
5359 | +#ifdef EAPI | |
5360 | + if ( modp->magic != MODULE_MAGIC_COOKIE_AP13 | |
5361 | + && modp->magic != MODULE_MAGIC_COOKIE_EAPI) { | |
5362 | +#else | |
5363 | if (modp->magic != MODULE_MAGIC_COOKIE) { | |
5364 | +#endif | |
5365 | return ap_pstrcat(cmd->pool, "API module structure `", modname, | |
5366 | "' in file ", szModuleFile, " is garbled -" | |
5367 | " perhaps this is not an Apache module DSO?", NULL); | |
5368 | diff -Nru apache_1.3.9/src/modules/standard/mod_status.c apache_1.3.9.EAPI/src/modules/standard/mod_status.c | |
5369 | --- apache_1.3.9/src/modules/standard/mod_status.c Wed Dec 29 22:03:43 1999 | |
5370 | +++ apache_1.3.9.EAPI/src/modules/standard/mod_status.c Wed Dec 29 21:25:56 1999 | |
5371 | @@ -480,12 +480,33 @@ | |
5372 | if (no_table_report) | |
5373 | ap_rputs("<p><hr><h2>Server Details</h2>\n\n", r); | |
5374 | else | |
5375 | +#ifndef NO_PRETTYPRINT | |
5376 | + ap_rputs("<p>\n\n<table bgcolor=\"#ffffff\" border=\"0\">" | |
5377 | + "<tr bgcolor=000000>" | |
5378 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Srv</b></font></td>" | |
5379 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>PID</b></font></td>" | |
5380 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Acc</b></font></td>" | |
5381 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>M</b></font></td>" | |
5382 | +#ifndef NO_TIMES | |
5383 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>CPU</b></font></td>" | |
5384 | +#endif | |
5385 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>SS</b></font></td>" | |
5386 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Req</b></font></td>" | |
5387 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Conn</b></font></td>" | |
5388 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Child</b></font></td>" | |
5389 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Slot</b></font></td>" | |
5390 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Host</b></font></td>" | |
5391 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>VHost</b></font></td>" | |
5392 | + "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Request</b></td>" | |
5393 | + "</tr>\n", r); | |
5394 | +#else /* NO_PRETTYPRINT */ | |
5395 | #ifdef NO_TIMES | |
5396 | /* Allow for OS/2 not having CPU stats */ | |
5397 | ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r); | |
5398 | #else | |
5399 | ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r); | |
5400 | #endif | |
5401 | +#endif /* NO_PRETTYPRINT */ | |
5402 | } | |
5403 | ||
5404 | for (i = 0; i < HARD_SERVER_LIMIT; ++i) { | |
5405 | @@ -602,14 +623,19 @@ | |
5406 | vhost ? vhost->server_hostname : "(unavailable)"); | |
5407 | } | |
5408 | else { /* !no_table_report */ | |
5409 | +#ifndef NO_PRETTYPRINT | |
5410 | + ap_rprintf(r,"<tr bgcolor=\"#ffffff\">"); | |
5411 | +#else | |
5412 | + ap_rprintf(r,"<tr>"); | |
5413 | +#endif | |
5414 | if (score_record.status == SERVER_DEAD) | |
5415 | ap_rprintf(r, | |
5416 | - "<tr><td><b>%d-%d</b><td>-<td>%d/%lu/%lu", | |
5417 | + "<td><b>%d-%d</b><td>-<td>%d/%lu/%lu", | |
5418 | i, (int) ps_record.generation, | |
5419 | (int) conn_lres, my_lres, lres); | |
5420 | else | |
5421 | ap_rprintf(r, | |
5422 | - "<tr><td><b>%d-%d</b><td>%d<td>%d/%lu/%lu", | |
5423 | + "<td><b>%d-%d</b><td>%d<td>%d/%lu/%lu", | |
5424 | i, (int) ps_record.generation, | |
5425 | (int) ps_record.pid, (int) conn_lres, | |
5426 | my_lres, lres); | |
5427 | @@ -669,11 +695,22 @@ | |
5428 | ap_rprintf(r, | |
5429 | "<td>?<td nowrap>?<td nowrap>..reading.. </tr>\n\n"); | |
5430 | else | |
5431 | +#ifndef NO_PRETTYPRINT | |
5432 | + ap_rprintf(r, | |
5433 | + "<td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">%s</font>" | |
5434 | + "<td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">%s</font>" | |
5435 | + "<td nowrap><font face=\"Arial,Helvetica\" size=\"-1\">%s</font>" | |
5436 | + "</tr>\n\n", | |
5437 | + score_record.client, | |
5438 | + vhost ? vhost->server_hostname : "(unavailable)", | |
5439 | + ap_escape_html(r->pool, score_record.request)); | |
5440 | +#else | |
5441 | ap_rprintf(r, | |
5442 | "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n", | |
5443 | score_record.client, | |
5444 | vhost ? vhost->server_hostname : "(unavailable)", | |
5445 | ap_escape_html(r->pool, score_record.request)); | |
5446 | +#endif | |
5447 | } /* no_table_report */ | |
5448 | } /* !short_report */ | |
5449 | } /* if (<active child>) */ | |
5450 | @@ -711,6 +748,12 @@ | |
5451 | </table>\n", r); | |
5452 | #endif | |
5453 | } | |
5454 | + | |
5455 | +#ifdef EAPI | |
5456 | + ap_hook_use("ap::mod_status::display", | |
5457 | + AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL, | |
5458 | + r, no_table_report, short_report); | |
5459 | +#endif | |
5460 | ||
5461 | } else { | |
5462 | ||
5463 | diff -Nru apache_1.3.9/src/support/apxs.pl apache_1.3.9.EAPI/src/support/apxs.pl | |
5464 | --- apache_1.3.9/src/support/apxs.pl Wed Dec 29 22:03:43 1999 | |
5465 | +++ apache_1.3.9.EAPI/src/support/apxs.pl Wed Dec 29 21:25:56 1999 | |
5466 | @@ -651,5 +651,11 @@ | |
5467 | NULL, /* child_init */ | |
5468 | NULL, /* child_exit */ | |
5469 | NULL /* [#0] post read-request */ | |
5470 | +#ifdef EAPI | |
5471 | + ,NULL, /* EAPI: add_module */ | |
5472 | + NULL, /* EAPI: remove_module */ | |
5473 | + NULL, /* EAPI: rewrite_command */ | |
5474 | + NULL /* EAPI: new_connection */ | |
5475 | +#endif | |
5476 | }; | |
5477 | ||
5478 | diff -Nru apache_1.3.9/src/support/httpd.exp apache_1.3.9.EAPI/src/support/httpd.exp | |
5479 | --- apache_1.3.9/src/support/httpd.exp Wed Dec 29 22:03:43 1999 | |
5480 | +++ apache_1.3.9.EAPI/src/support/httpd.exp Wed Dec 29 21:25:56 1999 | |
5481 | @@ -410,3 +410,59 @@ | |
5482 | XML_SetUnparsedEntityDeclHandler | |
5483 | XML_SetUserData | |
5484 | XML_UseParserAsHandlerArg | |
5485 | +ap_add_config_define | |
5486 | +ap_make_shared_sub_pool | |
5487 | +ap_global_ctx | |
5488 | +ap_ctx_new | |
5489 | +ap_ctx_get | |
5490 | +ap_ctx_set | |
5491 | +ap_hook_init | |
5492 | +ap_hook_kill | |
5493 | +ap_hook_configure | |
5494 | +ap_hook_register_I | |
5495 | +ap_hook_unregister_I | |
5496 | +ap_hook_status | |
5497 | +ap_hook_use | |
5498 | +ap_hook_call | |
5499 | +ap_mm_useable | |
5500 | +ap_MM_create | |
5501 | +ap_MM_permission | |
5502 | +ap_MM_destroy | |
5503 | +ap_MM_lock | |
5504 | +ap_MM_unlock | |
5505 | +ap_MM_malloc | |
5506 | +ap_MM_realloc | |
5507 | +ap_MM_free | |
5508 | +ap_MM_calloc | |
5509 | +ap_MM_strdup | |
5510 | +ap_MM_sizeof | |
5511 | +ap_MM_maxsize | |
5512 | +ap_MM_available | |
5513 | +ap_MM_error | |
5514 | +ap_mm_create | |
5515 | +ap_mm_permission | |
5516 | +ap_mm_destroy | |
5517 | +ap_mm_lock | |
5518 | +ap_mm_unlock | |
5519 | +ap_mm_malloc | |
5520 | +ap_mm_realloc | |
5521 | +ap_mm_free | |
5522 | +ap_mm_calloc | |
5523 | +ap_mm_strdup | |
5524 | +ap_mm_sizeof | |
5525 | +ap_mm_maxsize | |
5526 | +ap_mm_available | |
5527 | +ap_mm_error | |
5528 | +ap_mm_display_info | |
5529 | +ap_mm_core_create | |
5530 | +ap_mm_core_permission | |
5531 | +ap_mm_core_delete | |
5532 | +ap_mm_core_size | |
5533 | +ap_mm_core_lock | |
5534 | +ap_mm_core_unlock | |
5535 | +ap_mm_core_maxsegsize | |
5536 | +ap_mm_core_align2page | |
5537 | +ap_mm_core_align2word | |
5538 | +ap_mm_lib_error_set | |
5539 | +ap_mm_lib_error_get | |
5540 | +ap_mm_lib_version |