* 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
}
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);
}