From 0bc826dd70fb79004078c5505b707db6b564619b Mon Sep 17 00:00:00 2001 From: doursse Date: Thu, 24 Jul 2008 18:18:55 +0000 Subject: [PATCH] Add Visual Studio solution and vc projects to compile Evil with Microsoft (r) tools For those who want to try it, please read README.txt first Work of Dmitriy Mazovka. Thank you ! SVN revision: 35205 --- legacy/evil/win32/MANIFEST.txt | 25 ++ legacy/evil/win32/README.txt | 84 +++++ legacy/evil/win32/common/dirent.c | 301 ++++++++++++++++++ legacy/evil/win32/common/dirent.h | 200 ++++++++++++ legacy/evil/win32/common/fnmatch.c | 218 +++++++++++++ legacy/evil/win32/common/fnmatch.h | 50 +++ .../win32/common/fnmatch_list_of_states.c | 70 ++++ legacy/evil/win32/common/fnmatch_private.h | 28 ++ legacy/evil/win32/common/sys/time.c | 14 + legacy/evil/win32/common/sys/time.h | 63 ++++ legacy/evil/win32/set_env.bat | 19 ++ legacy/evil/win32/vs8/evil.sln | 32 ++ legacy/evil/win32/vs8/libdlfcn.vcproj | 201 ++++++++++++ legacy/evil/win32/vs8/libevil.vcproj | 263 +++++++++++++++ legacy/evil/win32/vs8/libmman.vcproj | 205 ++++++++++++ legacy/evil/win32/vs8/start.bat | 30 ++ 16 files changed, 1803 insertions(+) create mode 100644 legacy/evil/win32/MANIFEST.txt create mode 100644 legacy/evil/win32/README.txt create mode 100644 legacy/evil/win32/common/dirent.c create mode 100644 legacy/evil/win32/common/dirent.h create mode 100644 legacy/evil/win32/common/fnmatch.c create mode 100644 legacy/evil/win32/common/fnmatch.h create mode 100644 legacy/evil/win32/common/fnmatch_list_of_states.c create mode 100644 legacy/evil/win32/common/fnmatch_private.h create mode 100644 legacy/evil/win32/common/sys/time.c create mode 100644 legacy/evil/win32/common/sys/time.h create mode 100644 legacy/evil/win32/set_env.bat create mode 100644 legacy/evil/win32/vs8/evil.sln create mode 100644 legacy/evil/win32/vs8/libdlfcn.vcproj create mode 100644 legacy/evil/win32/vs8/libevil.vcproj create mode 100644 legacy/evil/win32/vs8/libmman.vcproj create mode 100644 legacy/evil/win32/vs8/start.bat diff --git a/legacy/evil/win32/MANIFEST.txt b/legacy/evil/win32/MANIFEST.txt new file mode 100644 index 0000000000..206cb51f3d --- /dev/null +++ b/legacy/evil/win32/MANIFEST.txt @@ -0,0 +1,25 @@ + + This folder content: + + common - common sources necessary to build efl with MSVC + sys - gettimeofday function implementation + time.c - source + time.h - header + + dirent.c - directory functions source + dirent.h - directory functions header + fnmatch.c - fnmatch function implementation source + fnmatch_list_of_states.c - fnmatch auxiliary source + fnmatch.h - fnmatch header + fnmatch_private.h - fnmatch private header + + vs8 - Visual Studio 8 project files + start.bat - batch script to start work with the solution + evil.sln - Evil MSVC solution + libdlfcn.vcproj - libdlfcn project + libevil.vcproj - libevil project + libmman.vcproj - libmman project + + set_env.bat - common environment startup + MANIFEST.txt - this file + README.txt - about this folder \ No newline at end of file diff --git a/legacy/evil/win32/README.txt b/legacy/evil/win32/README.txt new file mode 100644 index 0000000000..66b5317edb --- /dev/null +++ b/legacy/evil/win32/README.txt @@ -0,0 +1,84 @@ + This folder contains Microsoft Visual Studion projects and some sources for + building Evil. + +Important: + + Do not launch manually any solutions or projects in the folder, to start + a solution run proper start.bat script, it will setup environment for + projects and will check system requirements. + + Before start make sure that set_env.bat:EXT_DIR variable points to proper + extern directory. Extern directory layout and content (may be different, but + this is guaranteed to be enough): + + extern + bin + charset.dll + cjpeg.exe + djpeg.exe + exifautotran + freetype6.dll + glew32.dll + glewinfo.exe + glewinfo.txt + iconv.dll + jpeg62.dll + jpegexiforient.exe + jpegtran.exe + libpng12.dll + libpng13d.dll + libpng3.dll + libtiff3.dll + libungif4.dll + rdjpgcom.exe + visualinfo.exe + wrjpgcom.exe + zlib1.dll + + include + freetype + ... (freetype includes) + GL + glew.h + glxew.h + wglew.h + sys + param.h + + ansidecl.h + ft2build.h + getopt.h + gif_lib.h + iconv.h + jconfig.h + jerror.h + jmorecfg.h + jpeglib.h + libcharset.h + localcharset.h + png.h + pngconf.h + stdint.h + tiff.h + tiffconf.h + tiffio.h + tiffvers.h + unistd.h + zconf.h + zlib.h + + lib + charset.lib + freetype.lib + glew32.lib + glew32s.lib + iconv.lib + jpeg.def + jpeg.lib + libpng.lib + libpng13d.lib + libtiff.def + libtiff.lib + libungif.lib + zlib.def + zlib.lib diff --git a/legacy/evil/win32/common/dirent.c b/legacy/evil/win32/common/dirent.c new file mode 100644 index 0000000000..5de23bf8ae --- /dev/null +++ b/legacy/evil/win32/common/dirent.c @@ -0,0 +1,301 @@ +/* ///////////////////////////////////////////////////////////////////////////// + * 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 + +#include +#include +#include + +/* ///////////////////////////////////////////////////////////////////////////// + * 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; + } +} + +/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/legacy/evil/win32/common/dirent.h b/legacy/evil/win32/common/dirent.h new file mode 100644 index 0000000000..9729e23c1d --- /dev/null +++ b/legacy/evil/win32/common/dirent.h @@ -0,0 +1,200 @@ +/* ///////////////////////////////////////////////////////////////////////////// + * 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 + +/* ///////////////////////////////////////////////////////////////////////////// + * 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 */ + +/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/legacy/evil/win32/common/fnmatch.c b/legacy/evil/win32/common/fnmatch.c new file mode 100644 index 0000000000..1211fd5391 --- /dev/null +++ b/legacy/evil/win32/common/fnmatch.c @@ -0,0 +1,218 @@ +#include +#include + +#include "fnmatch.h" +#include "fnmatch_private.h" + +enum fnmatch_status + { + fnmatch_not_found = 0, + fnmatch_found = 1, + fnmatch_syntax_error = 2 + }; + +static +size_t +fnmatch_match_class_token(enum fnmatch_status *status, + const char *class_token, + char c) +{ + if (! *class_token) + { + *status = fnmatch_syntax_error; + return 0; + } + else if (class_token[1] == '-' && class_token[2] != ']') + { + if (class_token[0] <= c && c <= class_token[2]) + *status = fnmatch_found; + return 3; + } + else + { + if (c == *class_token) + *status = fnmatch_found; + return 1; + } +} + +static +size_t +fnmatch_complement_class(const char *class_token) +{ + switch (*class_token) + { + case 0: + return FNM_SYNTAXERR; + + case '!': + return 1; + + default: + return 0; + } +} + +static +size_t +fnmatch_match_class(const char *class, + char c) +{ + const size_t complement = fnmatch_complement_class(class + 1); + + if (complement == FNM_SYNTAXERR) + return FNM_SYNTAXERR; + + enum fnmatch_status status = fnmatch_not_found; + size_t pos = 1 + complement; + + do + pos += fnmatch_match_class_token(&status, class + pos, c); + while (class[pos] && class[pos] != ']'); + + if (status == fnmatch_syntax_error || ! class[pos]) + return FNM_SYNTAXERR; + + if (status == fnmatch_found) + return complement ? 0 : pos + 1; + else + return complement ? pos + 1 : 0; +} + +static +size_t +fnmatch_chrcasecmp(char a, char b) +{ + if ('A' <= a && a <= 'Z') + a += 'a' - 'A'; + if ('A' <= b && b <= 'Z') + b += 'a' - 'A'; + return a == b; +} + +static +size_t +fnmatch_match_token(const char *token, + char c, + _Bool leading, + int flags) +{ + if (*token == '\\' && !(flags & FNM_NOESCAPE)) + return token[1] ? (token[1] == c ? 2 : 0) : FNM_SYNTAXERR; + + if (c == '/' && (flags & FNM_PATHNAME)) + return *token == '/'; + + if (c == '.' && leading && (flags & FNM_PERIOD)) + return *token == '.'; + + switch (*token) + { + case '?': + return 1; + + case '[': + return fnmatch_match_class(token, c); + + default: + if (flags & FNM_CASEFOLD) + return fnmatch_chrcasecmp(*token, c); + return *token == c ? 1 : 0; + } +} + +static +void +fnmatch_init_states(struct list_of_states *states) +{ + states->size = 1; + states->states[0] = 0; + memset(states->has, 0, states->reserved * sizeof (*states->has)); + states->has[0] = 1; +} + +static +size_t +fnmatch_check_finals(const char *pattern, + const struct list_of_states *states) +{ + for (size_t i = 0; i < states->size; ++i) + { + _Bool match = 1; + + for (size_t j = states->states[i]; pattern[j]; ++j) + if (pattern[j] != '*') + { + match = 0; + break; + } + + if (match) + return 0; + } + return FNM_NOMATCH; +} + +int +fnmatch(const char *pattern, + const char *string, + int flags) +{ + assert(pattern); + assert(string); + + struct list_of_states *states = + fnmatch_list_of_states_alloc(2, strlen(pattern)); + struct list_of_states *new_states = states + 1; + + if (! states) + return FNM_NOMEM; + fnmatch_init_states(states); + + _Bool leading = 1; + + for (const char* c = string; *c && states->size; ++c) + { + fnmatch_list_of_states_clear(new_states); + + for (size_t i = 0; i < states->size; ++i) + { + const size_t pos = states->states[i]; + + if (! pattern[pos]) + { + if (*c == '/' && (flags & FNM_LEADING_DIR)) + return 0; + continue; + } + else if (pattern[pos] == '*') + { + fnmatch_list_of_states_insert(states, pos + 1); + if ((*c != '/' || !(flags & FNM_PATHNAME)) && + (*c != '.' || !leading || !(flags & FNM_PERIOD))) + fnmatch_list_of_states_insert(new_states, pos); + } + else + { + const int m = fnmatch_match_token(pattern + pos, *c, + leading, flags); + + if (m == FNM_SYNTAXERR) + return FNM_SYNTAXERR; + else if (m) + fnmatch_list_of_states_insert(new_states, pos + m); + } + } + { + struct list_of_states *tmp = states; + + states = new_states; + new_states = tmp; + } + leading = *c == '/' && (flags & FNM_PATHNAME); + } + + const size_t r = fnmatch_check_finals(pattern, states); + fnmatch_list_of_states_free(states < new_states ? states : new_states, 2); + return r; +} diff --git a/legacy/evil/win32/common/fnmatch.h b/legacy/evil/win32/common/fnmatch.h new file mode 100644 index 0000000000..d44a15467e --- /dev/null +++ b/legacy/evil/win32/common/fnmatch.h @@ -0,0 +1,50 @@ +#ifndef _FNMATCH_H +#define _FNMATCH_H + +#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 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* We #undef these before defining them because some losing systems + (HP-UX A.08.07 for example) define these in . */ +#undef FNM_PATHNAME +#undef FNM_NOESCAPE +#undef FNM_PERIOD + +/* Bits set in the FLAGS argument to `fnmatch'. */ +#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ +#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ + +#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE) +#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ +#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +#endif + +/* Value returned by `fnmatch' if STRING does not match PATTERN. */ +#define FNM_NOMATCH 1 + +/* Match STRING against the filename pattern PATTERN, + returning zero if it matches, FNM_NOMATCH if not. */ +EVIL_COMMON_API int fnmatch(const char *__pattern, const char *__string, int __flags); + +#ifdef __cplusplus +} +#endif + +#endif /* _FNMATCH_H */ diff --git a/legacy/evil/win32/common/fnmatch_list_of_states.c b/legacy/evil/win32/common/fnmatch_list_of_states.c new file mode 100644 index 0000000000..3400a9b95f --- /dev/null +++ b/legacy/evil/win32/common/fnmatch_list_of_states.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include + +#include "fnmatch_private.h" + +struct list_of_states* +fnmatch_list_of_states_alloc(size_t n, size_t pattern_len) +{ + struct list_of_states *l; + + const size_t reserved = pattern_len + 1; + const size_t states_size = sizeof (*l->states) * reserved; + const size_t has_size = sizeof (*l->has) * reserved; + const size_t states_has_size = states_size + has_size; + const size_t struct_size = sizeof (*l) + states_has_size; + + uint8_t *states; + uint8_t *has; + size_t i; + + if (! (l = malloc(n * struct_size))) + return 0; + + states = (uint8_t *) (l + n); + has = states + states_size; + + for (i = 0; i < n; ++i) + { + l[i].reserved = reserved; + l[i].states = (size_t *) states; + l[i].has = (_Bool *) has; + states += states_has_size; + has += states_has_size; + } + + return l; +} + +void +fnmatch_list_of_states_free(struct list_of_states *lists, size_t n) +{ + assert(lists); + + (void) n; + free(lists); +} + +void +fnmatch_list_of_states_insert(struct list_of_states *list, size_t state) +{ + assert(list); + assert(state < list->reserved); + + if (list->has[state]) + return; + + list->states[list->size++] = state; + list->has[state] = 1; +} + +void +fnmatch_list_of_states_clear(struct list_of_states *list) +{ + assert(list); + + list->size = 0; + memset(list->has, 0, list->reserved * sizeof (*list->has)); +} diff --git a/legacy/evil/win32/common/fnmatch_private.h b/legacy/evil/win32/common/fnmatch_private.h new file mode 100644 index 0000000000..5bced54c07 --- /dev/null +++ b/legacy/evil/win32/common/fnmatch_private.h @@ -0,0 +1,28 @@ +#ifndef FNMATCH_PRIVATE_H_ +# define FNMATCH_PRIVATE_H_ + +# include + +typedef int _Bool; + +struct list_of_states +{ + size_t reserved; + size_t size; + size_t *states; + _Bool *has; +}; + +struct list_of_states* +fnmatch_list_of_states_alloc(size_t n, size_t pattern_len); + +void +fnmatch_list_of_states_free(struct list_of_states *lists, size_t n); + +void +fnmatch_list_of_states_insert(struct list_of_states *list, size_t state); + +void +fnmatch_list_of_states_clear(struct list_of_states *list); + +#endif // ! FNMATCH_PRIVATE_H_ diff --git a/legacy/evil/win32/common/sys/time.c b/legacy/evil/win32/common/sys/time.c new file mode 100644 index 0000000000..762278cef8 --- /dev/null +++ b/legacy/evil/win32/common/sys/time.c @@ -0,0 +1,14 @@ +#include "time.h" + +#include + +int __cdecl gettimeofday(struct timeval *tv, void *tzp) +{ + struct _timeb timebuffer; + + _ftime(&timebuffer); + tv->tv_sec = timebuffer.time; + tv->tv_usec = timebuffer.millitm * 1000; + return 0; +} + diff --git a/legacy/evil/win32/common/sys/time.h b/legacy/evil/win32/common/sys/time.h new file mode 100644 index 0000000000..e1d4934809 --- /dev/null +++ b/legacy/evil/win32/common/sys/time.h @@ -0,0 +1,63 @@ +#ifndef _SYS_TIME_H_ +#define _SYS_TIME_H_ + +#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 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _WINSOCK2API_ +#ifndef timercmp //_TIMEVAL_DEFINED +#define _TIMEVAL_DEFINED +struct timeval { + long tv_sec; + long tv_usec; +}; +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec != (uvp)->tv_sec) ? \ + ((tvp)->tv_sec cmp (uvp)->tv_sec) : \ + ((tvp)->tv_usec cmp (uvp)->tv_usec)) +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#endif /* _TIMEVAL_DEFINED */ +#endif + +/* Provided for compatibility with code that assumes that + the presence of gettimeofday function implies a definition + of struct timezone. */ +struct timezone +{ + int tz_minuteswest; /* of Greenwich */ + int tz_dsttime; /* type of dst correction to apply */ +}; + +/* + Implementation as per: + The Open Group Base Specifications, Issue 6 + IEEE Std 1003.1, 2004 Edition + + The timezone pointer arg is ignored. Errors are ignored. +*/ +EVIL_COMMON_API int __cdecl gettimeofday(struct timeval *tv, void *tzp); + +#define HAVE_GETTIMEOFDAY + +#ifdef __cplusplus +} +#endif + + +#endif /* _SYS_TIME_H_ */ diff --git a/legacy/evil/win32/set_env.bat b/legacy/evil/win32/set_env.bat new file mode 100644 index 0000000000..47d667c0c4 --- /dev/null +++ b/legacy/evil/win32/set_env.bat @@ -0,0 +1,19 @@ +@echo off + +rem Set external libraries directory. +set EXT_DIR=%cd%\..\..\..\..\extern + +if not exist %EXT_DIR% ( + set EXT_DIR= + echo ERROR: External libs dir is not set. + pause + goto END +) + +rem Add installation directory pathes. +set INCLUDE=%EXT_DIR%\include;%INCLUDE% +set LIB=%EXT_DIR%\lib;%LIB% + +set INCLUDE=%cd%\common;%cd%\..\src\lib;%INCLUDE% + +:END diff --git a/legacy/evil/win32/vs8/evil.sln b/legacy/evil/win32/vs8/evil.sln new file mode 100644 index 0000000000..51f2c99233 --- /dev/null +++ b/legacy/evil/win32/vs8/evil.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libevil", "libevil.vcproj", "{689B4F2B-666D-439F-9BF3-1203D813DE3F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdlfcn", "libdlfcn.vcproj", "{2DAB1902-38E3-4F58-8403-C1BC7C077E1F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmman", "libmman.vcproj", "{799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {689B4F2B-666D-439F-9BF3-1203D813DE3F}.Debug|Win32.ActiveCfg = Debug|Win32 + {689B4F2B-666D-439F-9BF3-1203D813DE3F}.Debug|Win32.Build.0 = Debug|Win32 + {689B4F2B-666D-439F-9BF3-1203D813DE3F}.Release|Win32.ActiveCfg = Release|Win32 + {689B4F2B-666D-439F-9BF3-1203D813DE3F}.Release|Win32.Build.0 = Release|Win32 + {2DAB1902-38E3-4F58-8403-C1BC7C077E1F}.Debug|Win32.ActiveCfg = Debug|Win32 + {2DAB1902-38E3-4F58-8403-C1BC7C077E1F}.Debug|Win32.Build.0 = Debug|Win32 + {2DAB1902-38E3-4F58-8403-C1BC7C077E1F}.Release|Win32.ActiveCfg = Release|Win32 + {2DAB1902-38E3-4F58-8403-C1BC7C077E1F}.Release|Win32.Build.0 = Release|Win32 + {799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Debug|Win32.ActiveCfg = Debug|Win32 + {799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Debug|Win32.Build.0 = Debug|Win32 + {799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Release|Win32.ActiveCfg = Release|Win32 + {799E26AA-26BC-4C21-B65F-0DF8F02E8F5F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/legacy/evil/win32/vs8/libdlfcn.vcproj b/legacy/evil/win32/vs8/libdlfcn.vcproj new file mode 100644 index 0000000000..d6ce43bc46 --- /dev/null +++ b/legacy/evil/win32/vs8/libdlfcn.vcproj @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/legacy/evil/win32/vs8/libevil.vcproj b/legacy/evil/win32/vs8/libevil.vcproj new file mode 100644 index 0000000000..90eac628be --- /dev/null +++ b/legacy/evil/win32/vs8/libevil.vcproj @@ -0,0 +1,263 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/legacy/evil/win32/vs8/libmman.vcproj b/legacy/evil/win32/vs8/libmman.vcproj new file mode 100644 index 0000000000..0251639223 --- /dev/null +++ b/legacy/evil/win32/vs8/libmman.vcproj @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/legacy/evil/win32/vs8/start.bat b/legacy/evil/win32/vs8/start.bat new file mode 100644 index 0000000000..e7a3b131e4 --- /dev/null +++ b/legacy/evil/win32/vs8/start.bat @@ -0,0 +1,30 @@ +@echo off +rem Warning: environment is set for Win32 platform. + +rem Setup common Win32 environment variables + +pushd .. +call set_env.bat +popd + +set SolutionDirectory=%cd% +set DebugOutputDirectory=%SolutionDirectory%\out +set ReleaseOutputDirectory=%SolutionDirectory%\out +set DebugLibraryDirectory=%SolutionDirectory%\out +set ReleaseLibraryDirectory=%SolutionDirectory%\out +set TemporaryDirectory=%SolutionDirectory%\temp + + +rem Check for basic requirements +if "%VS80COMNTOOLS%" == "" ( + echo ERROR: Microsoft Visual Studio 2005 is not installed. + pause + goto END +) + +rem Setting environment for using Microsoft Visual Studio 2005 x86 tools. +call "%VS80COMNTOOLS%vsvars32.bat" + +evil.sln + +:END \ No newline at end of file