From: Joonbum Ko Date: Mon, 27 Apr 2020 10:07:02 +0000 (+0900) Subject: Added inline function tpl_getenv() to replace getenv. X-Git-Tag: accepted/tizen/unified/20200508.050228~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F232026%2F1;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git Added inline function tpl_getenv() to replace getenv. Change-Id: I1018d6f7c11bba4aaaee3e29cc53dd1660f70593 Signed-off-by: Joonbum Ko --- diff --git a/src/tpl.c b/src/tpl.c index 2a19d8d..8107b8f 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -2,6 +2,8 @@ unsigned int tpl_log_lvl = 0; unsigned int tpl_log_initialized = 0; +unsigned int tpl_getenv_initialized = 0; +unsigned int tpl_getenv_enabled = 0; unsigned int tpl_dump_lvl = 0; struct _tpl_runtime { diff --git a/src/tpl_utils.h b/src/tpl_utils.h index 7f55fec..9e0369f 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -6,6 +6,7 @@ #include #include #include +#include #if defined(__GNUC__) && __GNUC__ >= 4 # define TPL_API __attribute__ ((visibility("default"))) @@ -53,8 +54,33 @@ /* 0:uninitialized, 1:initialized,no log, 2:user log */ extern unsigned int tpl_log_lvl; extern unsigned int tpl_log_initialized; +extern unsigned int tpl_getenv_initialized; +extern unsigned int tpl_getenv_enabled; extern unsigned int tpl_dump_lvl; +#define TPL_GETENV_INIT() \ + { \ + if (!tpl_getenv_initialized) \ + { \ + int ret = access("/opt/usr/tpl_env", F_OK); \ + if (ret == 0) \ + tpl_getenv_enabled = 1; \ + else \ + tpl_getenv_enabled = 0; \ + tpl_getenv_initialized = 1; \ + } \ + } + +inline char *tpl_getenv(const char *name) +{ + TPL_GETENV_INIT(); + if (tpl_getenv_enabled) + return getenv(name); + else + return NULL; +} + + #define FONT_DEFAULT "\033[0m" /* for reset to default color */ #define FONT_RED "\033[31m" /* for error logs */ #define FONT_YELLOW "\033[33m" /* for warning logs */ @@ -289,7 +315,6 @@ extern unsigned int tpl_dump_lvl; } #endif - typedef struct _tpl_list_node tpl_list_node_t; typedef struct _tpl_list tpl_list_t; typedef struct tpl_util_map_entry tpl_util_map_entry_t;