diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-06-18 10:53:44 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-06-18 10:53:44 +0200 |
commit | 6da7dba782f37eafdec595acfc3445a56d445915 (patch) | |
tree | b38450d540df967df7a42fde71f4d8ba0e55c215 | |
parent | 1890cfccdfd3532d9df576bd5264f13d2024c98a (diff) | |
download | monitoring-plugins-6da7dba782f37eafdec595acfc3445a56d445915.tar.gz |
lib/parse_ini.c: Add comment on NAGIOS_CONFIG_PATH
We might want to spit out a warning when NAGIOS_CONFIG_PATH is used.
While at it, move the function that handles this environment variable to
the bottom.
-rw-r--r-- | lib/parse_ini.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c index 2e47e06d..ede0e5fe 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c @@ -68,8 +68,9 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts); /* internal function that converts a single line into options format */ static int add_option(FILE *f, np_arg_list **optlst); -/* internal function to find default file */ +/* internal functions to find default file */ static char *default_file(void); +static char *default_file_in_path(void); /* * Parse_locator decomposes a string of the form @@ -344,6 +345,20 @@ add_option(FILE *f, np_arg_list **optlst) } static char * +default_file(void) +{ + char **p, *ini_file; + + if ((ini_file = getenv("MP_CONFIG_FILE")) != NULL || + (ini_file = default_file_in_path()) != NULL) + return ini_file; + for (p = default_ini_path_names; *p != NULL; p++) + if (access(*p, F_OK) == 0) + return *p; + return NULL; +} + +static char * default_file_in_path(void) { char *config_path, **file; @@ -351,6 +366,7 @@ default_file_in_path(void) if ((config_path = getenv("NAGIOS_CONFIG_PATH")) == NULL) return NULL; + /* shall we spit out a warning that NAGIOS_CONFIG_PATH is deprecated? */ if ((tokens = strdup(config_path)) == NULL) die(STATE_UNKNOWN, _("Insufficient Memory")); @@ -367,17 +383,3 @@ default_file_in_path(void) free(tokens); return NULL; } - -static char * -default_file(void) -{ - char **p, *ini_file; - - if ((ini_file = getenv("MP_CONFIG_FILE")) != NULL || - (ini_file = default_file_in_path()) != NULL) - return ini_file; - for (p = default_ini_path_names; *p != NULL; p++) - if (access(*p, F_OK) == 0) - return *p; - return NULL; -} |