billiob pushed a commit to branch master. http://git.enlightenment.org/apps/terminology.git/commit/?id=dd7d88815c1060860b4983c5857df10aeb40208b
commit dd7d88815c1060860b4983c5857df10aeb40208b Author: Boris Faure <[email protected]> Date: Tue Jun 23 13:27:07 2020 +0200 utils: add the source files --- src/bin/utils.c | 23 +++++++++++++++++++++++ src/bin/utils.h | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/src/bin/utils.c b/src/bin/utils.c new file mode 100644 index 0000000..3452223 --- /dev/null +++ b/src/bin/utils.c @@ -0,0 +1,23 @@ +#include "private.h" +#include "utils.h" +#include <unistd.h> +#include <pwd.h> + +Eina_Bool +homedir_get(char *buf, size_t size) +{ + const char *home = getenv("HOME"); + if (!home) + { + uid_t uid = getuid(); + struct passwd *pw = getpwuid(uid); + if (pw) home = pw->pw_dir; + } + if (!home) + { + ERR("Could not get $HOME"); + return EINA_FALSE; + } + return eina_strlcpy(buf, home, size) < size; +} + diff --git a/src/bin/utils.h b/src/bin/utils.h new file mode 100644 index 0000000..c08ec43 --- /dev/null +++ b/src/bin/utils.h @@ -0,0 +1,7 @@ +#ifndef _UTILS_H__ +#define _UTILS_H__ + +#include <Eina.h> +Eina_Bool homedir_get(char *buf, size_t size); + +#endif --
