]> granicus.if.org Git - apache/commitdiff
Remove all function pointers from the ap_bucket type. These function
authorRyan Bloom <rbb@apache.org>
Fri, 13 Oct 2000 05:35:57 +0000 (05:35 +0000)
committerRyan Bloom <rbb@apache.org>
Fri, 13 Oct 2000 05:35:57 +0000 (05:35 +0000)
pointers are replaced with a global table that allows modules to register
their bucket types.  Those bucket types are then allowed to be used in
the server processing.  This also required removing all direct calls to
those functions.  The ap_bucket type has an index into an array, so in
each ap_bucket_* function, we use that index to find the correct set of
functions.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86575 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/mod_charset_lite.c
modules/filters/mod_include.c
modules/http/http_core.c
modules/http/http_protocol.c
server/util_filter.c

index 992c42220dfbc157b77791112071b12837d15a15..ee1b0e3b13197c188aeb0bf7ced57aef01786b9a 100644 (file)
@@ -688,7 +688,7 @@ static apr_status_t xlate_filter(ap_filter_t *f, ap_bucket_brigade *bb)
                 }
                 break;
             }
-            rv = dptr->read(dptr, &cur_str, &cur_len, 0);
+            rv = ap_bucket_read(dptr, &cur_str, &cur_len, 0);
             if (rv != APR_SUCCESS) {
                 done = 1;
                 ctx->ees = EES_BUCKET_READ;
index 5514e247c70417abc27647264d039fd7f50ca1b6..1c27509898a4d988c02826b901ee638f6cbc4a07 100644 (file)
@@ -190,10 +190,10 @@ static ap_bucket *find_string(ap_bucket *dptr, const char *str, ap_bucket *end)
     int state = 0;
 
     do {
-        if (dptr->type == AP_BUCKET_EOS) {
+        if (dptr->type == ap_eos_type()) {
             break;
         }
-        dptr->read(dptr, &buf, &len, 0);
+        ap_bucket_read(dptr, &buf, &len, 0);
         /* XXX handle retcodes */
         if (len == 0) { /* end of pipe? */
             break;
@@ -210,10 +210,10 @@ static ap_bucket *find_string(ap_bucket *dptr, const char *str, ap_bucket *end)
                      * on what we are searching for.
                      */
                     if (str[0] == '<') {
-                        dptr->split(dptr, c - buf - strlen(str));
+                        ap_bucket_split(dptr, c - buf - strlen(str));
                     }
                     else {
-                        dptr->split(dptr, c - buf);
+                        ap_bucket_split(dptr, c - buf);
                     }
                     return AP_BUCKET_NEXT(dptr);
                 }
@@ -348,7 +348,7 @@ static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, in
 
     /* Remove all whitespace */
     while (dptr) { 
-        dptr->read(dptr, &str, &length, 0);
+        ap_bucket_read(dptr, &str, &length, 0);
         c = str + *offset;
         while (c - str < length) {
             if (!apr_isspace(*c)) {
@@ -365,14 +365,14 @@ static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, in
     if (*c == '-') {
         c++;
         if (c == '\0') {
-            dptr->read(dptr, &str, &length, 0);
+            ap_bucket_read(dptr, &str, &length, 0);
             c = str;
         }
         if (*c == '-') {
             do {
                 c++;
                 if (c == '\0') {
-                    dptr->read(dptr, &str, &length, 0);
+                    ap_bucket_read(dptr, &str, &length, 0);
                     c = str;
                 }
             } while (apr_isspace(*c));
@@ -397,7 +397,7 @@ static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, in
         *(t++) = apr_tolower(*c);
         c++;
         if (c == '\0') {
-            dptr->read(dptr, &str, &length, 0);
+            ap_bucket_read(dptr, &str, &length, 0);
             c = str;
         }
     }
@@ -408,7 +408,7 @@ static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, in
     while (apr_isspace(*c)) {
         c++;
         if (c == '\0') {
-            dptr->read(dptr, &str, &length, 0);
+            ap_bucket_read(dptr, &str, &length, 0);
             c = str;
         }
     }
@@ -420,7 +420,7 @@ static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, in
     do {
         c++;
         if (c == '\0') {
-            dptr->read(dptr, &str, &length, 0);
+            ap_bucket_read(dptr, &str, &length, 0);
             c = str;
         }
     } while (apr_isspace(*c));
@@ -434,7 +434,7 @@ static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, in
     while (1) {
         c++;
         if (c == '\0') {
-            dptr->read(dptr, &str, &length, 0);
+            ap_bucket_read(dptr, &str, &length, 0);
             c = str;
         }
         if (t - tag == tagbuf_len) {
@@ -446,7 +446,7 @@ static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, in
             *(t++) = *c;         /* Add backslash */
             c++;
             if (c == '\0') {
-                dptr->read(dptr, &str, &length, 0);
+                ap_bucket_read(dptr, &str, &length, 0);
                 c = str;
             }
             if (*c == term) {    /* Only if */
@@ -478,7 +478,7 @@ static int get_directive(ap_bucket *in, char *dest, size_t len, apr_pool_t *p)
     --len;
 
     while (dptr) {
-        dptr->read(dptr, &str, &length, 0);
+        ap_bucket_read(dptr, &str, &length, 0);
         /* need to start past the <!--#
          */
         c = str + strlen(STARTING_SEQUENCE);
@@ -496,7 +496,7 @@ static int get_directive(ap_bucket *in, char *dest, size_t len, apr_pool_t *p)
     /* now get directive */
     while (dptr) {
         if (c - str >= length) {
-            dptr->read(dptr, &str, &length, 0);
+            ap_bucket_read(dptr, &str, &length, 0);
         }
         while (c - str < length) {
            if (d - dest == (int)len) {
index 9f5fa5feb949bf4c4401d99696dc21fcd4cde86e..5404a9d1054f257c9156409f9176ee64e70e781e 100644 (file)
@@ -3095,14 +3095,14 @@ static apr_status_t buffer_filter(ap_filter_t *f, ap_bucket_brigade *b)
             ap_bucket_destroy(destroy_me);
             destroy_me = NULL;
         }
-        if ((e->type == AP_BUCKET_EOS)  || (e->type == AP_BUCKET_FILE) ||
-            (e->type == AP_BUCKET_PIPE)) {
+        if ((e->type == ap_eos_type())  || (e->type == ap_file_type()) ||
+            (e->type == ap_pipe_type())) {
             pass_the_brigade = 1;
         }
         else {
             const char *str;
             apr_ssize_t n;
-            rv = e->read(e, &str, &n, 0);
+            rv = ap_bucket_read(e, &str, &n, 0);
             if (rv != APR_SUCCESS) {
                 /* XXX: log error */
                 return rv;
@@ -3204,7 +3204,7 @@ static apr_status_t chunk_filter(ap_filter_t *f, ap_bucket_brigade *b)
         char chunk_hdr[20]; /* enough space for the snprintf below */
 
        AP_BRIGADE_FOREACH(e, b) {
-           if (e->type == AP_BUCKET_EOS) {
+           if (e->type == ap_eos_type()) {
                /* there shouldn't be anything after the eos */
                eos = e;
                break;
@@ -3214,7 +3214,7 @@ static apr_status_t chunk_filter(ap_filter_t *f, ap_bucket_brigade *b)
                const char *data;
                apr_ssize_t len;
 
-               rv = e->read(e, &data, &len, 1);
+               rv = ap_bucket_read(e, &data, &len, 1);
                if (rv != APR_SUCCESS) {
                    return rv;
                }
@@ -3378,10 +3378,10 @@ static int core_output_filter(ap_filter_t *f, ap_bucket_brigade *b)
         nbytes = 0; /* in case more points to another brigade */
         more = NULL;
         AP_BRIGADE_FOREACH(e, b) {
-            if (e->type == AP_BUCKET_EOS) {
+            if (e->type == ap_eos_type()) {
                 break;
             }
-            else if (e->type == AP_BUCKET_FILE) {
+            else if (e->type == ap_file_type()) {
                 ap_bucket_file *a = e->data;
                 /* Assume there is at most one AP_BUCKET_FILE in the brigade */
                 fd = a->fd;
@@ -3391,7 +3391,7 @@ static int core_output_filter(ap_filter_t *f, ap_bucket_brigade *b)
             else {
                 const char *str;
                 apr_ssize_t n;
-                rv = e->read(e, &str, &n, 0);
+                rv = ap_bucket_read(e, &str, &n, 0);
                 if (n) {
                     nbytes += n;
                     if (!fd) {
@@ -3420,7 +3420,7 @@ static int core_output_filter(ap_filter_t *f, ap_bucket_brigade *b)
         /* Completed iterating over the brigades, now determine if we want to
          * buffer the brigade or send the brigade out on the network
          */
-        if (!fd && (!more) && (nbytes < MIN_SIZE_TO_WRITE) && (e->type != AP_BUCKET_EOS)) {
+        if (!fd && (!more) && (nbytes < MIN_SIZE_TO_WRITE) && (e->type != ap_eos_type())) {
             ap_save_brigade(f, &ctx->b, &b);
             return APR_SUCCESS;
         }
@@ -3498,6 +3498,11 @@ static const handler_rec core_handlers[] = {
 { NULL, NULL }
 };
 
+static void core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
+{
+    ap_init_bucket_types(pconf);
+}
+
 static void core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 {
     ap_set_version(pconf);
@@ -3536,6 +3541,7 @@ static void core_insert_filter(request_rec *r)
 
 static void register_hooks(void)
 {
+    ap_hook_pre_config(core_pre_config, NULL, NULL, AP_HOOK_REALLY_FIRST);
     ap_hook_post_config(core_post_config,NULL,NULL,AP_HOOK_REALLY_FIRST);
     ap_hook_translate_name(ap_core_translate,NULL,NULL,AP_HOOK_REALLY_LAST);
     ap_hook_pre_connection(ap_pre_http_connection,NULL,NULL,
index 16ea62846f7663791be3de6396e7183db996725f..02dbfa4e432b8cb32f16c402a750b4cda9157acd 100644 (file)
@@ -895,7 +895,7 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t lengt
 
         e = AP_BRIGADE_FIRST(b);
         while (e != AP_BRIGADE_SENTINEL(b)) {
-            e->read(e, &ignore, &len, 0);
+            ap_bucket_read(e, &ignore, &len, 0);
             if (remain <= len) {
                 break;
             }
@@ -904,7 +904,7 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t lengt
         }
         if (e != AP_BRIGADE_SENTINEL(b)) {
             if (remain <= len) {
-                e->split(e, remain);
+                ap_bucket_split(e, remain);
                 remain = 0;
             }
             bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
@@ -918,13 +918,13 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t lengt
     }
 
     AP_BRIGADE_FOREACH(e, b) {
-        if ((rv = e->read(e, (const char **)&buff, &len, 0)) != APR_SUCCESS) {
+        if ((rv = ap_bucket_read(e, (const char **)&buff, &len, 0)) != APR_SUCCESS) {
             return rv;
         }
 
         pos = memchr(buff, ASCII_LF, len);
         if (pos != NULL) {
-            e->split(e, pos - buff + 1);
+            ap_bucket_split(e, pos - buff + 1);
             bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
             ctx->b = bb;
             return APR_SUCCESS;
@@ -970,7 +970,7 @@ static int getline(char *s, int n, conn_rec *c, int fold)
             ap_bucket_destroy(e);
             continue;
         }
-        retval = e->read(e, &temp, &length, 0);
+        retval = ap_bucket_read(e, &temp, &length, 0);
 
         if (retval != APR_SUCCESS) {
             total = ((length < 0) && (total == 0)) ? -1 : total;
@@ -2428,9 +2428,9 @@ API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
 
         total = 0;
         do {
-            rv = b->read(b, &tempbuf, &len_read, 0);
+            rv = ap_bucket_read(b, &tempbuf, &len_read, 0);
             if (len_to_read < b->length) { /* shouldn't happen */
-                b->split(b, len_to_read);
+                ap_bucket_split(b, len_to_read);
             }
             else {
                 len_to_read = len_read;
index 613881d408d349c17af9b809c93400448060353f..909f95dc0374ea56705cb33684f8da04c44b21f4 100644 (file)
@@ -212,7 +212,7 @@ API_EXPORT(apr_status_t) ap_get_brigade(ap_filter_t *next,
 API_EXPORT(apr_status_t) ap_pass_brigade(ap_filter_t *next, ap_bucket_brigade *bb)
 {
     if (next) {
-        if (AP_BRIGADE_LAST(bb)->type == AP_BUCKET_EOS && next->r) {
+        if (AP_BRIGADE_LAST(bb)->type == ap_eos_type() && next->r) {
             next->r->eos_sent = 1;
         }
         return next->frec->filter_func.out_func(next, bb);
@@ -234,8 +234,7 @@ API_EXPORT(void) ap_save_brigade(ap_filter_t *f, ap_bucket_brigade **saveto,
     }
     
     AP_RING_FOREACH(e, &(*b)->list, ap_bucket, link) {
-        if (e->setaside)
-            e->setaside(e);
+        ap_bucket_setaside(e);
     }
     AP_BRIGADE_CONCAT(*saveto, *b);
 }