Lines Matching +full:no +full:- +full:can +full:- +full:fd
1 /*-
2 * Copyright (c) 2002-2015 Devin Teske <dteske@FreeBSD.org>
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44 * If no match is found, a pointer to the static dummy array (above) is
64 /* Re-initialize the dummy variable in case it was written to */ in get_config_option()
74 * Parse the configuration file at `path' and execute the `action' call-back
78 * For unknown directives that are encountered, you can optionally pass a
79 * call-back function for the third argument to be called for unknowns.
81 * Returns zero on success; otherwise returns -1 and errno should be consulted.
103 int fd; in parse_config() local
114 /* Sanity check: if no options and no unknown function, return */ in parse_config()
116 return (-1); in parse_config()
135 return (-1); in parse_config()
138 if ((fd = open(rpath, O_RDONLY)) < 0) in parse_config()
139 return (-1); in parse_config()
143 r = read(fd, p, 1); in parse_config()
154 r = read(fd, p, 1); in parse_config()
156 /* Test for EOF; if EOF then no directive was found */ in parse_config()
158 close(fd); in parse_config()
163 if ((curpos = lseek(fd, 0, SEEK_CUR)) == -1) { in parse_config()
164 close(fd); in parse_config()
165 return (-1); in parse_config()
167 curpos--; in parse_config()
179 r = read(fd, p, 1); in parse_config()
182 /* Test for EOF, if EOF then no directive was found */ in parse_config()
184 close(fd); in parse_config()
189 if (lseek(fd, curpos, SEEK_SET) == -1) { in parse_config()
190 close(fd); in parse_config()
191 return (-1); in parse_config()
197 close(fd); in parse_config()
198 return (-1); in parse_config()
202 r = read(fd, directive, n); in parse_config()
206 if (lseek(fd, 1, SEEK_CUR) != -1) in parse_config()
207 r = read(fd, p, 1); in parse_config()
223 r = read(fd, p, 1); in parse_config()
229 r = read(fd, p, 1); in parse_config()
231 r = read(fd, p, 1); in parse_config()
234 /* If no value, allocate a dummy value and jump to action */ in parse_config()
239 close(fd); in parse_config()
240 return (-1); in parse_config()
247 if ((curpos = lseek(fd, 0, SEEK_CUR)) == -1) { in parse_config()
248 close(fd); in parse_config()
249 return (-1); in parse_config()
251 curpos--; in parse_config()
257 /* Advance to the next character if we know we can */ in parse_config()
260 r = read(fd, p, 1); in parse_config()
265 * If we get this far, we've hit an end-key in parse_config()
269 if ((charpos = lseek(fd, 0, SEEK_CUR)) == -1) { in parse_config()
270 close(fd); in parse_config()
271 return (-1); in parse_config()
273 charpos--; in parse_config()
276 * Go back so we can read the character before the key in parse_config()
280 if (lseek(fd, -2, SEEK_CUR) == -1) { in parse_config()
281 close(fd); in parse_config()
282 return (-1); in parse_config()
284 r = read(fd, p, 1); in parse_config()
292 if (lseek(fd, -2, SEEK_CUR) == -1) { in parse_config()
293 close(fd); in parse_config()
294 return (-1); in parse_config()
296 r = read(fd, p, 1); in parse_config()
300 if (lseek(fd, charpos, SEEK_SET) == -1) { in parse_config()
301 close(fd); in parse_config()
302 return (-1); in parse_config()
304 r = read(fd, p, 1); in parse_config()
347 r = read(fd, p, 1); in parse_config()
351 if ((charpos = lseek(fd, 0, SEEK_CUR)) == -1) { in parse_config()
352 close(fd); in parse_config()
353 return (-1); in parse_config()
357 n = (uint32_t)(charpos - curpos); in parse_config()
359 n--; in parse_config()
362 if (lseek(fd, curpos, SEEK_SET) == -1) { in parse_config()
363 close(fd); in parse_config()
364 return (-1); in parse_config()
370 close(fd); in parse_config()
371 return (-1); in parse_config()
375 r = read(fd, value, n); in parse_config()
382 while (isspace(*--t)) in parse_config()
389 close(fd); in parse_config()
390 return (-1); in parse_config()
396 close(fd); in parse_config()
397 return (-1); in parse_config()
403 close(fd); in parse_config()
404 return (-1); in parse_config()
413 return (-1); in parse_config()
417 /* If there are no options defined, call unknown and loop */ in parse_config()
421 close(fd); in parse_config()
439 close(fd); in parse_config()
445 close(fd); in parse_config()
446 return (-1); in parse_config()
451 * No match was found for the value we read from the in parse_config()
456 close(fd); in parse_config()
462 close(fd); in parse_config()