manoj       99/10/31 01:02:57

  Modified:    src/include buff.h
               src/main buff.c http_protocol.c util_script.c
               src/modules/standard mod_cgi.c
  Log:
  Undo the ap_bgets errno patch. It will return status with ap_berror().
  
  Revision  Changes    Path
  1.10      +1 -2      apache-2.0/src/include/buff.h
  
  Index: buff.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/buff.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -d -u -r1.9 -r1.10
  --- buff.h    1999/10/30 08:05:07     1.9
  +++ buff.h    1999/10/31 09:02:52     1.10
  @@ -184,8 +184,7 @@
   /* I/O */
   API_EXPORT(ap_status_t) ap_bread(BUFF *fb, void *buf, ap_size_t nbyte,
                                    ap_ssize_t *bytes_read);
  -API_EXPORT(ap_status_t) ap_bgets(char *s, int n, BUFF *fb,
  -                                 ap_ssize_t *bytes_read);
  +API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb);
   API_EXPORT(int) ap_blookc(BUFF *fb);
   API_EXPORT(ap_status_t) ap_bwrite(BUFF *fb, const void *buf, ap_size_t nbyte,
                                     ap_ssize_t *bytes_written);
  
  
  
  1.22      +10 -21    apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -d -u -r1.21 -r1.22
  --- buff.c    1999/10/30 08:05:08     1.21
  +++ buff.c    1999/10/31 09:02:53     1.22
  @@ -429,11 +429,8 @@
    * read, it is replaced by a newline character.  The string is then
    * terminated with a null character.
    *
  - * Works a little differently than the other BUFF functions, returning
  - * APR_EOF on end-of-file instead of just setting bytes_read = 0,
  - * because it makes code simpler.
  - *
  - * XXX - I'm undecided on keeping this function inconsistent - manoj
  + * Returns the number of bytes stored in buff, or zero on end of
  + * transmission, or -1 on an error.
    *
    * Notes:
    *  If null characters are expected in the data stream, then
  @@ -443,20 +440,19 @@
    *  CR characters in the byte stream not immediately followed by a LF
    * will be preserved.
    */
  -API_EXPORT(ap_status_t) ap_bgets(char *buff, int n, BUFF *fb,
  -                                 ap_ssize_t *bytes_read)
  +API_EXPORT(int) ap_bgets(char *buff, int n, BUFF *fb)
   {
       int i, ch, ct;
       ap_status_t rv;
   
   /* Can't do bgets on an unbuffered stream */
       if (!(fb->flags & B_RD)) {
  -        *bytes_read = 0;
  -     return APR_EINVAL;
  +     errno = EINVAL;
  +     return -1;
       }
       if (fb->flags & B_RDERR) {
  -        *bytes_read = 0;
  -     return fb->saved_errno;
  +     errno = fb->saved_errno;
  +     return -1;
       }
   
       ct = 0;
  @@ -470,13 +466,9 @@
                break;
            rv = read_with_errors(fb, fb->inptr, fb->bufsiz, &i);
            if (rv != APR_SUCCESS) {
  +                errno = rv;
                buff[ct] = '\0';
  -                *bytes_read = ct;
  -#ifdef MIDWAY_ERROR_RETURNS_ERROR_BLAH_BLAH_BLAH
  -                return rv;
  -#else
  -             return *bytes_read ? APR_SUCCESS : rv;
  -#endif
  +             return ct ? ct : -1;
            }
            fb->incnt = i;
            if (i == 0)
  @@ -509,10 +501,7 @@
       fb->inptr += i;
   
       buff[ct] = '\0';
  -    *bytes_read = ct;
  -    if (i == 0)
  -        return APR_EOF;
  -    return APR_SUCCESS;
  +    return ct;
   }
   
   /*
  
  
  
  1.30      +10 -11    apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -d -u -r1.29 -r1.30
  --- http_protocol.c   1999/10/30 08:05:08     1.29
  +++ http_protocol.c   1999/10/31 09:02:53     1.30
  @@ -674,24 +674,23 @@
   static int getline(char *s, int n, BUFF *in, int fold)
   {
       char *pos, next;
  -    ap_status_t retval;
  -    ap_ssize_t nbytes;
  +    int retval;
       int total = 0;
   
       pos = s;
   
       do {
  -        retval = ap_bgets(pos, n, in, &nbytes);
  -       /* retval == APR_EOF if EOF, normal error codes otherwise */
  +        retval = ap_bgets(pos, n, in);
  +       /* retval == -1 if error, 0 if EOF */
   
  -        if (retval != APR_SUCCESS)        /* error or eof */
  -            return ((retval != APR_EOF) && (total == 0)) ? -1 : total;
  +        if (retval <= 0)
  +            return ((retval < 0) && (total == 0)) ? -1 : total;
   
  -        /* nbytes is the number of characters read, not including NUL      */
  +        /* retval is the number of characters read, not including NUL      */
   
  -        n -= nbytes;            /* Keep track of how much of s is full     */
  -        pos += (nbytes - 1);    /* and where s ends                        */
  -        total += nbytes;        /* and how long s has become               */
  +        n -= retval;            /* Keep track of how much of s is full     */
  +        pos += (retval - 1);    /* and where s ends                        */
  +        total += retval;        /* and how long s has become               */
   
           if (*pos == '\n') {     /* Did we get a full line of input?        */
               /*
  @@ -716,7 +715,7 @@
            * the last line was not empty and we have room in the buffer and
            * the next line begins with a continuation character.
            */
  -    } while (fold && (nbytes != 1) && (n > 1)
  +    } while (fold && (retval != 1) && (n > 1)
                     && (next = ap_blookc(in))
                     && ((next == ' ') || (next == '\t')));
   
  
  
  
  1.16      +1 -2      apache-2.0/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_script.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -d -u -r1.15 -r1.16
  --- util_script.c     1999/10/30 08:05:09     1.15
  +++ util_script.c     1999/10/31 09:02:54     1.16
  @@ -616,8 +616,7 @@
   
   static int getsfunc_BUFF(char *w, int len, void *fb)
   {
  -    ap_ssize_t n;       /* Ignored */
  -    return ap_bgets(w, len, (BUFF *) fb, &n) == APR_SUCCESS;
  +    return ap_bgets(w, len, (BUFF *) fb) > 0;
   }
   
   API_EXPORT(int) ap_scan_script_header_err_buff(request_rec *r, BUFF *fb,
  
  
  
  1.18      +10 -19    apache-2.0/src/modules/standard/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_cgi.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -d -u -r1.17 -r1.18
  --- mod_cgi.c 1999/10/30 08:05:10     1.17
  +++ mod_cgi.c 1999/10/31 09:02:55     1.18
  @@ -201,7 +201,6 @@
       ap_file_t *f;
       int i;
       struct stat finfo;
  -    ap_ssize_t n;       /* Ignored */
   
       if (!conf->logname ||
        ((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
  @@ -209,22 +208,19 @@
            (ap_open(&f, ap_server_root_relative(r->pool, conf->logname),
                     APR_APPEND, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
        /* Soak up script output */
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n)
  -               == APR_SUCCESS)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
            continue;
   #ifdef WIN32
           /* Soak up stderr and redirect it to the error log.
            * Script output to stderr is already directed to the error log
            * on Unix, thanks to the magic of fork().
            */
  -        while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
  -               == APR_SUCCESS) {
  +        while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
               ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r, 
                             "%s", argsbuffer);            
           }
   #else
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
  -               == APR_SUCCESS)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
            continue;
   #endif
        return ret;
  @@ -260,19 +256,18 @@
       if (sbuf && *sbuf)
        ap_fprintf(f, "%s\n", sbuf);
   
  -    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n) == APR_SUCCESS) 
{
  +    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
        ap_puts("%stdout\n", f);
        ap_puts(argsbuffer, f);
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n) > 0)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
            ap_puts(argsbuffer, f);
        ap_puts("\n", f);
       }
   
  -    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n) == 
APR_SUCCESS) {
  +    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
        ap_puts("%stderr\n", f);
        ap_puts(argsbuffer, f);
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
  -               == APR_SUCCESS)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
            ap_puts(argsbuffer, f);
        ap_puts("\n", f);
       }
  @@ -450,7 +445,6 @@
       char *argv0, *dbuf = NULL;
       char *command;
       char **argv = NULL;
  -    ap_ssize_t n;       /* Ignored */
   
       BUFF *script_out = NULL, *script_in = NULL, *script_err = NULL;
       char argsbuffer[HUGE_STRING_LEN];
  @@ -597,12 +591,10 @@
        if (location && location[0] == '/' && r->status == 200) {
   
            /* Soak up all the script output */
  -         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, &n)
  -                   == APR_SUCCESS) {
  +         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
                continue;
            }
  -         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
  -                   == APR_SUCCESS) {
  +         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
                continue;
            }
            /* This redirect needs to be a GET no matter what the original
  @@ -633,8 +625,7 @@
        }
        ap_bclose(script_in);
   
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, &n)
  -               == APR_SUCCESS) {
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
            continue;
        }
        ap_bclose(script_err);
  
  
  

Reply via email to