2 * Acess2 POSIX Emulation
3 * - By John Hodge (thePowersGang)
12 // TODO: Parse something like '/Acess/Conf/Users'
15 static const struct passwd gPwd_RootInfo = {
19 .pw_dir = "/Acess/Root",
20 .pw_shell = "/Acess/Bin/CLIShell",
25 struct passwd *getpwnam(const char *name)
27 static struct passwd ret_struct;
28 static char ret_buf[64];
29 struct passwd *ret_ptr;
30 errno = getpwnam_r(name, &ret_struct, ret_buf, sizeof(ret_buf), &ret_ptr);
34 struct passwd *getpwuid(uid_t uid)
36 static struct passwd ret_struct;
37 static char ret_buf[64];
38 struct passwd *ret_ptr;
39 errno = getpwuid_r(uid, &ret_struct, ret_buf, sizeof(ret_buf), &ret_ptr);
43 static int fill_pwd(const struct passwd *tpl, struct passwd *pwd, char *buf, size_t buflen)
46 #define _setstr(field) do { \
47 if( ofs + strlen(tpl->field)+1 > buflen ) \
49 pwd->field = buf + ofs; \
50 strcpy(pwd->field, tpl->field); \
53 pwd->pw_uid = tpl->pw_uid;
54 pwd->pw_gid = tpl->pw_gid;
61 int getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
64 if( strcmp(name, "root") == 0 ) {
65 int ret = fill_pwd(&gPwd_RootInfo, pwd, buf, buflen);
72 int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
76 int ret = fill_pwd(&gPwd_RootInfo, pwd, buf, buflen);
87 struct passwd *getpwent(void)