Просмотр исходного кода

Make extra-opts (C plugins) behave more like N::P:

  N::P allows both '#' and ';' for comments. Extra-opts used to allow only '#', it now allows both (';' is the standard for ini files)
  Extra-opts does not allow trailing comments anymore (like N::P)



git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2063 f882894a-f735-0410-b71e-b25c423dba1c
Thomas Guyot-Sionnest 17 лет назад
Родитель
Сommit
51ec51a8dc
3 измененных файлов с 9 добавлено и 5 удалено
  1. 2 0
      NEWS
  2. 3 4
      lib/parse_ini.c
  3. 4 1
      lib/tests/plugin.ini

+ 2 - 0
NEWS

@@ -6,6 +6,8 @@ This file documents the major additions and syntax changes between releases.
 	check_ifoperstatus -n flag now works as expected (sf.net #1569488)
 	check_ifoperstatus now supports ifType based lookup for ifIndex
 	check_ups now sends a LOGOUT string (debian bug #387001)
+	Extra-opts (C plugins) now allows both '#' and ';' for comments (like N::P)
+	Extra-opts (C plugins) does not allow trailing comments anymore (like N::P)
 
 1.4.13 25th Sept 2008
 	Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen)

+ 3 - 4
lib/parse_ini.c

@@ -132,6 +132,7 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts){
 		if(isspace(c)) continue;
 		switch(c){
 			/* globble up coment lines */
+			case ';':
 			case '#':
 				GOBBLE_TO(f, c, '\n');
 				break;
@@ -232,10 +233,8 @@ static int add_option(FILE *f, np_arg_list **optlst){
 	if(optptr==eqptr) die(STATE_UNKNOWN, _("Config file error\n"));
 	/* continue from '=' to start of value or EOL */
 	for(valptr=eqptr+1; valptr<lineend && isspace(*valptr); valptr++);
-	/* continue to the end of value (FIXME: watching for trailing comments) */
-	for(valend=valptr; valend<lineend; valend++)
-		/* FIXME: N::P doesn't allow comments here. Remove next line and parse_ini won't either */
-		if(*valend=='#') break;
+	/* continue to the end of value */
+	for(valend=valptr; valend<lineend; valend++);
 	--valend;
 	/* Finally trim off trailing spaces */
 	for(valend; isspace(*valend); valend--);

+ 4 - 1
lib/tests/plugin.ini

@@ -1,7 +1,10 @@
+# Non-standard (but accepted) comment
+; standard ini comment
 
 [check_mysql]
 username=operator
-password=secret		# Remember to change later
+; comment in the middle
+password=secret  
 
 [section_twice]
 foo=bar