cvs commit: apache-apr/apr/file_io/unix filedup.c fileio.h open.c readwrite.c seek.c

1999-08-16 Thread rbb
rbb 99/08/16 12:10:20

  Modified:apr/file_io/unix filedup.c fileio.h open.c readwrite.c
seek.c
  Log:
  Get the buffered file I/O stuff in APR for unix finally.  This has been on
  my TODO list for a while, but it's off now.
  
  Revision  ChangesPath
  1.16  +18 -0 apache-apr/apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/filedup.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- filedup.c 1999/06/02 18:44:33 1.15
  +++ filedup.c 1999/08/16 19:10:11 1.16
  @@ -67,6 +67,7 @@
*/ 
   ap_status_t ap_dupfile(struct file_t *old_file, struct file_t **new_file)
   {
  +char *buf_oflags;
   (*new_file) = (struct file_t *)ap_palloc(old_file->cntxt,
  sizeof(struct file_t));
   
  @@ -74,7 +75,24 @@
   return APR_ENOMEM;
   }
   (*new_file)->cntxt = old_file->cntxt; 
  +if (old_file->buffered) {
  +switch (old_file->oflags) {
  +case O_RDONLY:
  +buf_oflags = "r";
  +break;
  +case O_WRONLY:
  +buf_oflags = "w";
  +break;
  +case O_RDWR:
  +buf_oflags = "r+";
  +break;
  +}
  +(*new_file)->filehand = freopen(old_file->fname, buf_oflags, 
  +old_file->filehand); 
  +}
  +else {
   (*new_file)->filedes = dup(old_file->filedes); 
  +}
   (*new_file)->fname = ap_pstrdup(old_file->cntxt, old_file->fname);
   (*new_file)->buffered = old_file->buffered;
   (*new_file)->protection = old_file->protection;
  
  
  
  1.10  +2 -0  apache-apr/apr/file_io/unix/fileio.h
  
  Index: fileio.h
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/fileio.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- fileio.h  1999/08/04 17:51:53 1.9
  +++ fileio.h  1999/08/16 19:10:12 1.10
  @@ -69,7 +69,9 @@
   struct file_t {
   ap_context_t *cntxt;
   int filedes;
  +FILE *filehand;
   char * fname;
  +int oflags;
   int buffered;
   int stated;
   int eof_hit;
  
  
  
  1.34  +36 -1 apache-apr/apr/file_io/unix/open.c
  
  Index: open.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/open.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- open.c1999/08/04 17:51:54 1.33
  +++ open.c1999/08/16 19:10:13 1.34
  @@ -65,7 +65,15 @@
   ap_status_t file_cleanup(void *thefile)
   {
   struct file_t *file = thefile;
  -if (close(file->filedes) == 0) {
  +int rv;
  +if (file->buffered) {
  +rv = fclose(file->filehand);
  +}
  +else {
  +rv = close(file->filedes);
  +}
  +
  +if (rv == 0) {
   file->filedes = -1;
   return APR_SUCCESS;
   }
  @@ -100,10 +108,12 @@
   int oflags = 0;
   struct stat info;
   mode_t mode = get_fileperms(perm);
  +char *buf_oflags;
   
   (*new) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t));
   
   (*new)->cntxt = cont;
  +(*new)->oflags = oflags;
   
   if ((flag & APR_READ) && (flag & APR_WRITE)) {
   oflags = O_RDWR;
  @@ -154,6 +164,25 @@
  (*new)->eof_hit = 1;
   return errno;
   }
  +
  +if ((*new)->buffered) {
  +switch (oflags) {
  +case O_RDONLY: 
  +buf_oflags = "r";
  +break;
  +case O_WRONLY:
  +buf_oflags = "w";
  +break;
  +case O_RDWR:
  +buf_oflags = "r+";
  +break;
  +}
  +(*new)->filehand = fdopen((*new)->filedes, buf_oflags);
  +if ((*new)->filehand == NULL) {
  +file_cleanup(*new);
  +return errno; 
  +}
  +}
   (*new)->stated = 0;  /* we haven't called stat for this file yet. */
   (*new)->eof_hit = 0;
   ap_register_cleanup((*new)->cntxt, (void *)(*new), file_cleanup, NULL);
  @@ -239,6 +268,12 @@
   ap_status_t ap_eof(ap_file_t *fptr)
   {
   char ch;
  +if (fptr->buffered) {
  +if (feof(fptr->filehand) == 0) {
  +return APR_SUCCESS;
  +}
  +return APR_EOF;
  +}
   if (fptr->eof_hit == 1) {
   return APR_EOF;
   }
  
  
  
  1.15  +31 -4 apache-apr/apr/file_io/unix/readwrite.c
  
  Index: readwrite.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/readwrite.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u 

cvs commit: apache-apr/apr/file_io/unix filedup.c

1999-04-23 Thread rbb
rbb 99/04/23 05:45:33

  Modified:docs fileio.txt
   include  apr_file_io.h
   apr/file_io/unix filedup.c
  Log:
  Removing patch for pushfile function.  It isn't portable, and it isn't needed.
  Oh well, a stupid mistake, but easily fixable.
  
  Revision  ChangesPath
  1.17  +0 -7  apache-apr/docs/fileio.txt
  
  Index: fileio.txt
  ===
  RCS file: /home/cvs/apache-apr/docs/fileio.txt,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- fileio.txt1999/04/22 19:20:55 1.16
  +++ fileio.txt1999/04/23 12:45:10 1.17
  @@ -189,13 +189,6 @@
   NOTE:  If directory name is NULL, the platform decides where it is best to 
put
  the pipe.  To get it in the current dir, use "." here :) 
   
  -apr_status_t apr_pushfile(apr_file_t *, int)
  -   Push a platform specific file descriptor into the apr file type.
  - Arguments:
  -   arg 1)  the file descriptor to modify.
  -   arg 2)  The file descriptor to push.
  -   return) APR_SUCCESS or APR_FAILURE
  -
    IMPLEMENTATION DETAILS **
   
   struct apr_file_t {
  
  
  
  1.18  +0 -1  apache-apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===
  RCS file: /home/cvs/apache-apr/include/apr_file_io.h,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- apr_file_io.h 1999/04/22 19:20:56 1.17
  +++ apr_file_io.h 1999/04/23 12:45:18 1.18
  @@ -115,7 +115,6 @@
   apr_ssize_t apr_writev(apr_file_t *, const apr_iovec_t *, apr_ssize_t);
   
   apr_file_t *apr_dupfile(apr_file_t *);
  -apr_status_t apr_pushfile(apr_file_t *, int);
   apr_status_t apr_getfileinfo(char *, apr_file_t *);
   apr_status_t apr_updatefileinfo(apr_file_t *);
   apr_off_t apr_seek(apr_file_t *, apr_off_t, apr_seek_where_t);
  
  
  
  1.5   +0 -8  apache-apr/apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/filedup.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- filedup.c 1999/04/22 19:20:58 1.4
  +++ filedup.c 1999/04/23 12:45:26 1.5
  @@ -76,11 +76,3 @@
   old_file->ctime = new_file->ctime;
   }
   
  -apr_status_t apr_pushfile(apr_file_t *oldfile, int fd)
  -{
  -if (dup2(oldfile->filedes, fd) == -1)
  -return APR_FAILURE;
  -return APR_SUCCESS;
  -}
  -
  -
  
  
  


cvs commit: apache-apr/apr/file_io/unix filedup.c

1999-04-22 Thread rbb
rbb 99/04/22 12:20:59

  Modified:docs fileio.txt
   include  apr_file_io.h
   apr/file_io/unix filedup.c
  Log:
  A new file function to allow me to specify a file descriptor to be put into
  an apr_file.  I am still trying to figure out if this needs to be abstracted
  more, and how to do it.  But, the function is needed for the process stuff,
  so I am committing it now.
  
  Revision  ChangesPath
  1.16  +7 -0  apache-apr/docs/fileio.txt
  
  Index: fileio.txt
  ===
  RCS file: /home/cvs/apache-apr/docs/fileio.txt,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- fileio.txt1999/04/20 20:52:53 1.15
  +++ fileio.txt1999/04/22 19:20:55 1.16
  @@ -189,6 +189,13 @@
   NOTE:  If directory name is NULL, the platform decides where it is best to 
put
  the pipe.  To get it in the current dir, use "." here :) 
   
  +apr_status_t apr_pushfile(apr_file_t *, int)
  +   Push a platform specific file descriptor into the apr file type.
  + Arguments:
  +   arg 1)  the file descriptor to modify.
  +   arg 2)  The file descriptor to push.
  +   return) APR_SUCCESS or APR_FAILURE
  +
    IMPLEMENTATION DETAILS **
   
   struct apr_file_t {
  
  
  
  1.17  +1 -0  apache-apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===
  RCS file: /home/cvs/apache-apr/include/apr_file_io.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- apr_file_io.h 1999/04/20 20:46:42 1.16
  +++ apr_file_io.h 1999/04/22 19:20:56 1.17
  @@ -115,6 +115,7 @@
   apr_ssize_t apr_writev(apr_file_t *, const apr_iovec_t *, apr_ssize_t);
   
   apr_file_t *apr_dupfile(apr_file_t *);
  +apr_status_t apr_pushfile(apr_file_t *, int);
   apr_status_t apr_getfileinfo(char *, apr_file_t *);
   apr_status_t apr_updatefileinfo(apr_file_t *);
   apr_off_t apr_seek(apr_file_t *, apr_off_t, apr_seek_where_t);
  
  
  
  1.4   +8 -0  apache-apr/apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/filedup.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- filedup.c 1999/04/12 15:25:52 1.3
  +++ filedup.c 1999/04/22 19:20:58 1.4
  @@ -76,3 +76,11 @@
   old_file->ctime = new_file->ctime;
   }
   
  +apr_status_t apr_pushfile(apr_file_t *oldfile, int fd)
  +{
  +if (dup2(oldfile->filedes, fd) == -1)
  +return APR_FAILURE;
  +return APR_SUCCESS;
  +}
  +
  +
  
  
  


cvs commit: apache-apr/apr/file_io/unix filedup.c

1999-04-12 Thread rbb
rbb 99/04/12 08:25:53

  Modified:apr/file_io/unix filedup.c
  Log:
  compiler didn't catch these last time I made them, or at least I missed it, 
but
  this commit will actually let the duplicate file function work.
  
  Revision  ChangesPath
  1.3   +2 -2  apache-apr/apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/filedup.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- filedup.c 1999/04/12 15:06:35 1.2
  +++ filedup.c 1999/04/12 15:25:52 1.3
  @@ -52,7 +52,7 @@
* project, please see .
*
*/
  -
  +#include 
   #include "apr_file_io.h"
   #include "apr_general.h"
   
  @@ -65,7 +65,7 @@
   return NULL;
   } 
   old_file->filedes = dup(new_file->filedes); 
  -old_file->fname = stdup(new_file->fname);
  +old_file->fname = strdup(new_file->fname);
   old_file->buffered = new_file->buffered;
   old_file->protection = new_file->protection;
   old_file->user = new_file->user;
  
  
  


cvs commit: apache-apr/apr/file_io/unix filedup.c

1999-04-12 Thread rbb
rbb 99/04/12 08:06:35

  Modified:apr/file_io/unix filedup.c
  Log:
  Modified duplicatefile so we can close the original file after duplicating
  without affecting the new file.
  Submitted by: Brian Havard
  
  Revision  ChangesPath
  1.2   +2 -2  apache-apr/apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/filedup.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- filedup.c 1999/02/25 21:33:43 1.1
  +++ filedup.c 1999/04/12 15:06:35 1.2
  @@ -64,8 +64,8 @@
   errno = ENOMEM;
   return NULL;
   } 
  -old_file->filedes = new_file->filedes; 
  -old_file->fname = new_file->fname;
  +old_file->filedes = dup(new_file->filedes); 
  +old_file->fname = stdup(new_file->fname);
   old_file->buffered = new_file->buffered;
   old_file->protection = new_file->protection;
   old_file->user = new_file->user;
  
  
  


cvs commit: apache-apr/apr/file_io/unix filedup.c filestat.c Makefile open.c

1999-02-25 Thread rbb
rbb 99/02/25 13:33:46

  Modified:apr/file_io/unix Makefile open.c
  Added:   apr/file_io/unix filedup.c filestat.c
  Log:
  Added logic to copy apr file descriptos, and get stat information for
  files.
  
  Revision  ChangesPath
  1.3   +4 -3  apache-apr/apr/file_io/unix/Makefile
  
  Index: Makefile
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/Makefile,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile  1999/02/25 19:58:41 1.2
  +++ Makefile  1999/02/25 21:33:42 1.3
  @@ -47,7 +47,7 @@
   
   LIB=  libfile.a
   
  -OBJS= open.o readwrite.o\
  +OBJS= open.o readwrite.o filedup.o filestat.o\
   
   .c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $<
  @@ -82,6 +82,7 @@
   $(OBJS): Makefile
   
   # DO NOT REMOVE
  -alloc.o: open.c 
  +open.o: open.c filestat.c
   readwrite.o: readwrite.c
  -
  +filedup.o: filedup.c
  +filestat.o: filestat.c
  
  
  
  1.9   +1 -8  apache-apr/apr/file_io/unix/open.c
  
  Index: open.c
  ===
  RCS file: /home/cvs/apache-apr/apr/file_io/unix/open.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- open.c1999/02/25 19:58:41 1.8
  +++ open.c1999/02/25 21:33:43 1.9
  @@ -116,14 +116,7 @@
   return NULL;
   }
   
  -if (stat(dafile->fname, &info) == 0) {
  -dafile->protection = info.st_mode;
  - dafile->user = info.st_uid;
  - dafile->group = info.st_gid;
  - dafile->size = info.st_size;
  - dafile->atime = info.st_atime;
  - dafile->mtime = info.st_mtime;
  - dafile->ctime = info.st_ctime;
  +if (apr_updatefileinfo(dafile) == APR_SUCCESS) {
return dafile;
   }
   else {
  
  
  
  1.1  apache-apr/apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===
  /* 
   * Copyright (c) 1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *notice, this list of conditions and the following disclaimer in
   *the documentation and/or other materials provided with the
   *distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *software must display the following acknowledgment:
   *"This product includes software developed by the Apache Group
   *for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *endorse or promote products derived from this software without
   *prior written permission. For written permission, please contact
   *[EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *nor may "Apache" appear in their names without prior written
   *permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *acknowledgment:
   *"This product includes software developed by the Apache Group
   *for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * 
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see .
   *
   */
  
  #include "apr_file_io.h"
  #include "apr_general.h"
  
  apr_file_t *apr_dupfile(apr_file_t *old_file)
  {
  apr_file_t * new_file = (apr_file_t *)malloc(sizeof(apr_file_t));