utils.{c,h} is needed

This commit is contained in:
Boris Faure 2020-06-23 13:11:09 +02:00
parent ab35c9b7dd
commit 4bc712b07d
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
7 changed files with 31 additions and 50 deletions

View File

@ -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',

View File

@ -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

View File

@ -19,6 +19,7 @@
#include "miniview.h"
#include "gravatar.h"
#include "sb.h"
#include "utils.h"
#if defined (__MacOSX__) || (defined (__MACH__) && defined (__APPLE__))
# include <sys/proc_info.h>

View File

@ -12,6 +12,7 @@
#include "sb.h"
#include "utf8.h"
#include "theme.h"
#include "utils.h"
#else
#include <assert.h>
#include <math.h>

View File

@ -1,6 +1,7 @@
#include "private.h"
#include "theme.h"
#include "config.h"
#include "utils.h"
#include <unistd.h>
#include <pwd.h>
@ -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)
{

View File

@ -1,5 +1,5 @@
#ifndef _UTILS_H__
#define _UTILS_H__
#ifndef _THEME_H__
#define _THEME_H__
#include <Evas.h>
#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));

View File

@ -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)
{