xref: /onnv-gate/usr/src/cmd/sgs/gprof/common/printlist.c (revision 211:37c8180b1ace)
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
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
22*211Smike_s 
230Sstevel@tonic-gate /*
24*211Smike_s  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25*211Smike_s  * Use is subject to license terms.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include "gprof.h"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate /*
330Sstevel@tonic-gate  *	these are the lists of names:
340Sstevel@tonic-gate  *	there is the list head and then the listname
350Sstevel@tonic-gate  *	is a pointer to the list head
360Sstevel@tonic-gate  *	(for ease of passing to stringlist functions).
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate struct stringlist	fhead = { 0, 0 };
390Sstevel@tonic-gate struct stringlist	*flist = &fhead;
400Sstevel@tonic-gate struct stringlist	Fhead = { 0, 0 };
410Sstevel@tonic-gate struct stringlist	*Flist = &Fhead;
420Sstevel@tonic-gate struct stringlist	ehead = { 0, 0 };
430Sstevel@tonic-gate struct stringlist	*elist = &ehead;
440Sstevel@tonic-gate struct stringlist	Ehead = { 0, 0 };
450Sstevel@tonic-gate struct stringlist	*Elist = &Ehead;
460Sstevel@tonic-gate 
470Sstevel@tonic-gate void
addlist(struct stringlist * listp,char * funcname)480Sstevel@tonic-gate addlist(struct stringlist *listp, char *funcname)
490Sstevel@tonic-gate {
500Sstevel@tonic-gate 	struct stringlist	*slp;
510Sstevel@tonic-gate 
52*211Smike_s 	slp = malloc(sizeof (struct stringlist));
530Sstevel@tonic-gate 
540Sstevel@tonic-gate 	if (slp == NULL) {
55*211Smike_s 		(void) fprintf(stderr, "gprof: ran out room for printlist\n");
560Sstevel@tonic-gate 		exit(1);
570Sstevel@tonic-gate 	}
580Sstevel@tonic-gate 
590Sstevel@tonic-gate 	slp->next = listp->next;
600Sstevel@tonic-gate 	slp->string = funcname;
610Sstevel@tonic-gate 	listp->next = slp;
620Sstevel@tonic-gate }
630Sstevel@tonic-gate 
640Sstevel@tonic-gate bool
onlist(struct stringlist * listp,char * funcname)650Sstevel@tonic-gate onlist(struct stringlist *listp, char *funcname)
660Sstevel@tonic-gate {
670Sstevel@tonic-gate 	struct stringlist	*slp;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 	for (slp = listp->next; slp; slp = slp->next) {
700Sstevel@tonic-gate 		if (strcmp(slp->string, funcname) == 0)
710Sstevel@tonic-gate 			return (TRUE);
720Sstevel@tonic-gate 
730Sstevel@tonic-gate 		if (funcname[0] == '_' &&
740Sstevel@tonic-gate 		    strcmp(slp->string, &funcname[1]) == 0)
750Sstevel@tonic-gate 			return (TRUE);
760Sstevel@tonic-gate 	}
770Sstevel@tonic-gate 	return (FALSE);
780Sstevel@tonic-gate }
79