From ef5ef75eabd3955c1445f115aeb8953a4d2fcbe5 Mon Sep 17 00:00:00 2001 From: doursse Date: Tue, 10 Jun 2008 07:16:53 +0000 Subject: [PATCH] * configure.ac: * src/lib/dlfcn/dlfcn.h: * src/lib/mman/sys/mman.h: define EFL_EVIL_MMAN_BUILD and EFL_EVIL_DLFCN_BUILD so that functions in Evil.h are not declared as import * src/lib/evil.c: (setenv), (unsetenv), (realpath), (evil_sockets_init), (evil_sockets_shutdown), (evil_pipe), (evil_tmpdir_get), (evil_homedir_get): rename pipe() to evil_pipe(). set tmpdir to "Temp" and homedir to "My Documents" on WinCE * src/lib/Evil.h: define pipe() as evil_pipe(). This allow to use our pipe() implementation to be usedwith cegcc, as it is broken on that platform. move the defines at the end of the file SVN revision: 34787 --- legacy/evil/ChangeLog | 20 ++++ legacy/evil/configure.ac | 2 + legacy/evil/src/lib/Evil.h | 112 +++++++++++----------- legacy/evil/src/lib/dlfcn/dlfcn.h | 2 +- legacy/evil/src/lib/evil.c | 138 ++++++++++++++-------------- legacy/evil/src/lib/mman/sys/mman.h | 2 +- 6 files changed, 150 insertions(+), 126 deletions(-) diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog index 4c70e49f01..b96070b5db 100644 --- a/legacy/evil/ChangeLog +++ b/legacy/evil/ChangeLog @@ -1,3 +1,23 @@ +2008-06-10 Vincent Torri + + * configure.ac: + * src/lib/dlfcn/dlfcn.h: + * src/lib/mman/sys/mman.h: + define EFL_EVIL_MMAN_BUILD and EFL_EVIL_DLFCN_BUILD so + that functions in Evil.h are not declared as import + + * src/lib/evil.c: (setenv), (unsetenv), (realpath), + (evil_sockets_init), (evil_sockets_shutdown), (evil_pipe), + (evil_tmpdir_get), (evil_homedir_get): + rename pipe() to evil_pipe(). + set tmpdir to "Temp" and homedir to "My Documents" on WinCE + + * src/lib/Evil.h: + define pipe() as evil_pipe(). This allow to use our pipe() + implementation to be usedwith cegcc, as it is broken on that + platform. + move the defines at the end of the file + 2008-06-09 Vincent Torri * src/lib/Evil.h: diff --git a/legacy/evil/configure.ac b/legacy/evil/configure.ac index dcaf907b82..7da7ba1247 100644 --- a/legacy/evil/configure.ac +++ b/legacy/evil/configure.ac @@ -33,6 +33,8 @@ AC_SUBST(lt_enable_auto_import) dnl needed for correct definition of EAPI AC_DEFINE(EFL_EVIL_BUILD, 1, [Define to mention that evil is built]) +AC_DEFINE(EFL_EVIL_MMAM_BUILD, 1, [Define to mention that evil is built]) +AC_DEFINE(EFL_EVIL_DLFCN_BUILD, 1, [Define to mention that evil is built]) AM_INIT_AUTOMAKE(1.6 dist-bzip2) diff --git a/legacy/evil/src/lib/Evil.h b/legacy/evil/src/lib/Evil.h index 9283748613..d041752b4d 100644 --- a/legacy/evil/src/lib/Evil.h +++ b/legacy/evil/src/lib/Evil.h @@ -286,25 +286,6 @@ EAPI int symlink(const char *oldpath, const char *newpath); */ EAPI ssize_t readlink(const char *path, char *buf, size_t bufsiz); -/** - * @brief Create a pair of sockets. - * - * @param fds A pointer that contains two sockets. - * - * Create a pair of sockets that can be use with select(). - * Hence, evil_sockets_init() must have been caled at least - * once before. Contrary to Unix, that functions does not - * create a pair of file descriptors. - * - * Conformity: Not applicable. - * - * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, - * Windows XP. - * - * @ingroup Evil - */ -EAPI int pipe(int *fds); - /** * @brief Create, modify, or remove environment variables. * @@ -349,42 +330,6 @@ EAPI int unsetenv(const char *name); #endif /* ! __CEGCC__ */ - -#if defined(__MSDOS__) || defined(__EMX__) || \ - (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__) && !defined(__CEGCC__)) -# if defined(_MSC_VER) || defined(__MINGW32__) - -# ifdef S_ISDIR -# undef S_ISDIR -# endif -# ifdef S_ISREG -# undef S_ISREG -# endif -# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) -# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) - -# define S_IRUSR _S_IRUSR -# define S_IWUSR _S_IWUSR -# define S_IXUSR _S_IXUSR -# define S_IRGRP S_IRUSR -# define S_IROTH S_IRUSR -# define S_IWGRP S_IWUSR -# define S_IWOTH S_IWUSR -# define S_IXGRP S_IXUSR -# define S_IXOTH S_IXUSR -# define open(path,...) _open((path),__VA_ARGS__) -# define close(fd) _close(fd) -# define read(fd,buffer,count) _read((fd),(buffer),(count)) -# define write(fd,buffer,count) _write((fd),(buffer),(count)) -# define unlink(filename) _unlink((filename)) -# define mkdir(p,m) _mkdir(p) -# define getcwd(b,s) _getcwd((b),(s)) -# define lstat(f,s) _stat((f),(s)) -# define strdup(s) _strdup(s) - -# endif -#endif - /** * @brief Return an absolute or full path name for a specified relative path name. * @@ -442,6 +387,25 @@ EAPI int evil_sockets_init(void); */ EAPI void evil_sockets_shutdown(void); +/** + * @brief Create a pair of sockets. + * + * @param fds A pointer that contains two sockets. + * + * Create a pair of sockets that can be use with select(). + * Hence, evil_sockets_init() must have been caled at least + * once before. Contrary to Unix, that functions does not + * create a pair of file descriptors. + * + * Conformity: Not applicable. + * + * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, + * Windows XP. + * + * @ingroup Evil + */ +EAPI int evil_pipe(int *fds); + /** * @brief Return a dir to store temporary files. * @@ -563,6 +527,44 @@ EAPI char *evil_wchar_to_char(const wchar_t *text); EAPI char *evil_last_error_get(void); +#if defined(__MSDOS__) || defined(__EMX__) || \ + (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__) && !defined(__CEGCC__)) +# if defined(_MSC_VER) || defined(__MINGW32__) + +# ifdef S_ISDIR +# undef S_ISDIR +# endif +# ifdef S_ISREG +# undef S_ISREG +# endif +# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) + +# define S_IRUSR _S_IRUSR +# define S_IWUSR _S_IWUSR +# define S_IXUSR _S_IXUSR +# define S_IRGRP S_IRUSR +# define S_IROTH S_IRUSR +# define S_IWGRP S_IWUSR +# define S_IWOTH S_IWUSR +# define S_IXGRP S_IXUSR +# define S_IXOTH S_IXUSR +# define open(path,...) _open((path),__VA_ARGS__) +# define close(fd) _close(fd) +# define read(fd,buffer,count) _read((fd),(buffer),(count)) +# define write(fd,buffer,count) _write((fd),(buffer),(count)) +# define unlink(filename) _unlink((filename)) +# define mkdir(p,m) _mkdir(p) +# define getcwd(b,s) _getcwd((b),(s)) +# define lstat(f,s) _stat((f),(s)) +# define strdup(s) _strdup(s) + +# endif +#endif + +#define pipe(fd) evil_pipe(fd) + + #ifdef __cplusplus } #endif diff --git a/legacy/evil/src/lib/dlfcn/dlfcn.h b/legacy/evil/src/lib/dlfcn/dlfcn.h index 7a15ba7ec3..bf5a82f311 100644 --- a/legacy/evil/src/lib/dlfcn/dlfcn.h +++ b/legacy/evil/src/lib/dlfcn/dlfcn.h @@ -14,7 +14,7 @@ #endif /* EAPI */ #ifdef _WIN32 -# ifdef EFL_EVIL_BUILD +# ifdef EFL_EVIL_DLFCN_BUILD # ifdef DLL_EXPORT # define EAPI __declspec(dllexport) # else diff --git a/legacy/evil/src/lib/evil.c b/legacy/evil/src/lib/evil.c index 9ebf3b9f0c..e1bb61c807 100644 --- a/legacy/evil/src/lib/evil.c +++ b/legacy/evil/src/lib/evil.c @@ -245,12 +245,78 @@ readlink(const char *path, char *buf, size_t bufsiz) return -1; } +int +setenv(const char *name, const char *value) +{ + char *str; + int length; + int res; + + length = strlen(name) + strlen(value) + 2; + str = (char *)malloc(length); + sprintf(str, "%s=%s", name, value); + res = _putenv(str); + free(str); + + return res; +} + +int +unsetenv(const char *name) +{ + char *str; + int length; + int res; + + length = strlen(name) + 2; + str = (char *)malloc(length); + sprintf(str, "%s=", name); + res = _putenv(str); + free(str); + + return res; +} + +#endif /* ! __CEGCC__ */ + +char * +realpath(const char *file_name, char *resolved_name) +{ +#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) ) + return _fullpath(resolved_name, file_name, PATH_MAX); +#else + int length; + + length = strlen(file_name); + if ((length + 1) > PATH_MAX) + length = PATH_MAX - 1; + memcpy(resolved_name, file_name, length); + resolved_name[length] = '\0'; + + return resolved_name; +#endif /* __CEGCC__ || __MINGW32CE__ */ +} + +int +evil_sockets_init(void) +{ + WSADATA wsa_data; + + return (WSAStartup(MAKEWORD( 2, 2 ), &wsa_data) == 0) ? 1 : 0; +} + +void +evil_sockets_shutdown(void) +{ + WSACleanup(); +} + /* * The code of the following functions has been kindly offered * by Tor Lillqvist. */ int -pipe(int *fds) +evil_pipe(int *fds) { struct sockaddr_in saddr; struct timeval tv; @@ -355,77 +421,11 @@ pipe(int *fds) return -1; } -int -setenv(const char *name, const char *value) -{ - char *str; - int length; - int res; - - length = strlen(name) + strlen(value) + 2; - str = (char *)malloc(length); - sprintf(str, "%s=%s", name, value); - res = _putenv(str); - free(str); - - return res; -} - -int -unsetenv(const char *name) -{ - char *str; - int length; - int res; - - length = strlen(name) + 2; - str = (char *)malloc(length); - sprintf(str, "%s=", name); - res = _putenv(str); - free(str); - - return res; -} - -#endif /* ! __CEGCC__ */ - -char * -realpath(const char *file_name, char *resolved_name) -{ -#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) ) - return _fullpath(resolved_name, file_name, PATH_MAX); -#else - int length; - - length = strlen(file_name); - if ((length + 1) > PATH_MAX) - length = PATH_MAX - 1; - memcpy(resolved_name, file_name, length); - resolved_name[length] = '\0'; - - return resolved_name; -#endif /* __CEGCC__ || __MINGW32CE__ */ -} - -int -evil_sockets_init(void) -{ - WSADATA wsa_data; - - return (WSAStartup(MAKEWORD( 2, 2 ), &wsa_data) == 0) ? 1 : 0; -} - -void -evil_sockets_shutdown(void) -{ - WSACleanup(); -} - const char * evil_tmpdir_get(void) { #ifdef _WIN32_WCE - return "\\windows"; + return "\\temp"; #else char *tmpdir; @@ -443,7 +443,7 @@ const char * evil_homedir_get(void) { #ifdef _WIN32_WCE - return "\\windows"; + return "\\my documents"; #else char *homedir; diff --git a/legacy/evil/src/lib/mman/sys/mman.h b/legacy/evil/src/lib/mman/sys/mman.h index 12df1f6d3e..a918e8ebaf 100644 --- a/legacy/evil/src/lib/mman/sys/mman.h +++ b/legacy/evil/src/lib/mman/sys/mman.h @@ -7,7 +7,7 @@ #endif /* EAPI */ #ifdef _WIN32 -# ifdef EFL_EVIL_BUILD +# ifdef EFL_EVIL_MMAN_BUILD # ifdef DLL_EXPORT # define EAPI __declspec(dllexport) # else