[monitoring-plugins] lib/parse_ini.c: Add comment on NAGIOS_CONFIG_PATH

Holger Weiss git at monitoring-plugins.org
Wed Jun 18 11:20:08 CEST 2014


 Module: monitoring-plugins
 Branch: master
 Commit: 6da7dba782f37eafdec595acfc3445a56d445915
 Author: Holger Weiss <holger at zedat.fu-berlin.de>
   Date: Wed Jun 18 10:53:44 2014 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=6da7dba

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(-)

diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index 2e47e06..ede0e5f 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;
-}



More information about the Commits mailing list