Evil Win32 VS8 projects modified

SVN revision: 38281
This commit is contained in:
dm 2008-12-22 23:18:41 +00:00 committed by dm
parent 61199e56ee
commit 7ad6bb42fc
4 changed files with 92 additions and 537 deletions

View File

@ -1,301 +0,0 @@
/* /////////////////////////////////////////////////////////////////////////////
* File: dirent.c
*
* Purpose: Definition of the opendir() API functions for the Win32 platform.
*
* Created: 19th October 2002
* Updated: 16th February 2008
*
* Home: http://synesis.com.au/software/
*
* Copyright (c) 2002-2008, Matthew Wilson and Synesis Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - 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.
* - Neither the names of Matthew Wilson and Synesis Software nor the names of
* any contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS 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 COPYRIGHT OWNER OR 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.
*
* ////////////////////////////////////////////////////////////////////////// */
#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION
# define _SYNSOFT_VER_C_DIRENT_MAJOR 2
# define _SYNSOFT_VER_C_DIRENT_MINOR 2
# define _SYNSOFT_VER_C_DIRENT_REVISION 5
# define _SYNSOFT_VER_C_DIRENT_EDIT 33
#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////////
* Includes
*/
#include "dirent.h"
//#include <unixem/unixem.h>
#include <errno.h>
#include <stdlib.h>
#include <windows.h>
/* /////////////////////////////////////////////////////////////////////////////
* Compiler differences
*/
#if defined(__BORLANDC__)
# define UNIXEM_opendir_PROVIDED_BY_COMPILER
#elif defined(__DMC__)
# define UNIXEM_opendir_PROVIDED_BY_COMPILER
#elif defined(__GNUC__)
# define UNIXEM_opendir_PROVIDED_BY_COMPILER
#elif defined(__INTEL_COMPILER)
#elif defined(_MSC_VER)
#elif defined(__MWERKS__)
#elif defined(__WATCOMC__)
#else
# error Compiler not discriminated
#endif /* compiler */
#if defined(UNIXEM_opendir_PROVIDED_BY_COMPILER) && \
!defined(UNIXEM_FORCE_ANY_COMPILER)
# error The opendir() API is provided by this compiler, so should not be built here
#endif /* !UNIXEM_opendir_PROVIDED_BY_COMPILER */
/* /////////////////////////////////////////////////////////////////////////////
* Constants and definitions
*/
#ifndef FILE_ATTRIBUTE_ERROR
# define FILE_ATTRIBUTE_ERROR (0xFFFFFFFF)
#endif /* FILE_ATTRIBUTE_ERROR */
/* /////////////////////////////////////////////////////////////////////////////
* Typedefs
*/
struct dirent_dir
{
char directory[_MAX_DIR + 1]; /* . */
WIN32_FIND_DATAA find_data; /* The Win32 FindFile data. */
HANDLE hFind; /* The Win32 FindFile handle. */
struct dirent dirent; /* The handle's entry. */
};
struct wdirent_dir
{
wchar_t directory[_MAX_DIR + 1]; /* . */
WIN32_FIND_DATAW find_data; /* The Win32 FindFile data. */
HANDLE hFind; /* The Win32 FindFile handle. */
struct wdirent dirent; /* The handle's entry. */
};
/* /////////////////////////////////////////////////////////////////////////////
* Helper functions
*/
static HANDLE unixem__dirent__findfile_directory(char const *name, LPWIN32_FIND_DATAA data)
{
char search_spec[_MAX_PATH +1];
/* Simply add the *.*, ensuring the path separator is
* included.
*/
(void)lstrcpyA(search_spec, name);
if( '\\' != search_spec[lstrlenA(search_spec) - 1] &&
'/' != search_spec[lstrlenA(search_spec) - 1])
{
(void)lstrcatA(search_spec, "\\*.*");
}
else
{
(void)lstrcatA(search_spec, "*.*");
}
return FindFirstFileA(search_spec, data);
}
#if 0
static HANDLE unixem__dirent__wfindfile_directory(wchar_t const *name, LPWIN32_FIND_DATAW data)
{
wchar_t search_spec[_MAX_PATH +1];
/* Simply add the *.*, ensuring the path separator is
* included.
*/
lstrcpyW(search_spec, name);
if( L'\\' != search_spec[lstrlenW(search_spec) - 1] &&
L'/' != search_spec[lstrlenW(search_spec) - 1])
{
lstrcatW(search_spec, L"\\*.*");
}
else
{
lstrcatW(search_spec, L"*.*");
}
return FindFirstFileW(search_spec, data);
}
#endif /* 0 */
/* /////////////////////////////////////////////////////////////////////////////
* API functions
*/
DIR *opendir(char const *name)
{
DIR *result = NULL;
DWORD dwAttr;
/* Must be a valid name */
if( !name ||
!*name ||
(dwAttr = GetFileAttributesA(name)) == 0xFFFFFFFF)
{
errno = ENOENT;
}
/* Must be a directory */
else if(!(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
errno = ENOTDIR;
}
else
{
result = (DIR*)malloc(sizeof(DIR));
if(result == NULL)
{
errno = ENOMEM;
}
else
{
result->hFind = unixem__dirent__findfile_directory(name, &result->find_data);
if(result->hFind == INVALID_HANDLE_VALUE)
{
free(result);
result = NULL;
}
else
{
/* Save the directory, in case of rewind. */
(void)lstrcpyA(result->directory, name);
(void)lstrcpyA(result->dirent.d_name, result->find_data.cFileName);
result->dirent.d_mode = (int)result->find_data.dwFileAttributes;
}
}
}
#if 0
if(NULL != dir)
{
struct dirent *readdir(DIR *dir)
}
#endif /* 0 */
return result;
}
int closedir(DIR *dir)
{
int ret;
if(dir == NULL)
{
errno = EBADF;
ret = -1;
}
else
{
/* Close the search handle, if not already done. */
if(dir->hFind != INVALID_HANDLE_VALUE)
{
(void)FindClose(dir->hFind);
}
free(dir);
ret = 0;
}
return ret;
}
void rewinddir(DIR *dir)
{
/* Close the search handle, if not already done. */
if(dir->hFind != INVALID_HANDLE_VALUE)
{
(void)FindClose(dir->hFind);
}
dir->hFind = unixem__dirent__findfile_directory(dir->directory, &dir->find_data);
if(dir->hFind != INVALID_HANDLE_VALUE)
{
(void)lstrcpyA(dir->dirent.d_name, dir->find_data.cFileName);
}
}
struct dirent *readdir(DIR *dir)
{
/* The last find exhausted the matches, so return NULL. */
if(dir->hFind == INVALID_HANDLE_VALUE)
{
if(FILE_ATTRIBUTE_ERROR == dir->find_data.dwFileAttributes)
{
errno = EBADF;
}
else
{
dir->find_data.dwFileAttributes = FILE_ATTRIBUTE_ERROR;
}
return NULL;
}
else
{
/* Copy the result of the last successful match to
* dirent.
*/
(void)lstrcpyA(dir->dirent.d_name, dir->find_data.cFileName);
/* Attempt the next match. */
if(!FindNextFileA(dir->hFind, &dir->find_data))
{
/* Exhausted all matches, so close and null the
* handle.
*/
(void)FindClose(dir->hFind);
dir->hFind = INVALID_HANDLE_VALUE;
}
return &dir->dirent;
}
}
/* ////////////////////////////////////////////////////////////////////////// */

View File

@ -1,200 +0,0 @@
/* /////////////////////////////////////////////////////////////////////////////
* File: dirent.h
*
* Purpose: Declaration of the opendir() API functions and types for the
* Win32 platform.
*
* Created: 19th October 2002
* Updated: 22nd April 2008
*
* Home: http://synesis.com.au/software/
*
* Copyright (c) 2002-2008, Matthew Wilson and Synesis Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - 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.
* - Neither the names of Matthew Wilson and Synesis Software nor the names of
* any contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS 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 COPYRIGHT OWNER OR 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.
*
* ////////////////////////////////////////////////////////////////////////// */
#ifdef EVIL_COMMON_API
# undef EVIL_COMMON_API
#endif /* EVIL_COMMON_API */
# ifdef EFL_EVIL_BUILD
# ifdef DLL_EXPORT
# define EVIL_COMMON_API __declspec(dllexport)
# else
# define EVIL_COMMON_API
# endif /* ! DLL_EXPORT */
# else
# define EVIL_COMMON_API __declspec(dllimport)
# endif /* ! EFL_EVIL_BUILD */
/** \file dirent.h
*
* Contains the declarations for the opendir()/readdir() API.
*/
#ifndef SYNSOFT_UNIXEM_INCL_H_DIRENT
#define SYNSOFT_UNIXEM_INCL_H_DIRENT
#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION
# define SYNSOFT_UNIXEM_VER_H_DIRENT_MAJOR 3
# define SYNSOFT_UNIXEM_VER_H_DIRENT_MINOR 3
# define SYNSOFT_UNIXEM_VER_H_DIRENT_REVISION 1
# define SYNSOFT_UNIXEM_VER_H_DIRENT_EDIT 30
#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */
/* ////////////////////////////////////////////////////////////////////////// */
/** \weakgroup unixem Synesis Software UNIX Emulation for Win32
* \brief The UNIX emulation library
*/
/** \weakgroup unixem_dirent opendir()/readdir() API
* \ingroup UNIXem unixem
* \brief This API provides facilities for enumerating the contents of directories
* @{
*/
/* ////////////////////////////////////////////////////////////////////////// */
#ifndef _WIN32
# error This file is only currently defined for compilation on Win32 systems
#endif /* _WIN32 */
/* /////////////////////////////////////////////////////////////////////////////
* Includes
*/
#include <stddef.h>
/* /////////////////////////////////////////////////////////////////////////////
* Constants and definitions
*/
#ifndef NAME_MAX
# define NAME_MAX (260) /*!< \brief The maximum number of characters (including null terminator) in a directory entry name */
#endif /* !NAME_MAX */
/* /////////////////////////////////////////////////////////////////////////////
* Typedefs
*/
typedef struct dirent_dir DIR; /*!< \brief Handle type for ANSI directory enumeration. \note dirent_dir is defined internally */
typedef struct wdirent_dir wDIR; /*!< \brief Handle type for Unicode directory enumeration. \note dirent_dir is defined internally */
/** \brief Results structure for readdir()
*/
struct dirent
{
char d_name[NAME_MAX + 1]; /*!< file name (null-terminated) */
int d_mode;
};
/** \brief Results structure for wreaddir()
*/
struct wdirent
{
wchar_t d_name[NAME_MAX + 1]; /*!< file name (null-terminated) */
int d_mode;
};
/* /////////////////////////////////////////////////////////////////////////////
* API functions
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** \brief Returns a pointer to the next directory entry.
*
* This function opens the directory named by filename, and returns a
* directory to be used to in subsequent operations. NULL is returned
* if name cannot be accessed, or if resources cannot be acquired to
* process the request.
*
* \param name The name of the directory to search
* \return The directory handle from which the entries are read or NULL
*/
EVIL_COMMON_API DIR* opendir(char const* name);
/** \brief Identical semantics to opendir(), but for Unicode searches.
*/
EVIL_COMMON_API wDIR* wopendir(wchar_t const* name);
/** \brief Closes a directory handle
*
* This function closes a directory handle that was opened with opendir()
* and releases any resources associated with that directory handle.
*
* \param dir The directory handle from which the entries are read
* \return 0 on success, or -1 to indicate error.
*/
EVIL_COMMON_API int closedir(DIR* dir);
/** \brief Identical semantics to closedir(), but for Unicode searches.
*/
EVIL_COMMON_API int wclosedir(wDIR* dir);
/** \brief Resets a directory search position
*
* This function resets the position of the named directory handle to
* the beginning of the directory.
*
* \param dir The directory handle whose position should be reset
*/
EVIL_COMMON_API void rewinddir(DIR* dir);
/** \brief Identical semantics to rewinddir(), but for Unicode searches.
*/
EVIL_COMMON_API void wrewinddir(wDIR* dir);
/** \brief Returns a pointer to the next directory entry.
*
* This function returns a pointer to the next directory entry, or NULL upon
* reaching the end of the directory or detecting an invalid seekdir() operation
*
* \param dir The directory handle from which the entries are read
* \return A dirent structure or NULL
*/
EVIL_COMMON_API struct dirent* readdir(DIR* dir);
/** \brief Identical semantics to readdir(), but for Unicode searches.
*/
EVIL_COMMON_API struct wdirent* wreaddir(wDIR* dir);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/* ////////////////////////////////////////////////////////////////////////// */
/** @} // end of group unixem_dirent */
/* ////////////////////////////////////////////////////////////////////////// */
#endif /* SYNSOFT_UNIXEM_INCL_H_DIRENT */
/* ////////////////////////////////////////////////////////////////////////// */

View File

@ -41,7 +41,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(INCLUDE)"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;EFL_EVIL_DLFCN_BUILD;DLL_EXPORT;_POSIX_"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;EFL_EVIL_DLFCN_BUILD;DLL_EXPORT;_POSIX_;__UNUSED__="
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -117,7 +117,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="$(INCLUDE)"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;EFL_EVIL_DLFCN_BUILD;DLL_EXPORT;_POSIX_"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;EFL_EVIL_DLFCN_BUILD;DLL_EXPORT;_POSIX_;__UNUSED__="
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"

View File

@ -41,7 +41,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(INCLUDE)"
PreprocessorDefinitions="HAVE_ERRNO_H;SECURITY_WIN32;WIN32;_DEBUG;_WINDOWS;_USRDLL;EFL_EVIL_BUILD;DLL_EXPORT;snprintf=_snprintf_c;__CRT_INLINE=__inline;inline=__inline"
PreprocessorDefinitions="HAVE_ERRNO_H;SECURITY_WIN32;WIN32;_DEBUG;_WINDOWS;_USRDLL;EFL_EVIL_BUILD;DLL_EXPORT;snprintf=_snprintf_c;__CRT_INLINE=__inline;inline=__inline;__UNUSED__="
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -123,7 +123,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="$(INCLUDE)"
PreprocessorDefinitions="HAVE_ERRNO_H;SECURITY_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;EFL_EVIL_BUILD;DLL_EXPORT;snprintf=_snprintf_c;__CRT_INLINE=__inline;inline=__inline"
PreprocessorDefinitions="HAVE_ERRNO_H;SECURITY_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;EFL_EVIL_BUILD;DLL_EXPORT;snprintf=_snprintf_c;__CRT_INLINE=__inline;inline=__inline;__UNUSED__="
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -189,7 +189,15 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\src\lib\evil.c"
RelativePath="..\..\src\lib\evil_dirent.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_errno.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_fcntl.c"
>
</File>
<File
@ -200,6 +208,18 @@
RelativePath="..\..\src\lib\evil_fnmatch_list_of_states.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_langinfo.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_link_xp.cpp"
>
</File>
<File
RelativePath="..\..\src\lib\evil_main.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_mman.c"
>
@ -208,10 +228,22 @@
RelativePath="..\..\src\lib\evil_pwd.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_stdio.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_stdlib.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_string.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_time.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_unistd.c"
>
@ -220,32 +252,80 @@
RelativePath="..\..\src\lib\evil_util.c"
>
</File>
<File
RelativePath="..\..\src\lib\evil_uuid.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\src\lib\dirent.h"
>
</File>
<File
RelativePath="..\..\src\lib\errno.h"
>
</File>
<File
RelativePath="..\..\src\lib\Evil.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_fcntl.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_fnmatch_private.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_langinfo.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_main.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_private.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_stdio.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_stdlib.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_string.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_unistd.h"
>
</File>
<File
RelativePath="..\..\src\lib\evil_util.h"
>
</File>
<File
RelativePath="..\..\src\lib\fnmatch.h"
>
</File>
<Filter
Name="pwd"
<File
RelativePath="..\..\src\lib\sys\mman.h"
>
<File
RelativePath="..\..\src\lib\pwd\pwd.h"
>
</File>
</Filter>
</File>
<File
RelativePath="..\..\src\lib\pwd.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
@ -253,30 +333,6 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="Common"
>
<File
RelativePath="..\common\dirent.c"
>
</File>
<File
RelativePath="..\common\dirent.h"
>
</File>
<Filter
Name="sys"
>
<File
RelativePath="..\common\sys\time.c"
>
</File>
<File
RelativePath="..\common\sys\time.h"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>