From fb77cb87caf9c557ea48e8edbec69f20b7df5d37 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 4 Jun 2018 15:01:16 +0200 Subject: [PATCH] check in SRSLTE_CONFIG_DIR for configs by default --- lib/include/srslte/common/config_file.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/include/srslte/common/config_file.h b/lib/include/srslte/common/config_file.h index 80391f19a..36c844453 100644 --- a/lib/include/srslte/common/config_file.h +++ b/lib/include/srslte/common/config_file.h @@ -35,16 +35,15 @@ bool config_exists(std::string &filename, std::string default_name) { std::ifstream conf(filename.c_str(), std::ios::in); if(conf.fail()) { - const char *homedir = NULL; + const char *config_dir = NULL; char full_path[256]; ZERO_OBJECT(full_path); - if ((homedir = getenv("HOME")) == NULL) { - homedir = getpwuid(getuid())->pw_dir; - } - if (!homedir) { - homedir = "."; + if ((config_dir = getenv("SRSLTE_CONFIG_DIR")) == NULL) { + fprintf(stderr, "No environment variable SRSLTE_CONFIG_DIR defined.\n" + "Please run \"export SRSLTE_CONFIG_DIR=/usr/etc/srs\" to define it.\n\n"); + return false; } - snprintf(full_path, sizeof(full_path), "%s/.srs/%s", homedir, default_name.c_str()); + snprintf(full_path, sizeof(full_path), "%s/%s", config_dir, default_name.c_str()); filename = std::string(full_path); // try to open again