📄 eapi.patch
字号:
* */+#ifdef EAPI+ if ( modp->magic != MODULE_MAGIC_COOKIE_AP13 + && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {+#else if (modp->magic != MODULE_MAGIC_COOKIE) {+#endif return ap_pstrcat(cmd->pool, "API module structure `", modname, "' in file ", szModuleFile, " is garbled -" " perhaps this is not an Apache module DSO?", NULL); }+#ifdef EAPI+ if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {+ ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,+ "Loaded DSO %s uses plain Apache 1.3 API, "+ "this module might crash under EAPI! "+ "(please recompile it with -DEAPI)", filename);+ }+#endif /* * Add this module to the Apache core structures+---------------------------------------------------------------------------| Add additional logging functions to the CustomLog directive| which can be used by other modules to create additional| logfile tags. Actually we add two types of hooks: One hook| for intercepting the new and generic %x (eXtension) tag and| one hook for creating new %x tags at all.+---------------------------------------------------------------------------Index: src/modules/standard/mod_log_config.c--- src/modules/standard/mod_log_config.c 2000/02/24 13:55:38 1.1.1.9+++ src/modules/standard/mod_log_config.c 2000/02/24 13:58:17 1.22@@ -257,6 +257,9 @@ typedef const char *(*item_key_func) (request_rec *, char *); typedef struct {+#ifdef EAPI+ char ch;+#endif item_key_func func; char *arg; int condition_sense;@@ -554,15 +557,36 @@ } }; +#ifdef EAPI+static struct log_item_list *find_log_func(pool *p, char k)+#else /* EAPI */ static struct log_item_list *find_log_func(char k)+#endif /* EAPI */ { int i;+#ifdef EAPI+ struct log_item_list *lil;+#endif /* EAPI */ for (i = 0; log_item_keys[i].ch; ++i) if (k == log_item_keys[i].ch) { return &log_item_keys[i]; } +#ifdef EAPI+ if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k)) + != AP_HOOK_STATE_NOTEXISTANT) {+ lil = (struct log_item_list *)+ ap_pcalloc(p, sizeof(struct log_item_list));+ if (lil == NULL)+ return NULL;+ lil->ch = k;+ lil->func = NULL;+ lil->want_orig_default = 0;+ return lil;+ }+#endif /* EAPI */+ return NULL; } @@ -688,7 +712,11 @@ break; default:+#ifdef EAPI+ l = find_log_func(p, *s++);+#else /* EAPI */ l = find_log_func(*s++);+#endif /* EAPI */ if (!l) { char dummy[2]; @@ -697,6 +725,9 @@ return ap_pstrcat(p, "Unrecognized LogFormat directive %", dummy, NULL); }+#ifdef EAPI+ it->ch = s[-1];+#endif it->func = l->func; if (it->want_orig == -1) { it->want_orig = l->want_orig_default;@@ -758,6 +789,15 @@ /* We do. Do it... */ +#ifdef EAPI+ if (item->func == NULL) {+ cp = NULL;+ ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),+ AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),+ &cp, r, item->arg);+ }+ else+#endif cp = (*item->func) (item->want_orig ? orig : r, item->arg); return cp ? cp : "-"; }+---------------------------------------------------------------------------| Allow RewriteCond and RewriteRule directives to lookup | variables from other modules.+---------------------------------------------------------------------------Index: src/modules/standard/mod_rewrite.c--- src/modules/standard/mod_rewrite.c 2000/01/21 18:06:43 1.1.1.7+++ src/modules/standard/mod_rewrite.c 2000/01/21 19:51:11 1.5@@ -3770,6 +3770,15 @@ } #endif /* ndef WIN32 && NETWARE*/ +#ifdef EAPI+ else {+ ap_hook_use("ap::mod_rewrite::lookup_variable",+ AP_HOOK_SIG3(ptr,ptr,ptr), + AP_HOOK_DECLINE(NULL),+ &result, r, var);+ }+#endif+ if (result == NULL) { return ap_pstrdup(r->pool, ""); }+---------------------------------------------------------------------------| Add an EAPI hook to allow other modules to add content to | the status HTML page.+---------------------------------------------------------------------------Index: src/modules/standard/mod_status.c--- src/modules/standard/mod_status.c 2000/02/24 13:55:40 1.1.1.9+++ src/modules/standard/mod_status.c 2000/02/24 13:58:17 1.6@@ -708,6 +745,12 @@ </table>\n", r); #endif }++#ifdef EAPI+ ap_hook_use("ap::mod_status::display",+ AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL,+ r, no_table_report, short_report);+#endif } else { +---------------------------------------------------------------------------| Add hooks to the scheme processing to allow other modules to| recognize more schemes by intercepting this processing.+---------------------------------------------------------------------------Index: src/modules/proxy/mod_proxy.c--- src/modules/proxy/mod_proxy.c 2000/01/21 18:06:35 1.1.1.6+++ src/modules/proxy/mod_proxy.c 2000/02/24 17:43:28 1.13@@ -214,6 +214,9 @@ static int proxy_fixup(request_rec *r) { char *url, *p;+#ifdef EAPI+ int rc;+#endif /* EAPI */ if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0) return DECLINED;@@ -221,6 +224,14 @@ url = &r->filename[6]; /* canonicalise each specific scheme */+#ifdef EAPI+ if (ap_hook_use("ap::mod_proxy::canon",+ AP_HOOK_SIG3(int,ptr,ptr),+ AP_HOOK_DECLINE(DECLINED),+ &rc, r, url) && rc != DECLINED)+ return rc; + else+#endif /* EAPI */ if (strncasecmp(url, "http:", 5) == 0) return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT); else if (strncasecmp(url, "ftp:", 4) == 0)@@ -236,9 +247,44 @@ static void proxy_init(server_rec *r, pool *p) { ap_proxy_garbage_init(r, p);+#ifdef EAPI+ ap_hook_use("ap::mod_proxy::init", + AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p);+#endif }- +#ifdef EAPI+static void proxy_addmod(module *m)+{+ /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */+ ap_hook_configure("ap::mod_proxy::http::canon", + AP_HOOK_SIG5(int,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);+ ap_hook_register("ap::mod_proxy::http::canon", + ap_proxy_http_canon, AP_HOOK_NOCTX);++ /* export: ap_proxy_http_handler() as `ap::mod_proxy::http::handler' */+ ap_hook_configure("ap::mod_proxy::http::handler", + AP_HOOK_SIG6(int,ptr,ptr,ptr,ptr,int), AP_HOOK_TOPMOST);+ ap_hook_register("ap::mod_proxy::http::handler", + ap_proxy_http_handler, AP_HOOK_NOCTX);++ /* export: ap_proxyerror() as `ap::mod_proxy::error' */+ ap_hook_configure("ap::mod_proxy::error", + AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_TOPMOST);+ ap_hook_register("ap::mod_proxy::error", + ap_proxyerror, AP_HOOK_NOCTX);+ return;+}++static void proxy_remmod(module *m)+{+ /* remove the hook references */+ ap_hook_unregister("ap::mod_proxy::http::canon", ap_proxy_http_canon);+ ap_hook_unregister("ap::mod_proxy::http::handler", ap_proxy_http_handler);+ ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror);+ return;+}+#endif /* EAPI */ /* Send a redirection if the request contains a hostname which is not */ /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */@@ -368,6 +414,14 @@ /* CONNECT is a special method that bypasses the normal * proxy code. */+#ifdef EAPI+ if (!ap_hook_use("ap::mod_proxy::handler",+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),+ AP_HOOK_DECLINE(DECLINED),+ &rc, r, cr, url, + ents[i].hostname, ents[i].port, + ents[i].protocol) || rc == DECLINED) {+#endif /* EAPI */ if (r->method_number == M_CONNECT) rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname, ents[i].port);@@ -377,6 +431,9 @@ ents[i].port); else rc = DECLINED;+#ifdef EAPI+ }+#endif /* EAPI */ /* an error or success */ if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)@@ -390,6 +447,14 @@ * give up?? */ /* handle the scheme */+#ifdef EAPI+ if (ap_hook_use("ap::mod_proxy::handler",+ AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr),+ AP_HOOK_DECLINE(DECLINED),+ &rc, r, cr, url, + NULL, 0, scheme) && rc != DECLINED)+ return rc;+#endif /* EAPI */ if (r->method_number == M_CONNECT) return ap_proxy_connect_handler(r, cr, url, NULL, 0); if (strcasecmp(scheme, "http") == 0)@@ -954,6 +1019,12 @@ NULL, /* child_init */ NULL, /* child_exit */ proxy_detect /* post read-request */+#ifdef EAPI+ ,proxy_addmod, /* EAPI: add_module */+ proxy_remmod, /* EAPI: remove_module */+ NULL, /* EAPI: rewrite_command */+ NULL /* EAPI: new_connection */+#endif }; +---------------------------------------------------------------------------| Add hooks to the HTTP processing to allow other modules| to enhance it by intercepting this processing.+---------------------------------------------------------------------------Index: src/modules/proxy/proxy_http.c--- src/modules/proxy/proxy_http.c 2000/01/21 18:06:36 1.1.1.7+++ src/modules/proxy/proxy_http.c 2000/02/24 17:43:28 1.15@@ -189,6 +189,9 @@ const char *urlptr = NULL; const char *datestr; struct tbl_do_args tdo;+#ifdef EAPI+ char *peer;+#endif void *sconf = r->server->module_config; proxy_server_conf *conf =@@ -207,6 +210,12 @@ return HTTP_BAD_REQUEST; urlptr += 3; destport = DEFAULT_HTTP_PORT;+#ifdef EAPI+ ap_hook_use("ap::mod_proxy::http::handler::set_destport", + AP_HOOK_SIG2(int,ptr), + AP_HOOK_TOPMOST,+ &destport, r);+#endif /* EAPI */ strp = strchr(urlptr, '/'); if (strp == NULL) { desthost = ap_pstrdup(p, urlptr);@@ -243,12 +252,18 @@ err = ap_proxy_host2addr(proxyhost, &server_hp); if (err != NULL) return DECLINED; /* try another */+#ifdef EAPI+ peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport); +#endif } else { server.sin_port = htons(destport); err = ap_proxy_host2addr(desthost, &server_hp); if (err != NULL) return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);+#ifdef EAPI+ peer = ap_psprintf(p, "%s:%u", desthost, destport); +#endif } sock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP);@@ -305,13 +320,41 @@ f = ap_bcreate(p, B_RDWR | B_SOCKET); ap_bpushfd(f, sock, sock); +#ifdef EAPI+ {+ char *errmsg = NULL;+ ap_hook_use("ap::mod_proxy::http::handler::new_connection", + AP_HOOK_SIG4(ptr,ptr,ptr,ptr), + AP_HOOK_DECLINE(NULL),+ &errmsg, r, f, peer);+ if (errmsg != NULL)+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg);+ }+#endif /* EAPI */+ ap_hard_timeout("proxy send", r); ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF, NULL);+#ifdef EAPI+ {+ int rc = DECLINED;+ ap_hook_use("ap::mod_proxy::http::handler::write_host_header", + AP_HOOK_SIG6(int,ptr,ptr,ptr,int,ptr), + AP_HOOK_DECLINE(DECLINED),+ &rc, r, f, desthost, destport, destportstr);+ if (rc == DECLINED) {+ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)+ ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);+ else+ ap_bvputs(f, "Host: ", desthost, CRLF, NULL);+ }+ }+#else /* EAPI */ if (destportstr != NULL && destport != DEFAULT_HTTP_PORT) ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL); else ap_bvputs(f, "Host: ", desthost, CRLF, NULL);+#endif /* EAPI */ if (conf->viaopt == via_block) { /* Block all outgoing Via: headers */+---------------------------------------------------------------------------| Add EAPI hooks in module structure for APXS generated samples.+---------------------------------------------------------------------------Index: src/support/apxs.pl--- src/support/apxs.pl 2000/02/24 13:55:48 1.1.1.7+++ src/support/apxs.pl 2000/02/24 13:58:17 1.7@@ -651,5 +651,11 @@ NULL, /* child_init */ NULL, /* child_exit */ NULL /* [#0] post read-request */+#ifdef EAPI+ ,NULL, /* EAPI: add_module */+ NULL, /* EAPI: remove_module */+ NULL, /* EAPI: rewrite_command */+ NULL /* EAPI: new_connection */+#endif }; +---------------------------------------------------------------------------| Add the EAPI functions, so the stuff can be built under AIX| and similar braindead platforms as DSO.+---------------------------------------------------------------------------Index: src/support/httpd.exp--- src/support/httpd.exp 2000/01/21 18:07:02 1.1.1.7+++ src/support/httpd.exp 2000/01/21 19:51:12 1.9@@ -413,3 +413,59 @@ XML_SetUnparsedEntityDeclHandler XML_SetUserData XML_UseParserAsHandlerArg+ap_add_config_define+ap_make_shared_sub_pool+ap_global_ctx+ap_ctx_new+ap_ctx_get+ap_ctx_set+ap_hook_init+ap_hook_kill+ap_hook_configure+ap_hook_register_I+ap_hook_unregister_I+ap_hook_status+ap_hook_use+ap_hook_call+ap_mm_useable+ap_MM_create+ap_MM_permission+ap_MM_destroy+ap_MM_lock+ap_MM_unlock+ap_MM_malloc+ap_MM_realloc+ap_MM_free+ap_MM_calloc+ap_MM_strdup+ap_MM_sizeof+ap_MM_maxsize+ap_MM_available+ap_MM_error+ap_mm_create+ap_mm_permission+ap_mm_destroy+ap_mm_lock+ap_mm_unlock+ap_mm_malloc+ap_mm_realloc+ap_mm_free+ap_mm_calloc+ap_mm_strdup+ap_mm_sizeof+ap_mm_maxsize+ap_mm_available+ap_mm_error+ap_mm_display_info+ap_mm_core_create+ap_mm_core_permission+ap_mm_core_delete+ap_mm_core_size+ap_mm_core_lock+ap_mm_core_unlock+ap_mm_core_maxsegsize+ap_mm_core_align2page+ap_mm_core_align2word+ap_mm_lib_error_set+ap_mm_lib_error_get+ap_mm_lib_version+---------------------------------------------------------------------------| Add the EAPI functions, so the stuff can be built under| Windows 95 and similar braindead platforms as DDL.+---------------------------------------------------------------------------Index: src/ApacheCore.def--- src/ApacheCore.def 2000/01/21 18:06:11 1.1.1.5+++ src/ApacheCore.def 2000/01/26 08:00:38 1.7@@ -360,3 +360,17 @@ ap_SHA1Final @355 ap_sha1_base64 @356 ap_send_error_response @357+ ap_add_config_define @358+ ap_global_ctx @359+ ap_ctx_new @360+ ap_ctx_get @361+ ap_ctx_set @362+ ap_hook_init @363+ ap_hook_kill @364+ ap_hook_configure @365+ ap_hook_register_I @366+ ap_hook_unregister_I @367+ ap_hook_status @368+ ap_hook_use @369+ ap_hook_call @370+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -