summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Maki <jmaki@multitech.com>2010-05-06 18:18:42 -0500
committerJames Maki <jmaki@multitech.com>2010-05-06 18:18:42 -0500
commit2b85ae17d6c73c619d17f8987069c0e6aaf390a2 (patch)
treeb35de2a6afabea39c9a8a887fd6a3696a79654d0 /src
parent27b93ee76399af7dbb4f6c307dc5d89d1efd6493 (diff)
downloadsms-utils-2b85ae17d6c73c619d17f8987069c0e6aaf390a2.tar.gz
sms-utils-2b85ae17d6c73c619d17f8987069c0e6aaf390a2.tar.bz2
sms-utils-2b85ae17d6c73c619d17f8987069c0e6aaf390a2.zip
load config from SMS_CONFIG env first if it is set.
Diffstat (limited to 'src')
-rw-r--r--src/sms_config.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/sms_config.c b/src/sms_config.c
index 0fa4173..9386ff7 100644
--- a/src/sms_config.c
+++ b/src/sms_config.c
@@ -267,24 +267,23 @@ static int config_handle_event(struct config_info *config)
}
}
-#define SMS_CONFIG_FILE ".smsconfig"
-static int _sms_config_load(void)
+static int _sms_config_load(const char *filename)
{
int err;
struct config_info config;
struct stat sbuf;
- err = stat(SMS_CONFIG_FILE, &sbuf);
+ err = stat(filename, &sbuf);
if (err < 0) {
if (errno == ENOENT) {
- log_notice("sms config file missing");
+ log_debug("sms config file missing");
return 0;
}
return -1;
}
- err = config_open(&config, SMS_CONFIG_FILE);
+ err = config_open(&config, filename);
if (err < 0) {
log_error("open config failed");
return -1;
@@ -328,12 +327,20 @@ static int _sms_config_load(void)
return 0;
}
+#define SMS_CONFIG_FILE ".smsconfig"
+
int sms_config_load(void)
{
int err;
char *cp;
char prev[PATH_MAX];
char *home;
+ char *config;
+
+ config = getenv("SMS_CONFIG");
+ if (config) {
+ return _sms_config_load(config);
+ }
home = getenv("HOME");
if (!home) {
@@ -349,7 +356,7 @@ int sms_config_load(void)
chdir(home);
- err = _sms_config_load();
+ err = _sms_config_load(SMS_CONFIG_FILE);
chdir(prev);