1/*- 2 * Copyright (c) 2000 Kelly Yancey <kbyanc@posi.net> 3 * Derived from work done by Julian Elischer <julian@tfs.com, 4 * julian@dialix.oz.au>, 1993, and Peter Dufault <dufault@hda.com>, 1994. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sbin/camcontrol/modeedit.c 124830 2004-01-22 07:23:36Z grehan $"); |
31 32#include <sys/queue.h> 33#include <sys/types.h> 34 35#include <assert.h> 36#include <ctype.h> 37#include <err.h> 38#include <errno.h> --- 318 unchanged lines hidden (view full) --- 357 FILE *pagedb; 358 char str_pagenum[MAX_PAGENUM_LEN]; 359 char str_pagename[MAX_PAGENAME_LEN]; 360 int pagenum; 361 int depth; /* Quoting depth. */ 362 int found; 363 int lineno; 364 enum { LOCATE, PAGENAME, PAGEDEF } state; |
365 int ch; |
366 char c; 367 368#define SETSTATE_LOCATE do { \ 369 str_pagenum[0] = '\0'; \ 370 str_pagename[0] = '\0'; \ 371 pagenum = -1; \ 372 state = LOCATE; \ 373} while (0) --- 19 unchanged lines hidden (view full) --- 393 returnerr(ENOENT); 394 395 SLIST_INIT(&namelist); 396 397 depth = 0; 398 lineno = 0; 399 found = 0; 400 SETSTATE_LOCATE; |
401 while ((ch = fgetc(pagedb)) != EOF) { |
402 403 /* Keep a line count to make error messages more useful. */ 404 UPDATE_LINENO; 405 406 /* Skip over comments anywhere in the mode database. */ |
407 if (ch == '#') { |
408 do { |
409 ch = fgetc(pagedb); 410 } while (ch != '\n' && ch != EOF); |
411 UPDATE_LINENO; 412 continue; 413 } |
414 c = ch; |
415 416 /* Strip out newline characters. */ 417 if (c == '\n') 418 continue; 419 420 /* Keep track of the nesting depth for braces. */ 421 if (c == PAGEDEF_START) 422 depth++; --- 487 unchanged lines hidden --- |