summaryrefslogtreecommitdiff
path: root/src/bin/utils.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-10-09 17:20:27 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-10-09 17:20:27 +0000
commit0a4938a4f28c897a80bbb33b83233ffac4b79158 (patch)
tree16d1744ca4c6f1b1f5e84246c79e483ff55dbf2f /src/bin/utils.c
parent84d381344a2a19ac7e2cd99cf7968432c0554bef (diff)
utils: add and use homedir_get()
SVN revision: 77663
Diffstat (limited to 'src/bin/utils.c')
-rw-r--r--src/bin/utils.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/bin/utils.c b/src/bin/utils.c
index 215be61..316c0f7 100644
--- a/src/bin/utils.c
+++ b/src/bin/utils.c
@@ -1,5 +1,7 @@
1#include "private.h" 1#include "private.h"
2#include "utils.h" 2#include "utils.h"
3#include <unistd.h>
4#include <pwd.h>
3 5
4#include <Edje.h> 6#include <Edje.h>
5 7
@@ -52,6 +54,24 @@ theme_auto_reload_enable(Evas_Object *edje)
52} 54}
53 55
54Eina_Bool 56Eina_Bool
57homedir_get(char *buf, size_t size)
58{
59 const char *home = getenv("HOME");
60 if (!home)
61 {
62 uid_t uid = getuid();
63 struct passwd *pw = getpwuid(uid);
64 if (pw) home = pw->pw_dir;
65 }
66 if (!home)
67 {
68 ERR("Could not get $HOME");
69 return EINA_FALSE;
70 }
71 return eina_strlcpy(buf, home, size) < size;
72}
73
74Eina_Bool
55link_is_protocol(const char *str) 75link_is_protocol(const char *str)
56{ 76{
57 if (casestartswith(str, "http://") || 77 if (casestartswith(str, "http://") ||