Enlightenment CVS committal Author : doursse Project : e17 Module : proto/evil
Dir : e17/proto/evil/src/lib Modified Files: Evil.h Makefile.am evil.c Log Message: reviewed by: <delete if not using a buddy> * src/lib/Evil.h: * src/lib/Makefile.am: * src/lib/dlfcn/Makefile.am: * src/lib/dlfcn/dlfcn.c: (get_last_error), (dlopen), (dlsym): * src/lib/evil.c: (evil_char_to_wchar), (evil_wchar_to_char): * src/lib/mman/Makefile.am: * src/lib/mman/mman.c: =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/Evil.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- Evil.h 28 Mar 2008 17:05:16 -0000 1.8 +++ Evil.h 26 Apr 2008 16:27:46 -0000 1.9 @@ -392,6 +392,49 @@ EAPI const char *evil_tmpdir_get(void); +#if defined(__CEGCC__) || defined(__MINGW32CE__) + +/** + * @brief Convert a string from char * to wchar_t *. + * + * @param text The string to convert. + * @return The converted string. + * + * Convert a string from char * to wchar_t * and return it. If the + * allocation or conversion fails, NULL is returned. On success, the + * returned value must be freed. + * + * Conformity: Non applicable. + * + * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, + * Windows XP. + * + * @ingroup Evil + */ +EAPI wchar_t *evil_char_to_wchar(const char *text); + +/** + * @brief Convert a string from wchar_t * to char *. + * + * @param text The string to convert. + * @return The converted string. + * + * Convert a string from wchar_t * to char * and return it. If the + * allocation or conversion fails, NULL is returned. On success, the + * returned value must be freed. + * + * Conformity: Non applicable. + * + * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, + * Windows XP. + * + * @ingroup Evil + */ +EAPI char *evil_wchar_to_char(const wchar_t *text); + +#endif /* __CEGCC__ || __MINGW32CE__ */ + + #ifdef __cplusplus } #endif =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- Makefile.am 22 Apr 2008 22:53:54 -0000 1.2 +++ Makefile.am 26 Apr 2008 16:27:46 -0000 1.3 @@ -1,7 +1,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = dlfcn mman +SUBDIRS = . dlfcn mman lib_LTLIBRARIES = libevil.la @@ -10,5 +10,6 @@ libevil_la_CFLAGS = @win32_cflags@ libevil_la_LIBADD = @win32_libs@ +libevil_la_DEPENDENCIES = $(top_builddir)/config.h libevil_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/evil.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- evil.c 23 Mar 2008 14:51:22 -0000 1.5 +++ evil.c 26 Apr 2008 16:27:46 -0000 1.6 @@ -15,6 +15,10 @@ # include <sys/syslimits.h> #endif /* __CEGCC__ */ +#if defined(__CEGCC__) || defined(__MINGW32CE__) +# include <wchar.h> +#endif /* __CEGCC__ || __MINGW32CE__ */ + #include <sys/types.h> #include <sys/timeb.h> #include <fcntl.h> @@ -391,3 +395,50 @@ return tmpdir; } + + +#if defined(__CEGCC__) || defined(__MINGW32CE__) + +wchar_t * +evil_char_to_wchar(const char *text) +{ + wchar_t *wtext; + int wsize; + + wsize = MultiByteToWideChar(CP_ACP, 0, text, strlen(text) + 1, NULL, 0); + if ((wsize == 0) || + (wsize > (int)(ULONG_MAX/sizeof(wchar_t)))) + return NULL; + + wtext = malloc(wsize * sizeof(wchar_t)); + if (wtext) + if (!MultiByteToWideChar(CP_ACP, 0, text, strlen(text) + 1, wtext, wsize)) + return NULL; + + return wtext; +} + +char * +evil_wchar_to_char(const wchar_t *text) +{ + char * atext; + int size; + int asize; + + size = wcslen(text) + 1; + + asize = WideCharToMultiByte(CP_ACP, 0, text, size, NULL, 0, NULL, NULL); + if (asize == 0) + return NULL; + + atext = (char*)malloc((asize + 1) * sizeof(char)); + + if (atext) + if (!WideCharToMultiByte(CP_ACP, 0, text, size, atext, asize, NULL, NULL)) + return NULL; + atext[asize] = '\0'; + + return atext; +} + +#endif /* __CEGCC__ || __MINGW32CE__ */ ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs