diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-04-04 10:11:22 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-04-04 10:11:22 +0000 |
commit | 2a4640f6719b9688a68b796f697209b9b14cd179 (patch) | |
tree | c90a814eba255846196eede28260c3b64e391e8b /lib/parse_ini.c | |
parent | 815fbd802f1aeee32d3d1b3751bf294e46a4c090 (diff) | |
download | monitoring-plugins-2a4640f6719b9688a68b796f697209b9b14cd179.tar.gz |
make parse_ini die like in N::P if section isn't found
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1976 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/parse_ini.c')
-rw-r--r-- | lib/parse_ini.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c index d5661c9e..96551cfe 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <sys/stat.h> | 34 | #include <sys/stat.h> |
35 | #include <unistd.h> | 35 | #include <unistd.h> |
36 | 36 | ||
37 | /* TODO: die like N::P if section is not found */ | ||
38 | /* TODO: die like N::P if config file is not found */ | 37 | /* TODO: die like N::P if config file is not found */ |
39 | 38 | ||
40 | /* np_ini_info contains the result of parsing a "locator" in the format | 39 | /* np_ini_info contains the result of parsing a "locator" in the format |
@@ -104,11 +103,8 @@ np_arg_list* np_get_defaults(const char *locator, const char *default_section){ | |||
104 | inifile=fopen(i.file, "r"); | 103 | inifile=fopen(i.file, "r"); |
105 | } | 104 | } |
106 | if(inifile==NULL) die(STATE_UNKNOWN, _("Can't read config file")); | 105 | if(inifile==NULL) die(STATE_UNKNOWN, _("Can't read config file")); |
107 | if(read_defaults(inifile, i.stanza, &defaults)==FALSE && strcmp(i.stanza, default_section) && inifile!=stdin) { | 106 | if(read_defaults(inifile, i.stanza, &defaults)==FALSE) |
108 | /* We got nothing, try the default section */ | 107 | die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), i.stanza, i.file); |
109 | rewind(inifile); | ||
110 | read_defaults(inifile, default_section, &defaults); | ||
111 | } | ||
112 | 108 | ||
113 | free(i.file); | 109 | free(i.file); |
114 | if(inifile!=stdin) fclose(inifile); | 110 | if(inifile!=stdin) fclose(inifile); |