]> granicus.if.org Git - apache/commitdiff
Replace ap_get_data_from_filter and ap_save_data_to_filter with
authorRyan Bloom <rbb@apache.org>
Tue, 3 Oct 2000 00:44:00 +0000 (00:44 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 3 Oct 2000 00:44:00 +0000 (00:44 +0000)
ap_save_brigade.  This function does not try to save the actual brigade to
a specific location.  If just traverses the brigade, calls setaside if
it is available and concatenates it with a previously setaside brigade.

The resulting brigade is returned to the caller for them to save it to
the appropriate location.

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

include/util_filter.h
server/util_filter.c

index 41b4cd914ccab4a1bf349f31d7dcd9f3c1314bad..c7b20ba867740ca79abe730f854b68ecd5a60a6c 100644 (file)
@@ -346,28 +346,19 @@ API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r);
  * you retrieve data, if you pass in a bucket brigade to the get function,
  * it will append the current brigade onto the one that you are retrieving.
  */
-/**
- * Get data that was saved aside for the current filter from an earlier call
- * @param f The current filter
- * @param b The bucket brigade to append to the data that was saved earlier.
- *          This should be the brigade that was most recently passed to the
- *          filter
- * @return A single bucket brigade containing all of the data that was set 
- *         aside from a previous call to ap_save_data_to_filter and the data
- *         that was most recently passed to this filter.
- * @deffunc ap_bucket_brigade *ap_get_saved_data(ap_filter_t *f, ap_bucket_brigade **b)
- */
-API_EXPORT(ap_bucket_brigade *) ap_get_saved_data(ap_filter_t *f, 
-                                                  ap_bucket_brigade **b);
 
 /**
- * Save a bucket brigade to a filter.  This is used to save portions of the
- * data off to the side for consumption later
+ * prepare a bucket brigade to be setaside.  If a different brigade was 
+ * set-aside earlier, then the two brigades are concatenated together.
  * @param f The current filter
- * @param b The bucket brigade to save aside
- * @deffunc void ap_save_data_to_filter(ap_filter_t *f, ap_bucket_brigade **b)
+ * @param save_to The brigade that was previously set-aside.  Regardless, the
+ *             new bucket brigade is returned in this location.
+ * @param b The bucket brigade to save aside.  This brigade is always empty
+ *          on return
+ * @deffunc void ap_save_brigade(ap_filter_t *f, ap_bucket_brigade **save_to, ap_bucket_brigade **b)
  */
-API_EXPORT(void) ap_save_data_to_filter(ap_filter_t *f, ap_bucket_brigade **b);    
+API_EXPORT(void) ap_save_brigade(ap_filter_t *f, ap_bucket_brigade **save_to,
+                                        ap_bucket_brigade **b);    
 
 #ifdef __cplusplus
 }
index 2b0ff6f29cf8d26d23e3354f6e04e7cbd5cf6b2d..c7641c3c3fdefc86a1c3c2e007fe8b823576f30d 100644 (file)
@@ -209,48 +209,21 @@ API_EXPORT(apr_status_t) ap_pass_brigade(ap_filter_t *next, ap_bucket_brigade *b
     return AP_NOBODY_WROTE;
 }
 
-API_EXPORT(ap_bucket_brigade *) ap_get_saved_data(ap_filter_t *f, 
-                                                  ap_bucket_brigade **b)
+API_EXPORT(void) ap_save_brigade(ap_filter_t *f, ap_bucket_brigade **saveto,
+                                        ap_bucket_brigade **b)
 {
-    ap_bucket_brigade *bb = (ap_bucket_brigade *)f->ctx;
-
-    /* If we have never stored any data in the filter, then we had better
-     * create an empty bucket brigade so that we can concat.
-     */
-    if (!bb) {
-        bb = ap_brigade_create(f->r->pool);
-    }
-
-    /* join the two brigades together.  *b is now empty so we can 
-     * safely destroy it. 
-     */
-    AP_BRIGADE_CONCAT(bb, *b);
-    ap_brigade_destroy(*b);
-    /* clear out the filter's context pointer.  If we don't do this, then
-     * when we save more data to the filter, we will be appended to what is
-     * currently there.  This will mean repeating data.... BAD!  :-)
-     */
-    f->ctx = NULL;
-    
-    return bb;
-}
-
-API_EXPORT(void) ap_save_data_to_filter(ap_filter_t *f, ap_bucket_brigade **b)
-{
-    ap_bucket_brigade *bb = (ap_bucket_brigade *)f->ctx;
     ap_bucket *e;
 
     /* If have never stored any data in the filter, then we had better
      * create an empty bucket brigade so that we can concat.
      */
-    if (!bb) {
-        bb = ap_brigade_create(f->r->pool);
+    if (!(*saveto)) {
+        *saveto = ap_brigade_create(f->r->pool);
     }
     
     AP_RING_FOREACH(e, &(*b)->list, ap_bucket, link) {
         if (e->setaside)
             e->setaside(e);
     }
-    AP_BRIGADE_CONCAT(bb, *b);
-    f->ctx = bb;
+    AP_BRIGADE_CONCAT(*saveto, *b);
 }