apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: apr-util/buckets apr_brigade.c
Date Fri, 09 Feb 2001 11:42:55 GMT
gstein      01/02/09 03:42:53

  Modified:    include  apr_buckets.h
               buckets  apr_brigade.c
  Log:
  add an apr_brigade_length() function
  
  Revision  Changes    Path
  1.72      +15 -1     apr-util/include/apr_buckets.h
  
  Index: apr_buckets.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -u -r1.71 -r1.72
  --- apr_buckets.h	2001/02/09 11:03:34	1.71
  +++ apr_buckets.h	2001/02/09 11:42:45	1.72
  @@ -80,7 +80,10 @@
   
   #define APR_BUCKET_BUFF_SIZE 9000
   
  -typedef enum {APR_BLOCK_READ, APR_NONBLOCK_READ} apr_read_type_e;
  +typedef enum {
  +    APR_BLOCK_READ,
  +    APR_NONBLOCK_READ
  +} apr_read_type_e;
   
   /*
    * The one-sentence buzzword-laden overview: Bucket brigades represent
  @@ -618,6 +621,17 @@
    */
   APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b, int nbytes);
   #endif
  +
  +/**
  + * Return the total length of the brigade.
  + * @param bb The brigade to compute the length of
  + * @param read_all Read unknown-length buckets to force a size
  + @ @param length Set to length of the brigade, or -1 if it has unknown-length buckets
  + * @deffunc apr_status_t apr_brigade_length(apr_bucket_brigade *bb, int read_all)
  + */
  +APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
  +                                             int read_all,
  +                                             apr_ssize_t *length);
   
   /**
    * create an iovec of the elements in a bucket_brigade... return number 
  
  
  
  1.7       +30 -0     apr-util/buckets/apr_brigade.c
  
  Index: apr_brigade.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- apr_brigade.c	2001/02/09 11:03:37	1.6
  +++ apr_brigade.c	2001/02/09 11:42:51	1.7
  @@ -167,6 +167,36 @@
       return NULL;
   }
   
  +APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
  +                                             int read_all, apr_ssize_t *length)
  +{
  +    apr_ssize_t total = 0;
  +    apr_bucket *bkt;
  +
  +    APR_BRIGADE_FOREACH(bkt, bb) {
  +        if (bkt->length == -1) {
  +            const char *ignore;
  +            apr_size_t len;
  +            apr_status_t status;
  +
  +            if (!read_all) {
  +                *length = -1;
  +                return APR_SUCCESS;
  +            }
  +
  +            if ((status = apr_bucket_read(bkt, &ignore, &len,
  +                                          APR_BLOCK_READ)) != APR_SUCCESS) {
  +                return status;
  +            }
  +        }
  +
  +        total += bkt->length;
  +    }
  +
  +    *length = total;
  +    return APR_SUCCESS;
  +}
  +
   APU_DECLARE(int) apr_brigade_to_iovec(apr_bucket_brigade *b, 
   				    struct iovec *vec, int nvec)
   {
  
  
  

Mime
View raw message