From: Bill Stoddard Date: Fri, 30 Nov 2001 14:08:44 +0000 (+0000) Subject: Modify buff.h and buff.c to enable modules to intercept the X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=732ec6b15e0b0cb86b925d21ec7381bd9cb6acc9;p=thirdparty%2Fapache%2Fhttpd.git Modify buff.h and buff.c to enable modules to intercept the output byte stream for dynamic page caching. A pointer to a 'filter callback' function is added to the end of buff.h. This function, if registered by a module, is called at the top of buff_write() and writev_it_all(). MMN Minor bumped. Obtained from: [Kevin Mallory Reviewed by: Bill Stoddard git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@92260 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index 2eac0097cf3..1cb6daf3d1f 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,4 +1,11 @@ Changes with Apache 1.3.23 + *) Modify buff.h and buff.c to enable modules to intercept the + output byte stream for dynamic page caching. A pointer to a + 'filter callback' function is added to the end of buff.h. + This function, if registered by a module, is called + at the top of buff_write() and writev_it_all(). + [Kevin Mallory + *) When the default of 'Group #-1' was changed to 'Group "#-1"', the Makefile wasn't updated to recognise the quotation marks. [Owen Boyle ] diff --git a/src/include/ap_mmn.h b/src/include/ap_mmn.h index 287304970e1..fd99387b72e 100644 --- a/src/include/ap_mmn.h +++ b/src/include/ap_mmn.h @@ -231,6 +231,8 @@ * 19990320.8 - add request_rec.case_preserved_filename * 19990320.9 - renamed alloc.h to ap_alloc.h * 19990320.10 - add ap_is_rdirectory() and ap_stripprefix() + * 20011130.11 - Add a couple of fields, callback_data and + * filter_callback to the end of buff.h */ #define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */ @@ -238,7 +240,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 19990320 #endif -#define MODULE_MAGIC_NUMBER_MINOR 10 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 11 /* 0...n */ /* Useful for testing for features. */ #define AP_MODULE_MAGIC_AT_LEAST(major,minor) \ diff --git a/src/include/buff.h b/src/include/buff.h index c4353dc3c7e..6a12b4e766c 100644 --- a/src/include/buff.h +++ b/src/include/buff.h @@ -129,6 +129,10 @@ struct buff_struct { Sfio_t *sf_in; Sfio_t *sf_out; #endif + + void *callback_data; + void (*filter_callback)(BUFF *, const void *, int ); + }; #ifdef B_SFIO diff --git a/src/main/buff.c b/src/main/buff.c index b49ccc59a2b..79357044480 100644 --- a/src/main/buff.c +++ b/src/main/buff.c @@ -356,6 +356,10 @@ static ap_inline int buff_write(BUFF *fb, const void *buf, int nbyte) { int rv; + if (fb->filter_callback != NULL) { + fb->filter_callback(fb, buf, nbyte); + } + #if defined(WIN32) || defined(NETWARE) if (fb->flags & B_SOCKET) { rv = sendwithtimeout(fb->fd, buf, nbyte, 0); @@ -438,6 +442,9 @@ API_EXPORT(BUFF *) ap_bcreate(pool *p, int flags) (size_t) SF_UNBOUND, 1, SF_WRITE); #endif + fb->callback_data = NULL; + fb->filter_callback = NULL; + return fb; } @@ -1077,6 +1084,12 @@ static int write_it_all(BUFF *fb, const void *buf, int nbyte) static int writev_it_all(BUFF *fb, struct iovec *vec, int nvec) { int i, rv; + + if (fb->filter_callback != NULL) { + for (i = 0; i < nvec; i++) { + fb->filter_callback(fb, vec[i].iov_base, vec[i].iov_len); + } + } /* while it's nice an easy to build the vector and crud, it's painful * to deal with a partial writev()