X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Futils.c;h=16f38852af6324e697402d79ad5f18153c7849c1;hb=bf9abc514ce1871a1cb26cfd9f73257edf7d24a0;hp=3e659a1c81079d74b52aab9993c555fcaba6b62d;hpb=0c7bcad5eaa11b368460759fc87f949e8c56b98f;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index 3e659a1c8..16f38852a 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -32,6 +32,7 @@ #include #include "utils.h" +#include "defaults.h" /* * Return the realpath(3) of the path even if the last directory token does not @@ -440,6 +441,7 @@ static void regex_print_error(int errcode, regex_t *regex) * * @return 0 on success, -1 on failure. */ +LTTNG_HIDDEN int utils_parse_size_suffix(char *str, uint64_t *size) { regex_t regex; @@ -580,3 +582,18 @@ int utils_get_count_order_u32(uint32_t x) return fls_u32(x - 1); } + +/** + * Obtain the value of LTTNG_HOME environment variable, if exists. + * Otherwise returns the value of HOME. + */ +LTTNG_HIDDEN +char *utils_get_home_dir(void) +{ + char *val = NULL; + val = getenv(DEFAULT_LTTNG_HOME_ENV_VAR); + if (val != NULL) { + return val; + } + return getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR); +}