You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2001/02/09 08:04:52 UTC
cvs commit: httpd-2.0/server util_filter.c
rbb 01/02/08 23:04:52
Modified: . CHANGES
include util_filter.h
server util_filter.c
Log:
Allow filters to buffer data in a brigade using the ap_f* functions.
These have become simple macros that just wrap the apr_brigade functions,
allowing filter writers to ignore the flush function and the ctx pointer.
Revision Changes Path
1.81 +4 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -b -w -u -r1.80 -r1.81
--- CHANGES 2001/02/07 20:49:23 1.80
+++ CHANGES 2001/02/09 07:04:50 1.81
@@ -1,5 +1,9 @@
Changes with Apache 2.0b1
+ *) Allow filters to buffer data using the ap_f* functions. These have
+ become macros that resolve directly to apr_brigade_*.
+ [Ryan Bloom]
+
*) Get the Unix MPM's to do a graceful restart again. If we are going
to register a cleanup with ap_cleanup_scoreboard, then we have to
kill the cleanup with the same function, and that function can't be
1.39 +69 -0 httpd-2.0/include/util_filter.h
Index: util_filter.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/util_filter.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -b -w -u -r1.38 -r1.39
--- util_filter.h 2001/02/03 20:25:13 1.38
+++ util_filter.h 2001/02/09 07:04:51 1.39
@@ -393,6 +393,75 @@
AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f, apr_bucket_brigade **save_to,
apr_bucket_brigade **b);
+/**
+ * Flush function for apr_brigade_* calls. This calls ap_pass_brigade
+ * to flush the brigade if the brigade buffer overflows.
+ * @param bb The brigade to flush
+ * @param ctx The filter to pass the brigade to
+ * @deffunc apr_status_t filter_flush(apr_bucket_brigade *bb, void *ctx)
+ */
+apr_status_t filter_flush(apr_bucket_brigade *bb, void *ctx);
+
+/**
+ * Flush the current brigade down the filter stack
+ * @param f the next filter in the stack
+ * @param bb The brigade to flush
+ * @deffunc int ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb)
+ */
+AP_DECLARE(int) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb);
+
+/**
+ * Write a buffer for the current filter, buffering if possible.
+ * @param f the filter to write to
+ * @param bb The brigade to buffer into
+ * @param str The string to write
+ * @param byte The number of characters in the string
+ * @deffunc int ap_fwrite(ap_filter_t *f, apr_bucket_brigade *bb, const char *str, apr_ssize_t byte);
+ */
+#define ap_fwrite(f, bb, str, byte) \
+ apr_brigade_write(bb, filter_flush, f->next, str, byte)
+
+/**
+ * Write a buffer for the current filter, buffering if possible.
+ * @param f the filter to write to
+ * @param bb The brigade to buffer into
+ * @param str The string to write
+ * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, const char *str);
+ */
+#define ap_fputs(f, bb, str) \
+ apr_brigade_puts(bb, filter_flush, f->next, str)
+
+/**
+ * Write a character for the current filter, buffering if possible.
+ * @param f the filter to write to
+ * @param bb The brigade to buffer into
+ * @param str The character to write
+ * @deffunc int ap_fputc(ap_filter_t *f, apr_bucket_brigade *bb, char str);
+ */
+#define ap_fputc(f, bb, str) \
+ apr_brigade_putc(bb, filter_flush, f->next, str)
+
+/**
+ * Write an unspecified number of strings to the current filter
+ * @param f the filter to write to
+ * @param bb The brigade to buffer into
+ * @param ... The strings to write
+ * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, ...);
+ */
+#define ap_fvputs(f, bb, args...) \
+ apr_brigade_putstrs(bb, filter_flush, f->next, ##args)
+
+/**
+ * Output data to the filter in printf format
+ * @param f the filter to write to
+ * @param bb The brigade to buffer into
+ * @param fmt The format string
+ * @param ... The argumets to use to fill out the format string
+ * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt, ...);
+ */
+#define ap_fprintf(f, bb, fmt, args...) \
+ apr_brigade_printf(bb, filter_flush, f->next, fmt, ##args)
+
#ifdef __cplusplus
}
#endif
1.45 +19 -0 httpd-2.0/server/util_filter.c
Index: util_filter.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/util_filter.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -b -w -u -r1.44 -r1.45
--- util_filter.c 2001/02/08 07:44:21 1.44
+++ util_filter.c 2001/02/09 07:04:52 1.45
@@ -265,3 +265,22 @@
APR_BRIGADE_CONCAT(*saveto, *b);
return APR_SUCCESS;
}
+
+apr_status_t filter_flush(apr_bucket_brigade *bb, void *ctx)
+{
+ ap_filter_t *f = ctx;
+
+ return ap_pass_brigade(f, bb);
+}
+
+AP_DECLARE(int) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb)
+{
+ apr_bucket *b;
+
+ b = apr_bucket_flush_create();
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+ if (ap_pass_brigade(f->next, bb) != APR_SUCCESS)
+ return -1;
+ return 0;
+}
+
Re: cvs commit: httpd-2.0/server util_filter.c
Posted by Greg Stein <gs...@lyra.org>.
On Fri, Feb 09, 2001 at 06:26:38AM -0800, rbb@covalent.net wrote:
> On Fri, 9 Feb 2001, Greg Stein wrote:
>...
> > I'm a bit concerned about these two macros. GCC is saying they are non-ANSI.
> > Could people test them out on their compilers? I suspect we may need to
> > convert these two to real functions.
> >
> > [ that said: the feature is sweet... no idea it existed! ]
>
> I was concerned about them too. I have them same macros for ap_r*. I am
> not getting any errors from GCC though. I am using maintainer-mode. It
> is easy to turn them into functions, but I really do like this more if it
> is portable. :-(
I was suspicious, so I compiled a test program with -ansi -pedantic :-) I
wasn't getting errors normally, either.
Some GCC extension, apparently.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: cvs commit: httpd-2.0/server util_filter.c
Posted by rb...@covalent.net.
On Fri, 9 Feb 2001, Greg Stein wrote:
> On Fri, Feb 09, 2001 at 07:04:52AM -0000, rbb@apache.org wrote:
> >...
> > --- util_filter.h 2001/02/03 20:25:13 1.38
> > +++ util_filter.h 2001/02/09 07:04:51 1.39
> >...
> > +/**
> > + * Write an unspecified number of strings to the current filter
> > + * @param f the filter to write to
> > + * @param bb The brigade to buffer into
> > + * @param ... The strings to write
> > + * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, ...);
> > + */
> > +#define ap_fvputs(f, bb, args...) \
> > + apr_brigade_putstrs(bb, filter_flush, f->next, ##args)
> > +
> > +/**
> > + * Output data to the filter in printf format
> > + * @param f the filter to write to
> > + * @param bb The brigade to buffer into
> > + * @param fmt The format string
> > + * @param ... The argumets to use to fill out the format string
> > + * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt, ...);
> > + */
> > +#define ap_fprintf(f, bb, fmt, args...) \
> > + apr_brigade_printf(bb, filter_flush, f->next, fmt, ##args)
>
> I'm a bit concerned about these two macros. GCC is saying they are non-ANSI.
> Could people test them out on their compilers? I suspect we may need to
> convert these two to real functions.
>
> [ that said: the feature is sweet... no idea it existed! ]
I was concerned about them too. I have them same macros for ap_r*. I am
not getting any errors from GCC though. I am using maintainer-mode. It
is easy to turn them into functions, but I really do like this more if it
is portable. :-(
Ryan
_______________________________________________________________________________
Ryan Bloom rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------
Re: cvs commit: httpd-2.0/server util_filter.c
Posted by Greg Stein <gs...@lyra.org>.
On Fri, Feb 09, 2001 at 07:04:52AM -0000, rbb@apache.org wrote:
>...
> --- util_filter.h 2001/02/03 20:25:13 1.38
> +++ util_filter.h 2001/02/09 07:04:51 1.39
>...
> +/**
> + * Write an unspecified number of strings to the current filter
> + * @param f the filter to write to
> + * @param bb The brigade to buffer into
> + * @param ... The strings to write
> + * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, ...);
> + */
> +#define ap_fvputs(f, bb, args...) \
> + apr_brigade_putstrs(bb, filter_flush, f->next, ##args)
> +
> +/**
> + * Output data to the filter in printf format
> + * @param f the filter to write to
> + * @param bb The brigade to buffer into
> + * @param fmt The format string
> + * @param ... The argumets to use to fill out the format string
> + * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt, ...);
> + */
> +#define ap_fprintf(f, bb, fmt, args...) \
> + apr_brigade_printf(bb, filter_flush, f->next, fmt, ##args)
I'm a bit concerned about these two macros. GCC is saying they are non-ANSI.
Could people test them out on their compilers? I suspect we may need to
convert these two to real functions.
[ that said: the feature is sweet... no idea it existed! ]
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: cvs commit: httpd-2.0/server util_filter.c
Posted by rb...@covalent.net.
On 9 Feb 2001, Jeff Trawick wrote:
> rbb@apache.org writes:
>
> > rbb 01/02/08 23:04:52
>
> not portable...
>
> Tru64's compiler says:
>
> > cc: Warning: /home/trawick/regress/httpd-2.0/include/util_filter.h, line 451: Formal parameter isn't an identifier. (badformalparm)
> > #define ap_fvputs(f, bb, args...) \
> > -----------------------------^
> > cc: Warning: /home/trawick/regress/httpd-2.0/include/util_filter.h, line 462: Formal parameter isn't an identifier. (badformalparm)
> > #define ap_fprintf(f, bb, fmt, args...) \
> > -----------------------------------^
>
> (and again every time util_filter.h is included :) )
>
> Besides the warning for the macro definition, an error is generated if
> the macro is actually used in the way you intend.
>
> (no idea how to fix with a macro)
Darn. :-( It was a really cool feature. I'll code up some quick and
dirty functions to do this, and commit ASAP.
Ryan
_______________________________________________________________________________
Ryan Bloom rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------
Re: cvs commit: httpd-2.0/server util_filter.c
Posted by Jeff Trawick <tr...@bellsouth.net>.
rbb@apache.org writes:
> rbb 01/02/08 23:04:52
...
> Index: util_filter.h
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/include/util_filter.h,v
> retrieving revision 1.38
> retrieving revision 1.39
> diff -u -d -b -w -u -r1.38 -r1.39
> --- util_filter.h 2001/02/03 20:25:13 1.38
> +++ util_filter.h 2001/02/09 07:04:51 1.39
> +/**
> + * Write an unspecified number of strings to the current filter
> + * @param f the filter to write to
> + * @param bb The brigade to buffer into
> + * @param ... The strings to write
> + * @deffunc int ap_fputs(ap_filter_t *f, apr_bucket_brigade *bb, ...);
> + */
> +#define ap_fvputs(f, bb, args...) \
> + apr_brigade_putstrs(bb, filter_flush, f->next, ##args)
not portable...
Tru64's compiler says:
> cc: Warning: /home/trawick/regress/httpd-2.0/include/util_filter.h, line 451: Formal parameter isn't an identifier. (badformalparm)
> #define ap_fvputs(f, bb, args...) \
> -----------------------------^
> cc: Warning: /home/trawick/regress/httpd-2.0/include/util_filter.h, line 462: Formal parameter isn't an identifier. (badformalparm)
> #define ap_fprintf(f, bb, fmt, args...) \
> -----------------------------------^
(and again every time util_filter.h is included :) )
Besides the warning for the macro definition, an error is generated if
the macro is actually used in the way you intend.
(no idea how to fix with a macro)
--
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...