3036 Update hwdata to current upstream data
[unleashed.git] / usr / src / tools / protocmp / exception_list.c
blob5dd98fb6fe2260ef326edad60b1c18fc6f1f4322
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
31 #include "list.h"
32 #include "exception_list.h"
33 #include "arch.h"
36 * This is global so that the protodir reading functions can rely on the
37 * exception list to weed out innocuous problems in the IHV gate.
39 elem_list exception_list;
41 #define FS " \t\n"
43 static int
44 parse_exception_line(char *line, elem_list *list)
46 char *name, *arch;
47 elem *e;
49 if ((name = strtok(line, FS)) == NULL) {
50 /* don't complain; this is only a blank line */
51 return (0);
54 if ((arch = strtok(NULL, FS)) == NULL) {
55 arch = "all";
58 e = (elem *) malloc(sizeof (elem));
60 e->inode = 0;
61 e->perm = 0;
62 e->ref_cnt = 0;
63 e->flag = 0;
64 e->major = 0;
65 e->minor = 0;
66 e->link_parent = NULL;
67 e->link_sib = NULL;
68 e->symsrc = NULL;
69 e->file_type = DIR_T;
71 while ((e->arch = assign_arch(arch)) == NULL) {
72 if ((arch = strtok(NULL, FS)) == NULL) {
73 return (0);
77 (void) strcpy(e->name, name);
78 add_elem(list, e);
80 return (1);
83 int
84 read_in_exceptions(const char *exception_file, int verbose)
86 FILE *except_fp;
87 char buf[BUFSIZ];
88 int count = 0;
90 exception_file = exception_file ? exception_file : EXCEPTION_FILE;
92 if (verbose) {
93 (void) printf("reading in exceptions from %s...\n",
94 exception_file);
97 if ((except_fp = fopen(exception_file, "r")) == NULL) {
98 perror(exception_file);
99 return (0);
101 while (fgets(buf, BUFSIZ, except_fp)) {
102 if (buf[0] != '#') /* allow for comments */
103 count += parse_exception_line(buf, &exception_list);
105 if (verbose)
106 (void) printf("read in %d exceptions...\n", count);
108 return (count);