httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@hyperreal.org
Subject cvs commit: apache-apr/apr/file_io/unix open.c
Date Thu, 25 Feb 1999 16:36:39 GMT
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  Changes    Path
  1.7       +22 -17    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- open.c	1999/02/23 21:07:44	1.6
  +++ open.c	1999/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;
       }
   }
   
  
  
  

Mime
View raw message