diff --git a/src/bin/meson.build b/src/bin/meson.build index f2d38992..5d5b8f5f 100644 --- a/src/bin/meson.build +++ b/src/bin/meson.build @@ -32,6 +32,7 @@ terminology_sources = ['private.h', 'termptyext.c', 'termptyext.h', 'backlog.c', 'backlog.h', 'md5.c', 'md5.h', + 'utils.c', 'utils.h', 'utf8.c', 'utf8.h', 'win.c', 'win.h', 'theme.c', 'theme.h', @@ -60,6 +61,7 @@ tyfuzz_sources = ['termptyesc.c', 'termptyesc.h', 'col.c', 'col.h', 'sb.c', 'sb.h', 'theme.h', + 'utils.c', 'utils.h', 'utf8.c', 'utf8.h', 'tytest_common.c', 'tytest_common.h', 'tyfuzz.c'] @@ -76,6 +78,7 @@ tytest_sources = ['termptyesc.c', 'termptyesc.h', 'col.c', 'col.h', 'sb.c', 'sb.h', 'utf8.c', 'utf8.h', + 'utils.c', 'utils.h', 'theme.h', 'md5.c', 'md5.h', 'unit_tests.h', diff --git a/src/bin/private.h b/src/bin/private.h index 2f4d5178..b91d8e21 100644 --- a/src/bin/private.h +++ b/src/bin/private.h @@ -52,4 +52,27 @@ extern int _log_domain; (DIV_ROUND_UP((_v), (_n)) * (_n)) #endif + +#define casestartswith(str, constref) \ + (!strncasecmp(str, constref, sizeof(constref) - 1)) +#define startswith(str, constref) \ + (!strncmp(str, constref, sizeof(constref) - 1)) + +#if !defined(HAVE_STRCHRNUL) +static inline char * +strchrnul(const char *s, int c) +{ + const char *p = s; + + while (*p) + { + if (*p == c) + return (char *)p; + + ++p; + } + return (char *) (p); +} +#endif + #endif diff --git a/src/bin/termio.c b/src/bin/termio.c index b07fda31..ddf2f99a 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -19,6 +19,7 @@ #include "miniview.h" #include "gravatar.h" #include "sb.h" +#include "utils.h" #if defined (__MacOSX__) || (defined (__MACH__) && defined (__APPLE__)) # include diff --git a/src/bin/termiolink.c b/src/bin/termiolink.c index 69f2f358..8d4a63f7 100644 --- a/src/bin/termiolink.c +++ b/src/bin/termiolink.c @@ -12,6 +12,7 @@ #include "sb.h" #include "utf8.h" #include "theme.h" +#include "utils.h" #else #include #include diff --git a/src/bin/theme.c b/src/bin/theme.c index 0f9e4f28..582ac4f8 100644 --- a/src/bin/theme.c +++ b/src/bin/theme.c @@ -1,6 +1,7 @@ #include "private.h" #include "theme.h" #include "config.h" +#include "utils.h" #include #include @@ -154,24 +155,6 @@ theme_auto_reload_enable(Evas_Object *edje) (edje, "edje,change,file", "edje", theme_reload_cb, NULL); } -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; -} - Eina_Bool utils_need_scale_wizard(void) { diff --git a/src/bin/theme.h b/src/bin/theme.h index cbad8ece..3e6df7ad 100644 --- a/src/bin/theme.h +++ b/src/bin/theme.h @@ -1,5 +1,5 @@ -#ifndef _UTILS_H__ -#define _UTILS_H__ +#ifndef _THEME_H__ +#define _THEME_H__ #include #include "config.h" @@ -11,32 +11,8 @@ void theme_reload(Evas_Object *edje); void theme_auto_reload_enable(Evas_Object *edje); const char *theme_path_get(const char *name); -Eina_Bool homedir_get(char *buf, size_t size); Eina_Bool utils_need_scale_wizard(void); -#define casestartswith(str, constref) \ - (!strncasecmp(str, constref, sizeof(constref) - 1)) -#define startswith(str, constref) \ - (!strncmp(str, constref, sizeof(constref) - 1)) - -#if !defined(HAVE_STRCHRNUL) -static inline char * -strchrnul(const char *s, int c) -{ - const char *p = s; - - while (*p) - { - if (*p == c) - return (char *)p; - - ++p; - } - return (char *) (p); -} -#endif - - #if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 20) # if __GNUC__ >= 7 # define EINA_FALLTHROUGH __attribute__ ((fallthrough)); diff --git a/src/bin/tytest_common.c b/src/bin/tytest_common.c index fa4e1cb7..6cbfa91b 100644 --- a/src/bin/tytest_common.c +++ b/src/bin/tytest_common.c @@ -306,12 +306,6 @@ termio_color_class_set(Evas_Object *termio EINA_UNUSED, const char *key, return -1; } -Eina_Bool -homedir_get(char *buf, size_t size) -{ - return eina_strlcpy(buf, "/home/foo", size) < size; -} - void termio_reset_main_colors(Evas_Object *termio EINA_UNUSED) {