* configure.ac:

add a flag to know if cegcc is used or not
	* src/lib/Makefile.am:
	* src/lib/dirent.h:
	* src/lib/evil_dirent.c:
	add opendir(), closedir() and readdir() implementations
	for Windows XP and CE. Now, the evas engines are correctly
	found.
	* src/lib/fnmatch.h:
	formatting



SVN revision: 37376
This commit is contained in:
Vincent Torri 2008-11-01 17:07:41 +00:00
parent 437c220266
commit 9efc8ecf79
6 changed files with 284 additions and 4 deletions

View File

@ -1,3 +1,18 @@
2008-11-01 Vincent Torri <doursse at users dot sf dot net>
* configure.ac:
add a flag to know if cegcc is used or not
* src/lib/Makefile.am:
* src/lib/dirent.h:
* src/lib/evil_dirent.c:
add opendir(), closedir() and readdir() implementations
for Windows XP and CE. Now, the evas engines are correctly
found.
* src/lib/fnmatch.h:
formatting
2008-11-01 Vincent Torri <doursse at users dot sf dot net>
* configure.ac:

View File

@ -78,9 +78,11 @@ win32_cppflags="-DEFL_EVIL_BUILD"
win32_cflags=""
have_wince="no"
have_mingw32ce="no"
have_cegcc="no"
case "$host_os" in
cegcc*)
have_wince="yes"
have_cegcc="yes"
win32_cflags="-mwin32"
win32_cppflags="${win32_cppflags} -D_WIN32_WCE=0x0420"
;;
@ -99,6 +101,7 @@ AC_SUBST(win32_cflags)
AM_CONDITIONAL(EVIL_HAVE_WINCE, test "x${have_wince}" = "xyes")
AM_CONDITIONAL(EVIL_HAVE_MINGW32CE, test "x${have_mingw32ce}" = "xyes")
AM_CONDITIONAL(EVIL_HAVE_CEGCC, test "x${have_cegcc}" = "xyes")
### Checks for linker characteristics

View File

@ -23,6 +23,12 @@ nobase_include_HEADERS += fnmatch.h errno.h
endif
if ! EVIL_HAVE_CEGCC
nobase_include_HEADERS += dirent.h
endif
libevil_la_SOURCES = \
evil_errno.c \
evil_fcntl.c \
@ -39,6 +45,12 @@ evil_unistd.c \
evil_util.c \
evil_uuid.c
if ! EVIL_HAVE_CEGCC
libevil_la_SOURCES += evil_dirent.c
endif
if EVIL_HAVE_WINCE
libevil_la_SOURCES += evil_link_ce.c
@ -51,7 +63,7 @@ endif
libevil_la_CPPFLAGS = @win32_cppflags@
libevil_la_CFLAGS = @win32_cflags@
libevil_la_CXXFLAGS = -fno-exceptions
libevil_la_CXXFLAGS = -fno-rtti -fno-exceptions
libevil_la_LIBADD = @win32_libs@ $(EFL_MPATROL_LIBS)
libevil_la_LDFLAGS = -no-undefined -Wl,--enable-auto-import -version-info @version_info@

View File

@ -0,0 +1,52 @@
#ifndef __EVIL_DIRENT_H__
#define __EVIL_DIRENT_H__
#ifdef EAPI
# undef EAPI
#endif /* EAPI */
#ifdef _WIN32
# ifdef EFL_EVIL_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EVIL_BUILD */
#endif /* _WIN32 */
#ifdef UNICODE
# include <wchar.h>
#endif
typedef struct DIR DIR;
struct dirent
{
char d_name[260 + 1];
int d_mode;
};
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
EAPI DIR *opendir(char const *name);
EAPI int closedir(DIR *dir);
EAPI struct dirent *readdir(DIR *dir);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __EVIL_DIRENT_H__ */

View File

@ -0,0 +1,198 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <dirent.h>
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#include "Evil.h"
struct DIR
{
struct dirent dirent;
WIN32_FIND_DATA data;
HANDLE handle;
};
#if defined (_MSC_VER) || \
(defined (_WIN32_WCE) && ! defined (__CEGCC__))
DIR *opendir(char const *name)
{
DIR *dir;
char *tmp1;
char *tmp2;
DWORD attr;
int l;
#ifdef UNICODE
wchar_t *wname;
char *d_name;
#endif
/* valid name */
if (!name || !*name)
{
#ifdef HAVE_ERRNO_H
errno = ENOENT;
#endif
return NULL;
}
#ifdef UNICODE
wname = evil_char_to_wchar(name);
if (!wname)
{
#ifdef HAVE_ERRNO_H
errno = ENOMEM;
#endif
return NULL;
}
if((attr = GetFileAttributes(wname)) == 0xFFFFFFFF)
#else
if((attr = GetFileAttributes(name)) == 0xFFFFFFFF)
#endif
{
#ifdef HAVE_ERRNO_H
errno = ENOENT;
#endif
return NULL;
}
#ifdef UNICODE
free(wname);
#endif
/* directory */
if (attr != FILE_ATTRIBUTE_DIRECTORY)
{
#ifdef HAVE_ERRNO_H
errno = ENOTDIR;
#endif
return NULL;
}
dir = (DIR *)malloc(sizeof(DIR));
if (!dir)
{
#ifdef HAVE_ERRNO_H
errno = ENOMEM;
#endif
return NULL;
}
l = strlen(name);
tmp1 = (char *)malloc(sizeof(char) * l + 5);
if (!tmp1)
{
#ifdef HAVE_ERRNO_H
errno = ENOMEM;
#endif
return NULL;
}
memcpy(tmp1, name, l);
memcpy(tmp1 + l, "\\*.*", 5);
tmp2 = tmp1;
while (*tmp2)
{
if (*tmp2 == '/') *tmp2 = '\\';
tmp2++;
}
#ifdef UNICODE
wname = evil_char_to_wchar(tmp1);
if (!wname)
{
#ifdef HAVE_ERRNO_H
errno = ENOMEM;
#endif
free(tmp1);
return NULL;
}
dir->handle = FindFirstFile(wname, &dir->data);
free(wname);
#else
dir->handle = FindFirstFile(tmp1, &dir->data);
#endif
free(tmp1);
if (dir->handle == INVALID_HANDLE_VALUE)
{
free(dir);
return NULL;
}
#ifdef UNICODE
d_name = evil_wchar_to_char(dir->data.cFileName);
strcpy(dir->dirent.d_name, d_name);
free(d_name);
#else
strcpy(dir->dirent.d_name, dir->data.cFileName);
#endif
dir->dirent.d_mode = (int)dir->data.dwFileAttributes;
return dir;
}
int closedir(DIR *dir)
{
if (!dir)
{
#ifdef HAVE_ERRNO_H
errno = EBADF;
#endif
return -1;
}
if (dir->handle != INVALID_HANDLE_VALUE)
FindClose(dir->handle);
free(dir);
return 0;
}
struct dirent *readdir(DIR *dir)
{
#ifdef UNICODE
char *d_name;
#endif
if (!dir)
{
#ifdef HAVE_ERRNO_H
errno = EBADF;
#endif
return NULL;
}
if (dir->handle == INVALID_HANDLE_VALUE)
return NULL;
#ifdef UNICODE
d_name = evil_wchar_to_char(dir->data.cFileName);
strcpy(dir->dirent.d_name, d_name);
free(d_name);
#else
strcpy(dir->dirent.d_name, dir->data.cFileName);
#endif
if (!FindNextFile(dir->handle, &dir->data))
{
FindClose(dir->handle);
dir->handle = INVALID_HANDLE_VALUE;
}
return &dir->dirent;
}
#endif /* _MSC_VER || ( _WIN32_WCE && ! __CEGCC__ ) */

View File

@ -1,5 +1,5 @@
#ifndef _FNMATCH_H
#define _FNMATCH_H
#ifndef __EVIL_FNMATCH_H__
#define __EVIL_FNMATCH_H__
#ifdef EAPI
# undef EAPI
@ -51,4 +51,4 @@ EAPI int fnmatch(const char *__pattern, const char *__string, int __flags);
}
#endif
#endif /* _FNMATCH_H */
#endif /* __EVIL_FNMATCH_H__ */