summaryrefslogtreecommitdiff
path: root/www/apache/patches/patch-af
blob: e702eea2084b3f8bd2106c7cc7a34c119a76d2f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
$NetBSD: patch-af,v 1.1 1998/12/03 17:23:53 tv Exp $

--- src/modules/standard/mod_include.c.orig	Thu Sep 24 10:06:42 1998
+++ src/modules/standard/mod_include.c	Wed Dec  2 10:36:06 1998
@@ -92,7 +92,9 @@
 #include "http_log.h"
 #include "http_main.h"
 #include "util_script.h"
+#include "ap_include_extern.h"
 #endif
+#define get_tag ap_include_get_tag
 
 #define STARTING_SEQUENCE "<!--#"
 #define ENDING_SEQUENCE "-->"
@@ -111,6 +113,12 @@
 /* just need some arbitrary non-NULL pointer which can't also be a request_rec */
 #define NESTED_INCLUDE_MAGIC	(&includes_module)
 
+static struct extern_handler {
+    struct extern_handler *next;
+    char cmd[20];
+    ap_include_extern_func func;
+} *extern_handlers;
+
 /* ------------------------ Environment function -------------------------- */
 
 /* XXX: could use ap_table_overlap here */
@@ -354,7 +362,8 @@
  * the tag value is html decoded if dodecode is non-zero
  */
 
-static char *get_tag(pool *p, FILE *in, char *tag, int tagbuf_len, int dodecode)
+API_EXPORT(char *)
+ap_include_get_tag(pool *p, FILE *in, char *tag, int tagbuf_len, int dodecode)
 {
     char *t = tag, *tag_val, c, term;
 
@@ -2090,6 +2099,50 @@
     }
 }
 
+API_EXPORT(int)
+ap_register_include_extern(const char *cmd, ap_include_extern_func func) {
+    struct extern_handler *h;
+
+    for (h = extern_handlers; h; h = h->next)
+	if (!strncmp(h->cmd, cmd, 20))
+	    return -1;
+    if (!(h = calloc(1, sizeof(*h))))
+	return -1;
+
+    h->next = extern_handlers;
+    strncpy(h->cmd, cmd, 20);
+    h->func = func;
+    extern_handlers = h;
+    return 0;
+}
+
+/*
+ * Since we should be compiled in, dynamic modules will all initialize
+ * _after_ us.  This assumption breaks if mod_includes is made dynamic,
+ * or if modules using ap_register_include_extern() are compiled in.
+ */
+static void includes_init(server_rec *s, pool *p) {
+    struct extern_handler *h, *n;
+
+    for (h = extern_handlers; h; h = n) {
+	n = h->next;
+	free(h);
+    }
+    extern_handlers = NULL;
+}
+
+static int do_externs(FILE *in, request_rec *r, const char *error,
+		      const char *cmd, int *ret) {
+    struct extern_handler *h;
+
+    for (h = extern_handlers; h; h = h->next)
+	if (!strncmp(h->cmd, cmd, 20)) {
+	    *ret = (*h->func)(in, r, error);
+	    return 0;
+	}
+    return -1;
+}
+
 
 
 /* -------------------------- The main function --------------------------- */
@@ -2213,6 +2266,7 @@
                 ret = handle_perl(f, r, error);
             }
 #endif
+	    else if (!do_externs(f, r, error, directive, &ret)) {}
             else {
                 ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
                             "httpd: unknown directive \"%s\" "
@@ -2420,7 +2474,7 @@
 module MODULE_VAR_EXPORT includes_module =
 {
     STANDARD_MODULE_STUFF,
-    NULL,                       /* initializer */
+    includes_init,              /* initializer */
     create_includes_dir_config, /* dir config creater */
     NULL,                       /* dir merger --- default is to override */
     NULL,                       /* server config */