141120Sjdp/*
2103976Spst * Copyright (c) 1983, 1993
341120Sjdp *	The Regents of the University of California.  All rights reserved.
441120Sjdp *
541120Sjdp * Redistribution and use in source and binary forms, with or without
641120Sjdp * modification, are permitted provided that the following conditions
741120Sjdp * are met:
841120Sjdp * 1. Redistributions of source code must retain the above copyright
941120Sjdp *    notice, this list of conditions and the following disclaimer.
1041120Sjdp * 2. Redistributions in binary form must reproduce the above copyright
1141120Sjdp *    notice, this list of conditions and the following disclaimer in the
1241120Sjdp *    documentation and/or other materials provided with the distribution.
1341120Sjdp * 4. Neither the name of the University nor the names of its contributors
1441120Sjdp *    may be used to endorse or promote products derived from this software
1541120Sjdp *    without specific prior written permission.
1641120Sjdp *
1741120Sjdp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1841120Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1941120Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2041120Sjdp * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2141120Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2241120Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2341120Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2441120Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2541120Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2641120Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2741120Sjdp * SUCH DAMAGE.
2841120Sjdp */
2941120Sjdp
3041120Sjdp#if 0
3141120Sjdp#ifndef lint
3241120Sjdpstatic char sccsid[] = "@(#)printlist.c	8.1 (Berkeley) 6/6/93";
3341120Sjdp#endif /* not lint */
3441120Sjdp#endif
3541120Sjdp
3641120Sjdp#include <sys/cdefs.h>
3741120Sjdp__FBSDID("$FreeBSD: releng/10.3/usr.bin/gprof/printlist.c 246783 2013-02-14 08:16:03Z charnier $");
3841120Sjdp
3941120Sjdp#include <err.h>
4041120Sjdp#include <string.h>
4141120Sjdp
4241120Sjdp#include "gprof.h"
4341120Sjdp
44103976Spst    /*
45103976Spst     *	these are the lists of names:
46103976Spst     *	there is the list head and then the listname
47103976Spst     *	is a pointer to the list head
4841120Sjdp     *	(for ease of passing to stringlist functions).
4941120Sjdp     */
5041120Sjdpstruct stringlist	kfromhead = { 0 , 0 };
5141120Sjdpstruct stringlist	*kfromlist = &kfromhead;
5241120Sjdpstruct stringlist	ktohead = { 0 , 0 };
5341120Sjdpstruct stringlist	*ktolist = &ktohead;
5441120Sjdpstruct stringlist	fhead = { 0 , 0 };
5541120Sjdpstruct stringlist	*flist = &fhead;
5641120Sjdpstruct stringlist	Fhead = { 0 , 0 };
5741120Sjdpstruct stringlist	*Flist = &Fhead;
5841120Sjdpstruct stringlist	ehead = { 0 , 0 };
5941120Sjdpstruct stringlist	*elist = &ehead;
6041120Sjdpstruct stringlist	Ehead = { 0 , 0 };
6141120Sjdpstruct stringlist	*Elist = &Ehead;
6241120Sjdp
6341120Sjdpvoid
6441120Sjdpaddlist(struct stringlist *listp, char *funcname)
6541120Sjdp{
6641120Sjdp    struct stringlist	*slp;
6741120Sjdp
6841120Sjdp    slp = (struct stringlist *) malloc( sizeof(struct stringlist));
6941120Sjdp    if ( slp == (struct stringlist *) 0 )
7041120Sjdp	errx( 1 , "no room for printlist");
7141120Sjdp    slp -> next = listp -> next;
7241120Sjdp    slp -> string = funcname;
7341120Sjdp    listp -> next = slp;
7441120Sjdp}
7541120Sjdp
7641120Sjdpbool
7741120Sjdponlist(struct stringlist *listp, const char *funcname)
7841120Sjdp{
7941120Sjdp    struct stringlist	*slp;
8041120Sjdp
8141120Sjdp    for ( slp = listp -> next ; slp ; slp = slp -> next ) {
8241120Sjdp	if ( ! strcmp( slp -> string , funcname ) ) {
8341120Sjdp	    return TRUE;
8441120Sjdp	}
8541120Sjdp	if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) {
8641120Sjdp	    return TRUE;
8741120Sjdp	}
8841120Sjdp    }
89103976Spst    return FALSE;
90103976Spst}
91103976Spst