summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 252d9a7)
raw | patch | inline | side by side (parent: 252d9a7)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sat, 15 Mar 2008 22:42:01 +0000 (22:42 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Sat, 15 Mar 2008 22:42:01 +0000 (22:42 +0000) |
All tests should return ok now.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1950 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1950 f882894a-f735-0410-b71e-b25c423dba1c
lib/parse_ini.c | patch | blob | history |
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index 3f2aa3b8ccbfc1bb94cab4b0a8bb1a43111cc665..70da7f14dc7570a6b4cc0156e33c66dbacb38cac 100644 (file)
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
#define GOBBLE_TO(f, c, n) do { (c)=fgetc((f)); } while((c)!=EOF && (c)!=(n))
/* internal function that returns the constructed defaults options */
-static np_arg_list* read_defaults(FILE *f, const char *stanza);
+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);
inifile=fopen(i.file, "r");
}
if(inifile==NULL) die(STATE_UNKNOWN, _("Config file error"));
- defaults=read_defaults(inifile, i.stanza);
+ if(read_defaults(inifile, i.stanza, &defaults)==FALSE && strcmp(i.stanza, default_section) && inifile!=stdout) { /* FIXME: Shouldn't it be 'stdin' ??? */
+ /* We got nothing, try the default section */
+ rewind(inifile);
+ read_defaults(inifile, default_section, &defaults);
+ }
+
free(i.file);
if(inifile!=stdout) fclose(inifile); /* FIXME: Shouldn't it be 'stdin' ??? */
}
* be extra careful about user-supplied input (i.e. avoiding possible
* format string vulnerabilities, etc)
*/
-static np_arg_list* read_defaults(FILE *f, const char *stanza){
- int c;
- np_arg_list *opts=NULL;
+static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts){
+ int c, status=FALSE;
size_t i, stanza_len;
enum { NOSTANZA, WRONGSTANZA, RIGHTSTANZA } stanzastate=NOSTANZA;
/* okay, this is where we start taking the config */
case RIGHTSTANZA:
ungetc(c, f);
- if(add_option(f, &opts)){
+ if(add_option(f, opts)){
die(STATE_UNKNOWN, _("Config file error"));
}
+ status=TRUE;
break;
}
break;
}
}
- return opts;
+ return status;
}
/*