summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-06-18 08:52:09 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-06-18 08:52:09 (GMT)
commit1890cfccdfd3532d9df576bd5264f13d2024c98a (patch)
treee6812fe6a7b2a589cd0ab08ee56c935c6caa76bb /lib
parentf627b3f33bc16f7d5a3d4d56bc6d5c935fecb8d9 (diff)
downloadmonitoring-plugins-1890cfccdfd3532d9df576bd5264f13d2024c98a.tar.gz
lib/parse_ini.c: Cosmetic changes to comments
Diffstat (limited to 'lib')
-rw-r--r--lib/parse_ini.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index b33ce08..2e47e06 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -48,7 +48,7 @@ static char *default_ini_file_names[] = {
48static char *default_ini_path_names[] = { 48static char *default_ini_path_names[] = {
49 "/usr/local/etc/monitoring-plugins.ini", 49 "/usr/local/etc/monitoring-plugins.ini",
50 "/etc/monitoring-plugins.ini", 50 "/etc/monitoring-plugins.ini",
51 /* Deprecated path names (for backward compatibility): */ 51 /* deprecated path names (for backward compatibility): */
52 "/etc/nagios/plugins.ini", 52 "/etc/nagios/plugins.ini",
53 "/usr/local/nagios/etc/plugins.ini", 53 "/usr/local/nagios/etc/plugins.ini",
54 "/usr/local/etc/nagios/plugins.ini", 54 "/usr/local/etc/nagios/plugins.ini",
@@ -71,9 +71,10 @@ static int add_option(FILE *f, np_arg_list **optlst);
71/* internal function to find default file */ 71/* internal function to find default file */
72static char *default_file(void); 72static char *default_file(void);
73 73
74/* parse_locator decomposes a string of the form 74/*
75 * Parse_locator decomposes a string of the form
75 * [stanza][@filename] 76 * [stanza][@filename]
76 * into its seperate parts 77 * into its seperate parts.
77 */ 78 */
78static void 79static void
79parse_locator(const char *locator, const char *def_stanza, np_ini_info *i) 80parse_locator(const char *locator, const char *def_stanza, np_ini_info *i)
@@ -105,7 +106,9 @@ parse_locator(const char *locator, const char *def_stanza, np_ini_info *i)
105 _("Cannot find config file in any standard location.\n")); 106 _("Cannot find config file in any standard location.\n"));
106} 107}
107 108
108/* this is the externally visible function used by extra_opts */ 109/*
110 * This is the externally visible function used by extra_opts.
111 */
109np_arg_list * 112np_arg_list *
110np_get_defaults(const char *locator, const char *default_section) 113np_get_defaults(const char *locator, const char *default_section)
111{ 114{
@@ -133,11 +136,12 @@ np_get_defaults(const char *locator, const char *default_section)
133 return defaults; 136 return defaults;
134} 137}
135 138
136/* read_defaults is where the meat of the parsing takes place. 139/*
140 * The read_defaults() function is where the meat of the parsing takes place.
137 * 141 *
138 * note that this may be called by a setuid binary, so we need to 142 * Note that this may be called by a setuid binary, so we need to
139 * be extra careful about user-supplied input (i.e. avoiding possible 143 * be extra careful about user-supplied input (i.e. avoiding possible
140 * format string vulnerabilities, etc) 144 * format string vulnerabilities, etc).
141 */ 145 */
142static int 146static int
143read_defaults(FILE *f, const char *stanza, np_arg_list **opts) 147read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
@@ -148,7 +152,7 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
148 152
149 stanza_len = strlen(stanza); 153 stanza_len = strlen(stanza);
150 154
151 /* our little stanza-parsing state machine. */ 155 /* our little stanza-parsing state machine */
152 while ((c = fgetc(f)) != EOF) { 156 while ((c = fgetc(f)) != EOF) {
153 /* gobble up leading whitespace */ 157 /* gobble up leading whitespace */
154 if (isspace(c)) 158 if (isspace(c))
@@ -159,12 +163,12 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
159 case '#': 163 case '#':
160 GOBBLE_TO(f, c, '\n'); 164 GOBBLE_TO(f, c, '\n');
161 break; 165 break;
162 /* start of a stanza. check to see if it matches */ 166 /* start of a stanza, check to see if it matches */
163 case '[': 167 case '[':
164 stanzastate = WRONGSTANZA; 168 stanzastate = WRONGSTANZA;
165 for (i = 0; i < stanza_len; i++) { 169 for (i = 0; i < stanza_len; i++) {
166 c = fgetc(f); 170 c = fgetc(f);
167 /* Strip leading whitespace */ 171 /* strip leading whitespace */
168 if (i == 0) 172 if (i == 0)
169 for (; isspace(c); c = fgetc(f)) 173 for (; isspace(c); c = fgetc(f))
170 continue; 174 continue;
@@ -177,7 +181,7 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
177 /* if it matched up to here and the next char is ']'... */ 181 /* if it matched up to here and the next char is ']'... */
178 if (i == stanza_len) { 182 if (i == stanza_len) {
179 c = fgetc(f); 183 c = fgetc(f);
180 /* Strip trailing whitespace */ 184 /* strip trailing whitespace */
181 for (; isspace(c); c = fgetc(f)) 185 for (; isspace(c); c = fgetc(f))
182 continue; 186 continue;
183 if (c == ']') 187 if (c == ']')
@@ -214,9 +218,9 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
214} 218}
215 219
216/* 220/*
217 * read one line of input in the format 221 * Read one line of input in the format
218 * ^option[[:space:]]*(=[[:space:]]*value)? 222 * ^option[[:space:]]*(=[[:space:]]*value)?
219 * and creates it as a cmdline argument 223 * and create it as a cmdline argument
220 * --option[=value] 224 * --option[=value]
221 * appending it to the linked list optbuf. 225 * appending it to the linked list optbuf.
222 */ 226 */
@@ -250,7 +254,7 @@ add_option(FILE *f, np_arg_list **optlst)
250 } 254 }
251 } 255 }
252 lineend = &linebuf[read_pos]; 256 lineend = &linebuf[read_pos];
253 /* all that to read one line. isn't C fun? :) now comes the parsing :/ */ 257 /* all that to read one line, isn't C fun? :) now comes the parsing :/ */
254 258
255 /* skip leading whitespace */ 259 /* skip leading whitespace */
256 for (optptr = linebuf; optptr < lineend && isspace(*optptr); optptr++) 260 for (optptr = linebuf; optptr < lineend && isspace(*optptr); optptr++)
@@ -276,7 +280,7 @@ add_option(FILE *f, np_arg_list **optlst)
276 for (valend = valptr; valend < lineend; valend++) 280 for (valend = valptr; valend < lineend; valend++)
277 continue; 281 continue;
278 --valend; 282 --valend;
279 /* Finally trim off trailing spaces */ 283 /* finally trim off trailing spaces */
280 for (; isspace(*valend); valend--) 284 for (; isspace(*valend); valend--)
281 continue; 285 continue;
282 /* calculate the length of "--foo" */ 286 /* calculate the length of "--foo" */
@@ -297,7 +301,7 @@ add_option(FILE *f, np_arg_list **optlst)
297 equals = 1; 301 equals = 1;
298 cfg_len += 1; 302 cfg_len += 1;
299 } 303 }
300 /* A line with no equal sign isn't valid */ 304 /* a line with no equal sign isn't valid */
301 if (equals == 0) 305 if (equals == 0)
302 die(STATE_UNKNOWN, "%s\n", _("Config file error")); 306 die(STATE_UNKNOWN, "%s\n", _("Config file error"));
303 307