You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gs...@apache.org on 2001/06/08 13:00:45 UTC
cvs commit: apr-util/buckets apr_brigade.c
gstein 01/06/08 04:00:44
Modified: include util_filter.h
server util_filter.c
include apr_buckets.h
buckets apr_brigade.c
Log:
Convert the filter and brigade writing functions to return status values,
not byte counts.
Revision Changes Path
1.54 +7 -2 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.53
retrieving revision 1.54
diff -u -u -r1.53 -r1.54
--- util_filter.h 2001/05/06 23:27:11 1.53
+++ util_filter.h 2001/06/08 11:00:03 1.54
@@ -431,7 +431,9 @@
* @param bb The brigade to buffer into
* @param ... The strings to write
*/
-AP_DECLARE_NONSTD(int) ap_fputstrs(ap_filter_t *f, apr_bucket_brigade *bb, ...);
+AP_DECLARE_NONSTD(apr_status_t) ap_fputstrs(ap_filter_t *f,
+ apr_bucket_brigade *bb,
+ ...);
/**
* Output data to the filter in printf format
@@ -440,7 +442,10 @@
* @param fmt The format string
* @param ... The argumets to use to fill out the format string
*/
-AP_DECLARE_NONSTD(int) ap_fprintf(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt, ...)
+AP_DECLARE_NONSTD(apr_status_t) ap_fprintf(ap_filter_t *f,
+ apr_bucket_brigade *bb,
+ const char *fmt,
+ ...)
__attribute__((format(printf,3,4)));
#ifdef __cplusplus
1.60 +13 -8 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.59
retrieving revision 1.60
diff -u -u -r1.59 -r1.60
--- util_filter.c 2001/06/07 10:13:25 1.59
+++ util_filter.c 2001/06/08 11:00:14 1.60
@@ -289,24 +289,29 @@
return ap_pass_brigade(f, bb);
}
-AP_DECLARE_NONSTD(int) ap_fputstrs(ap_filter_t *f, apr_bucket_brigade *bb, ...)
+AP_DECLARE_NONSTD(apr_status_t) ap_fputstrs(ap_filter_t *f,
+ apr_bucket_brigade *bb, ...)
{
va_list args;
- int res;
+ apr_status_t rv;
va_start(args, bb);
- res = apr_brigade_vputstrs(bb, ap_filter_flush, f, args);
+ rv = apr_brigade_vputstrs(bb, ap_filter_flush, f, args);
va_end(args);
- return res;
+ return rv;
}
-AP_DECLARE_NONSTD(int) ap_fprintf(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt, ...){
+AP_DECLARE_NONSTD(apr_status_t) ap_fprintf(ap_filter_t *f,
+ apr_bucket_brigade *bb,
+ const char *fmt,
+ ...)
+{
va_list args;
- int res;
+ apr_status_t rv;
va_start(args, fmt);
- res = apr_brigade_vprintf(bb, ap_filter_flush, f, fmt, args);
+ rv = apr_brigade_vprintf(bb, ap_filter_flush, f, fmt, args);
va_end(args);
- return res;
+ return rv;
}
1.97 +41 -37 apr-util/include/apr_buckets.h
Index: apr_buckets.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -u -r1.96 -r1.97
--- apr_buckets.h 2001/06/07 12:11:12 1.96
+++ apr_buckets.h 2001/06/08 11:00:24 1.97
@@ -646,9 +646,10 @@
* appropriate, and/or modify start on last element
* @param b The brigade to consume data from
* @param nbytes The number of bytes to consume
- * @deffunc void apr_brigade_consume(apr_bucket_brigade *b, int nbytes)
+ * @deffunc void apr_brigade_consume(apr_bucket_brigade *b, apr_size_t nbytes)
*/
-APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b, int nbytes);
+APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b,
+ apr_size_t nbytes);
#endif
/**
@@ -666,69 +667,70 @@
* create an iovec of the elements in a bucket_brigade... return number
* of elements used. This is useful for writing to a file or to the
* network efficiently.
- * @param The bucket brigade to create the iovec from
- * @param The iovec to create
- * @param The number of elements in the iovec
- * @return The number of iovec elements actually filled out.
- * @deffunc int apr_brigade_to_iovec(apr_bucket_brigade *b, struct iovec *vec, int nvec);
+ * @param b The bucket brigade to create the iovec from
+ * @param vec The iovec to create
+ * @param nvec The number of elements in the iovec. On return, it is the
+ * number of iovec elements actually filled out.
+ * @deffunc apr_status_t apr_brigade_to_iovec(apr_bucket_brigade *b, struct iovec *vec, int *nvec);
*/
-APU_DECLARE(int) apr_brigade_to_iovec(apr_bucket_brigade *b,
- struct iovec *vec, int nvec);
+APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b,
+ struct iovec *vec, int *nvec);
/**
* This function writes a list of strings into a bucket brigade.
* @param b The bucket brigade to add to
* @param va A list of strings to add
* @return The number of bytes added to the brigade
- * @deffunc int apr_brigade_vputstrs(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, va_list va)
+ * @deffunc apr_status_t apr_brigade_vputstrs(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, va_list va)
*/
-APU_DECLARE(int) apr_brigade_vputstrs(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- va_list va);
+APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx,
+ va_list va);
/**
* This function writes an string into a bucket brigade.
* @param b The bucket brigade to add to
* @param str The string to add
* @return The number of bytes added to the brigade
- * @deffunc int apr_brigade_write(ap_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *str, apr_size_t nbyte)
+ * @deffunc apr_status_t apr_brigade_write(ap_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *str, apr_size_t nbyte)
*/
-APU_DECLARE(int) apr_brigade_write(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char *str, apr_size_t nbyte);
+APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b,
+ apr_brigade_flush flush, void *ctx,
+ const char *str, apr_size_t nbyte);
/**
* This function writes an string into a bucket brigade.
* @param b The bucket brigade to add to
* @param str The string to add
* @return The number of bytes added to the brigade
- * @deffunc int apr_brigade_puts(ap_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *str)
+ * @deffunc apr_status_t apr_brigade_puts(ap_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *str)
*/
-APU_DECLARE(int) apr_brigade_puts(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char *str);
+APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *b,
+ apr_brigade_flush flush, void *ctx,
+ const char *str);
/**
* This function writes a character into a bucket brigade.
* @param b The bucket brigade to add to
* @param c The character to add
* @return The number of bytes added to the brigade
- * @deffunc int apr_brigade_putc(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char c)
+ * @deffunc apr_status_t apr_brigade_putc(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char c)
*/
-APU_DECLARE(int) apr_brigade_putc(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char c);
+APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b,
+ apr_brigade_flush flush, void *ctx,
+ const char c);
/**
* This function writes an unspecified number of strings into a bucket brigade.
* @param b The bucket brigade to add to
* @param ... The strings to add
* @return The number of bytes added to the brigade
- * @deffunc int apr_brigade_putstrs(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, ...)
+ * @deffunc apr_status_t apr_brigade_putstrs(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, ...)
*/
-APU_DECLARE_NONSTD(int) apr_brigade_putstrs(apr_bucket_brigade *b,
- apr_brigade_flush flush,
- void *ctx, ...);
+APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx, ...);
/**
* Evaluate a printf and put the resulting string at the end
@@ -737,11 +739,12 @@
* @param fmt The format of the string to write
* @param ... The arguments to fill out the format
* @return The number of bytes added to the brigade
- * @deffunc int apr_brigade_printf(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *fmt, ...)
+ * @deffunc apr_status_t apr_brigade_printf(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *fmt, ...)
*/
-APU_DECLARE_NONSTD(int) apr_brigade_printf(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char *fmt, ...)
+APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx,
+ const char *fmt, ...)
__attribute__((format(printf,4,5)));
/**
@@ -751,11 +754,12 @@
* @param fmt The format of the string to write
* @param va The arguments to fill out the format
* @return The number of bytes added to the brigade
- * @deffunc int apr_brigade_vprintf(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *fmt, va_list va)
+ * @deffunc apr_status_t apr_brigade_vprintf(apr_bucket_brigade *b, apr_brigade_flush flush, void *ctx, const char *fmt, va_list va)
*/
-APU_DECLARE(int) apr_brigade_vprintf(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char *fmt, va_list va);
+APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx,
+ const char *fmt, va_list va);
/* ***** Bucket Functions ***** */
1.16 +58 -44 apr-util/buckets/apr_brigade.c
Index: apr_brigade.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -u -r1.15 -r1.16
--- apr_brigade.c 2001/05/21 19:14:32 1.15
+++ apr_brigade.c 2001/06/08 11:00:36 1.16
@@ -201,22 +201,30 @@
return APR_SUCCESS;
}
-APU_DECLARE(int) apr_brigade_to_iovec(apr_bucket_brigade *b,
- struct iovec *vec, int nvec)
+APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b,
+ struct iovec *vec, int *nvec)
{
+ int left = *nvec;
apr_bucket *e;
struct iovec *orig;
apr_size_t iov_len;
+ apr_status_t rv;
orig = vec;
APR_BRIGADE_FOREACH(e, b) {
- if (nvec-- == 0)
+ if (left-- == 0)
break;
- apr_bucket_read(e, (const char **)&vec->iov_base, &iov_len, APR_NONBLOCK_READ);
+
+ rv = apr_bucket_read(e, (const char **)&vec->iov_base, &iov_len,
+ APR_NONBLOCK_READ);
+ if (rv != APR_SUCCESS)
+ return rv;
vec->iov_len = iov_len; /* set indirectly in case size differs */
++vec;
}
- return vec - orig;
+
+ *nvec = vec - orig;
+ return APR_SUCCESS;
}
static int check_brigade_flush(const char **str,
@@ -258,34 +266,37 @@
return 0;
}
-APU_DECLARE(int) apr_brigade_vputstrs(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- va_list va)
-{
- const char *x;
- int j, k;
-
- for (k = 0;;) {
- x = va_arg(va, const char *);
- if (x == NULL)
+APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx,
+ va_list va)
+{
+ for (;;) {
+ const char *str = va_arg(va, const char *);
+ apr_status_t rv;
+
+ if (str == NULL)
break;
- j = strlen(x);
-
- k += apr_brigade_write(b, flush, ctx, x, j);
+
+ rv = apr_brigade_write(b, flush, ctx, str, strlen(str));
+ if (rv != APR_SUCCESS)
+ return rv;
}
- return k;
+
+ return APR_SUCCESS;
}
-APU_DECLARE(int) apr_brigade_putc(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char c)
+APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b,
+ apr_brigade_flush flush, void *ctx,
+ const char c)
{
return apr_brigade_write(b, flush, ctx, &c, 1);
}
-APU_DECLARE(int) apr_brigade_write(apr_bucket_brigade *bb,
- apr_brigade_flush flush, void *ctx,
- const char *str, apr_size_t nbyte)
+APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *bb,
+ apr_brigade_flush flush,
+ void *ctx,
+ const char *str, apr_size_t nbyte)
{
if (check_brigade_flush(&str, &nbyte, bb, flush)) {
if (flush) {
@@ -315,45 +326,48 @@
memcpy(buf, str, nbyte);
b->length += nbyte;
}
- return nbyte;
+
+ return APR_SUCCESS;
}
-APU_DECLARE(int) apr_brigade_puts(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char *str)
+APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *b,
+ apr_brigade_flush flush, void *ctx,
+ const char *str)
{
return apr_brigade_write(b, flush, ctx, str, strlen(str));
}
-APU_DECLARE_NONSTD(int) apr_brigade_putstrs(apr_bucket_brigade *b,
- apr_brigade_flush flush,
- void *ctx, ...)
+APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx, ...)
{
va_list va;
- int written;
+ apr_status_t rv;
va_start(va, ctx);
- written = apr_brigade_vputstrs(b, flush, ctx, va);
+ rv = apr_brigade_vputstrs(b, flush, ctx, va);
va_end(va);
- return written;
+ return rv;
}
-APU_DECLARE_NONSTD(int) apr_brigade_printf(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char *fmt, ...)
+APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx,
+ const char *fmt, ...)
{
va_list ap;
- int res;
+ apr_status_t rv;
va_start(ap, fmt);
- res = apr_brigade_vprintf(b, flush, ctx, fmt, ap);
+ rv = apr_brigade_vprintf(b, flush, ctx, fmt, ap);
va_end(ap);
- return res;
+ return rv;
}
-APU_DECLARE(int) apr_brigade_vprintf(apr_bucket_brigade *b,
- apr_brigade_flush flush, void *ctx,
- const char *fmt, va_list va)
+APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b,
+ apr_brigade_flush flush,
+ void *ctx,
+ const char *fmt, va_list va)
{
/* XXX: This needs to be replaced with a function to printf
* directly into a bucket. I'm being lazy right now. RBB