--- /dev/null
+if HAVE_WINDOWS
+
+### Library
+
+lib_LTLIBRARIES = libevil.la
+
+install_evilheadersdir = $(includedir)/evil-@VMAJ@
+dist_install_evilheaders_DATA = \
+Evil.h \
+evil_dlfcn.h \
+evil_fcntl.h \
+evil_inet.h \
+evil_langinfo.h \
+evil_locale.h \
+evil_macro.h \
+evil_macro_pop.h \
+evil_macro_wrapper.h \
+evil_main.h \
+evil_stdio.h \
+evil_stdlib.h \
+evil_string.h \
+evil_time.h \
+evil_unistd.h \
+evil_util.h \
+dirent.h \
+fnmatch.h \
+pwd.h
+
+evilmmanheadersdir = $(includedir)/evil-@VMAJ@/sys
+dist_evilmmanheaders_DATA = \
+sys/mman.h
+
+libevil_la_SOURCES = \
+evil_dirent.c \
+evil_dlfcn.c \
+evil_fcntl.c \
+evil_fnmatch.c \
+evil_fnmatch_list_of_states.c \
+evil_inet.c \
+evil_langinfo.c \
+evil_locale.c \
+evil_link_xp.cpp \
+evil_main.c \
+evil_mman.c \
+evil_pwd.c \
+evil_stdio.c \
+evil_stdlib.c \
+evil_string.c \
+evil_time.c \
+evil_unistd.c \
+evil_util.c \
+evil_private.h \
+evil_fnmatch_private.h
+
+libevil_la_CPPFLAGS = @EVIL_CPPFLAGS@
+libevil_la_CFLAGS = @EVIL_CFLAGS@ @EVIL_CFLAGS_WRN@ -D__USE_MINGW_ANSI_STDIO
+libevil_la_CXXFLAGS = @EVIL_CXXFLAGS@ @EVIL_CFLAGS@
+libevil_la_LIBADD = @EVIL_SUBBUILD_LIBS@
+libevil_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
+
+# regex
+
+dist_install_evilheaders_DATA += \
+regex/regex.h
+
+libevil_la_SOURCES += \
+regex/regcomp.c \
+regex/regerror.c \
+regex/regexec.c \
+regex/regfree.c \
+regex/cclass.h \
+regex/cname.h \
+regex/regex2.h \
+regex/utils.h
+
+libevil_la_CPPFLAGS += \
+-I$(top_srcdir)/src/lib/evil \
+-I$(top_srcdir)/src/lib/evil/regex \
+-DPOSIX_MISTAKE
+
+endif
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+
+#include <psapi.h> /* EnumProcessModules(Ex) */
+
+#include "evil_macro.h"
+#include "evil_util.h"
+#include "evil_dlfcn.h"
+#include "evil_private.h"
+
+
+static char *_dl_err = NULL;
+static int _dl_err_viewed = 0;
+
+static void
+_dl_get_last_error(char *desc)
+{
+ char *str;
+ size_t l1;
+ size_t l2;
+
+ str = evil_last_error_get();
+
+ l1 = strlen(desc);
+ l2 = strlen(str);
+
+ if (_dl_err)
+ free(_dl_err);
+
+ _dl_err = (char *)malloc(sizeof(char) * (l1 + l2 + 1));
+ if (!_dl_err)
+ _dl_err = strdup("not enough resource");
+ else
+ {
+ memcpy(_dl_err, desc, l1);
+ memcpy(_dl_err + l1, str, l2);
+ _dl_err[l1 + l2] = '\0';
+ }
+ free(str);
+ _dl_err_viewed = 0;
+}
+
+void *
+dlopen(const char* path, int mode EVIL_UNUSED)
+{
+ HMODULE module = NULL;
+
+ if (!path)
+ {
+ module = GetModuleHandle(NULL);
+ if (!module)
+ _dl_get_last_error("GetModuleHandle returned: ");
+ }
+ else
+ {
+ char *new_path;
+ size_t l;
+ unsigned int i;
+
+ /* according to MSDN, we must change the slash to backslash */
+ l = strlen(path);
+ new_path = (char *)malloc(sizeof(char) * (l + 1));
+ if (!new_path)
+ {
+ if (_dl_err)
+ free(_dl_err);
+ _dl_err = strdup("not enough resource");
+ _dl_err_viewed = 0;
+ return NULL;
+ }
+ for (i = 0; i <= l; i++)
+ {
+ if (path[i] == '/')
+ new_path[i] = '\\';
+ else
+ new_path[i] = path[i];
+ }
+#ifdef UNICODE
+ {
+ wchar_t *wpath;
+
+ wpath = evil_char_to_wchar(new_path);
+ module = LoadLibrary(wpath);
+ free(wpath);
+ }
+#else
+ module = LoadLibraryEx(new_path, NULL,
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+#endif /* ! UNICODE */
+ if (!module)
+ _dl_get_last_error("LoadLibraryEx returned: ");
+
+ free(new_path);
+ }
+
+ return module;
+}
+
+int
+dlclose(void* handle)
+{
+ if (FreeLibrary(handle))
+ return 0;
+ else
+ {
+ _dl_get_last_error("FreeLibrary returned: ");
+ return -1;
+ }
+}
+
+void *
+dlsym(void *handle, const char *symbol)
+{
+ FARPROC fp = NULL;
+ LPCTSTR new_symbol;
+
+ if (!symbol || !*symbol) return NULL;
+
+#ifdef UNICODE
+ new_symbol = evil_char_to_wchar(symbol);
+#else
+ new_symbol = symbol;
+#endif /* UNICODE */
+
+ if (handle == RTLD_DEFAULT)
+ {
+ HMODULE modules[1024];
+ DWORD needed;
+ DWORD i;
+
+ /* TODO: use EnumProcessModulesEx() on Windows >= Vista */
+ if (!EnumProcessModules(GetCurrentProcess(),
+ modules, sizeof(modules), &needed))
+ {
+#ifdef UNICODE
+ _dl_get_last_error("EnumProcessModules returned: ");
+ free((void *)new_symbol);
+#endif /* UNICODE */
+ return NULL;
+ }
+
+ for (i = 0; i < (needed / sizeof(HMODULE)); i++)
+ {
+ fp = GetProcAddress(modules[i], new_symbol);
+ if (fp) break;
+ }
+ }
+ else
+ fp = GetProcAddress(handle, new_symbol);
+
+#ifdef UNICODE
+ free((void *)new_symbol);
+#endif /* UNICODE */
+
+ if (!fp)
+ _dl_get_last_error("GetProcAddress returned: ");
+
+ return fp;
+}
+
+char *
+dlerror (void)
+{
+ if (!_dl_err_viewed)
+ {
+ _dl_err_viewed = 1;
+ return _dl_err;
+ }
+ else
+ {
+ if (_dl_err)
+ free(_dl_err);
+ return NULL;
+ }
+}
+
+#ifdef _GNU_SOURCE
+
+static char _dli_fname[MAX_PATH];
+static char _dli_sname[MAX_PATH]; /* a symbol should have at most 255 char */
+
+static int
+_dladdr_comp(const void *p1, const void *p2)
+{
+ return ( *(int *)p1 - *(int *)p2);
+}
+
+int
+dladdr (const void *addr, Dl_info *info)
+{
+ TCHAR tpath[PATH_MAX];
+ MEMORY_BASIC_INFORMATION mbi;
+ unsigned char *base;
+ char *path;
+ size_t length;
+
+ IMAGE_NT_HEADERS *nth;
+ IMAGE_EXPORT_DIRECTORY *ied;
+ DWORD *addresses;
+ WORD *ordinals;
+ DWORD *names;
+ DWORD *tmp;
+ DWORD res;
+ DWORD rva_addr;
+ DWORD i;
+
+ if (!info)
+ return 0;
+
+ info->dli_fname = NULL;
+ info->dli_fbase = NULL;
+ info->dli_sname = NULL;
+ info->dli_saddr = NULL;
+
+ /* Get the name and base address of the module */
+
+ if (!VirtualQuery(addr, &mbi, sizeof(mbi)))
+ {
+ _dl_get_last_error("VirtualQuery returned: ");
+ return 0;
+ }
+
+ if (mbi.State != MEM_COMMIT)
+ return 0;
+
+ if (!mbi.AllocationBase)
+ return 0;
+
+ base = (unsigned char *)mbi.AllocationBase;
+
+ if (!GetModuleFileName((HMODULE)base, (LPTSTR)&tpath, PATH_MAX))
+ {
+ _dl_get_last_error("GetModuleFileName returned: ");
+ return 0;
+ }
+
+# ifdef UNICODE
+ path = evil_wchar_to_char(tpath);
+# else
+ path = tpath;
+# endif /* ! UNICODE */
+
+ length = strlen(path);
+ if (length >= PATH_MAX)
+ {
+ length = PATH_MAX - 1;
+ path[PATH_MAX - 1] = '\0';
+ }
+
+ memcpy(_dli_fname, path, length + 1);
+ info->dli_fname = (const char *)_dli_fname;
+ info->dli_fbase = base;
+
+# ifdef UNICODE
+ free(path);
+# endif /* ! UNICODE */
+
+ /* get the name and the address of the required symbol */
+
+ if (((IMAGE_DOS_HEADER *)base)->e_magic != IMAGE_DOS_SIGNATURE)
+ {
+ SetLastError(1276);
+ return 0;
+ }
+
+ nth = (IMAGE_NT_HEADERS *)(base + ((IMAGE_DOS_HEADER *)base)->e_lfanew);
+ if (nth->Signature != IMAGE_NT_SIGNATURE)
+ {
+ SetLastError(1276);
+ return 0;
+ }
+
+ /* no exported symbols ? it's an EXE and we exit without error */
+ if (nth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress == 0)
+ {
+ return 1;
+ }
+
+ /* we assume now that the PE file is well-formed, so checks only when needed */
+ ied = (IMAGE_EXPORT_DIRECTORY *)(base + nth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
+ addresses = (DWORD *)(base + ied->AddressOfFunctions);
+ ordinals = (WORD *)(base + ied->AddressOfNameOrdinals);
+ names = (DWORD *)(base + ied->AddressOfNames);
+
+ /* the addresses are not ordered, so we need to order them */
+ tmp = malloc(ied->NumberOfFunctions * sizeof(DWORD));
+ if (!tmp)
+ {
+ SetLastError(8);
+ return 0;
+ }
+
+ memcpy(tmp, addresses, ied->NumberOfFunctions * sizeof(DWORD));
+ qsort(tmp, ied->NumberOfFunctions, sizeof(DWORD), _dladdr_comp);
+ rva_addr = (unsigned char *)addr - base;
+ res = (DWORD)(-1);
+ for (i = 0; i < ied->NumberOfFunctions; i++)
+ {
+ if (tmp[i] < rva_addr)
+ continue;
+
+ res = tmp[i];
+ break;
+ }
+
+ /* if rva_addr is too high, we store the latest address */
+ if (res == (DWORD)(-1))
+ res = tmp[ied->NumberOfFunctions - 1];
+
+ free(tmp);
+
+ for (i = 0; i < ied->NumberOfNames; i++)
+ {
+ if (addresses[ordinals[i]] == res)
+ {
+ char *name;
+
+ name = (char *)(base + names[i]);
+ length = strlen(name);
+ if (length >= PATH_MAX)
+ {
+ length = PATH_MAX - 1;
+ name[PATH_MAX - 1] = '\0';
+ }
+ memcpy(_dli_sname, name, length + 1);
+ info->dli_sname = (const char *)_dli_sname;
+ info->dli_saddr = base + res;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#endif /* _GNU_SOURCE */
--- /dev/null
+#ifndef __EVIL_DLFCN_H__
+#define __EVIL_DLFCN_H__
+
+
+#include <limits.h>
+
+
+/**
+ * @file evil_dlfcn.h
+ * @brief The file that provides functions to manage dynamic-link libraries
+ * @defgroup Evil_Dlfcn Functions that manage dynamic-link libraries.
+ * @ingroup Evil
+ *
+x * This header provides functions to load and unload dynamic-link
+ * libaries, to get the address of a symbol, and to get diagnostic
+ * information.
+ */
+
+
+/**
+ * @def RTLD_LAZY
+ * Lazy function call binding.
+ */
+# define RTLD_LAZY 0x00001 /* lazy function call binding. Unused */
+
+/**
+ * @def RTLD_NOW
+ * Immediate function call binding.
+ */
+# define RTLD_NOW 0x00002 /* immediate function call binding. Unused */
+
+/**
+ * @def RTLD_GLOBAL
+ * Symbols in this dlopen'ed obj are visible to other dlopen'ed objs.
+ */
+# define RTLD_GLOBAL 0x00004 /* symbols in this dlopen'ed obj are visible
+ to other dlopen'ed objs. Unused */
+
+/**
+ * @def RTLD_LOCAL
+ * Symbols in this dlopen'ed obj are not visible to other dlopen'ed objs.
+ */
+# define RTLD_LOCAL 0x00008 /* symbols in this dlopen'ed obj are not visible
+ to other dlopen'ed objs. Unused */
+
+/**
+ * @def RTLD_NODELETE
+ * Symbols are not deleted when closed.
+ */
+#define RTLD_NODELETE 0x01000 /* do not delete object when closed. */
+
+#ifdef _GNU_SOURCE
+
+/**
+ * @def RTLD_DEFAULT
+ * Symbols are searched in all the DLL opened by the current process.
+ * This symbol is defined only when _GNU_SOURCE was defined before
+ * including dlfcn.h.
+ */
+#define RTLD_DEFAULT ((void*)1) /* search the symbol on all the DLL of the current process */
+
+/**
+ * @typedef Dl_info
+ * @brief A structure that stores infomation of a calling process.
+ * This typedef is defined only when _GNU_SOURCE was defined before
+ * including dlfcn.h.
+ */
+typedef struct Dl_info Dl_info;
+
+/**
+ * @struct Dl_info
+ * @brief A structure that stores infomation of a calling process.
+ * This structure is defined only when _GNU_SOURCE was defined before
+ * including dlfcn.h.
+ */
+struct Dl_info
+{
+ const char *dli_fname; /**< Filename of defining object */
+ void *dli_fbase; /**< Load address of that object */
+ const char *dli_sname; /**< Name of nearest lower symbol */
+ void *dli_saddr; /**< Exact value of nearest symbol */
+};
+
+#endif /* _GNU_SOURCE */
+
+/**
+ * @brief Map a specified executable module (either a .dll or .exe file)
+ * into the address space of the user process.
+ *
+ * @param path Name of the module.
+ * @param mode Unused.
+ * @return A pointer that represent the module, or @c NULL on failure.
+ *
+ * Map a specified executable module (either a .dll or .exe file)
+ * into the address space of the user process. If @p path is @c NULL,
+ * then the module corresponding to the current process is returned.
+ * Otherwise the module specified by @p path is loaded if it exists.
+ * If not, @c NULL is returned. The directory separators can be forward
+ * slash, or backward ones. Mapping a module can map other modules.
+ * @p mode is unused.
+ *
+ * If an error occurred, an error string can be retrived with dlerror().
+ *
+ * According to the OS, the search order of the module can change,
+ * according to the value of SafeDllSearchMode.
+ *
+ * - For Windows Vista, Windows Server 2003, and Windows XP SP2:
+ * SafeDLLSearchMode is enabled by default.
+ * - For Windows XP and Windows 2000 SP4: SafeDLLSearchMode is disabled
+ * by default.
+ *
+ * If SafeDllSearchMode is enabled
+ * - The directory from which the application loaded.
+ * - The system directory. Use the GetSystemDirectory() function
+ * to get the path of this directory.
+ * - The 16-bit system directory. There is no function that obtains
+ * the path of this directory, but it is searched.
+ * - The Windows directory. Use the GetWindowsDirectory() function
+ * to get the path of this directory.
+ * - The current directory.
+ * - The directories that are listed in the PATH environment variable.
+ * Note that this does not include the per-application path specified
+ * by the App Paths registry key.
+ *
+ * If SafeDllSearchMode is disabled
+ * - The directory from which the application loaded.
+ * - The current directory.
+ * - The system directory. Use the GetSystemDirectory() function
+ * to get the path of this directory.
+ * - The 16-bit system directory. There is no function that obtains
+ * the path of this directory, but it is searched.
+ * - The Windows directory. Use the GetWindowsDirectory() function
+ * to get the path of this directory.
+ * - The directories that are listed in the PATH environment variable.
+ * Note that this does not include the per-application path specified
+ * by the App Paths registry key.
+ *
+ * Conformity: None.
+ *
+ * Supported OS: Windows Vista, Windows XP or Windows 2000
+ * Professional.
+ *
+ * @ingroup Evil_Dlfcn
+ */
+EAPI void *dlopen(const char* path, int mode);
+
+/**
+ * @brief Close a dynamic-link library.
+ *
+ * @param handle Handle that references a dynamic-link library.
+ * @return O on sucess, -1 otherwise.
+ *
+ * Release a reference to the dynamic-link library referenced
+ * by @p handle. If the reference count drops to 0, the handle is
+ * removed from the address space and is rendered invalid. @p handle
+ * is the value returned by a previous call to dlopen().
+ *
+ * If no error occurred, the returned value is 0, otherwise the
+ * returned value is -1 and an error string can be retrived with
+ * dlerror().
+ *
+ * Conformity: None.
+ *
+ * Supported OS: Windows Vista, Windows XP or Windows 2000
+ * Professional.
+ *
+ * @ingroup Evil_Dlfcn
+ */
+EAPI int dlclose(void* handle);
+
+/**
+ * @brief Get the address of a symbol.
+ *
+ * @param handle Handle that references a dynamic-link library.
+ * @param symbol @c NULL-terminated string.
+ * @return O on sucess, NULL otherwise.
+ *
+ * Return the address of the code or data location specified by the
+ * string @p symbol. @p handle references a library that contains
+ * the function or variable @p symbol.
+ *
+ * If no error occurred, the returned value is the code or data
+ * location, otherwise the returned value is NULL and an error
+ * string can be retrived with dlerror().
+ *
+ * Conformity: None.
+ *
+ * Supported OS: Windows Vista, Windows XP or Windows 2000
+ * Professional.
+ *
+ * @ingroup Evil_Dlfcn
+ */
+EAPI void *dlsym(void* handle, const char* symbol);
+
+#ifdef _GNU_SOURCE
+
+/**
+ * @brief Resolve module and function pointers from the given function
+ * pointer address.
+ *
+ * @param addr A function pointer.
+ * @param info Pointer to the #Dl_info to fill.
+ * @return 1 on success, 0 otherwise.
+ *
+ * Fill @p info with the absolute name of the module which has the
+ * fonction pointer @p addr, the base address of that module, the name
+ * and address of the symbol. If no symbol matching @p addr could be
+ * found (as in an EXE file), then dli_sname and dli_saddr are set to
+ * NULL and the function returns 1. See #Dl_info for more informations.
+ *
+ * This function is available only when _GNU_SOURCE was defined before
+ * including dlfcn.h.
+ *
+ * Conformity: None.
+ *
+ * Supported OS: Windows Vista, Windows XP.
+ *
+ * @ingroup Evil_Dlfcn
+ */
+EAPI int dladdr (const void *addr, Dl_info *info);
+
+#endif /* _GNU_SOURCE */
+
+/**
+ * @brief Get diagnostic information
+ *
+ * @return A @c NULL-terminated string if an error occurred, @c NULL
+ * otherwise.
+ *
+ * Return a @c NULL-terminated character string describing the last
+ * error that occurred on this thread during a call to dlopen(),
+ * dlsym(), or dlclose(). If no such error has occurred, dlerror()
+ * returns a null pointer. At each call to dlerror(), the error
+ * indication is reset. Thus in the case of two calls to dlerror(),
+ * where the second call follows the first immediately, the second
+ * call will always return a null pointer.
+ *
+ * Conformity: None.
+ *
+ * Supported OS: Windows Vista, Windows XP or Windows 2000
+ * Professional.
+ *
+ * @ingroup Evil_Dlfcn
+ */
+EAPI char *dlerror (void);
+
+
+#endif /* __EVIL_DLFCN_H__ */
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string.h>
+#include <locale.h>
+#include <errno.h>
+
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+
+#include "evil_macro.h"
+#include "evil_locale.h"
+
+/*
+ * LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME need at least a buffer
+ * of 9 char each (including NULL char). So we need 2*8 + the trailing NULL
+ * char + '_', so 18 char.
+ */
+static char _evil_locale_buf[18];
+
+char *evil_setlocale(int category, const char *locale)
+{
+ char buf[9];
+ int l1;
+ int l2;
+
+ if (category != LC_MESSAGES)
+ return setlocale(category, locale);
+
+ if (locale != NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ l1 = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME,
+ buf, sizeof(buf));
+ if (!l1) return NULL;
+
+ memcpy(_evil_locale_buf, buf, l1 - 1);
+ _evil_locale_buf[l1 - 1] = '_';
+
+ l2 = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME,
+ buf, sizeof(buf));
+ if (!l2) return NULL;
+
+ memcpy(_evil_locale_buf + l1, buf, l2);
+
+ return _evil_locale_buf;
+}
--- /dev/null
+#ifndef __EVIL_LOCALE_H__
+#define __EVIL_LOCALE_H__
+
+
+/**
+ * @file evil_locale.h
+ * @brief The file that provides functions ported from Unix in locale.h.
+ * @defgroup Evil_Locale_Group locale.h functions.
+ * @ingroup Evil
+ *
+ * This header provides functions ported from Unix in locale.h.
+ *
+ * @{
+ */
+
+
+/**
+ * @def LC_MESSAGES
+ *
+ * New locale value, based on the one in libintl.h
+ *
+ * @since 1.16
+ */
+#ifdef LC_MESSAGES
+# undef LC_MESSAGES
+#endif
+#define LC_MESSAGES 1729
+
+/**
+ * @brief Return the string associated to the given locale and category.
+ *
+ * @param category The category affected by locale.
+ * @param locale The locale specifier.
+ * @return The string associated to the specified locale and category.
+ *
+ * This function returns the string associated to @p locale and
+ * @p category. If @p category is LC_ALL, LC_COLLATE, LC_CTYPE,
+ * LC_MONETARY, LC_NUMERIC or LC_TIME, it just returns the standard
+ * setlocale() function. If @p category is #LC_MESSAGES, then if @p locale
+ * is not @c NULL, errno is set to EINVAL and @c NULL is returned, otherwise
+ * the string <language>_<country> is returned. This string is a static buffer
+ * and must not be freed. It will also be rewritten each time @category is
+ * #LC_MESSAGES and @p locale is @c NULL.
+ *
+ * Conformity: Non applicable.
+ *
+ * Supported OS: Windows XP.
+ *
+ * @since 1.16
+ */
+EAPI char *evil_setlocale(int category, const char *locale);
+
+
+/**
+ * @}
+ */
+
+
+#endif /*__EVIL_LOCALE_H__ */
--- /dev/null
+#ifndef __EVIL_MACRO_WRAPPER_H__
+#define __EVIL_MACRO_WRAPPER_H__
+
+
+/*
+ * evil_inet.h
+ */
+
+#if ! (_WIN32_WINNT >= 0x600 /* _WIN32_WINNT_VISTA */)
+
+/**
+ * @def inet_pton(x,y,z)
+ *
+ * Wrapper around evil_inet_pton().
+ */
+#define inet_pton(x,y,z) evil_inet_pton(x,y,z)
+
+/**
+ * @def inet_ntop(x,y,z,s)
+ *
+ * Wrapper around evil_inet_ntop().
+ */
+#define inet_ntop(x,y,z,s) evil_inet_ntop(x,y,z,s)
+
+
+#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */
+
+/*
+ * evil_locale.h
+ */
+
+/**
+ * @def setlocale(cat, loc)
+ *
+ * Wrapper around evil_setlocale().
+ * @since 1.16
+ */
+#ifdef setlocale /* libintl.h defines setlocale() but always returns "C" */
+# undef setlocale
+#endif
+#define setlocale(cat, loc) evil_setlocale(cat, loc)
+
+/*
+ * evil_stdio.h
+ */
+
+/**
+ * @def rename(src, dest)
+ *
+ * Wrapper around evil_rename().
+ *
+ * @since 1.8
+ */
+#ifdef rename
+# undef rename
+#endif
+#define rename(src, dst) evil_rename(src, dst)
+
+/**
+ * @def mkdir(dirname, mode)
+ *
+ * Wrapper around evil_mkdir().
+ *
+ * @since 1.15
+ */
+#ifdef mkdir
+# undef mkdir
+#endif
+#define mkdir(dirname, mode) evil_mkdir(dirname, mode)
+
+/*
+ * evil_time.h
+ */
+
+/**
+ * @def localtime_r(t, r)
+ *
+ * Wrapper around evil_localtime_r().
+ */
+#ifdef localtime_r
+# undef localtime_r
+#endif
+#define localtime_r(t, r) evil_localtime_r(t, r)
+
+/*
+ * evil_unistd.h
+ */
+
+/**
+ * @def getcwd(b,s)
+ *
+ * Wrapper around evil_getcwd().
+ */
+#ifdef getcwd
+# undef getcwd
+#endif
+#define getcwd(b,s) evil_getcwd((b),(s))
+
+/**
+ * @def pipe(fds)
+ *
+ * Wrapper around evil_pipe().
+ */
+#ifdef pipe
+# undef pipe
+#endif
+#define pipe(fds) evil_pipe(fds)
+
+
+#endif
--- /dev/null
+#ifndef EFL_CHECK_H
+#define EFL_CHECK_H
+
+#include <stdlib.h> /* getenv */
+#include <stdio.h> /* fprintf, fputs */
+#include <string.h> /* strcmp */
+
+typedef struct _Efl_Test_Case Efl_Test_Case;
+struct _Efl_Test_Case
+{
+ const char *test_case;
+ void (*build)(TCase *tc);
+};
+
+static void
+_efl_tests_list(const Efl_Test_Case *etc)
+{
+ const Efl_Test_Case *itr = etc;
+ fputs("Available Test Cases:\n", stderr);
+ for (; itr->test_case; itr++)
+ fprintf(stderr, "\t%s\n", itr->test_case);
+}
+
+static int
+_efl_test_option_disp(int argc, char **argv, const Efl_Test_Case *etc)
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ {
+ if ((strcmp(argv[i], "-h") == 0) ||
+ (strcmp(argv[i], "--help") == 0))
+ {
+ fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
+ argv[0]);
+ _efl_tests_list(etc);
+ return 0;
+ }
+ else if ((strcmp(argv[i], "-l") == 0) ||
+ (strcmp(argv[i], "--list") == 0))
+ {
+ _efl_tests_list(etc);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+static int
+_efl_test_use(int argc, const char **argv, const char *test_case)
+{
+ if (argc < 1)
+ return 1;
+
+ for (; argc > 0; argc--, argv++)
+ if (strcmp(test_case, *argv) == 0)
+ return 1;
+ return 0;
+}
+
+static int
+_efl_test_fork_has(SRunner *sr)
+{
+ if (srunner_fork_status(sr) == CK_FORK)
+ return 1;
+ else if (srunner_fork_status(sr) == CK_NOFORK)
+ return 0;
+ else if (srunner_fork_status(sr) == CK_FORK_GETENV)
+ {
+ char *res;
+
+ res = getenv("CF_FORK");
+ if (res && (strcmp(res, "no") == 0))
+ return 0;
+ else
+ return 1;
+ }
+
+ /* should never get there */
+ return 0;
+}
+
+static int
+_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc)
+{
+ Suite *s;
+ SRunner *sr;
+ TCase *tc;
+ int i, failed_count;
+
+ s = suite_create(suite_name);
+ sr = srunner_create(s);
+
+ for (i = 0; etc[i].test_case; ++i)
+ {
+ if (!_efl_test_use(argc, argv, etc[i].test_case))
+ continue;
+
+ tc = tcase_create(etc[i].test_case);
+
+ if (_efl_test_fork_has(sr))
+ tcase_set_timeout(tc, 0);
+
+ etc[i].build(tc);
+ suite_add_tcase(s, tc);
+ }
+
+ srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
+ srunner_run_all(sr, CK_ENV);
+ failed_count = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return failed_count;
+}
+
+#endif