X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Firssi%2Fsrc%2Fcore%2Fmisc.c;h=93612d6bb5ab7704f786fa2dc51fd21e5ee4fbf7;hb=9734af565c9da0fdf77fd93283d7adcd8eb34b80;hp=6bf871779a7a6b061f5d9d304db47cf9326c6972;hpb=6f6c6b1f52138ed5138c530614b24a503e542024;p=silc.git diff --git a/apps/irssi/src/core/misc.c b/apps/irssi/src/core/misc.c index 6bf87177..93612d6b 100644 --- a/apps/irssi/src/core/misc.c +++ b/apps/irssi/src/core/misc.c @@ -26,6 +26,7 @@ #ifdef HAVE_REGEX_H # include #endif +#include typedef struct { int condition; @@ -448,11 +449,24 @@ int mkpath(const char *path, int mode) return 0; } +/* Get home directory */ +const char *get_home_dir(void) +{ + struct passwd *pw = getpwuid(getuid()); + if (!pw) { + if (g_getenv("HOME")) + return g_getenv("HOME"); + else + return "."; + } + return pw->pw_dir; +} + /* convert ~/ to $HOME */ char *convert_home(const char *path) { return *path == '~' && (*(path+1) == '/' || *(path+1) == '\0') ? - g_strconcat(g_get_home_dir(), path+1, NULL) : + g_strconcat((char *)get_home_dir, path+1, NULL) : g_strdup(path); }