mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-03 12:24:17 +01:00
WINGs: Do not look static information up every time
Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
This commit is contained in:
committed by
Carlos R. Mafra
parent
752d084609
commit
660b61a182
@@ -35,38 +35,50 @@
|
||||
|
||||
char *wgethomedir()
|
||||
{
|
||||
char *home = getenv("HOME");
|
||||
static char *home = NULL;
|
||||
struct passwd *user;
|
||||
|
||||
if (home)
|
||||
return home;
|
||||
|
||||
home = getenv("HOME");
|
||||
if (home)
|
||||
return home;
|
||||
|
||||
user = getpwuid(getuid());
|
||||
if (!user) {
|
||||
werror(_("could not get password entry for UID %i"), getuid());
|
||||
return "/";
|
||||
}
|
||||
if (!user->pw_dir) {
|
||||
return "/";
|
||||
} else {
|
||||
return user->pw_dir;
|
||||
home = "/";
|
||||
}
|
||||
|
||||
if (!user->pw_dir)
|
||||
home = "/";
|
||||
else
|
||||
home = wstrdup(user->pw_dir);
|
||||
|
||||
out:
|
||||
return home;
|
||||
}
|
||||
|
||||
static char *getuserhomedir(const char *username)
|
||||
{
|
||||
static char *home = NULL;
|
||||
struct passwd *user;
|
||||
|
||||
if (home)
|
||||
return home;
|
||||
|
||||
user = getpwnam(username);
|
||||
if (!user) {
|
||||
werror(_("could not get password entry for user %s"), username);
|
||||
return NULL;
|
||||
}
|
||||
if (!user->pw_dir) {
|
||||
return "/";
|
||||
} else {
|
||||
return user->pw_dir;
|
||||
}
|
||||
if (!user->pw_dir)
|
||||
home = "/";
|
||||
else
|
||||
home = wstrdup(user->pw_dir);
|
||||
|
||||
return home;
|
||||
}
|
||||
|
||||
char *wexpandpath(char *path)
|
||||
|
||||
Reference in New Issue
Block a user