10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*11838SLiane.Praza@Sun.COM * Common Development and Distribution License (the "License").
6*11838SLiane.Praza@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
21*11838SLiane.Praza@Sun.COM
220Sstevel@tonic-gate /*
23*11838SLiane.Praza@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate #include <stdio.h>
280Sstevel@tonic-gate #include <stdlib.h>
290Sstevel@tonic-gate #include <string.h>
300Sstevel@tonic-gate
310Sstevel@tonic-gate #include "list.h"
320Sstevel@tonic-gate #include "exception_list.h"
330Sstevel@tonic-gate #include "arch.h"
340Sstevel@tonic-gate
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate * This is global so that the protodir reading functions can rely on the
370Sstevel@tonic-gate * exception list to weed out innocuous problems in the IHV gate.
380Sstevel@tonic-gate */
390Sstevel@tonic-gate elem_list exception_list;
400Sstevel@tonic-gate
410Sstevel@tonic-gate #define FS " \t\n"
420Sstevel@tonic-gate
430Sstevel@tonic-gate static int
parse_exception_line(char * line,elem_list * list)440Sstevel@tonic-gate parse_exception_line(char *line, elem_list *list)
450Sstevel@tonic-gate {
460Sstevel@tonic-gate char *name, *arch;
470Sstevel@tonic-gate elem *e;
480Sstevel@tonic-gate
490Sstevel@tonic-gate if ((name = strtok(line, FS)) == NULL) {
500Sstevel@tonic-gate /* don't complain; this is only a blank line */
510Sstevel@tonic-gate return (0);
520Sstevel@tonic-gate }
530Sstevel@tonic-gate
540Sstevel@tonic-gate if ((arch = strtok(NULL, FS)) == NULL) {
55*11838SLiane.Praza@Sun.COM arch = "all";
560Sstevel@tonic-gate }
570Sstevel@tonic-gate
580Sstevel@tonic-gate e = (elem *) malloc(sizeof (elem));
590Sstevel@tonic-gate
600Sstevel@tonic-gate e->inode = 0;
610Sstevel@tonic-gate e->perm = 0;
620Sstevel@tonic-gate e->ref_cnt = 0;
630Sstevel@tonic-gate e->flag = 0;
640Sstevel@tonic-gate e->major = 0;
650Sstevel@tonic-gate e->minor = 0;
660Sstevel@tonic-gate e->link_parent = NULL;
670Sstevel@tonic-gate e->link_sib = NULL;
680Sstevel@tonic-gate e->symsrc = NULL;
690Sstevel@tonic-gate e->file_type = DIR_T;
700Sstevel@tonic-gate
71*11838SLiane.Praza@Sun.COM while ((e->arch = assign_arch(arch)) == NULL) {
72*11838SLiane.Praza@Sun.COM if ((arch = strtok(NULL, FS)) == NULL) {
73*11838SLiane.Praza@Sun.COM return (0);
74*11838SLiane.Praza@Sun.COM }
750Sstevel@tonic-gate }
760Sstevel@tonic-gate
770Sstevel@tonic-gate (void) strcpy(e->name, name);
780Sstevel@tonic-gate add_elem(list, e);
790Sstevel@tonic-gate
800Sstevel@tonic-gate return (1);
810Sstevel@tonic-gate }
820Sstevel@tonic-gate
830Sstevel@tonic-gate int
read_in_exceptions(const char * exception_file,int verbose)840Sstevel@tonic-gate read_in_exceptions(const char *exception_file, int verbose)
850Sstevel@tonic-gate {
860Sstevel@tonic-gate FILE *except_fp;
870Sstevel@tonic-gate char buf[BUFSIZ];
880Sstevel@tonic-gate int count = 0;
890Sstevel@tonic-gate
900Sstevel@tonic-gate exception_file = exception_file ? exception_file : EXCEPTION_FILE;
910Sstevel@tonic-gate
920Sstevel@tonic-gate if (verbose) {
930Sstevel@tonic-gate (void) printf("reading in exceptions from %s...\n",
940Sstevel@tonic-gate exception_file);
950Sstevel@tonic-gate }
960Sstevel@tonic-gate
970Sstevel@tonic-gate if ((except_fp = fopen(exception_file, "r")) == NULL) {
980Sstevel@tonic-gate perror(exception_file);
990Sstevel@tonic-gate return (0);
1000Sstevel@tonic-gate }
1010Sstevel@tonic-gate while (fgets(buf, BUFSIZ, except_fp)) {
1020Sstevel@tonic-gate if (buf[0] != '#') /* allow for comments */
1030Sstevel@tonic-gate count += parse_exception_line(buf, &exception_list);
1040Sstevel@tonic-gate }
1050Sstevel@tonic-gate if (verbose)
1060Sstevel@tonic-gate (void) printf("read in %d exceptions...\n", count);
1070Sstevel@tonic-gate
1080Sstevel@tonic-gate return (count);
1090Sstevel@tonic-gate }
110