aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2014-06-18 00:50:48 +0200
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2014-06-18 00:50:48 +0200
commit95ed0a996c84d8df0485b2ffbadf6e92d3fef80f (patch)
tree34275b8cde04ffc00798a38d60281cbbff90efb4 /lib
parentfbe13d8f32dc0e3bb76e32ee690e6f15bcafb0f5 (diff)
downloadmonitoring-plugins-95ed0a996c84d8df0485b2ffbadf6e92d3fef80f.tar.gz
lib/parse_ini.c: Remove outdated comment and code
The lib/parse_ini.c:np_get_defaults() function now dies if no configuration file is found.
Diffstat (limited to 'lib')
-rw-r--r--lib/parse_ini.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index f352d78c..2e42df7c 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -30,8 +30,6 @@
#include <sys/stat.h>
#include <unistd.h>
-/* TODO: die like N::P if config file is not found */
-
/* np_ini_info contains the result of parsing a "locator" in the format
* [stanza_name][@config_filename] (check_foo@/etc/foo.ini, for example)
*/
@@ -112,20 +110,17 @@ np_arg_list* np_get_defaults(const char *locator, const char *default_section){
np_ini_info i;
parse_locator(locator, default_section, &i);
- /* if a file was specified or if we're using the default file */
- if(i.file != NULL && strlen(i.file) > 0){
- if(strcmp(i.file, "-")==0){
- inifile=stdin;
- } else {
- inifile=fopen(i.file, "r");
- }
- if(inifile==NULL) die(STATE_UNKNOWN, "%s\n", _("Can't read config file"));
- if(read_defaults(inifile, i.stanza, &defaults)==FALSE)
- die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), i.stanza, i.file);
-
- free(i.file);
- if(inifile!=stdin) fclose(inifile);
+ if(strcmp(i.file, "-")==0){
+ inifile=stdin;
+ } else {
+ inifile=fopen(i.file, "r");
}
+ if(inifile==NULL) die(STATE_UNKNOWN, "%s\n", _("Can't read config file"));
+ if(read_defaults(inifile, i.stanza, &defaults)==FALSE)
+ die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), i.stanza, i.file);
+
+ free(i.file);
+ if(inifile!=stdin) fclose(inifile);
free(i.stanza);
return defaults;
}