httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@hyperreal.org
Subject cvs commit: apache-apr/apr/file_io/os2 dir.c fileacc.c pipe.c fileio.h filedup.c filestat.c maperrorcode.c open.c readwrite.c seek.c
Date Fri, 04 Jun 1999 13:13:21 GMT
bjh         99/06/04 06:13:21

  Modified:    apr/file_io/os2 filedup.c filestat.c maperrorcode.c open.c
                        readwrite.c seek.c
  Added:       apr/file_io/os2 dir.c fileacc.c pipe.c fileio.h
  Log:
  Update file_io lib for OS/2 to current spec.
  
  Revision  Changes    Path
  1.3       +14 -20    apache-apr/apr/file_io/os2/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/os2/filedup.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- filedup.c	1999/05/10 14:36:22	1.2
  +++ filedup.c	1999/06/04 13:13:16	1.3
  @@ -53,39 +53,33 @@
    *
    */
   
  +#include "fileio.h"
   #include "apr_file_io.h"
  -#include "apr_general.h"
  +#include "apr_lib.h"
   #include <string.h>
   
   #define INCL_DOS
   #include <os2.h>
   
  -ap_file_t *ap_dupfile(ap_file_t *old_file)
  +ap_status_t ap_dupfile(struct file_t *old_file, struct file_t **new_file)
   {
       int rv;
  -    ap_file_t * new_file = (ap_file_t *)malloc(sizeof(ap_file_t));
  +    struct file_t *dup_file = (struct file_t *)ap_palloc(old_file->cntxt, sizeof(struct
file_t));
       
       if (new_file == NULL) {
  -        errno = ENOMEM;
  -        return NULL;
  +        return APR_ENOMEM;
       } 
       
  -    rv = DosDupHandle(old_file->filedes, (ULONG *)&new_file->filedes);
  +    rv = DosDupHandle(old_file->filedes, &dup_file->filedes);
       
  -    if ( rv ) {
  -        errno = os2errno(rv);
  -        free(new_file);
  -        return NULL;
  +    if (rv) {
  +        return os2errno(rv);
       }
       
  -    old_file->filedes = new_file->filedes; 
  -    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;
  -    old_file->group = new_file->group;
  -    old_file->size = new_file->size;
  -    old_file->atime = new_file->atime;    
  -    old_file->mtime = new_file->mtime;
  -    old_file->ctime = new_file->ctime;
  +    dup_file->cntxt = old_file->cntxt;
  +    dup_file->fname = ap_pstrdup(dup_file->cntxt, old_file->fname);
  +    dup_file->buffered = old_file->buffered;
  +    dup_file->status = old_file->status;
  +    *new_file = dup_file;
  +    return APR_SUCCESS;
   }
  
  
  
  1.3       +23 -36    apache-apr/apr/file_io/os2/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/os2/filestat.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- filestat.c	1999/05/10 14:36:22	1.2
  +++ filestat.c	1999/06/04 13:13:17	1.3
  @@ -53,9 +53,10 @@
    *
    */
   
  +#include "fileio.h"
   #include "apr_file_io.h"
  -#include "apr_general.h"
  -#include "apr_errno.h"
  +#include "apr_lib.h"
  +#include <sys/time.h>
   
   #define INCL_DOS
   #include <os2.h>
  @@ -90,47 +91,33 @@
     return mktime( &tmpdate );
   }
   
  -ap_status_t ap_getfileinfo(char * fname, ap_file_t *thefile)
  -{
  -    FILESTATUS3 info;
  -    int rv = DosQueryPathInfo(fname, FIL_STANDARD, &info, sizeof(info));
  +
   
  -    if (rv == 0) {
  -        thefile->protection = (info.attrFile & FILE_READONLY) ? 0555 : 0777;
  -        thefile->user = 0;
  -        thefile->group = 0;
  -        thefile->size = info.cbFile;
  -        thefile->atime = os2date2unix(info.fdateLastAccess, info.ftimeLastAccess);
  -        thefile->mtime = os2date2unix(info.fdateLastWrite, info.ftimeLastWrite);
  -        thefile->ctime = os2date2unix(info.fdateCreation, info.ftimeCreation);
  +ap_status_t ap_getfileinfo(struct file_t *thefile)
  +{
  +    ULONG rc = DosQueryPathInfo(thefile->fname, FIL_STANDARD, &thefile->status,
sizeof(thefile->status));
  +    
  +    if (rc == 0) {
  +        thefile->validstatus = TRUE;
           return APR_SUCCESS;
       }
  -    else {
  -        errno = ENOSTAT;
  -        return APR_FAILURE;
  -    }
  +    
  +    thefile->validstatus = FALSE;
  +    return os2errno(rc);
   }
   
  -ap_status_t ap_updatefileinfo(ap_file_t *thefile)
  -{
  -    FILESTATUS3 info;
  -    int rv = DosQueryFileInfo(thefile->filedes, FIL_STANDARD, &info, sizeof(info));
   
  -    if (rv == 0) {
  -        thefile->protection = (info.attrFile & FILE_READONLY) ? 0555 : 0777;
  -        thefile->user = 0;
  -        thefile->group = 0;
  -        thefile->size = info.cbFile;
  -        thefile->atime = os2date2unix(info.fdateLastAccess, info.ftimeLastAccess);
  -        thefile->mtime = os2date2unix(info.fdateLastWrite, info.ftimeLastWrite);
  -        thefile->ctime = os2date2unix(info.fdateCreation, info.ftimeCreation);
  +
  +ap_status_t ap_updatefileinfo(struct file_t *thefile)
  +{
  +    ULONG rc = DosQueryFileInfo(thefile->filedes, FIL_STANDARD, &thefile->status,
sizeof(thefile->status));
  +    
  +    if (rc == 0) {
  +        thefile->validstatus = TRUE;
           return APR_SUCCESS;
  -    }
  -    else {
  -        errno = ENOSTAT;
  -        return APR_FAILURE;
       }
  +    
  +    thefile->validstatus = FALSE;
  +    return os2errno(rc);
   }
  -
  -
   
  
  
  
  1.2       +13 -12    apache-apr/apr/file_io/os2/maperrorcode.c
  
  Index: maperrorcode.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/os2/maperrorcode.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maperrorcode.c	1999/04/09 18:39:15	1.1
  +++ maperrorcode.c	1999/06/04 13:13:17	1.2
  @@ -61,18 +61,19 @@
   #include <os2.h>
   
   int errormap[][2] = {
  -    { ERROR_FILE_NOT_FOUND,       ENOENT       },
  -    { ERROR_PATH_NOT_FOUND,       ENOENT       },
  -    { ERROR_TOO_MANY_OPEN_FILES,  EMFILE       },
  -    { ERROR_ACCESS_DENIED,        EACCES       },
  -    { ERROR_SHARING_VIOLATION,    EACCES       },
  -    { ERROR_INVALID_PARAMETER,    EINVAL       },
  -    { ERROR_OPEN_FAILED,          ENOENT       },
  -    { ERROR_DISK_FULL,            ENOSPC       },
  -    { ERROR_FILENAME_EXCED_RANGE, ENAMETOOLONG },
  -    { ERROR_INVALID_FUNCTION,     EINVAL       },
  -    { ERROR_INVALID_HANDLE,       EBADF        },
  -    { ERROR_NEGATIVE_SEEK,        ESPIPE       }
  +    { NO_ERROR,                   APR_SUCCESS      },
  +    { ERROR_FILE_NOT_FOUND,       APR_ENOENT       },
  +    { ERROR_PATH_NOT_FOUND,       APR_ENOENT       },
  +    { ERROR_TOO_MANY_OPEN_FILES,  APR_EMFILE       },
  +    { ERROR_ACCESS_DENIED,        APR_EACCES       },
  +    { ERROR_SHARING_VIOLATION,    APR_EACCES       },
  +    { ERROR_INVALID_PARAMETER,    APR_EINVAL       },
  +    { ERROR_OPEN_FAILED,          APR_ENOENT       },
  +    { ERROR_DISK_FULL,            APR_ENOSPC       },
  +    { ERROR_FILENAME_EXCED_RANGE, APR_ENAMETOOLONG },
  +    { ERROR_INVALID_FUNCTION,     APR_EINVAL       },
  +    { ERROR_INVALID_HANDLE,       APR_EBADF        },
  +    { ERROR_NEGATIVE_SEEK,        APR_ESPIPE       }
   };
   
   #define MAPSIZE (sizeof(errormap)/sizeof(errormap[0]))
  
  
  
  1.3       +49 -42    apache-apr/apr/file_io/os2/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/os2/open.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- open.c	1999/05/10 14:36:22	1.2
  +++ open.c	1999/06/04 13:13:17	1.3
  @@ -53,22 +53,35 @@
    *
    */
   
  +#include "fileio.h"
   #include "apr_file_io.h"
  -#include <errno.h>
  +#include "apr_lib.h"
   #include <string.h>
   
   #define INCL_DOS
   #include <os2.h>
   
  -ap_file_t *ap_open(char *fname, ap_int32_t flag,  ap_fileperms_t mode)
  +ap_status_t file_cleanup(void *thefile)
   {
  +    struct file_t *file = thefile;
  +    return ap_close(file);
  +}
  +
  +
  +
  +ap_status_t ap_open(ap_context_t *cntxt, char *fname, ap_int32_t flag,  ap_fileperms_t
perm, struct file_t **new)
  +{
       int oflags = 0;
       int mflags = OPEN_FLAGS_FAIL_ON_ERROR|OPEN_SHARE_DENYNONE;
       int rv;
  -    ap_file_t *dafile = (ap_file_t *)malloc(sizeof(ap_file_t));
  -    struct stat info;
       ULONG action;
  +    ap_file_t *dafile = (struct file_t *)ap_palloc(cntxt, sizeof(struct file_t));
   
  +    *new = dafile;
  +    dafile->cntxt = cntxt;
  +    dafile->isopen = FALSE;
  +    dafile->validstatus = FALSE;
  +    
       if ((flag & APR_READ) && (flag & APR_WRITE)) {
           mflags |= OPEN_ACCESS_READWRITE;
       } else if (flag & APR_READ) {
  @@ -76,14 +89,11 @@
       } else if (flag & APR_WRITE) {
           mflags |= OPEN_ACCESS_WRITEONLY;
       } else {
  -        errno = EACCES;
  -        free(dafile);
  -        return NULL;
  +        dafile->filedes = -1;
  +        return APR_EACCES;
       }
   
  -    if (flag & APR_BUFFERED) {
  -        dafile->buffered = TRUE;
  -    }
  +    dafile->buffered = (flag & APR_BUFFERED) > 0;
   
       if (flag & APR_CREATE) {
           oflags |= OPEN_ACTION_CREATE_IF_NEW; 
  @@ -95,11 +105,8 @@
           }
       }
       
  -    if ((flag & APR_EXCL) && !(flag & APR_CREATE)) {
  -        errno = EACCES;
  -        free(dafile);
  -        return NULL;
  -    }
  +    if ((flag & APR_EXCL) && !(flag & APR_CREATE))
  +        return APR_EACCES;
   
       if (flag & APR_TRUNCATE) {
           oflags |= OPEN_ACTION_REPLACE_IF_EXISTS;
  @@ -110,42 +117,42 @@
       if (rv == 0 && (flag & APR_APPEND)) {
           ULONG newptr;
           rv = DosSetFilePtr(dafile->filedes, 0, FILE_END, &newptr );
  +        
  +        if (rv)
  +            DosClose(dafile->filedes);
       }
       
  -    if (rv != 0) {
  -        free(dafile);
  -        return NULL;
  -    }
  -
  -    if (ap_updatefileinfo(dafile) == APR_SUCCESS) {
  -        dafile->fname = strdup(fname);
  -        return dafile;
  -    } else {
  -        errno = ENOSTAT;
  -        free(dafile);
  -        return NULL;
  -    }
  +    if (rv != 0)
  +        return os2errno(rv);
  +    
  +    dafile->isopen = TRUE;
  +    dafile->fname = ap_pstrdup(cntxt, fname);
  +    return APR_SUCCESS;
   }
   
  +
  +
   ap_status_t ap_close(ap_file_t *file)
   {
  -    if (DosClose(file->filedes) == 0) {
  -        free(file->fname);
  -        free(file);
  -        return APR_SUCCESS;
  -    } else {
  -        return APR_FAILURE;
  -        /* Are there any error conditions other than EINTR or EBADF? */
  +    ULONG rc; 
  +    
  +    if (file && file->isopen) {
  +        rc = DosClose(file->filedes);
  +    
  +        if (rc == 0) {
  +            file->isopen = FALSE;
  +            return APR_SUCCESS;
  +        } else {
  +            return os2errno(rc);
  +        }
       }
   }
  +
  +
   
  -ap_status_t ap_remove_file(char *path)
  +ap_status_t ap_remove_file(ap_context_t *cntxt, char *path)
   {
  -    if (DosDelete(path) == 0) {
  -        return APR_SUCCESS;
  -    }
  -    else {
  -        return APR_FAILURE;
  -    }
  +    ULONG rc = DosDelete(path);
  +    return os2errno(rc);
   }
   
  
  
  
  1.3       +34 -24    apache-apr/apr/file_io/os2/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/os2/readwrite.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- readwrite.c	1999/05/10 14:36:23	1.2
  +++ readwrite.c	1999/06/04 13:13:18	1.3
  @@ -53,43 +53,53 @@
    *
    */
   
  +#include "fileio.h"
   #include "apr_file_io.h"
  -#include "apr_general.h"
  -#include "apr_errno.h"
  -#include <errno.h>
  -#include <unistd.h>
  +#include "apr_lib.h"
   
  -ap_ssize_t ap_read(ap_file_t *thefile, void *buf, ap_ssize_t nbytes)
  +#define INCL_DOS
  +#include <os2.h>
  +
  +ap_status_t ap_read(const struct file_t *thefile, void *buf, ap_ssize_t *nbytes)
   {
  -    ap_size_t rv;
  +    ULONG rc;
  +    ULONG bytesread;
   
  -    if (thefile->filedes < 0) {
  -        errno = EBADF;
  -        return -1;
  +    if (!thefile->isopen) {
  +        *nbytes = 0;
  +        return APR_EBADF;
       }
   
  -    rv = read(thefile->filedes, buf, nbytes);
  +    rc = DosRead(thefile->filedes, buf, *nbytes, &bytesread);
   
  -    return rv;
  +    if (rc) {
  +        *nbytes = 0;
  +        return os2errno(rc);
  +    }
  +    
  +    *nbytes = bytesread;
  +    return APR_SUCCESS;
   }
  +
  +
   
  -ap_ssize_t ap_write(ap_file_t *thefile, void * buf, ap_ssize_t nbytes)
  +ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes)
   {
  -    ap_size_t rv;
  -    struct stat info;
  +    ULONG rc;
  +    ULONG byteswritten;
   
  -    if (thefile->filedes < 0) {
  -        errno = EBADF;
  -        return -1;
  +    if (!thefile->isopen) {
  +        *nbytes = 0;
  +        return APR_EBADF;
       }
   
  -    rv = write(thefile->filedes, buf, nbytes);
  +    rc = DosWrite(thefile->filedes, buf, *nbytes, &byteswritten);
   
  -    if (stat(thefile->fname, &info) == 0) {
  -        thefile->size = info.st_size;
  -        thefile->atime = info.st_atime;
  -        thefile->mtime = info.st_mtime;
  -        thefile->ctime = info.st_ctime;
  +    if (rc) {
  +        *nbytes = 0;
  +        return os2errno(rc);
       }
  -    return rv;
  +    
  +    *nbytes = byteswritten;
  +    return APR_SUCCESS;
   }
  
  
  
  1.3       +11 -17    apache-apr/apr/file_io/os2/seek.c
  
  Index: seek.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/file_io/os2/seek.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- seek.c	1999/05/10 14:36:23	1.2
  +++ seek.c	1999/06/04 13:13:18	1.3
  @@ -53,8 +53,9 @@
    *
    */
   
  +#include "fileio.h"
   #include "apr_file_io.h"
  -#include <errno.h>
  +#include "apr_lib.h"
   #include <string.h>
   #include <io.h>
   
  @@ -63,32 +64,25 @@
   
   int os2errno( ULONG oserror );
   
  -ap_off_t ap_seek(ap_file_t *file, ap_off_t offset, ap_seek_where_t origin)
  +ap_status_t ap_seek(struct file_t *thefile, ap_seek_where_t where, ap_off_t *offset)
   {
  -    int rv;
  -    ULONG newpos;
  +    if (!thefile->isopen) {
  +        return APR_EBADF;
  +    }
       
  -    switch (origin) {
  +    switch (where) {
           case APR_SET:
  -            origin = FILE_BEGIN;
  +            where = FILE_BEGIN;
               break;
               
           case APR_CUR:
  -            origin = FILE_CURRENT;
  +            where = FILE_CURRENT;
               break;
               
           case APR_END:
  -            origin = FILE_END;
  +            where = FILE_END;
               break;
       }
               
  -    rv = DosSetFilePtr(file->filedes, offset, origin, &newpos);
  -    printf( "DosSetFilePtr()=%d\n", rv );
  -    
  -    if (rv) {
  -        errno = os2errno( rv );
  -        return -1;
  -    }
  -    
  -    return newpos;
  +    return os2errno(DosSetFilePtr(thefile->filedes, *offset, where, (ULONG *)&offset));
   }
  
  
  
  1.1                  apache-apr/apr/file_io/os2/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
   *    apache@apache.org.
   *
   * 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 "fileio.h"
  #include "apr_file_io.h"
  #include "apr_lib.h"
  #include <string.h>
  
  #define INCL_DOS
  #include <os2.h>
  
  ap_status_t dir_cleanup(void *thedir)
  {
      struct dir_t *dir = thedir;
      return ap_closedir(dir);
  }
  
  
  
  ap_status_t ap_opendir(ap_context_t *cntxt, const char *dirname, struct dir_t **new)
  {
      struct dir_t *thedir = (struct dir_t *)ap_palloc(cntxt, sizeof(struct dir_t));
      
      if (thedir == NULL)
          return APR_ENOMEM;
      
      thedir->cntxt = cntxt;
      thedir->dirname = ap_pstrdup(cntxt, dirname);
      thedir->handle = 0;
      thedir->validentry = FALSE;
      *new = thedir;
      return APR_SUCCESS;
  }
  
  
  
  ap_status_t ap_closedir(struct dir_t *thedir)
  {
      int rv = 0;
      
      if (thedir->handle) {
          rv = DosFindClose(thedir->handle);
          
          if (rv == 0) {
              thedir->handle = 0;
          }
      }
  
      return os2errno(rv);
  } 
  
  
  
  ap_status_t ap_readdir(struct dir_t *thedir)
  {
      int rv;
      ULONG entries = 1;
      
      if (thedir->handle == 0) {
          thedir->handle = HDIR_CREATE;
          rv = DosFindFirst(ap_pstrcat(thedir->cntxt, thedir->dirname, "/*", NULL),
&thedir->handle, 
                            FILE_ARCHIVED|FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY,

                            &thedir->entry, sizeof(thedir->entry), &entries,
FIL_STANDARD);
      } else {
          rv = DosFindNext(thedir->handle, &thedir->entry, sizeof(thedir->entry),
&entries);
      }
  
      if (rv == 0 && entries == 1) {
          thedir->validentry = TRUE;
          return APR_SUCCESS;
      }
          
      thedir->validentry = FALSE;
      
      if (rv)
          return os2errno(rv);
      
      return APR_ENOENT;
  }
  
  
  
  ap_status_t ap_rewinddir(struct dir_t *thedir)
  {
      return ap_closedir(thedir);
  }
  
  
  
  ap_status_t ap_make_dir(ap_context_t *cont, const char *path, ap_fileperms_t perm)
  {
      return os2errno(DosCreateDir(path, NULL));
  }
  
  
  
  ap_status_t ap_remove_dir(ap_context_t *cont, const char *path)
  {
      return os2errno(DosDeleteDir(path));
  }
  
  
  
  ap_status_t ap_dir_entry_size(struct dir_t *thedir, ap_ssize_t *size)
  {
      if (thedir->validentry) {
          *size = thedir->entry.cbFile;
          return APR_SUCCESS;
      }
      
      return APR_ENOFILE;
  }
  
  
  
  ap_status_t ap_dir_entry_mtime(struct dir_t *thedir, time_t *time)
  {
      if (thedir->validentry) {
          *time = os2date2unix(thedir->entry.fdateLastWrite, thedir->entry.ftimeLastWrite);
          return APR_SUCCESS;
      }
  
      return APR_ENOFILE;
  }
  
  
  
  ap_status_t ap_dir_entry_ftype(struct dir_t *thedir, ap_filetype_e *type)
  {
      int rc;
      HFILE hFile;
      ULONG action, Type, Attr;
      ap_filetype_e typemap[8] = { APR_REG, APR_CHR, APR_PIPE };
  
      if (thedir->validentry) {
          if (thedir->entry.attrFile & FILE_DIRECTORY) {
              *type = APR_DIR;
              return APR_SUCCESS;
          } else {
              rc = DosOpen(ap_pstrcat(thedir->cntxt, thedir->dirname, "/", thedir->entry.achName,
NULL) ,
                           &hFile, &action, 0, 0,
                           OPEN_ACTION_FAIL_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE|OPEN_ACCESS_READONLY,
                           NULL);
  
              if ( rc == 0 ) {
                  rc = DosQueryHType( hFile, &Type, &Attr );
  
                  if ( rc == 0 ) {
              *type = typemap[(Type & 0x0007)];
                  }
                  DosClose( hFile );
              }
  
              return os2errno(rc);
          }
      }
  
      return APR_ENOFILE;
  }
  
  
  
  ap_status_t ap_get_dir_filename(struct dir_t *thedir, char **new)
  {
      if (thedir->validentry) {
          *new = thedir->entry.achName;
          return APR_SUCCESS;
      }
  
      return APR_ENOFILE;
  }
  
  
  
  1.1                  apache-apr/apr/file_io/os2/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
   *    apache@apache.org.
   *
   * 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 "fileio.h"
  #include "apr_file_io.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  #include <errno.h>
  #include <string.h>
  #include <sys/types.h>
  
  /* A file to put ALL of the accessor functions for struct file_t types. */
  
  ap_status_t ap_get_filename(struct file_t *thefile, char **new)
  {
      if (thefile != NULL) {
          *new = ap_pstrdup(thefile->cntxt, thefile->fname);
          return APR_SUCCESS;
      } else {
          *new = NULL;
          return APR_ENOFILE;
      }
  }
  
  
  
  ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size)
  {
      ap_status_t rv;
      
      if (file != NULL) {
          if (!file->validstatus) {
              rv = ap_updatefileinfo(file);
              
              if (rv)
                  return rv;
          }
          
          *size = file->status.cbFile;
          return APR_SUCCESS;
      } else {
          *size = -1;
          return APR_ENOFILE;
      }
  }
  
  
  
  ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm)
  {
      ap_status_t rv;
    
      if (file != NULL) {
          if (!file->validstatus) {
              rv = ap_updatefileinfo(file);
              
              if (rv)
                  return rv;
          }
          
          *perm = (file->status.attrFile & FILE_READONLY) ? 0555 : 0777;
          return APR_SUCCESS;
      } else {
          *perm = -1;
          return APR_ENOFILE;
      }
  }
  
  
  
  ap_status_t ap_get_fileatime(struct file_t *file, time_t *time)
  {    
      ap_status_t rv;
  
      if (file != NULL) {
          if (!file->validstatus) {
              rv = ap_updatefileinfo(file);
              
              if (rv)
                  return rv;
          }
          
          *time = os2date2unix( file->status.fdateLastAccess, file->status.ftimeLastAccess
);
          return APR_SUCCESS;
      } else {
          *time = -1;
          return APR_ENOFILE;
      }
  }
  
  
  
  ap_status_t ap_get_filectime(struct file_t *file, time_t *time)
  {    
      ap_status_t rv;
  
      if (file != NULL) {
          if (!file->validstatus) {
              rv = ap_updatefileinfo(file);
              
              if (rv)
                  return rv;
          }
          
          *time = os2date2unix( file->status.fdateCreation, file->status.ftimeCreation
);
          return APR_SUCCESS;
      }
      else {
          *time = -1;
          return APR_ENOFILE;
      }
  }
  
  
  
  ap_status_t ap_get_filemtime(struct file_t *file, time_t *time)
  {    
      ap_status_t rv;
  
      if (file != NULL) {
          if (!file->validstatus) {
              rv = ap_updatefileinfo(file);
              
              if (rv)
                  return rv;
          }
          
          *time = os2date2unix( file->status.fdateLastWrite, file->status.ftimeLastWrite
);
          return APR_SUCCESS;
      }
      else {
          *time = -1;
          return APR_ENOFILE;
      }
  }
  
  
  
  
  1.1                  apache-apr/apr/file_io/os2/pipe.c
  
  Index: pipe.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
   *    apache@apache.org.
   *
   * 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 "fileio.h"
  #include "apr_file_io.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  #include <string.h>
  
  ap_status_t ap_create_pipe(ap_context_t *cont, struct file_t **in, struct file_t **out)
  {
      ULONG filedes[2];
      ULONG rc;
  
      rc = DosCreatePipe(filedes, filedes+1, 4096);
          
      if (rc) {
          return os2errno(rc);
      }
      
      (*in) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t));
      (*in)->cntxt = cont;
      (*in)->filedes = filedes[0];
      (*in)->fname = ap_pstrdup(cont, "PIPE");
  
      (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t));
      (*out)->cntxt = cont;
      (*out)->filedes = filedes[1];
      (*out)->fname = ap_pstrdup(cont, "PIPE");
  
      return APR_SUCCESS;
  }
  
  
  
  ap_status_t ap_create_namedpipe(ap_context_t *cont, char *dirpath, ap_fileperms_t perm,
char **new)
  {
      /* Not yet implemented, interface not suitable */
      return -1;
  } 
  
   
  
  
  
  1.1                  apache-apr/apr/file_io/os2/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
   *    apache@apache.org.
   *
   * 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
  
  #define INCL_DOS
  #include <os2.h>
  
  #include "apr_general.h"
  #include "apr_file_io.h"
  #include "apr_errno.h"
  
  struct file_t {
      ap_context_t *cntxt;
      ULONG filedes;
      char * fname;
      int isopen;
      int buffered;
      FILESTATUS3 status;
      int validstatus;
  };
  
  struct dir_t {
      ap_context_t *cntxt;
      char *dirname;
      ULONG handle;
      FILEFINDBUF3 entry;
      int validentry;
  };
  
  struct iovec_t {
      struct iovec *iovec;
  };
  
  ap_status_t file_cleanup(void *);
  mode_t get_fileperms(ap_fileperms_t);
  long os2date2unix( FDATE os2date, FTIME os2time );
  
  #endif  /* ! FILE_IO_H */
  
  
  
  

Mime
View raw message