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: * configure.ac: * src/lib/Evil.h: * src/lib/Makefile.am: * src/lib/evil.c: * src/lib/pwd/Makefile.am: * src/lib/pwd/pwd.h: add langinfo and getpwuid support * src/lib/mman/sys/mman.h: * src/lib/dlfcn/dlfcn.h: fix comment =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/Evil.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- Evil.h 11 Jun 2008 21:34:09 -0000 1.19 +++ Evil.h 29 Jun 2008 12:09:47 -0000 1.20 @@ -65,6 +65,8 @@ #include <sys/time.h> #include <limits.h> #include <sys/stat.h> +#include <fcntl.h> +#include <locale.h> #ifdef PATH_MAX # undef PATH_MAX @@ -141,6 +143,7 @@ pid_t l_pid; /**< lock owner */ }; + /** * @brief Provide control over file descriptors. * @@ -523,13 +526,45 @@ EAPI char *evil_last_error_get(void); +typedef int nl_item; -#ifdef _MSC_VER +#define __NL_ITEM( CATEGORY, INDEX ) ((CATEGORY << 16) | INDEX) +#define __NL_ITEM_CATEGORY( ITEM ) (ITEM >> 16) +#define __NL_ITEM_INDEX( ITEM ) (ITEM & 0xffff) + +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 -typedef int pid_t; +EAPI char *nl_langinfo(nl_item index); -typedef long ssize_t; +#ifndef uid_t +typedef unsigned long uid_t; +#endif + +#ifndef gid_t +typedef unsigned long gid_t; +#endif + +#ifdef _MSC_VER + +typedef int pid_t; +typedef long ssize_t; typedef unsigned short mode_t; #define F_OK 0 /* Check for file existence */ @@ -567,6 +602,7 @@ # 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)) =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- Makefile.am 8 Jun 2008 21:39:49 -0000 1.4 +++ Makefile.am 29 Jun 2008 12:09:48 -0000 1.5 @@ -1,7 +1,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = . dlfcn mman +SUBDIRS = . dlfcn mman pwd lib_LTLIBRARIES = libevil.la =================================================================== RCS file: /cvs/e/e17/proto/evil/src/lib/evil.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- evil.c 10 Jun 2008 07:16:53 -0000 1.13 +++ evil.c 29 Jun 2008 12:09:48 -0000 1.14 @@ -36,6 +36,11 @@ #endif /* HAVE___ATTRIBUTE__ */ #include "Evil.h" +#include "pwd/pwd.h" + + +static struct passwd pw; + #ifndef __CEGCC__ @@ -125,6 +130,33 @@ return (pid_t)GetCurrentProcessId(); } +struct passwd * +getpwuid (uid_t uid) +{ + static char user_name[PATH_MAX]; + DWORD length; + BOOL res; + + length = PATH_MAX; + /* get from USERPROFILE for win 98 ? */ + res = GetUserName(user_name, &length); + pw.pw_name = (res ? user_name : NULL); + pw.pw_passwd = NULL; + pw.pw_uid = uid; + pw.pw_gid = 0; + pw.pw_change = 0; + pw.pw_class = NULL; + pw.pw_gecos = (res ? user_name : NULL); + pw.pw_dir = (char *)evil_homedir_get(); + pw.pw_shell = getenv("SHELL"); + if (pw.pw_shell == NULL) + pw.pw_shell = "sh"; + pw.pw_expire = 0; + pw.pw_fields = 0; + + return &pw; +} + /* REMARK: Windows has no symbolic link. */ /* Nevertheless, it can create and read .lnk files */ int @@ -580,4 +612,43 @@ LocalFree(str2); return strdup(str); +} + +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 = 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; } ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs