11590Srgrimes/*
21590Srgrimes * Copyright (c) 1983, 1993
31590Srgrimes *	The Regents of the University of California.  All rights reserved.
41590Srgrimes *
51590Srgrimes * Redistribution and use in source and binary forms, with or without
61590Srgrimes * modification, are permitted provided that the following conditions
71590Srgrimes * are met:
81590Srgrimes * 1. Redistributions of source code must retain the above copyright
91590Srgrimes *    notice, this list of conditions and the following disclaimer.
101590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111590Srgrimes *    notice, this list of conditions and the following disclaimer in the
121590Srgrimes *    documentation and/or other materials provided with the distribution.
131590Srgrimes * 4. Neither the name of the University nor the names of its contributors
141590Srgrimes *    may be used to endorse or promote products derived from this software
151590Srgrimes *    without specific prior written permission.
161590Srgrimes *
171590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271590Srgrimes * SUCH DAMAGE.
281590Srgrimes */
291590Srgrimes
30105243Scharnier#if 0
311590Srgrimes#ifndef lint
321590Srgrimesstatic char sccsid[] = "@(#)printlist.c	8.1 (Berkeley) 6/6/93";
33105243Scharnier#endif /* not lint */
3427313Scharnier#endif
35105243Scharnier
3699112Sobrien#include <sys/cdefs.h>
3799112Sobrien__FBSDID("$FreeBSD$");
381590Srgrimes
3927313Scharnier#include <err.h>
40129657Sstefanf#include <string.h>
41129657Sstefanf
421590Srgrimes#include "gprof.h"
431590Srgrimes
441590Srgrimes    /*
451590Srgrimes     *	these are the lists of names:
461590Srgrimes     *	there is the list head and then the listname
471590Srgrimes     *	is a pointer to the list head
481590Srgrimes     *	(for ease of passing to stringlist functions).
491590Srgrimes     */
501590Srgrimesstruct stringlist	kfromhead = { 0 , 0 };
511590Srgrimesstruct stringlist	*kfromlist = &kfromhead;
521590Srgrimesstruct stringlist	ktohead = { 0 , 0 };
531590Srgrimesstruct stringlist	*ktolist = &ktohead;
541590Srgrimesstruct stringlist	fhead = { 0 , 0 };
551590Srgrimesstruct stringlist	*flist = &fhead;
561590Srgrimesstruct stringlist	Fhead = { 0 , 0 };
571590Srgrimesstruct stringlist	*Flist = &Fhead;
581590Srgrimesstruct stringlist	ehead = { 0 , 0 };
591590Srgrimesstruct stringlist	*elist = &ehead;
601590Srgrimesstruct stringlist	Ehead = { 0 , 0 };
611590Srgrimesstruct stringlist	*Elist = &Ehead;
621590Srgrimes
63105243Scharniervoid
64246783Scharnieraddlist(struct stringlist *listp, char *funcname)
651590Srgrimes{
661590Srgrimes    struct stringlist	*slp;
671590Srgrimes
681590Srgrimes    slp = (struct stringlist *) malloc( sizeof(struct stringlist));
69105243Scharnier    if ( slp == (struct stringlist *) 0 )
70105243Scharnier	errx( 1 , "no room for printlist");
711590Srgrimes    slp -> next = listp -> next;
721590Srgrimes    slp -> string = funcname;
731590Srgrimes    listp -> next = slp;
741590Srgrimes}
751590Srgrimes
761590Srgrimesbool
77246783Scharnieronlist(struct stringlist *listp, const char *funcname)
781590Srgrimes{
791590Srgrimes    struct stringlist	*slp;
801590Srgrimes
811590Srgrimes    for ( slp = listp -> next ; slp ; slp = slp -> next ) {
821590Srgrimes	if ( ! strcmp( slp -> string , funcname ) ) {
831590Srgrimes	    return TRUE;
841590Srgrimes	}
851590Srgrimes	if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) {
861590Srgrimes	    return TRUE;
871590Srgrimes	}
881590Srgrimes    }
891590Srgrimes    return FALSE;
901590Srgrimes}
91