/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1997-1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include <errno.h>
#include "parser.h"
#include "errlog.h"
/*
* handles the extends clause of the 'function' keyword
* Returns the number of errors encountered
* This function is recursive.
*/
int
{
static int extends_count = 0;
char *ifilename, *f, *p;
Meta_info M;
int retval;
int scan;
if (extends_count > MAX_EXTENDS) {
++errors;
goto ret;
}
switch (scan) {
case 0: /* funname not set */
case 1: /* buf not set, though ignored */
case 2: /* filename not set */
"'data' or 'function' line\n",
++errors;
goto ret;
break;
case 3:
break;
default:
break;
}
/* All info is from parent file - extends */
M.mi_ext_cnt = extends_count;
}
if (f == NULL) {
++errors;
goto ret;
}
}
++errors;
goto ret;
}
M.mi_line_number = 0;
/* search for begin function */
M.mi_line_number += M.mi_nlines;
continue;
}
if (p == NULL) {
"Unable to allocate memory\n");
}
localvalue = p;
/* check if architecture matches */
break;
}
}
if (found) {
int extends_err = 0;
static int extends_warn = 0;
switch (extends_err) {
case -1: /* Error */
"checking for extends clause\n",
M.mi_filename, M.mi_line_number);
++errors;
/*FALLTHRU*/
case 0: /* No Extends */
break;
case 1: /* Extends */
/*
* Warning on more then one level of extends
* but only warn once.
*/
if (extends_count == 1) {
extends_warn = 1;
}
!= 0) {
if (extends_count == 1) {
"Error occurred while "
"processing 'extends'\n",
}
errors += extends_err;
}
"Warning: \"%s\" does not extend "
"a base specification",
funname);
}
break;
default: /* Programmer Error */
"Error: invalid return from "
"check4extends: %d\n", extends_err);
}
M.mi_line_number += M.mi_nlines;
continue;
}
if (p == NULL) {
if (p == NULL) {
"Error: unable to "
"allocate memory\n");
}
}
localvalue = p;
switch (ki) {
case XLATOR_KW_END:
goto end;
break;
case XLATOR_KW_FUNC:
case XLATOR_KW_DATA:
"Error: Interface is missing \"end\"\n"
"\"%s\", line %d: Error while processing "
++errors;
goto end;
break;
case XLATOR_KW_NOTFOUND:
"uninteresting keyword: %s\n", key);
break;
default:
if (retval) {
"Error in "
"xlator_take_kvpair\n");
++errors;
}
}
}
} else {
++errors;
}
end:
ret:
return (errors);
}
/*
* find_fun()
* given a key value pair, and the name of the function you are
* searching for in the SPEC source file, this function returns 1
* if the beginning of the function in the SPEC source file is found.
* returns 0 otherwise.
*/
static int
{
return (0);
}
return (1);
}
return (0);
}
/*
* arch_match(FILE *fp, int arch)
* This function takes a FILE pointer, and an architecture token
* The FILE pointer is assumed to point at the beginning of a Function
* or Data specification (specifically at the first line of spec AFTER
* the Function or Data line)
* It reads all the way to the "End" line.
* If it finds an "arch" keyword along the way, it is checked to see if
* it matches the architecture currently being generated and returns
* 1 if a match is found. If a match is not found, it returns a
* 0. If no "arch" keyword is found, it returns 1.
*
* XXX - the algorithm in arch_match is very inefficient. it read through
* the file to find "arch" and rewinds before returning.
* Later all the data that was skipped while searching for "arch" may
* be needed and it is re-read from the disk. It would be nice to just
* read the data once.
*/
int
{
int len;
int has_arch = 0;
int archset = 0;
if (offset == -1) {
}
/* replace comments with single whitespace */
/* get complete line */
if (len > 1) {
break;
}
}
} /* end of 'get complete line' */
continue;
}
if (p == NULL) {
if (p == NULL) {
"Error: unable to "
"allocate memory\n");
}
}
localvalue = p;
has_arch = 1;
archset = arch_strtoi(a);
free(p);
}
return (1);
}
}
break;
}
}
end:
free(p);
}
if (has_arch == 0)
return (1);
return (0);
}