forked from enlightenment/efl
Summary: remove pwd code in Evil Test Plan: compilation Reviewers: zmike, cedric, raster Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9420devs/bu5hm4n/work_travis
parent
04848c98f2
commit
a6ade14c5e
28 changed files with 89 additions and 175 deletions
@ -1,69 +0,0 @@ |
||||
#ifdef HAVE_CONFIG_H |
||||
# include "config.h" |
||||
#endif /* HAVE_CONFIG_H */ |
||||
|
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
|
||||
#define _POSIX |
||||
#include <io.h> |
||||
#include <lmcons.h> |
||||
|
||||
#include "evil_private.h" |
||||
#include "pwd.h" |
||||
|
||||
|
||||
static struct passwd pw = { NULL, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, 0, 0 }; |
||||
|
||||
struct passwd * |
||||
getpwnam(const char *n) |
||||
{ |
||||
static char user_name[UNLEN + 1]; |
||||
static char user_gecos[UNLEN + 4]; |
||||
TCHAR name[UNLEN + 1]; |
||||
DWORD length; |
||||
BOOLEAN res; |
||||
#ifdef UNICODE |
||||
char *a_name; |
||||
# endif /* UNICODE */ |
||||
|
||||
if (!n) |
||||
return NULL; |
||||
|
||||
length = UNLEN + 1; |
||||
res = GetUserName(name, &length); |
||||
if (!res) |
||||
return NULL; |
||||
|
||||
#ifdef UNICODE |
||||
a_name = evil_wchar_to_char(name); |
||||
if (a_name) |
||||
{ |
||||
int l; |
||||
|
||||
l = strlen(a_name); |
||||
if (l >= PATH_MAX) |
||||
l = PATH_MAX; |
||||
memcpy(user_name, a_name, l); |
||||
user_name[l] = '\0'; |
||||
free(a_name); |
||||
} |
||||
else |
||||
return NULL; |
||||
#else |
||||
memcpy(user_name, name, strlen(name) + 1); |
||||
#endif /* UNICODE */ |
||||
|
||||
if (strcmp(n, user_name) != 0) |
||||
return NULL; |
||||
|
||||
pw.pw_name = user_name; |
||||
snprintf(user_gecos, sizeof(user_gecos), "%s,,,", user_name); |
||||
pw.pw_gecos = user_gecos; |
||||
pw.pw_dir = getenv("USERPROFILE"); |
||||
pw.pw_shell = getenv("SHELL"); |
||||
if (!pw.pw_shell) |
||||
pw.pw_shell = "cmd.exe"; |
||||
|
||||
return &pw; |
||||
} |
@ -1,89 +0,0 @@ |
||||
#ifndef __EVIL_PWD_H__ |
||||
#define __EVIL_PWD_H__ |
||||
|
||||
|
||||
/**
|
||||
* @file pwd.h |
||||
* @brief The file that provides functions ported from Unix in pwd.h. |
||||
* @defgroup Evil_Pwd_Group Pwd.h functions |
||||
* @ingroup Evil |
||||
* |
||||
* This header provides functions ported from Unix in pwd.h. |
||||
* |
||||
* @{ |
||||
*/ |
||||
|
||||
|
||||
#include <time.h> |
||||
|
||||
#include <Evil.h> |
||||
|
||||
#ifdef EAPI |
||||
# undef EAPI |
||||
#endif |
||||
|
||||
#ifdef _WIN32 |
||||
# ifdef EFL_BUILD |
||||
# ifdef DLL_EXPORT |
||||
# define EAPI __declspec(dllexport) |
||||
# else |
||||
# define EAPI |
||||
# endif |
||||
# else |
||||
# define EAPI __declspec(dllimport) |
||||
# endif |
||||
#endif |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
|
||||
/**
|
||||
* @struct passwd |
||||
* @brief A structure that describes a password. |
||||
*/ |
||||
struct passwd { |
||||
char *pw_name; /**< user name */ |
||||
char *pw_passwd; /**< encrypted password (always @c NULL) */ |
||||
uid_t pw_uid; /**< user uid (always 0) */ |
||||
gid_t pw_gid; /**< user gid (always 0) */ |
||||
time_t pw_change; /**< password change time (always 0) */ |
||||
char *pw_class; /**< user access class (always @c NULL) */ |
||||
char *pw_gecos; /**< Honeywell login info */ |
||||
char *pw_dir; /**< home directory */ |
||||
char *pw_shell; /**< default shell */ |
||||
time_t pw_expire; /**< account expiration (always 0) */ |
||||
int pw_fields; /**< internal: fields filled in (always 0) */ |
||||
}; |
||||
|
||||
/**
|
||||
* @brief Return a passwd structure. |
||||
* |
||||
* @param n The name of the user. |
||||
* @return A stacally allocated passwd structure. |
||||
* |
||||
* This function fills a static buffer @ref passwd with the user name @p n. |
||||
* |
||||
* Conformity: None. |
||||
* |
||||
* Supported OS: Windows XP. |
||||
*/ |
||||
EAPI struct passwd *getpwnam(const char *n); |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#undef EAPI |
||||
#define EAPI |
||||
|
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
|
||||
#endif /* __EVIL_PWD_H__ */ |
Loading…
Reference in new issue