xref: /csrg-svn/usr.bin/gprof/printlist.c (revision 34199)
121964Sdist /*
221964Sdist  * Copyright (c) 1983 Regents of the University of California.
3*34199Sbostic  * All rights reserved.
4*34199Sbostic  *
5*34199Sbostic  * Redistribution and use in source and binary forms are permitted
6*34199Sbostic  * provided that this notice is preserved and that due credit is given
7*34199Sbostic  * to the University of California at Berkeley. The name of the University
8*34199Sbostic  * may not be used to endorse or promote products derived from this
9*34199Sbostic  * software without specific prior written permission. This software
10*34199Sbostic  * is provided ``as is'' without express or implied warranty.
1121964Sdist  */
1221964Sdist 
137175Speter #ifndef lint
14*34199Sbostic static char sccsid[] = "@(#)printlist.c	5.3 (Berkeley) 05/05/88";
15*34199Sbostic #endif /* not lint */
167175Speter 
177175Speter #include "gprof.h"
187175Speter 
197222Speter     /*
207222Speter      *	these are the lists of names:
217222Speter      *	there is the list head and then the listname
227222Speter      *	is a pointer to the list head
237222Speter      *	(for ease of passing to stringlist functions).
247222Speter      */
2530963Smckusick struct stringlist	kfromhead = { 0 , 0 };
2630963Smckusick struct stringlist	*kfromlist = &kfromhead;
2730963Smckusick struct stringlist	ktohead = { 0 , 0 };
2830963Smckusick struct stringlist	*ktolist = &ktohead;
297222Speter struct stringlist	fhead = { 0 , 0 };
307222Speter struct stringlist	*flist = &fhead;
317222Speter struct stringlist	Fhead = { 0 , 0 };
327222Speter struct stringlist	*Flist = &Fhead;
337222Speter struct stringlist	ehead = { 0 , 0 };
347222Speter struct stringlist	*elist = &ehead;
357222Speter struct stringlist	Ehead = { 0 , 0 };
367222Speter struct stringlist	*Elist = &Ehead;
377175Speter 
387222Speter addlist( listp , funcname )
397222Speter     struct stringlist	*listp;
407222Speter     char		*funcname;
417175Speter {
427175Speter     struct stringlist	*slp;
437175Speter 
447175Speter     slp = (struct stringlist *) malloc( sizeof(struct stringlist));
457175Speter     if ( slp == (struct stringlist *) 0 ) {
467175Speter 	fprintf( stderr, "gprof: ran out room for printlist\n" );
477175Speter 	done();
487175Speter     }
497222Speter     slp -> next = listp -> next;
507175Speter     slp -> string = funcname;
517222Speter     listp -> next = slp;
527175Speter }
537175Speter 
547175Speter bool
557222Speter onlist( listp , funcname )
567222Speter     struct stringlist	*listp;
577222Speter     char		*funcname;
587175Speter {
597175Speter     struct stringlist	*slp;
607175Speter 
617222Speter     for ( slp = listp -> next ; slp ; slp = slp -> next ) {
627175Speter 	if ( ! strcmp( slp -> string , funcname ) ) {
637175Speter 	    return TRUE;
647175Speter 	}
657175Speter 	if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) {
667175Speter 	    return TRUE;
677175Speter 	}
687175Speter     }
697175Speter     return FALSE;
707175Speter }
71