From 6da7dba782f37eafdec595acfc3445a56d445915 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 18 Jun 2014 10:53:44 +0200 Subject: 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. --- lib/parse_ini.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'lib') 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 @@ -343,6 +344,20 @@ add_option(FILE *f, np_arg_list **optlst) return 0; } +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) { @@ -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; -} -- cgit v1.2.3