rbb         99/04/09 11:02:59

  Modified:    apr/file_io/unix readwrite.c
               apr/test testfile.c
               docs     fileio.txt
               include  apr_file_io.h
  Log:
  Added apr_writev call, and requisite defines.  I also added the permissions
  abstraction #defines.
  
  Revision  Changes    Path
  1.4       +16 -3     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- readwrite.c       1999/04/09 14:36:57     1.3
  +++ readwrite.c       1999/04/09 18:02:41     1.4
  @@ -58,8 +58,8 @@
   #include "apr_errno.h"
   #include <errno.h>
   #include <unistd.h>
  -
  -apr_ssize_t apr_read(apr_file_t *thefile, void *buf, apr_size_t nbytes)
  +#include <sys/uio.h>
  +apr_ssize_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t nbytes)
   {
       apr_size_t rv;
   
  @@ -73,7 +73,7 @@
       return rv;
   }
   
  -apr_ssize_t apr_write(apr_file_t *thefile, void * buf, apr_size_t nbytes)
  +apr_ssize_t apr_write(apr_file_t *thefile, void *buf, apr_ssize_t nbytes)
   {
       apr_size_t rv;
       struct stat info;
  @@ -93,3 +93,16 @@
       }
       return rv;
   }
  +
  +apr_ssize_t apr_writev(apr_file_t *thefile, const apr_iovec_t * vec, 
apr_ssize_t iocnt)
  +{
  +    int bytes;
  +    if ((bytes = writev(thefile->filedes, vec, iocnt)) < 0) {
  +        return APR_FAILURE;
  +    }
  +    else {
  +        return bytes;
  +    }
  +}
  +
  +
  
  
  
  1.9       +5 -5      apache-apr/apr/test/testfile.c
  
  Index: testfile.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/test/testfile.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- testfile.c        1999/04/09 15:05:16     1.8
  +++ testfile.c        1999/04/09 18:02:52     1.9
  @@ -78,7 +78,7 @@
       fprintf(stdout, "Testing file functions.\n");
   
       fprintf(stdout, "\tOpening file.......");
  -    thefile = apr_open(filename, flag, 444);
  +    thefile = apr_open(filename, flag, APR_UREAD | APR_UWRITE | APR_GREAD);
       if (thefile == NULL) {
           perror("Didn't open file");
           exit(-1);
  @@ -162,7 +162,7 @@
       }
       
       fprintf(stdout, "\tMaking sure it's gone.......");
  -    thefile = apr_open(filename, APR_READ, 444);
  +    thefile = apr_open(filename, APR_READ, APR_UREAD | APR_UWRITE | 
APR_GREAD);
       if (thefile != NULL) {
           fprintf(stderr, "I could open the file for some reason?\n");
           exit(-1);
  @@ -190,7 +190,7 @@
       apr_file_t *thefile;
       apr_int32_t flag = APR_READ | APR_WRITE | APR_CREATE;
       
  -    thefile = apr_open("testdel", flag, 444);
  +    thefile = apr_open("testdel", flag, APR_UREAD | APR_UWRITE | APR_GREAD);
       if (thefile == NULL) {
            return APR_FAILURE;
       }
  @@ -203,7 +203,7 @@
           return APR_FAILURE;
       }
   
  -    thefile = apr_open("testdel", APR_READ, 444);
  +    thefile = apr_open("testdel", APR_READ, APR_UREAD | APR_UWRITE | 
APR_GREAD);
       if (thefile != NULL) {
           return APR_FAILURE;
       }
  @@ -227,7 +227,7 @@
           fprintf(stdout, "OK\n");
       }
   
  -    if (apr_open("testdir/testfile", APR_READ | APR_WRITE | APR_CREATE, 444) 
!= NULL) {;
  +    if (apr_open("testdir/testfile", APR_READ | APR_WRITE | APR_CREATE, 
APR_UREAD | APR_UWRITE | APR_UEXECUTE) != NULL) {;
           return -1;
       }
   
  
  
  
  1.10      +5 -10     apache-apr/docs/fileio.txt
  
  Index: fileio.txt
  ===================================================================
  RCS file: /home/cvs/apache-apr/docs/fileio.txt,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- fileio.txt        1999/04/09 14:37:00     1.9
  +++ fileio.txt        1999/04/09 18:02:55     1.10
  @@ -143,22 +143,17 @@
           arg 1)  The path of the directory to remove.
           return) APR_SUCCESS or APR_FAILURE
   
  - APRStatus apr_writev(APRFile, APRIOVec *, APRUInt64, APUInt64 *)
  + apr_ssize_t apr_writev(APRFile, APRIOVec *, APRUInt64)
        Same as apr_write, except it gets the data from the APRIOVec array.
        Arguments:
        arg 1)  File descriptor to write data to
        arg 2)  Array from which to get the data to write to the file
        arg 3)  Number of elements in the APRIOVec array.  Must be smaller
                than apr_MAX_IOVEC_SIZE, if not function will fail with
  -             apr_BUFFER_OVERFLOW_ERROR
  -     arg 4) number of bytes written.  APR_FAILURE on failure.
  -     NOTES: apr_writev will write a complete entry from APRIOVec array before
  -         moving on to the next one.
  - APRStatus apr_access(char *, APRFilePerms)
  -     Determine the Accessibility of a file
  -     Arguments:
  -     arg 1)  path to file 
  -     arg 3)  Which access permissions to check for.
  +             APR_BUFFER_OVERFLOW_ERROR
  +     return) number of bytes written.  APR_FAILURE on failure.
  +Notes: apr_writev will write a complete entry from APRIOVec array before
  +       moving on to the next one.
   
   **************** IMPLEMENTATION DETAILS **************
   
  
  
  
  1.12      +20 -4     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- apr_file_io.h     1999/04/09 14:37:04     1.11
  +++ apr_file_io.h     1999/04/09 18:02:58     1.12
  @@ -61,6 +61,7 @@
   #include <fcntl.h>
   #include <time.h>
   #include <dirent.h>
  +#include <sys/uio.h>
   #include "apr_general.h"
   #include "apr_errno.h"
   
  @@ -81,6 +82,19 @@
   #define APR_CUR SEEK_CUR
   #define APR_END SEEK_END
   
  +/* Permissions flags */
  +#define APR_UREAD     S_IRUSR
  +#define APR_UWRITE    S_IWUSR
  +#define APR_UEXECUTE  S_IXUSR
  +
  +#define APR_GREAD     S_IRGRP
  +#define APR_GWRITE    S_IWGRP
  +#define APR_GEXECUTE  S_IXGRP
  +
  +#define APR_WREAD     S_IROTH
  +#define APR_WWRITE    S_IWOTH
  +#define APR_WEXECUTE  S_IXOTH
  +
   /* should be same as whence type in lseek, POSIZ defines this as int */
   typedef int apr_seek_where_t;
   
  @@ -102,16 +116,18 @@
       DIR *dirstruct;
   } apr_dir_t;
   
  -typedef mode_t apr_fileperms_t;
  -typedef struct dirent apr_dirent_t;
  +typedef mode_t            apr_fileperms_t;
  +typedef struct dirent     apr_dirent_t;
  +typedef struct iovec      apr_iovec_t;
   
   /*   Function definitions */
   apr_file_t *apr_open(char *, apr_int32_t, apr_fileperms_t);
   apr_status_t apr_close(apr_file_t *);
   apr_status_t apr_remove_file(char *);
   
  -apr_ssize_t apr_read(apr_file_t *, void *, apr_size_t);
  -apr_ssize_t apr_write(apr_file_t *, void *, apr_size_t);
  +apr_ssize_t apr_read(apr_file_t *, void *, apr_ssize_t);
  +apr_ssize_t apr_write(apr_file_t *, void *, apr_ssize_t);
  +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_getfileinfo(char *, apr_file_t *);
  
  
  

Reply via email to