add Berkeley specific header; written by K. McKusick and P. Kessler
[unix-history] / usr / src / usr.bin / gprof / printlist.c
CommitLineData
c0bc4ef7
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
ddb85eed
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
c0bc4ef7
DF
11 */
12
98a06e30 13#ifndef lint
ddb85eed
KB
14static char sccsid[] = "@(#)printlist.c 5.3 (Berkeley) %G%";
15#endif /* not lint */
98a06e30
PK
16
17#include "gprof.h"
18
a441395b
PK
19 /*
20 * these are the lists of names:
21 * there is the list head and then the listname
22 * is a pointer to the list head
23 * (for ease of passing to stringlist functions).
24 */
3cdecae8
KM
25struct stringlist kfromhead = { 0 , 0 };
26struct stringlist *kfromlist = &kfromhead;
27struct stringlist ktohead = { 0 , 0 };
28struct stringlist *ktolist = &ktohead;
a441395b
PK
29struct stringlist fhead = { 0 , 0 };
30struct stringlist *flist = &fhead;
31struct stringlist Fhead = { 0 , 0 };
32struct stringlist *Flist = &Fhead;
33struct stringlist ehead = { 0 , 0 };
34struct stringlist *elist = &ehead;
35struct stringlist Ehead = { 0 , 0 };
36struct stringlist *Elist = &Ehead;
37
38addlist( listp , funcname )
39 struct stringlist *listp;
40 char *funcname;
98a06e30
PK
41{
42 struct stringlist *slp;
43
44 slp = (struct stringlist *) malloc( sizeof(struct stringlist));
45 if ( slp == (struct stringlist *) 0 ) {
46 fprintf( stderr, "gprof: ran out room for printlist\n" );
47 done();
48 }
a441395b 49 slp -> next = listp -> next;
98a06e30 50 slp -> string = funcname;
a441395b 51 listp -> next = slp;
98a06e30
PK
52}
53
54bool
a441395b
PK
55onlist( listp , funcname )
56 struct stringlist *listp;
57 char *funcname;
98a06e30
PK
58{
59 struct stringlist *slp;
60
a441395b 61 for ( slp = listp -> next ; slp ; slp = slp -> next ) {
98a06e30
PK
62 if ( ! strcmp( slp -> string , funcname ) ) {
63 return TRUE;
64 }
65 if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) {
66 return TRUE;
67 }
68 }
69 return FALSE;
70}