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:03:41 GMT
gstein      01/02/09 03:03:40

  Modified:    include  apr_buckets.h
               buckets  apr_brigade.c
  Log:
  *) namespace protect the "brigade_flush" type
  *) remove code dup by implementing apr_brigade_putc() in terms of _write()
  
  Revision  Changes    Path
  1.71      +27 -15    apr-util/include/apr_buckets.h
  
  Index: apr_buckets.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -u -r1.70 -r1.71
  --- apr_buckets.h	2001/02/09 06:19:44	1.70
  +++ apr_buckets.h	2001/02/09 11:03:34	1.71
  @@ -250,7 +250,7 @@
       APR_RING_HEAD(apr_bucket_list, apr_bucket) list;
   };
   
  -typedef apr_status_t (*brigade_flush)(apr_bucket_brigade *bb, void *ctx);
  +typedef apr_status_t (*apr_brigade_flush)(apr_bucket_brigade *bb, void *ctx);
   
   /**
    * Wrappers around the RING macros to reduce the verbosity of the code
  @@ -637,45 +637,55 @@
    * @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, brigade_flush flush, void *ctx,
va_list va)
  + * @deffunc int 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, 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);
   
   /**
    * 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, brigade_flush flush, void *ctx,
const char *str)
  + * @deffunc int 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, 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);
   
   /**
    * 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, brigade_flush flush, void *ctx,
const char *str)
  + * @deffunc int 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, 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);
   
   /**
    * 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, brigade_flush flush, void *ctx,
const char c)
  + * @deffunc int 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, 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);
   
   /**
    * 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, brigade_flush flush, void *ctx,
...)
  + * @deffunc int apr_brigade_putstrs(apr_bucket_brigade *b, apr_brigade_flush flush, void
*ctx, ...)
    */
  -APU_DECLARE_NONSTD(int) apr_brigade_putstrs(apr_bucket_brigade *b, brigade_flush flush,
void *ctx, ...);
  +APU_DECLARE_NONSTD(int) apr_brigade_putstrs(apr_bucket_brigade *b,
  +                                            apr_brigade_flush flush,
  +                                            void *ctx, ...);
   
   /**
    * Evaluate a printf and put the resulting string at the end 
  @@ -684,10 +694,11 @@
    * @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, brigade_flush flush, void *ctx,
const char *fmt, ...) 
  + * @deffunc int 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, 
  -                                          brigade_flush flush, void *ctx, const char *fmt,
...);
  +                                           apr_brigade_flush flush, void *ctx,
  +                                           const char *fmt, ...);
   
   /**
    * Evaluate a printf and put the resulting string at the end 
  @@ -696,10 +707,11 @@
    * @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, brigade_flush flush, void *ctx,
const char *fmt, va_list va) 
  + * @deffunc int 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, 
  -                                    brigade_flush flush, void *ctx, const char *fmt, va_list
va);
  +                                     apr_brigade_flush flush, void *ctx,
  +                                     const char *fmt, va_list va);
   
   
   /*  *****  Bucket Functions  *****  */
  
  
  
  1.6       +15 -48    apr-util/buckets/apr_brigade.c
  
  Index: apr_brigade.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -u -r1.5 -r1.6
  --- apr_brigade.c	2001/02/09 06:19:43	1.5
  +++ apr_brigade.c	2001/02/09 11:03:37	1.6
  @@ -187,7 +187,7 @@
   
   static int check_brigade_flush(const char **str, 
                                  apr_size_t *n, apr_bucket_brigade *bb,
  -                               brigade_flush flush)
  +                               apr_brigade_flush flush)
   {
       apr_bucket *b = APR_BRIGADE_LAST(bb);
   
  @@ -228,10 +228,8 @@
   }
   
   APU_DECLARE(int) apr_brigade_vputstrs(apr_bucket_brigade *b, 
  -                                      brigade_flush flush, void *ctx,
  +                                      apr_brigade_flush flush, void *ctx,
                                         va_list va)
  -                                    
  -                                   
   {
       const char *x;
       int j, k;
  @@ -247,48 +245,15 @@
       return k;
   }
   
  -APU_DECLARE(int) apr_brigade_putc(apr_bucket_brigade *b, 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)
   {
  -    apr_size_t nbyte = 1;
  -    const char *str = &c;
  -
  -    if (check_brigade_flush(&str, &nbyte, b, flush)) {
  -        if (flush) {
  -            return flush(b, ctx);
  -        }
  -    }
  -    else {
  -        apr_bucket *buck = APR_BRIGADE_LAST(b);
  -        apr_bucket_shared *s;
  -        apr_bucket_heap *h;
  -        char *buf;
  -
  -        if (!APR_BUCKET_IS_HEAP(buck) || APR_BRIGADE_EMPTY(b)) {
  -            buf = malloc(APR_BUCKET_BUFF_SIZE);
  -
  -            buck = apr_bucket_heap_create(buf, APR_BUCKET_BUFF_SIZE, 0, NULL);
  -            s = buck->data;
  -            s->start = s->end = 0;
  -            h = s->data;
  -
  -            APR_BRIGADE_INSERT_TAIL(b, buck);
  -        }
  -        else {
  -            s = buck->data;
  -            h = s->data;
  -
  -            buf = h->base + s->end;
  -        }
  -        memcpy(buf, &c, 1);
  -        s->end++;
  -    }
  -
  -    return 1;
  +    return apr_brigade_write(b, flush, ctx, &c, 1);
   }
   
   APU_DECLARE(int) apr_brigade_write(apr_bucket_brigade *b, 
  -                                   brigade_flush flush, void *ctx, 
  +                                   apr_brigade_flush flush, void *ctx, 
                                      const char *str, apr_size_t nbyte)
   {
       if (check_brigade_flush(&str, &nbyte, b, flush)) {
  @@ -325,14 +290,16 @@
       return nbyte;
   }
   
  -APU_DECLARE(int) apr_brigade_puts(apr_bucket_brigade *b, 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)
   {
       return apr_brigade_write(b, flush, ctx, str, strlen(str));
   }
   
   APU_DECLARE_NONSTD(int) apr_brigade_putstrs(apr_bucket_brigade *b, 
  -                                           brigade_flush flush, void *ctx, ...)
  +                                            apr_brigade_flush flush,
  +                                            void *ctx, ...)
   {
       va_list va;
       int written;
  @@ -344,7 +311,7 @@
   }
   
   APU_DECLARE_NONSTD(int) apr_brigade_printf(apr_bucket_brigade *b, 
  -                                           brigade_flush flush, void *ctx, 
  +                                           apr_brigade_flush flush, void *ctx, 
                                              const char *fmt, ...)
   {
       va_list ap;
  @@ -357,7 +324,7 @@
   }
   
   APU_DECLARE(int) apr_brigade_vprintf(apr_bucket_brigade *b, 
  -                                     brigade_flush flush, void *ctx, 
  +                                     apr_brigade_flush flush, void *ctx, 
                                        const char *fmt, va_list va)
   {
       /* XXX:  This needs to be replaced with a function to printf
  @@ -365,7 +332,7 @@
        */
       char buf[4096];
   
  -    apr_vsnprintf(buf, 4096, fmt, va);
  +    apr_vsnprintf(buf, sizeof(buf), fmt, va);
   
       return apr_brigade_puts(b, flush, ctx, buf);
   } 
  
  
  

Mime
View raw message