Enlightenment CVS committal Author : doursse Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: Makefile.am ewl_base.h ewl_config.c ewl_engines.c ewl_entry.c ewl_filelist.c ewl_private.h ewl_theme.c Log Message: add opengl engine for Windows =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v retrieving revision 1.57 retrieving revision 1.58 diff -u -3 -r1.57 -r1.58 --- Makefile.am 14 Nov 2007 21:55:30 -0000 1.57 +++ Makefile.am 16 Nov 2007 18:50:57 -0000 1.58 @@ -196,4 +196,4 @@ installed_headers_DATA = $(EWLHEADERS) libewl_la_LIBADD = @EMOTION_LIBS@ @EPSILON_LIBS@ @EFREET_LIBS@ @EDJE_LIBS@ @ECORE_LIBS@ @EVAS_LIBS@ -lm -libewl_la_LDFLAGS = -version-info @INTERFACE_VERSION@ +libewl_la_LDFLAGS = @create_shared_lib@ -version-info @INTERFACE_VERSION@ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_base.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- ewl_base.h 12 Feb 2007 13:16:04 -0000 1.2 +++ ewl_base.h 16 Nov 2007 18:50:57 -0000 1.3 @@ -9,6 +9,13 @@ #include <Ecore.h> #include <Ecore_Data.h> +/* typedef to allow inclusion of ewl_filelist.h */ +/* and ewl_filelist_model.h on Windows */ +#ifdef _WIN32 +typedef unsigned long uid_t; +typedef unsigned long gid_t; +#endif /* _WIN32 */ + #include <ewl_enums.h> #include <ewl_object.h> #include <ewl_widget.h> =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_config.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- ewl_config.c 14 Nov 2007 06:44:04 -0000 1.33 +++ ewl_config.c 16 Nov 2007 18:50:57 -0000 1.34 @@ -5,10 +5,17 @@ #include "ewl_debug.h" #include <Evas.h> -#include <ctype.h> -#include <fcntl.h> +#if HAVE_FCNTL_H +# include <fcntl.h> +#endif /* HAVE_FCNTL_H */ #include <libgen.h> +#ifdef _WIN32 +# include <io.h> +# include <share.h> +# include <sys/locking.h> +#endif /* _WIN32 */ + Ewl_Config *ewl_config = NULL; Ewl_Config_Cache ewl_config_cache; @@ -21,6 +28,9 @@ extern Ecore_List *ewl_embed_list; +static int ewl_config_file_read_lock(int fd, long size); +static int ewl_config_file_write_lock(int fd, long size); +static int ewl_config_file_unlock(int fd, long size); static int ewl_config_load(Ewl_Config *cfg); static int ewl_config_file_load(Ewl_Config *cfg, unsigned int is_system, const char *file); @@ -447,11 +457,68 @@ } static int +ewl_config_file_read_lock(int fd, long size) +{ +#if defined(F_SETLKW) + struct flock fl; + + fl.l_type = F_RDLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + + return (fcntl(fd, F_SETLKW, &fl) == 0); +#else +# if HAVE__LOCKING + return (_locking(fd, _LK_LOCK, size) == 0); +# endif /* HAVE__LOCKING */ +#endif /* !defined(F_SETLKW) */ +} + +static int +ewl_config_file_write_lock(int fd, long size) +{ +#if defined(F_SETLKW) + struct flock fl; + + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + + return (fcntl(fd, F_SETLKW, &fl) == 0); +#else +# if HAVE__LOCKING + return (_locking(fd, _LK_LOCK, size) == 0); +# endif /* HAVE__LOCKING */ +#endif /* !defined(F_SETLKW) */ +} + +static int +ewl_config_file_unlock(int fd, long size) +{ +#if defined(F_SETLKW) + struct flock fl; + + fl.l_type = F_UNLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + + return (fcntl(fd, F_SETLK, &fl) == 0); +#else +# if HAVE__LOCKING + return (_locking(fd, _LK_UNLCK, size) == 0); +# endif /* HAVE__LOCKING */ +#endif /* !defined(F_SETLKW) */ +} + +static int ewl_config_save(Ewl_Config *cfg, Ecore_Hash *hash, const char *file) { Ecore_List *keys; char *key, data[512], *path; - struct flock fl; + long size; int fd; DENTER_FUNCTION(DLEVEL_STABLE); @@ -472,20 +539,25 @@ if (!hash) DRETURN_INT(TRUE, DLEVEL_STABLE); +#ifndef _WIN32 fd = open(file, O_CREAT | O_WRONLY | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH); +#else +# ifdef __MINGW32__ + fd = _sopen(file, O_CREAT | O_WRONLY | O_TRUNC, _SH_DENYRD, S_IRWXU); +# else + _sopen_s(&fd, file, O_CREAT | O_WRONLY | O_TRUNC, _SH_DENYRD, S_IRWXU); +# endif /* __MINGW32 */ +#endif /* _WIN32 */ if (fd == -1) { DWARNING("Unable to open cfg file %s.", file); DRETURN_INT(FALSE, DLEVEL_STABLE); } - fl.l_type = F_WRLCK; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; + size = ecore_file_size(file); - if (fcntl(fd, F_SETLKW, &fl) == -1) + if (!ewl_config_file_write_lock(fd, size)) { DWARNING("Unable to lock %s for write.", file); close(fd); @@ -506,8 +578,7 @@ } /* release the lock */ - fl.l_type = F_UNLCK; - fcntl(fd, F_SETLK, &fl); + ewl_config_file_unlock(fd, size); close(fd); DRETURN_INT(TRUE, DLEVEL_STABLE); @@ -780,9 +851,8 @@ { Ecore_Hash *hash; int fd; + long size; char *data; - struct flock fl; - struct stat buf; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(cfg, FALSE); @@ -792,19 +862,24 @@ if (!ecore_file_exists(file)) DRETURN_INT(FALSE, DLEVEL_STABLE); +#ifndef _WIN32 fd = open(file, O_RDONLY, S_IRUSR); +#else +# ifdef __MINGW32__ + fd = _sopen(file, O_RDONLY, _SH_DENYWR, S_IRUSR); +# else + _sopen_s(&fd, file, O_RDONLY, _SH_DENYWR, S_IRUSR); +# endif /* __MINGW32 */ +#endif /* _WIN32 */ if (fd == -1) { DWARNING("Unable to open cfg file %s.", file); DRETURN_INT(FALSE, DLEVEL_STABLE); } - fl.l_type = F_RDLCK; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; + size = ecore_file_size(file); - if (fcntl(fd, F_SETLKW, &fl) == -1) + if (!ewl_config_file_read_lock(fd, size)) { DWARNING("Unable to lock %s for read.", file); @@ -817,14 +892,12 @@ * XXX we may want to do this in chunks as the config could be * large ... */ - stat(file, &buf); - data = malloc(sizeof(char) * (buf.st_size + 1)); - read(fd, data, buf.st_size); - data[buf.st_size] = '\0'; + data = malloc(sizeof(char) * (size + 1)); + read(fd, data, size); + data[size] = '\0'; /* release the lock as the file is in memory */ - fl.l_type = F_UNLCK; - fcntl(fd, F_SETLK, &fl); + ewl_config_file_unlock(fd, size); close(fd); /* create the hash to store the values */ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_engines.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -3 -r1.52 -r1.53 --- ewl_engines.c 12 Nov 2007 22:42:22 -0000 1.52 +++ ewl_engines.c 16 Nov 2007 18:50:57 -0000 1.53 @@ -6,6 +6,12 @@ #define EWL_ENGINE_DIR "engines" +#ifdef _WIN32 +# define EWL_ENGINE_EXT ".dll" +#else +# define EWL_ENGINE_EXT ".so" +#endif /* _WIN32 */ + enum Ewl_Engine_Hook_Type { EWL_ENGINE_HOOK_TYPE_WINDOW, @@ -96,7 +102,7 @@ { char *lastext; lastext = strrchr(file, '.'); - if (!strncmp(lastext, ".so", 3) && ext == lastext) { + if (!strncmp(lastext, EWL_ENGINE_EXT, strlen(EWL_ENGINE_EXT)) && ext == lastext) { *ext = '\0'; ecore_list_append(names, strdup(file)); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_entry.c,v retrieving revision 1.80 retrieving revision 1.81 diff -u -3 -r1.80 -r1.81 --- ewl_entry.c 12 Nov 2007 22:42:22 -0000 1.80 +++ ewl_entry.c 16 Nov 2007 18:50:57 -0000 1.81 @@ -3,11 +3,85 @@ #include "ewl_entry.h" #include "ewl_text_trigger.h" #include <Ecore_Txt.h> -#include <langinfo.h> #include "ewl_macros.h" #include "ewl_private.h" +#if HAVE_LANGINFO_H +# include <langinfo.h> +#endif /* HAVE_LANGINFO_H */ #include "ewl_debug.h" +#ifdef _WIN32 +# include <locale.h> + +typedef int nl_item; +# define __NL_ITEM( CATEGORY, INDEX ) ((CATEGORY << 16) | INDEX) + +# define __NL_ITEM_CATEGORY( ITEM ) (ITEM >> 16) +# define __NL_ITEM_INDEX( ITEM ) (ITEM & 0xffff) + +/* + * Enumerate the item classification indices... + * + */ +enum { + /* + * LC_CTYPE category... + * Character set classification items. + * + */ + _NL_CTYPE_CODESET = __NL_ITEM( LC_CTYPE, 0 ), + + /* + * Dummy entry, to terminate the list. + * + */ + _NL_ITEM_CLASSIFICATION_END +}; + +/* + * Define the public aliases for the enumerated classification indices... + * + */ +# define CODESET _NL_CTYPE_CODESET + +static char *replace( char *prev, char *value ) +{ + if( value == NULL ) + return prev; + + if( prev ) + free( prev ); + return strdup( value ); +} + +char *nl_langinfo( nl_item index ) +{ + // static char result[128]; + static char *result = NULL; + static char *nothing = ""; + + switch( index ) + { + case CODESET: + { + char *p; + result = replace( result, setlocale( LC_CTYPE, NULL )); + if( (p = strrchr( result, '.' )) == NULL ) + return nothing; + + if( (++p - result) > 2 ) + strcpy( result, "cp" ); + else + *result = '\0'; + strcat( result, p ); + return result; + } + } + return nothing; +} + +#endif /* _WIN32 */ + /** * @return Returns a new Ewl_Widget on success or NULL on failure * @brief Create and return a new Ewl_Entry widget @@ -836,4 +910,3 @@ DRETURN_INT(ewl_text_cursor_position_get(EWL_TEXT(c->parent)), DLEVEL_STABLE); } - =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -3 -r1.39 -r1.40 --- ewl_filelist.c 15 Nov 2007 18:11:29 -0000 1.39 +++ ewl_filelist.c 16 Nov 2007 18:50:57 -0000 1.40 @@ -603,6 +603,7 @@ if ((S_IWUSR & st_mode) == S_IWUSR) perm[1] = 'w'; if ((S_IXUSR & st_mode) == S_IXUSR) perm[2] = 'x'; +#ifndef _WIN32 if ((S_IRGRP & st_mode) == S_IRGRP) perm[3] = 'r'; if ((S_IWGRP & st_mode) == S_IWGRP) perm[4] = 'w'; if ((S_IXGRP & st_mode) == S_IXGRP) perm[5] = 'x'; @@ -610,12 +611,14 @@ if ((S_IROTH & st_mode) == S_IROTH) perm[6] = 'r'; if ((S_IWOTH & st_mode) == S_IWOTH) perm[7] = 'w'; if ((S_IXOTH & st_mode) == S_IXOTH) perm[8] = 'x'; +#endif /* _WIN32 */ DRETURN_PTR(perm, DLEVEL_STABLE); } /** - * @param st_uid: The userid to lookup + * @param st_uid: The userid to lookup. On Windows, this parameter + * should be unused. * @return Returns the user name for the given user id * @brief Convertes the given user id into the approriate user name */ @@ -623,14 +626,43 @@ ewl_filelist_username_get(uid_t st_uid) { char name[PATH_MAX]; - struct passwd *pwd; +#ifdef HAVE_PWD_H + struct passwd *pwd = NULL; +#else +# ifdef _WIN32 + char *homedir; +# endif /* _WIN32 */ +#endif /* HAVE_PWD_H */ DENTER_FUNCTION(DLEVEL_STABLE); +#ifdef HAVE_PWD_H pwd = getpwuid(st_uid); if (pwd) snprintf(name, PATH_MAX, "%s", pwd->pw_name); else +#else +# ifdef _WIN32 + /* we are on Windows, so we get the user name from */ + /* the environment variable HOME or USERPROFILE */ + homedir = getenv("HOME"); + if (!homedir) + homedir = getenv("USERPROFILE"); + if (homedir) + { + char *p; + p = homedir; + while (p) + { + if (*p == '\\') *p = '/'; + p++; + } + p = strrchr(homedir, '/'); + snprintf(name, PATH_MAX, "%s", p); + } + else +# endif /* _WIN32 */ +#endif /* HAVE_PWD_H */ snprintf(name, PATH_MAX, "%-8d", (int)st_uid); DRETURN_PTR(strdup(name), DLEVEL_STABLE); @@ -645,14 +677,18 @@ ewl_filelist_groupname_get(gid_t st_gid) { char name[PATH_MAX]; +#ifdef HAVE_GRP_H struct group *grp; +#endif /* HAVE_GRP_H */ DENTER_FUNCTION(DLEVEL_STABLE); +#ifdef HAVE_GRP_H grp = getgrgid(st_gid); if (grp) snprintf(name, PATH_MAX, "%s", grp->gr_name); else +#endif /* HAVE_GRP_H */ snprintf(name, PATH_MAX, "%-8d", (int)st_gid); DRETURN_PTR(strdup(name), DLEVEL_STABLE); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_private.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_private.h 20 Jul 2007 13:54:07 -0000 1.21 +++ ewl_private.h 16 Nov 2007 18:50:57 -0000 1.22 @@ -5,6 +5,10 @@ #include <Ecore_Str.h> #include <Ecore_File.h> +#ifdef HAVE_CONFIG_H +#include "ewl-config.h" +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -17,16 +21,28 @@ #include <assert.h> #include <time.h> #include <fnmatch.h> -#include <pwd.h> -#include <grp.h> -#include <langinfo.h> - -#ifdef HAVE_CONFIG_H -#include "ewl-config.h" -#endif +#if HAVE_PWD_H +# include <pwd.h> +#endif /* HAVE_PWD_H */ +#if HAVE_GRP_H +# include <grp.h> +#endif /* HAVE_GRP_H */ #ifdef HAVE_ALLOCA_H -#include <alloca.h> +# include <alloca.h> +#elif defined __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#elif defined _MSC_VER +# include <malloc.h> +# define alloca _alloca +#else +# include <stddef.h> +# ifdef __cplusplus +extern "C" +# endif +void *alloca (size_t); #endif #ifndef PATH_MAX =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_theme.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -3 -r1.47 -r1.48 --- ewl_theme.c 12 Nov 2007 22:42:22 -0000 1.47 +++ ewl_theme.c 16 Nov 2007 18:50:57 -0000 1.48 @@ -236,7 +236,11 @@ /* * Convert a relative path to an absolute path */ +#ifndef _WIN32 if (*data != '/') { +#else + if (*(data + 1) != ':') { +#endif /* _WIN32 */ char path[PATH_MAX]; snprintf(path, PATH_MAX, "%s/%s", ewl_theme_path, data); ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs