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

1999-05-07 Thread rbb
rbb 99/05/07 11:19:20

  Modified:apr/file_io/unix open.c
  Log:
  Changing another malloc to apr_palloc.
  
  Revision  ChangesPath
  1.16  +3 -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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- open.c1999/04/30 18:38:51 1.15
  +++ open.c1999/05/07 18:19:20 1.16
  @@ -75,8 +75,10 @@
   apr_file_t *apr_open(apr_context_t *cont, char *fname, apr_int32_t flag,  
apr_fileperms_t mode)
   {
   int oflags = 0;
  -apr_file_t *dafile = (apr_file_t *)malloc(sizeof(apr_file_t));
  +apr_file_t *dafilel;
   struct stat info;
  +
  +dafile = (apr_file_t *)apr_palloc(cont-pool, sizeof(apr_file_t));
   
   if ((flag  APR_READ)  (flag  APR_WRITE)) {
   oflags = O_RDWR;
  
  
  


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

1999-02-25 Thread rbb
rbb 99/02/25 08:36:38

  Modified:apr/file_io/unix open.c
  Log:
  Finally got around to testing this code, so here is a working apr_open and
  apr_close. :)
  
  Revision  ChangesPath
  1.7   +22 -17apache-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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- open.c1999/02/23 21:07:44 1.6
  +++ open.c1999/02/25 16:36:37 1.7
  @@ -55,6 +55,7 @@
   
   #include apr_file_io.h
   #include errno.h
  +#include string.h
   
   apr_file_t *apr_open(char *fname, apr_int32_t flag,  apr_fileperms_t mode)
   {
  @@ -62,53 +63,56 @@
   apr_file_t *dafile = (apr_file_t *)malloc(sizeof(apr_file_t));
   struct stat info;
   
  -if ((flag  APR_READ)  (flag  APR_WRITE)) {
  +if ((flag  APR_READ)  (flag  APR_WRITE)) {
   oflags = O_RDWR;
   }
  -else if (flag  APR_READ) {
  +else if (flag  APR_READ) {
   oflags = O_RDONLY;
   }
  -else if (flag  APR_WRITE) {
  +else if (flag  APR_WRITE) {
   oflags = O_WRONLY;
   }
   else {
   errno = EACCES;
  - return NULL;
  + free(dafile);
  +return NULL;
   }
   
  -if (flag  APR_BUFFERED) {
  +if (flag  APR_BUFFERED) {
   dafile-buffered = TRUE;
   }
  -strcpy(dafile-fname, fname);
  +dafile-fname = strdup(fname);
   
  -if (flag  APR_CREATE) {
  +if (flag  APR_CREATE) {
   oflags |= O_CREAT; 
  - if (flag  APR_EXCL) {
  + if (flag  APR_EXCL) {
oflags |= O_EXCL;
}
   }
  -if ((flag  APR_EXCL)  !(flag  APR_CREATE)) {
  +if ((flag  APR_EXCL)  !(flag  APR_CREATE)) {
   errno = EACCES;
  - return NULL;
  + free(dafile);
  +return NULL;
   }   
   
  -if (flag  APR_APPEND) {
  +if (flag  APR_APPEND) {
   oflags |= O_APPEND;
   }
  -if (flag  APR_TRUNCATE) {
  -oflags = O_TRUNC;
  +if (flag  APR_TRUNCATE) {
  +oflags |= O_TRUNC;
   }
  -if (flag  APR_NONBLOCK) {
  -oflags = O_NONBLOCK;
  +if (flag  APR_NONBLOCK) {
  +oflags |= O_NONBLOCK;
   }
   else {
  -oflags = O_SYNC;
  +oflags |= O_SYNC;
   }

   dafile-filedes = open(fname, oflags, mode);
   
   if (dafile-filedes  0) {
   dafile-filedes = -1;
  +free(dafile);
   return NULL;
   }
   
  @@ -124,7 +128,8 @@
   }
   else {
   errno = ENOSTAT;
  - return NULL;
  + free(dafile);
  +return NULL;
   }
   }
   
  
  
  


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

1999-02-23 Thread rbb
rbb 99/02/23 07:07:02

  Modified:apr/file_io/unix open.c
  Log:
  Inserted the apr_close function.
  
  Revision  ChangesPath
  1.5   +13 -0 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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- open.c1999/02/22 16:24:47 1.4
  +++ open.c1999/02/23 15:07:02 1.5
  @@ -108,6 +108,7 @@
   dafile-filedes = open(fname, oflags, mode);
   
   if (dafile-filedes  0) {
  +dafile-filedes = -1;
   return NULL;
   }
   
  @@ -124,5 +125,17 @@
   else {
   errno = ENOSTAT;
return NULL;
  +}
  +}
  +
  +APRStatus apr_close(APRFile file)
  +{
  +if (close(file.filedes) == 0) {
  +file.filedes = -1;
  +return APR_SUCCESS;
  +}
  +else {
  +return APR_FAILURE;
  + /* Are there any error conditions other than EINTR or EBADF? */
   }
   }
  
  
  


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

1999-02-23 Thread rbb
rbb 99/02/23 13:07:45

  Modified:apr/file_io/unix open.c
  Log:
  Change names to conform to naming style proposed on new-httpd.  I am also
  fixing a bug in the code, because I forgot to allocate space for the file
  when I wrote this code.  Oops.
  
  Revision  ChangesPath
  1.6   +3 -3  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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- open.c1999/02/23 15:07:02 1.5
  +++ open.c1999/02/23 21:07:44 1.6
  @@ -56,10 +56,10 @@
   #include apr_file_io.h
   #include errno.h
   
  -APRFile *apr_open(char *fname, int flag, mode_t mode)
  +apr_file_t *apr_open(char *fname, apr_int32_t flag,  apr_fileperms_t mode)
   {
   int oflags = 0;
  -APRFile *dafile;
  +apr_file_t *dafile = (apr_file_t *)malloc(sizeof(apr_file_t));
   struct stat info;
   
   if ((flag  APR_READ)  (flag  APR_WRITE)) {
  @@ -128,7 +128,7 @@
   }
   }
   
  -APRStatus apr_close(APRFile file)
  +apr_status_t apr_close(apr_file_t file)
   {
   if (close(file.filedes) == 0) {
   file.filedes = -1;
  
  
  


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

1999-02-22 Thread coar
coar99/02/22 07:36:17

  Modified:apr/file_io/unix open.c
  Log:
Style guide..
  
  Revision  ChangesPath
  1.2   +26 -14apache-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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- open.c1999/02/22 13:04:10 1.1
  +++ open.c1999/02/22 15:36:17 1.2
  @@ -1,3 +1,4 @@
  +
   #include file_io.h
   
   API_EXPORT(APRFile *) apr_open(char *fname, int flag, mode_t mode)
  @@ -6,45 +7,55 @@
   APR_FILE *dafile;
   struct stat info;
   
  -if ((flag  APR_READ)  (flag  APR_WRITE))
  +if ((flag  APR_READ)  (flag  APR_WRITE)) {
   oflags = O_RDWR;
  -else if (flag  APR_READ)
  +}
  +else if (flag  APR_READ) {
   oflags = O_RDONLY;
  -else if (flag  APR_WRITE)
  +}
  +else if (flag  APR_WRITE) {
   oflags = O_WRONLY;
  +}
   else {
   errno = EACCESS;
return NULL;
   }
   
  -if (flag  APR_BUFFERED)
  -dafile-buffered = TRUE
  +if (flag  APR_BUFFERED) {
  +dafile-buffered = TRUE;
  +}
   strcpy(dafile-fname, fname);
   
   if (flag  APR_CREATE) {
  -oflags |= O_CREAT;
  - if (flag  APR_EXCL)
  +oflags |= O_CREAT; 
  + if (flag  APR_EXCL) {
oflags |= O_EXCL;
  + }
   }
   if ((flag  APR_EXCL)  !(flag  APR_CREATE)) {
   errno = EACCESS;
return NULL;
   }   
   
  -if (flag  APR_APPEND)
  +if (flag  APR_APPEND) {
   oflags |= O_APPEND;
  -if (flag  APR_TRUNCATE)
  +}
  +if (flag  APR_TRUNCATE) {
   oflags = O_TRUNC;
  -if (flag  APR_NONBLOCK)
  +}
  +if (flag  APR_NONBLOCK) {
   oflags = O_NONBLOCK;
  -else
  +}
  +else {
   oflags = O_SYNC;
  +}

   dafile-filedes = open(fname, oflags, mode);
   
  -if (dafile-filedes  0) 
  +if (dafile-filedes  0) {
   return NULL;
  -
  +}
  +
   if (stat(dafile-filedes, info) == 0) {
   dafile-protection = info.st_mode;
dafile-user = info.st_uid;
  @@ -54,7 +65,8 @@
dafile-mtime = info.st_mtime;
dafile-ctime = info.st_ctime;
return dafile;
  -} else {
  +}
  +else {
   errno = ENOSTAT;
return NULL;
   }
  
  
  


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

1999-02-22 Thread rbb
rbb 99/02/22 08:24:48

  Modified:apr/file_io/unix open.c
  Log:
  Fix some compile time errors that I missed last night.
  
  Revision  ChangesPath
  1.4   +6 -5  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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- open.c1999/02/22 15:51:46 1.3
  +++ open.c1999/02/22 16:24:47 1.4
  @@ -54,11 +54,12 @@
*/
   
   #include apr_file_io.h
  +#include errno.h
   
  -API_EXPORT(APRFile *) apr_open(char *fname, int flag, mode_t mode)
  +APRFile *apr_open(char *fname, int flag, mode_t mode)
   {
   int oflags = 0;
  -APR_FILE *dafile;
  +APRFile *dafile;
   struct stat info;
   
   if ((flag  APR_READ)  (flag  APR_WRITE)) {
  @@ -71,7 +72,7 @@
   oflags = O_WRONLY;
   }
   else {
  -errno = EACCESS;
  +errno = EACCES;
return NULL;
   }
   
  @@ -87,7 +88,7 @@
}
   }
   if ((flag  APR_EXCL)  !(flag  APR_CREATE)) {
  -errno = EACCESS;
  +errno = EACCES;
return NULL;
   }   
   
  @@ -110,7 +111,7 @@
   return NULL;
   }
   
  -if (stat(dafile-filedes, info) == 0) {
  +if (stat(dafile-fname, info) == 0) {
   dafile-protection = info.st_mode;
dafile-user = info.st_uid;
dafile-group = info.st_gid;