* 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


SVN revision: 34942
This commit is contained in:
doursse 2008-06-29 12:09:48 +00:00 committed by doursse
parent d6b97fd852
commit 6aba69be2f
9 changed files with 190 additions and 9 deletions

View File

@ -1,3 +1,17 @@
2008-06-29 Vincent Torri <doursse at users dot sf dot net>
* 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
2008-06-11 Vincent Torri <doursse at users dot sf dot net>
* src/lib/Evil.h:

View File

@ -33,8 +33,9 @@ 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])
AC_DEFINE(EFL_EVIL_MMAN_BUILD, 1, [Define to mention that evil mman is built])
AC_DEFINE(EFL_EVIL_DLFCN_BUILD, 1, [Define to mention that evil dlfcn is built])
AC_DEFINE(EFL_EVIL_PWD_BUILD, 1, [Define to mention that evil pwd is built])
AM_INIT_AUTOMAKE(1.6 dist-bzip2)
@ -79,6 +80,7 @@ src/bin/Makefile
src/lib/Makefile
src/lib/dlfcn/Makefile
src/lib/mman/Makefile
src/lib/pwd/Makefile
])
AC_OUTPUT

View File

@ -65,6 +65,8 @@ extern "C" {
#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 @@ struct flock
pid_t l_pid; /**< lock owner */
};
/**
* @brief Provide control over file descriptors.
*
@ -523,13 +526,45 @@ EAPI char *evil_wchar_to_char(const wchar_t *text);
EAPI char *evil_last_error_get(void);
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)
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
EAPI char *nl_langinfo(nl_item index);
#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 int pid_t;
typedef long ssize_t;
typedef unsigned short mode_t;
#define F_OK 0 /* Check for file existence */
@ -567,6 +602,7 @@ typedef unsigned short mode_t;
# 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))

View File

@ -1,7 +1,7 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = . dlfcn mman
SUBDIRS = . dlfcn mman pwd
lib_LTLIBRARIES = libevil.la

View File

@ -22,7 +22,7 @@
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EVIL_BUILD */
# endif /* ! EFL_EVIL_DLFCN_BUILD */
#endif /* _WIN32 */

View File

@ -36,6 +36,11 @@
#endif /* HAVE___ATTRIBUTE__ */
#include "Evil.h"
#include "pwd/pwd.h"
static struct passwd pw;
#ifndef __CEGCC__
@ -125,6 +130,33 @@ getpid(void)
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
@ -581,3 +613,42 @@ evil_last_error_get(void)
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;
}

View File

@ -15,7 +15,7 @@
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EVIL_BUILD */
# endif /* ! EFL_EVIL_MMAN_BUILD */
#endif /* _WIN32 */
#ifdef __cplusplus

View File

@ -0,0 +1,4 @@
MAINTAINERCLEANFILES = Makefile.in
include_HEADERS = pwd.h

View File

@ -0,0 +1,54 @@
#ifndef __EVIL_PWD_H__
#define __EVIL_PWD_H__
#include <time.h>
#include <Evil.h>
#ifdef EAPI
# undef EAPI
#endif /* EAPI */
#ifdef _WIN32
# ifdef EFL_EVIL_PWD_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EVIL_PWD_BUILD */
#endif /* _WIN32 */
#ifdef __cplusplus
extern "C" {
#endif
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* encrypted password */
uid_t pw_uid; /* user uid */
gid_t pw_gid; /* user gid */
time_t pw_change; /* password change time */
char *pw_class; /* user access class */
char *pw_gecos; /* Honeywell login info */
char *pw_dir; /* home directory */
char *pw_shell; /* default shell */
time_t pw_expire; /* account expiration */
int pw_fields; /* internal: fields filled in */
};
EAPI struct passwd * getpwuid (uid_t uid);
#ifdef __cplusplus
}
#endif
#endif /* __EVIL_PWD_H__ */