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/include apr_errno.h apr_file_io.h apr_general.h
Date Thu, 03 Jun 1999 19:44:05 GMT
rbb         99/06/03 12:44:04

  Modified:    apr/include apr_win.h
               apr/lib  lib.def
               apr/test testfile.c
               include  apr_errno.h apr_file_io.h apr_general.h
  Added:       apr/file_io/win32 dir.c file_io.def file_io.dsp fileacc.c
                        filedup.c fileio.h filestat.c open.c pipe.c
                        readdir.c readdir.h readwrite.c seek.c
               apr/test testfile.dsp
  Log:
  First pass at Windows File_io stuff.  This should be enought to build and run the testfile
  program.  I'll check this though, and commit anything else that is needed.
  
  Revision  Changes    Path
  1.1                  apache-apr/apr/file_io/win32/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/>.
   *
   */
  #ifdef HAVE_ERRNO_H
  #include <errno.h>
  #endif
  #ifdef HAVE_STRING_H
  #include <string.h>
  #endif
  #ifdef HAVE_DIRENT_H
  #include <dirent.h>
  #endif
  #ifdef HAVE_SYS_STAT_H
  #include <sys/stat.h>
  #endif
  #ifdef WIN32
  #include "apr_win.h"
  #include <windows.h>
  #endif
  #include "fileio.h"
  #include "apr_file_io.h"
  #include "apr_lib.h"
  
  ap_status_t dir_cleanup(void *thedir)
  {
      struct dir_t *dir = thedir;
      if (CloseHandle(dir->dirhand) == 0) {
          return APR_SUCCESS;
      }
      else {
          return errno;
      }
  } 
  
  ap_status_t ap_opendir(ap_context_t *cont, const char *dirname, struct dir_t **new)
  {
  	char * temp;
  	(*new) = ap_palloc(cont, sizeof(struct dir_t));
      (*new)->cntxt = cont;
  	(*new)->entry = NULL;
      temp = canonical_filename((*new)->cntxt, dirname);
      if (temp[strlen(temp)] == '/') {
      	(*new)->dirname = ap_pstrcat(cont, dirname, "*", NULL);
  	}
  	else {
          (*new)->dirname = ap_pstrcat(cont, dirname, "/*", NULL);
  	}
  	(*new)->dirhand = INVALID_HANDLE_VALUE;
  	ap_register_cleanup((*new)->cntxt, (void *)(*new), dir_cleanup, NULL);
      return APR_SUCCESS;
  }
  
  ap_status_t ap_closedir(struct dir_t *thedir)
  {
  	if (FindClose(thedir->dirhand)) {
  		ap_kill_cleanup(thedir->cntxt, thedir, dir_cleanup);
  		return APR_SUCCESS;
  	}
  	return APR_EEXIST;
  }
  
  ap_status_t ap_readdir(struct dir_t *thedir)
  {
  	if (thedir->dirhand == INVALID_HANDLE_VALUE) {
  		thedir->entry = ap_palloc(thedir->cntxt, sizeof(WIN32_FIND_DATA));
  		thedir->dirhand = FindFirstFile(thedir->dirname, thedir->entry);
  		if (thedir->dirhand == INVALID_HANDLE_VALUE) {
  			return APR_EEXIST;
  		}
  		return APR_SUCCESS;
  	}
  	if (FindNextFile(thedir->dirhand, thedir->entry)) {
  		return APR_SUCCESS;
  	}
  	return APR_EEXIST;
  }
  
  ap_status_t ap_rewinddir(struct dir_t *thedir)
  {
  	ap_status_t stat;
  	ap_context_t *cont = thedir->cntxt;
      char *temp = strdup(thedir->dirname);
  	temp[strlen(temp) - 2] = '\0';   /*remove the \* at the end */
  	if (thedir->dirhand == INVALID_HANDLE_VALUE) {
  		return APR_SUCCESS;
  	}
      if ((stat = ap_closedir(thedir)) == APR_SUCCESS) {
  		if ((stat = ap_opendir(cont, temp, &thedir)) == APR_SUCCESS) {
  			ap_readdir(thedir);
  			return APR_SUCCESS;
  		}
  	}
  	return stat;	
  }
  
  ap_status_t ap_make_dir(ap_context_t *cont, const char *path, ap_fileperms_t perm)
  {
      if (CreateDirectory(path, NULL)) {
  		return APR_SUCCESS;
  	}
      return APR_EEXIST;
  }
  
  ap_status_t ap_remove_dir(ap_context_t *cont, const char *path)
  {
  DWORD huh;
      char *temp = canonical_filename(cont, path);
  	if (RemoveDirectory(temp)) {
  		return APR_SUCCESS;
  	}
  	huh = GetLastError();
  	return APR_EEXIST;
  }
  
  ap_status_t ap_dir_entry_size(struct dir_t *thedir, ap_ssize_t *size)
  {
      if (thedir == NULL || thedir->entry == NULL) {
  		return APR_ENODIR;
  	}
  	(*size) = (thedir->entry->nFileSizeHigh * MAXDWORD) + 
  		       thedir->entry->nFileSizeLow;
      return APR_SUCCESS;
  }
  
  ap_status_t ap_dir_entry_mtime(struct dir_t *thedir, time_t *time)
  {
      if (thedir == NULL || thedir->entry == NULL) {
  		return APR_ENODIR;
  	}
  
  	*time = WinTimeToUnixTime(&thedir->entry->ftLastWriteTime);
   
      return APR_SUCCESS;
  }
   
  ap_status_t ap_dir_entry_ftype(struct dir_t *thedir, ap_filetype_e *type)
  {
  	switch(thedir->entry->dwFileAttributes) {
  	case FILE_ATTRIBUTE_DIRECTORY: {
  		(*type) = APR_DIR;
  		return APR_SUCCESS;
  								   }
  	case FILE_ATTRIBUTE_NORMAL: {
  		(*type) = APR_REG;
  		return APR_SUCCESS;
  								}
  	default: {
  		(*type) = APR_REG;     /* As valid as anything else.*/
  		return APR_SUCCESS;
  			 }
  	}
  }
  
  ap_status_t ap_get_dir_filename(struct dir_t *thedir, char **new)
  {
      (*new) = ap_pstrdup(thedir->cntxt, thedir->entry->cFileName);
      return APR_SUCCESS;
  }
  
  
  
  
  1.1                  apache-apr/apr/file_io/win32/file_io.def
  
  Index: file_io.def
  ===================================================================
  ; file_io.def : 
  
  LIBRARY file_io
  DESCRIPTION ''
  
  EXPORTS
  	; Add new API calls to the end of this list.
  	ap_opendir   @1
  	ap_closedir   @2
  	ap_readdir   @3
  	ap_rewinddir   @4
  	ap_make_dir   @5
  	ap_remove_dir   @6
  	ap_dir_entry_size   @7
  	ap_dir_entry_mtime   @8
  	ap_dir_entry_ftype   @9
  	ap_get_dir_filename   @10
  	ap_get_filename   @11
  	ap_get_filesize   @12
  	ap_get_fileatime   @13
  	ap_get_filectime   @14
  	ap_get_filemtime   @15
  	ap_dupfile   @16
  	ap_getfileinfo   @17
  	ap_open   @18
  	ap_close   @19
  	ap_remove_file   @20
  	ap_create_pipe   @21
  	ap_read   @22
  	ap_write   @23
  	ap_seek   @24\
  
  	
  
  
  1.1                  apache-apr/apr/file_io/win32/file_io.dsp
  
  Index: file_io.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="file_io" - Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 5.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
  
  CFG=file_io - Win32 Debug
  !MESSAGE This is not a valid makefile. To build this project using NMAKE,
  !MESSAGE use the Export Makefile command and run
  !MESSAGE 
  !MESSAGE NMAKE /f "file_io.mak".
  !MESSAGE 
  !MESSAGE You can specify a configuration when running NMAKE
  !MESSAGE by defining the macro CFG on the command line. For example:
  !MESSAGE 
  !MESSAGE NMAKE /f "file_io.mak" CFG="file_io - Win32 Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "file_io - Win32 Release" (based on\
   "Win32 (x86) Dynamic-Link Library")
  !MESSAGE "file_io - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
  !MESSAGE 
  
  # Begin Project
  # PROP Scc_ProjName ""
  # PROP Scc_LocalPath ""
  CPP=cl.exe
  MTL=midl.exe
  RSC=rc.exe
  
  !IF  "$(CFG)" == "file_io - Win32 Release"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 0
  # PROP BASE Output_Dir "Release"
  # PROP BASE Intermediate_Dir "Release"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 0
  # PROP Output_Dir "Release"
  # PROP Intermediate_Dir "Release"
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
  # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
  # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
  # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
  # ADD BASE RSC /l 0x409 /d "NDEBUG"
  # ADD RSC /l 0x409 /d "NDEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
  
  !ELSEIF  "$(CFG)" == "file_io - Win32 Debug"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 1
  # PROP BASE Output_Dir "Debug"
  # PROP BASE Intermediate_Dir "Debug"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 1
  # PROP Output_Dir "Debug"
  # PROP Intermediate_Dir "Debug"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
  # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
  # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
  # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
  # ADD BASE RSC /l 0x409 /d "_DEBUG"
  # ADD RSC /l 0x409 /d "_DEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\misc\win32\Debug\misc.lib ..\..\lib\Debug\lib.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
  
  !ENDIF 
  
  # Begin Target
  
  # Name "file_io - Win32 Release"
  # Name "file_io - Win32 Debug"
  # Begin Source File
  
  SOURCE=.\dir.c
  # End Source File
  # Begin Source File
  
  SOURCE=.\file_io.def
  # End Source File
  # Begin Source File
  
  SOURCE=.\fileacc.c
  # End Source File
  # Begin Source File
  
  SOURCE=.\filedup.c
  # End Source File
  # Begin Source File
  
  SOURCE=.\fileio.h
  # End Source File
  # Begin Source File
  
  SOURCE=.\filestat.c
  # End Source File
  # Begin Source File
  
  SOURCE=.\open.c
  # End Source File
  # Begin Source File
  
  SOURCE=.\pipe.c
  # End Source File
  # Begin Source File
  
  SOURCE=.\readwrite.c
  # End Source File
  # Begin Source File
  
  SOURCE=.\seek.c
  # End Source File
  # End Target
  # End Project
  
  
  
  1.1                  apache-apr/apr/file_io/win32/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;
      }
  }
  
  /*mode_t get_fileperms(ap_fileperms_t mode)
  {
      mode_t rv = 0;
  
      if (mode & APR_UREAD)
          rv |= S_IRUSR;
      if (mode & APR_UWRITE)
          rv |= S_IWUSR;
      if (mode & APR_UEXECUTE)
          rv |= S_IXUSR;
  
      if (mode & APR_GREAD)
          rv |= S_IRGRP;
      if (mode & APR_GWRITE)
          rv |= S_IWGRP;
      if (mode & APR_GEXECUTE)
          rv |= S_IXGRP;
  
      if (mode & APR_WREAD)
          rv |= S_IROTH;
      if (mode & APR_WWRITE)
          rv |= S_IWOTH;
      if (mode & APR_WEXECUTE)
          rv |= S_IXOTH;
  
      return rv;
  }*/
  
  ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size)
  {
      if (file != NULL) {
          *size = file->size;
          return APR_SUCCESS;
      }
      else {
          *size = -1;
          return APR_ENOFILE;
      }
  }
  /*
  ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm)
  {
      if (file != NULL) {
          *perm = file->protection;
          return APR_SUCCESS;
      }
      else {
          *perm = -1;
          return APR_ENOFILE;
      }
  }
  */
  ap_status_t ap_get_fileatime(struct file_t *file, time_t *time)
  {    
      if (file != NULL) {
          *time = file->atime;
          return APR_SUCCESS;
      }
      else {
          *time = -1;
          return APR_ENOFILE;
      }
  }
  
  ap_status_t ap_get_filectime(struct file_t *file, time_t *time)
  {    
      if (file != NULL) {
          *time = file->ctime;
          return APR_SUCCESS;
      }
      else {
          *time = -1;
          return APR_ENOFILE;
      }
  }
  
  ap_status_t ap_get_filemtime(struct file_t *file, time_t *time)
  {    
      if (file != NULL) {
          *time = file->mtime;
          return APR_SUCCESS;
      }
      else {
          *time = -1;
          return APR_ENOFILE;
      }
  }
  
  
  
  
  1.1                  apache-apr/apr/file_io/win32/filedup.c
  
  Index: filedup.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_dupfile(struct file_t *old_file, struct file_t **new_file)
  {
      (*new_file) = (struct file_t *)ap_palloc(old_file->cntxt,
                                 sizeof(struct file_t));
      
      if ((*new_file) == NULL) {
          return APR_ENOMEM;
      }
      (*new_file)->cntxt = old_file->cntxt; 
      (*new_file)->filehand = old_file->filehand; 
      (*new_file)->fname = ap_pstrdup(old_file->cntxt, old_file->fname);
      (*new_file)->demonfname = ap_pstrdup(old_file->cntxt, old_file->demonfname);
      (*new_file)->lowerdemonfname = ap_pstrdup(old_file->cntxt, old_file->lowerdemonfname);
      (*new_file)->buffered = old_file->buffered;
  	(*new_file)->append = old_file->append;
   /*   (*new_file)->protection = old_file->protection;
      (*new_file)->user = old_file->user;
      (*new_file)->group = old_file->group;*/
      (*new_file)->size = old_file->size;
      (*new_file)->atime = old_file->atime;    
      (*new_file)->mtime = old_file->mtime;
      (*new_file)->ctime = old_file->ctime;
      ap_register_cleanup((*new_file)->cntxt, (void *)(*new_file), file_cleanup, NULL);
      return APR_SUCCESS;
  }
  
  
  
  
  1.1                  apache-apr/apr/file_io/win32/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
  
  #ifdef HAVE_SYS_STAT_H
  #include <sys/stat.h>
  #endif
  #ifdef HAVE_SYS_TYPES_H
  #include <sys/types.h>
  #endif
  #ifdef HAVE_SYS_FCNTL_H
  #include <fcntl.h>
  #endif
  #ifdef HAVE_TIME_H
  #include <time.h>
  #endif
  #ifdef HAVE_DIRENT_H
  #include <dirent.h>
  #endif
  #ifdef HAVE_UIO_H
  #include <sys/uio.h>
  #endif
  #include "apr_win.h"
  #include "apr_pools.h"
  #include "apr_general.h"
  #include "apr_file_io.h"
  #include "apr_errno.h"
  
  struct file_t {
      ap_context_t *cntxt;
      HANDLE filehand;
      char *fname;
      char *demonfname;
  	char *lowerdemonfname;
      int buffered;
  	int append;
  /*    mode_t protection;
      uid_t user;
      gid_t group;*/
      off_t size;
      time_t atime;
      time_t mtime;
      time_t ctime;
  };
  
  struct dir_t {
      ap_context_t *cntxt;
      char *dirname;
      HANDLE dirhand;
  	WIN32_FIND_DATA *entry;
  };
  
  struct iovec_t {
      ap_context_t *cntxt;
      struct iovec *iovec;
  };
  
  ap_status_t file_cleanup(void *);
  /*mode_t get_fileperms(ap_fileperms_t);
  */
  API_EXPORT(char *) ap_os_systemcase_filename(struct context_t *pCont, 
                                               const char *szFile);
  char * canonical_filename(struct context_t *pCont, const char *szFile);
  
  #endif  /* ! FILE_IO_H */
  
  
  
  
  1.1                  apache-apr/apr/file_io/win32/filestat.c
  
  Index: filestat.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 "apr_win.h"
  #include "fileio.h"
  #include "apr_file_io.h"
  #include "apr_general.h"
  #include "apr_errno.h"
  
  ap_status_t ap_getfileinfo(struct file_t *thefile)
  {
  	FILETIME atime, ctime, mtime;
  
  /*        thefile->protection = info.st_mode;
          thefile->user = info.st_uid;
          thefile->group = info.st_gid;*/
  	thefile->size = GetFileSize(thefile->filehand, NULL);
  	GetFileTime(thefile->filehand, &ctime, &atime, &mtime);
  	thefile->atime = WinTimeToUnixTime(&atime);
  	thefile->mtime = WinTimeToUnixTime(&mtime);
  	thefile->ctime = WinTimeToUnixTime(&ctime);
      return APR_SUCCESS;
  }
  
  
  
  
  
  
  1.1                  apache-apr/apr/file_io/win32/open.c
  
  Index: open.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/>.
   *
   */
  #ifdef WIN32
  #include "apr_win.h"
  #endif
  #include "fileio.h"
  #include "apr_file_io.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  #include <errno.h>
  #include <string.h>
  #include <sys/stat.h>
  
  ap_status_t file_cleanup(void *thefile)
  {
      struct file_t *file = thefile;
      if (CloseHandle(file->filehand)) {
          file->filehand = INVALID_HANDLE_VALUE;
          return APR_SUCCESS;
      }
      else {
          return APR_EEXIST;
  	/* Are there any error conditions other than EINTR or EBADF? */
      }
  }
  
  ap_status_t ap_open(ap_context_t *cont, char *fname, ap_int32_t flag, ap_fileperms_t perm,
  					struct file_t **dafile)
  {
      DWORD oflags = 0;
  	DWORD createflags = 0;
      /*mode_t mode = get_fileperms(perm);*/
  
      (*dafile) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t));
  
  	(*dafile)->cntxt = cont;
  
      if (flag & APR_READ) {
          oflags |= GENERIC_READ;
      }
      if (flag & APR_WRITE) {
          oflags |= GENERIC_WRITE;
      }
      if (!(flag & APR_READ) && !(flag & APR_WRITE)) {
          (*dafile)->filehand = INVALID_HANDLE_VALUE;
          return APR_EACCES;
      }
  
      if (flag & APR_BUFFERED) {
          (*dafile)->buffered = FALSE;
      }
      (*dafile)->fname = strdup(fname);
  
  	(*dafile)->demonfname = canonical_filename((*dafile)->cntxt, fname);
  	(*dafile)->lowerdemonfname = strlwr((*dafile)->demonfname);
  
      if (flag & APR_CREATE) {
          createflags = OPEN_ALWAYS; 
  	    if (flag & APR_EXCL) {
  			createflags = CREATE_NEW;
  		}
      }
      if ((flag & APR_EXCL) && !(flag & APR_CREATE)) {
          (*dafile)->filehand = INVALID_HANDLE_VALUE;
          return APR_EACCES;
      }   
  
      if (flag & APR_APPEND) {
          (*dafile)->append = 1;
      }
  	else {
  		(*dafile)->append = 0;
  	}
  
      if (flag & APR_TRUNCATE) {
          createflags = TRUNCATE_EXISTING;
      }
   
      (*dafile)->filehand = CreateFile(fname, oflags, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  						   NULL, createflags, FILE_ATTRIBUTE_NORMAL, 0);
  
      if ((*dafile)->filehand == INVALID_HANDLE_VALUE) {
          return APR_EEXIST;
      }
  
      if (ap_getfileinfo(*dafile) == APR_SUCCESS) {
  	    ap_register_cleanup((*dafile)->cntxt, (void *)(*dafile), file_cleanup, NULL);
          return APR_SUCCESS;
      }
      else {
          (*dafile)->filehand = INVALID_HANDLE_VALUE;
          return APR_ENOSTAT;
      }
  }
  
  ap_status_t ap_close(struct file_t *file)
  {
  	ap_status_t stat;
      if ((stat = file_cleanup(file)) == APR_SUCCESS) {
          ap_kill_cleanup(file->cntxt, file, file_cleanup);
          return APR_SUCCESS;
      }
      return stat;
  }
  
  ap_status_t ap_remove_file(ap_context_t *cont, char *path)
  {
      char *temp = canonical_filename(cont, path);
  
      if (DeleteFile(temp) == 0) {
  		return APR_SUCCESS;
      }
      else {
  		return APR_EEXIST;
      }
  }
  
  
  
  
  1.1                  apache-apr/apr/file_io/win32/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 <errno.h>
  #include <string.h>
  #include <stdio.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  
  ap_status_t ap_create_pipe(ap_context_t *cont, struct file_t **in, struct file_t **out)
  {
      (*in) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t));
      (*in)->cntxt = cont;
      (*in)->fname = ap_pstrdup(cont, "PIPE");
  
      (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t));
      (*out)->cntxt = cont;
      (*out)->fname = ap_pstrdup(cont, "PIPE");
  
      if (CreatePipe((*in)->filehand, (*out)->filehand, NULL, 0) == -1) {
          return errno;
      }
  
      return APR_SUCCESS;
  }
  
  /*
  ap_status_t ap_create_namedpipe(ap_context_t *cont, char *dirpath, ap_fileperms_t perm, char **new)
  {
      mode_t mode = get_fileperms(perm);
  
      *new = tempnam(dirpath, NULL);
      if (mkfifo((*new), mode) == -1) {
          return errno;
      }
      return APR_SUCCESS;
  } 
  */        
   
  
  
  
  1.1                  apache-apr/apr/file_io/win32/readdir.c
  
  Index: readdir.c
  ===================================================================
  #include <malloc.h>
  #include <string.h>
  #include <errno.h>
  
  #include "readdir.h"
  
  /**********************************************************************
   * Implement dirent-style opendir/readdir/closedir on Window 95/NT
   *
   * Functions defined are opendir(), readdir() and closedir() with the
   * same prototypes as the normal dirent.h implementation.
   *
   * Does not implement telldir(), seekdir(), rewinddir() or scandir(). 
   * The dirent struct is compatible with Unix, except that d_ino is 
   * always 1 and d_off is made up as we go along.
   *
   * The DIR typedef is not compatible with Unix.
   **********************************************************************/
  
  API_EXPORT(DIR *) opendir(const char *dir)
  {
      DIR *dp;
      char *filespec;
      long handle;
      int index;
  
      filespec = malloc(strlen(dir) + 2 + 1);
      strcpy(filespec, dir);
      index = strlen(filespec) - 1;
      if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
          filespec[index] = '\0';
      strcat(filespec, "/*");
  
      dp = (DIR *)malloc(sizeof(DIR));
      dp->offset = 0;
      dp->finished = 0;
      dp->dir = strdup(dir);
  
      if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) {
          if (errno == ENOENT)
              dp->finished = 1;
          else
          return NULL;
      }
  
      dp->handle = handle;
      free(filespec);
  
      return dp;
  }
  
  API_EXPORT(struct dirent *) readdir(DIR *dp)
  {
      if (!dp || dp->finished) return NULL;
  
      if (dp->offset != 0) {
          if (_findnext(dp->handle, &(dp->fileinfo)) < 0) {
              dp->finished = 1;
              return NULL;
          }
      }
      dp->offset++;
  
      strncpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME);
      dp->dent.d_ino = 1;
      dp->dent.d_reclen = strlen(dp->dent.d_name);
      dp->dent.d_off = dp->offset;
  
      return &(dp->dent);
  }
  
  API_EXPORT(int) closedir(DIR *dp)
  {
      if (!dp) return 0;
      _findclose(dp->handle);
      if (dp->dir) free(dp->dir);
      if (dp) free(dp);
  
      return 0;
  }
  
  
  
  1.1                  apache-apr/apr/file_io/win32/readdir.h
  
  Index: readdir.h
  ===================================================================
  /*
   * Structures and types used to implement opendir/readdir/closedir
   * on Windows 95/NT.
   */
  
  #include <io.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <sys/types.h>
  
  #ifndef API_EXPORT
  # define API_EXPORT(type)    __declspec(dllexport) type __stdcall
  #endif
  
  /* struct dirent - same as Unix */
  struct dirent {
      long d_ino;                    /* inode (always 1 in WIN32) */
      off_t d_off;                /* offset to this dirent */
      unsigned short d_reclen;    /* length of d_name */
      char d_name[_MAX_FNAME+1];    /* filename (null terminated) */
  };
  
  /* typedef DIR - not the same as Unix */
  typedef struct {
      long handle;                /* _findfirst/_findnext handle */
      short offset;                /* offset into directory */
      short finished;             /* 1 if there are not more files */
      struct _finddata_t fileinfo;  /* from _findfirst/_findnext */
      char *dir;                  /* the dir we are reading */
      struct dirent dent;         /* the dirent to return */
  } DIR;
  
  /* Function prototypes */
  API_EXPORT(DIR *) opendir(const char *);
  API_EXPORT(struct dirent *) readdir(DIR *);
  API_EXPORT(int) closedir(DIR *);
  
  
  
  1.1                  apache-apr/apr/file_io/win32/readwrite.c
  
  Index: readwrite.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 "apr_errno.h"
  #include <windows.h>
  
  ap_status_t ap_read(const struct file_t *thefile, void *buf, ap_ssize_t *nbytes)
  {
  	DWORD bread;
  
      if (thefile->filehand == INVALID_HANDLE_VALUE) {
          *nbytes = -1;
          return APR_EBADF;
      }
      
      if (ReadFile(thefile->filehand, buf, *nbytes, &bread, NULL)) {\
  		*nbytes = bread;
  	    return APR_SUCCESS;
  	}
  	*nbytes = -1;
  	return APR_EEXIST;
  }
  
  ap_status_t ap_write(struct file_t *thefile, void *buf, ap_ssize_t *nbytes)
  {
      DWORD bwrote;
  	FILETIME atime, mtime, ctime;
  	
      if (thefile->filehand == INVALID_HANDLE_VALUE) {
          *nbytes = -1;
          return APR_EBADF;
      }
  
      if (WriteFile(thefile->filehand, buf, *nbytes, &bwrote, NULL)) {
  		if (strcmp(thefile->fname, "PIPE")) {
  			FlushFileBuffers(thefile->filehand);
  			thefile->size = GetFileSize(thefile->filehand, NULL);
  			GetFileTime(thefile->filehand, &ctime, &atime, &mtime);
  			thefile->atime = WinTimeToUnixTime(&atime);
  			thefile->mtime = WinTimeToUnixTime(&mtime);
  			thefile->ctime = WinTimeToUnixTime(&ctime);
  		}
  		*nbytes = bwrote;
  		return APR_SUCCESS;
  	}
  	(*nbytes) = -1;
  	return APR_EEXIST;
  }
  /*
  ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt)
  {
      int bytes;
      if ((bytes = writev(thefile->filedes, vec->iovec, *iocnt)) < 0) {
          *iocnt = bytes;
          return errno;
      12}
      else {
          *iocnt = bytes;
          return APR_SUCCESS;
      }
  }
  */
  
  
  
  
  1.1                  apache-apr/apr/file_io/win32/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
   *    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 <errno.h>
  #include <string.h>
  
  ap_status_t ap_seek(struct file_t *thefile, ap_seek_where_t where, ap_off_t *offset)
  {
      DWORD howmove;
  	DWORD rv;
  
  	switch(where) {
  	case APR_SET: {
  		howmove = FILE_BEGIN;
  		break;
  				  }
  	case APR_CUR: {
  		howmove = FILE_CURRENT;
  		break;
  				  }
  	case APR_END: {
  		howmove = FILE_END;
  		break;
  				  }
  	}
  
      rv = SetFilePointer(thefile->filehand, *offset,NULL, howmove);
      if (rv == -1) {
          *offset = -1;
          return APR_EEXIST;
      }
      else {
          *offset = rv;
          return APR_SUCCESS;
      }
  }
  
  
  
  1.3       +6 -0      apache-apr/apr/include/apr_win.h
  
  Index: apr_win.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/include/apr_win.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_win.h	1999/06/01 18:15:18	1.2
  +++ apr_win.h	1999/06/03 19:43:50	1.3
  @@ -58,9 +58,13 @@
   #ifndef APR_WIN_H
   #define APR_WIN_H
   
  +#include <windows.h>
   #include <sys\types.h>
   #include <stdio.h>
  +#include <time.h>
   
  +typedef enum {APR_WIN_NT, APR_WIN_95, APR_WIN_98} ap_oslevel_e;
  +
   typedef _off_t      off_t;
   typedef int         pid_t;
   typedef void Sigfunc(int);
  @@ -75,6 +79,8 @@
   
   #define strcasecmp(s1, s2)       stricmp(s1, s2)
   #define sleep(t)                 Sleep(t * 1000)
  +
  +time_t WinTimeToUnixTime(FILETIME *);
   
   #endif  /*APR_WIN_H*/
   #endif  /*WIN32*/
  
  
  
  1.2       +2 -0      apache-apr/apr/lib/lib.def
  
  Index: lib.def
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/lib/lib.def,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- lib.def	1999/06/01 18:52:40	1.1
  +++ lib.def	1999/06/03 19:43:53	1.2
  @@ -9,6 +9,8 @@
   	apr_MD5Init   @2
   	apr_MD5Update   @3
       apr_cpystrn   @4
  +	ap_register_cleanup   @5
  +	ap_kill_cleanup   @6
   	apr_fnmatch   @7
   	apr_is_fnmatch   @8
   	apr_MD5Encode   @9
  
  
  
  1.25      +4 -2      apache-apr/apr/test/testfile.c
  
  Index: testfile.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/test/testfile.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- testfile.c	1999/06/02 18:44:55	1.24
  +++ testfile.c	1999/06/03 19:43:55	1.25
  @@ -64,7 +64,7 @@
   int test_filedel(ap_context_t *);
   int testdirs(ap_context_t *);
   
  -int main()
  +void main()
   {
       ap_context_t *context;
       ap_file_t *thefile = NULL;
  @@ -297,6 +297,8 @@
           fprintf(stdout, "OK\n");
       }
   
  +	ap_close(file);
  +
       fprintf(stdout, "\tRemoving file from directory.......");
       if (ap_remove_file(context, "testdir/testfile")  != APR_SUCCESS) {
           fprintf(stderr, "Could not remove file\n");
  @@ -308,7 +310,7 @@
   
       fprintf(stdout, "\tRemoving Directory.......");
       if (ap_remove_dir(context, "testdir")  != APR_SUCCESS) {
  -        fprintf(stderr, "Could not create directory\n");
  +        fprintf(stderr, "Could not remove directory\n");
           return -1;
       }
       else {
  
  
  
  1.1                  apache-apr/apr/test/testfile.dsp
  
  Index: testfile.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="testfile" - Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 5.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Console Application" 0x0103
  
  CFG=testfile - Win32 Debug
  !MESSAGE This is not a valid makefile. To build this project using NMAKE,
  !MESSAGE use the Export Makefile command and run
  !MESSAGE 
  !MESSAGE NMAKE /f "testfile.mak".
  !MESSAGE 
  !MESSAGE You can specify a configuration when running NMAKE
  !MESSAGE by defining the macro CFG on the command line. For example:
  !MESSAGE 
  !MESSAGE NMAKE /f "testfile.mak" CFG="testfile - Win32 Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "testfile - Win32 Release" (based on\
   "Win32 (x86) Console Application")
  !MESSAGE "testfile - Win32 Debug" (based on "Win32 (x86) Console Application")
  !MESSAGE 
  
  # Begin Project
  # PROP Scc_ProjName ""
  # PROP Scc_LocalPath ""
  CPP=cl.exe
  RSC=rc.exe
  
  !IF  "$(CFG)" == "testfile - Win32 Release"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 0
  # PROP BASE Output_Dir "Release"
  # PROP BASE Intermediate_Dir "Release"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 0
  # PROP Output_Dir "Release"
  # PROP Intermediate_Dir "Release"
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  # ADD BASE RSC /l 0x409 /d "NDEBUG"
  # ADD RSC /l 0x409 /d "NDEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
  
  !ELSEIF  "$(CFG)" == "testfile - Win32 Debug"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 1
  # PROP BASE Output_Dir "Debug"
  # PROP BASE Intermediate_Dir "Debug"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 1
  # PROP Output_Dir "Debug"
  # PROP Intermediate_Dir "Debug"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\include" /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
  # ADD BASE RSC /l 0x409 /d "_DEBUG"
  # ADD RSC /l 0x409 /d "_DEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\file_io\win32\Debug\file_io.lib ..\lib\Debug\lib.lib ..\misc\win32\Debug\misc.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
  
  !ENDIF 
  
  # Begin Target
  
  # Name "testfile - Win32 Release"
  # Name "testfile - Win32 Debug"
  # Begin Source File
  
  SOURCE=.\testfile.c
  # End Source File
  # End Target
  # End Project
  
  
  
  1.16      +1 -0      apache-apr/include/apr_errno.h
  
  Index: apr_errno.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/include/apr_errno.h,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- apr_errno.h	1999/05/26 15:45:58	1.15
  +++ apr_errno.h	1999/06/03 19:43:58	1.16
  @@ -390,6 +390,7 @@
   #define APR_ENOCONT        4005
   #define APR_ENOPROC        4006
   #define APR_ENOTIME        4007
  +#define APR_ENODIR         4008
   
   /*  APR STATUS VALUES */
   #define APR_INCHILD        5001
  
  
  
  1.33      +1 -0      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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- apr_file_io.h	1999/06/01 12:05:41	1.32
  +++ apr_file_io.h	1999/06/03 19:44:00	1.33
  @@ -58,6 +58,7 @@
   
   #include "apr_general.h"
   #include "apr_errno.h"
  +#include <time.h>
   
   #ifdef __cplusplus
   extern "C" {
  
  
  
  1.14      +17 -0     apache-apr/include/apr_general.h
  
  Index: apr_general.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/include/apr_general.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- apr_general.h	1999/06/02 18:44:24	1.13
  +++ apr_general.h	1999/06/03 19:44:02	1.14
  @@ -53,9 +53,18 @@
    *
    */
   
  +#ifdef HAVE_MALLOC_H
   #include <malloc.h>
  +#endif
  +#ifdef HAVE_UNISTD_H
   #include <unistd.h>
  +#endif
  +#ifdef HAVE_SYS_TYPES_H
   #include <sys/types.h>
  +#endif
  +#ifdef WIN32
  +#include <windows.h>
  +#endif
   #include "apr_errno.h"
   
   #ifndef APR_GENERAL_H
  @@ -76,9 +85,17 @@
   typedef unsigned long     ap_uint64_t;
   
   typedef size_t            ap_size_t; 
  +#ifdef ssize_t
   typedef ssize_t           ap_ssize_t; 
  +#else
  +typedef size_t            ap_ssize_t;
  +#endif
   
  +#ifdef off_t
   typedef off_t             ap_off_t;
  +#else
  +typedef size_t            ap_off_t;
  +#endif
   
   typedef struct context_t  ap_context_t;
   
  
  
  

Mime
View raw message