diff options
Diffstat (limited to 'lib/parse_ini.c')
-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); | |||
68 | /* internal function that converts a single line into options format */ | 68 | /* internal function that converts a single line into options format */ |
69 | static int add_option(FILE *f, np_arg_list **optlst); | 69 | static int add_option(FILE *f, np_arg_list **optlst); |
70 | 70 | ||
71 | /* internal function to find default file */ | 71 | /* internal functions to find default file */ |
72 | static char *default_file(void); | 72 | static char *default_file(void); |
73 | static char *default_file_in_path(void); | ||
73 | 74 | ||
74 | /* | 75 | /* |
75 | * Parse_locator decomposes a string of the form | 76 | * Parse_locator decomposes a string of the form |
@@ -344,6 +345,20 @@ add_option(FILE *f, np_arg_list **optlst) | |||
344 | } | 345 | } |
345 | 346 | ||
346 | static char * | 347 | static char * |
348 | default_file(void) | ||
349 | { | ||
350 | char **p, *ini_file; | ||
351 | |||
352 | if ((ini_file = getenv("MP_CONFIG_FILE")) != NULL || | ||
353 | (ini_file = default_file_in_path()) != NULL) | ||
354 | return ini_file; | ||
355 | for (p = default_ini_path_names; *p != NULL; p++) | ||
356 | if (access(*p, F_OK) == 0) | ||
357 | return *p; | ||
358 | return NULL; | ||
359 | } | ||
360 | |||
361 | static char * | ||
347 | default_file_in_path(void) | 362 | default_file_in_path(void) |
348 | { | 363 | { |
349 | char *config_path, **file; | 364 | char *config_path, **file; |
@@ -351,6 +366,7 @@ default_file_in_path(void) | |||
351 | 366 | ||
352 | if ((config_path = getenv("NAGIOS_CONFIG_PATH")) == NULL) | 367 | if ((config_path = getenv("NAGIOS_CONFIG_PATH")) == NULL) |
353 | return NULL; | 368 | return NULL; |
369 | /* shall we spit out a warning that NAGIOS_CONFIG_PATH is deprecated? */ | ||
354 | 370 | ||
355 | if ((tokens = strdup(config_path)) == NULL) | 371 | if ((tokens = strdup(config_path)) == NULL) |
356 | die(STATE_UNKNOWN, _("Insufficient Memory")); | 372 | die(STATE_UNKNOWN, _("Insufficient Memory")); |
@@ -367,17 +383,3 @@ default_file_in_path(void) | |||
367 | free(tokens); | 383 | free(tokens); |
368 | return NULL; | 384 | return NULL; |
369 | } | 385 | } |
370 | |||
371 | static char * | ||
372 | default_file(void) | ||
373 | { | ||
374 | char **p, *ini_file; | ||
375 | |||
376 | if ((ini_file = getenv("MP_CONFIG_FILE")) != NULL || | ||
377 | (ini_file = default_file_in_path()) != NULL) | ||
378 | return ini_file; | ||
379 | for (p = default_ini_path_names; *p != NULL; p++) | ||
380 | if (access(*p, F_OK) == 0) | ||
381 | return *p; | ||
382 | return NULL; | ||
383 | } | ||