rbb         99/04/23 07:50:37

  Modified:    apr/file_io/beos Makefile open.c readwrite.c
  Added:       apr/file_io/beos dir.c fileacc.c fileio.h seek.c
  Log:
  Bring BeOS file I/O code up to par with the UNIX version.
  Submitted by:  David Reid
  
  Revision  Changes    Path
  1.2       +5 -2      apache-apr/apr/file_io/beos/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/beos/Makefile,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile  1999/02/26 17:06:44     1.1
  +++ Makefile  1999/04/23 14:50:32     1.2
  @@ -17,7 +17,7 @@
   EXTRA_DEPS=
   OSDIR=
   INCDIR=../../../include
  -INCLUDES0=-I $(INCDIR)
  +INCLUDES0=-I. -I $(INCDIR)
   SHELL=/bin/sh
   CC=gcc
   CPP=gcc -E
  @@ -47,7 +47,7 @@
   
   LIB=  libfile.a
   
  -OBJS= open.o readwrite.o filedup.o filestat.o\
  +OBJS= open.o readwrite.o filedup.o filestat.o seek.o dir.o fileacc.o\
   
   .c.o:
        $(CC) -c $(INCLUDES) $(CFLAGS) $<
  @@ -86,3 +86,6 @@
   readwrite.o: readwrite.c
   filedup.o: filedup.c
   filestat.o: filestat.c
  +seek.o: seek.c
  +dir.o: dir.c
  +fileacc.o: fileacc.c
  
  
  
  1.2       +18 -3     apache-apr/apr/file_io/beos/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/beos/open.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- open.c    1999/02/26 17:06:44     1.1
  +++ open.c    1999/04/23 14:50:33     1.2
  @@ -54,9 +54,10 @@
    */
   
   
  -// BeOS port by David Reid 23 Feb 1999
  +/* BeOS port by David Reid 23 Feb 1999 */
   
   #include "apr_file_io.h"
  +#include "apr_general.h"
   #include <errno.h>
   #include <support/SupportDefs.h>
   #include <kernel/OS.h>
  @@ -84,8 +85,7 @@
                free (dafile);
                return NULL;
       }
  -    //strcpy(dafile->fname, fname);
  -     dafile->fname = fname;
  +    dafile->fname = (char*)strdup(fname);
       if (flag & APR_CREATE) {
           oflags |= B_CREATE_FILE; 
                if (flag & APR_EXCL) {
  @@ -94,6 +94,7 @@
       }
       if ((flag & APR_EXCL) && !(flag & APR_CREATE)) {
           errno = EACCES;
  +        free(dafile->fname);
                free (dafile);
                return NULL;
       }   
  @@ -108,6 +109,7 @@
       
       if (dafile->filedes < 0) {
           dafile->filedes = -1;
  +        free(dafile->fname);
                free (dafile);
           return NULL;
       }
  @@ -117,6 +119,7 @@
       }
       else {
           errno = ENOSTAT;
  +        free(dafile->fname);
                free (dafile);
                return NULL;
       }
  @@ -126,6 +129,8 @@
   {
       if (close(file->filedes) == 0) {
           file->filedes = -1;
  +        free(file->fname);
  +        free(file);
           return APR_SUCCESS;
       }
       else {
  @@ -133,3 +138,13 @@
        /* Are there any error conditions other than EINTR or EBADF? */
       }
   }
  +
  +apr_status_t apr_remove_file(char *path) 
  +{ 
  +    if (unlink(path) == 0) { 
  +        return APR_SUCCESS; 
  +    } 
  +    else { 
  +        return APR_FAILURE; 
  +    } 
  +} 
  
  
  
  1.2       +16 -4     apache-apr/apr/file_io/beos/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/beos/readwrite.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- readwrite.c       1999/02/26 17:06:44     1.1
  +++ readwrite.c       1999/04/23 14:50:33     1.2
  @@ -59,9 +59,9 @@
   #include <errno.h>
   #include <unistd.h>
   
  -apr_uint64_t apr_read(apr_file_t *thefile, void *buf, apr_uint64_t nbytes)
  +apr_ssize_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t nbytes)
   {
  -    apr_int64_t rv;
  +    apr_size_t rv;
   
       if (thefile->filedes < 0) {
           errno = EBADF;
  @@ -73,9 +73,9 @@
       return rv;
   }
   
  -apr_uint64_t apr_write(apr_file_t *thefile, void * buf, apr_uint64_t nbytes)
  +apr_ssize_t apr_write(apr_file_t *thefile, void * buf, apr_ssize_t nbytes)
   {
  -    apr_int64_t rv;
  +    apr_size_t rv;
       struct stat info;
   
       if (thefile->filedes < 0) {
  @@ -92,4 +92,16 @@
           thefile->ctime = info.st_ctime;
       }
       return rv;
  +}    
  +
  +apr_ssize_t apr_writev(apr_file_t *thefile,const apr_iovec_t *vec, 
apr_ssize_t iocnt)
  +{
  +     apr_ssize_t bytes;
  +     if ((bytes = writev(thefile->filedes, vec, iocnt)) < 0){
  +             return APR_FAILURE;
  +     }
  +     else {
  +             return bytes;
  +     }
   }
  +
  
  
  
  1.1                  apache-apr/apr/file_io/beos/dir.c
  
  Index: dir.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 <http://www.apache.org/>.
   *
   */
  
  #include "apr_file_io.h"
  #include <errno.h>
  #include <string.h>
  #include <dirent.h>
  #include <stdio.h>
  /*#include <sys/stat.h> */
  
  apr_dir_t *apr_opendir(const char *dirname)
  {
      apr_dir_t *thedir = (apr_dir_t *)malloc(sizeof(apr_dir_t));
      thedir->dirname = strdup(dirname);
      thedir->dirstruct = opendir(dirname);
  
      if (thedir->dirstruct == NULL) {
          free(thedir);
          return NULL;
      }    
      else {
          return thedir;
      }
  }
  
  apr_status_t apr_closedir(apr_dir_t *thedir)
  {
      if (closedir(thedir->dirstruct) == 0) {
          free(thedir->dirname);
          free(thedir);
          thedir = NULL;
          return APR_SUCCESS;
      }
      else {
          return APR_FAILURE;
      }
  } 
  
  apr_dirent_t *apr_readdir(apr_dir_t *thedir)
  {
      return readdir(thedir->dirstruct);
  }
  
  apr_status_t apr_rewinddir(apr_dir_t *thedir)
  {
      rewinddir(thedir->dirstruct);
      return APR_SUCCESS;
  }
  
  apr_status_t apr_make_dir(const char *path, apr_fileperms_t mode)
  {
      if (mkdir(path, mode) == 0) {
          return APR_SUCCESS;
      }
      else {
          return APR_FAILURE;
      }
  }
  
  apr_status_t apr_remove_dir(const char *path)
  {
      if (rmdir(path) == 0) {
          return APR_SUCCESS;
      }
      else {
          return APR_FAILURE;
      }
  }
  
  
  
  1.1                  apache-apr/apr/file_io/beos/fileacc.c
  
  Index: fileacc.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 <http://www.apache.org/>.
   *
   */
  
  #include "apr_file_io.h"
  #include "apr_general.h"
  #include <errno.h>
  #include <string.h>
  
  /* A file to put ALL of the accessor functions for apr_file_t types. */
  
  apr_status_t apr_valid_file(apr_file_t *thefile) 
  {
      if (thefile != NULL && thefile->filedes > 0) {
          return APR_SUCCESS;
      }
      else {
          return APR_FAILURE;
      }
  }
  
  char * apr_get_filename(apr_file_t *thefile)
  {
      if (thefile != NULL) {
          return thefile->fname;
      }
      else {
          return NULL;
      }
  }
  
  
  
  
  
  1.1                  apache-apr/apr/file_io/beos/fileio.h
  
  Index: fileio.h
  ===================================================================
  /* ====================================================================
   * 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 <http://www.apache.org/>.
   *
   */
  
  #ifndef FILE_IO_H
  #define FILE_IO_H
  
  #include <sys/stat.h>
  #include <sys/types.h>
  #include <fcntl.h>
  #include <time.h>
  #include <dirent.h>
  #include <sys/uio.h>
  
  #define UREAD         S_IRUSR
  #define UWRITE                S_IWUSR
  #define UEXECUTE      S_IXUSR
  
  #define GREAD         S_IRGRP
  #define GWRITE                S_IWGRP
  #define GEXECUTE      S_IXGRP
  
  #define WREAD         S_IROTH
  #define WWRITE                S_IWOTH
  #define WEXECUTE      S_IXOTH
  
  typedef struct file_t {
      int filedes;
      char * fname;
      int buffered;
      mode_t protection;
      uid_t user;
      gid_t group;
      off_t size;
      time_t atime;    
      time_t mtime;
      time_t ctime;
  } file_t;
  
  typedef struct dir_t {
      char *dirname;
      DIR *dirstruct;
  } dir_t;
  
  typedef mode_t                        fileperms_t;
  typedef struct iovec  iovec_t;
  
  #endif /* ! FILE_IO_H */
  
  
  
  1.1                  apache-apr/apr/file_io/beos/seek.c
  
  Index: seek.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 <http://www.apache.org/>.
   *
   */
  
  #include "apr_file_io.h"
  #include <errno.h>
  #include <string.h>
  
  apr_off_t apr_seek(apr_file_t *thefile, apr_off_t offset, apr_seek_where_t 
where)
  {
      return lseek(thefile->filedes, offset, where);
  }
  
  
  

Reply via email to