temp files should be protected; bug report 4.3BSD/usr.bin/186
[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
2124b336
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
c0bc4ef7
DF
16 */
17
98a06e30 18#ifndef lint
2124b336 19static char sccsid[] = "@(#)printlist.c 5.4 (Berkeley) %G%";
ddb85eed 20#endif /* not lint */
98a06e30
PK
21
22#include "gprof.h"
23
a441395b
PK
24 /*
25 * these are the lists of names:
26 * there is the list head and then the listname
27 * is a pointer to the list head
28 * (for ease of passing to stringlist functions).
29 */
3cdecae8
KM
30struct stringlist kfromhead = { 0 , 0 };
31struct stringlist *kfromlist = &kfromhead;
32struct stringlist ktohead = { 0 , 0 };
33struct stringlist *ktolist = &ktohead;
a441395b
PK
34struct stringlist fhead = { 0 , 0 };
35struct stringlist *flist = &fhead;
36struct stringlist Fhead = { 0 , 0 };
37struct stringlist *Flist = &Fhead;
38struct stringlist ehead = { 0 , 0 };
39struct stringlist *elist = &ehead;
40struct stringlist Ehead = { 0 , 0 };
41struct stringlist *Elist = &Ehead;
42
43addlist( listp , funcname )
44 struct stringlist *listp;
45 char *funcname;
98a06e30
PK
46{
47 struct stringlist *slp;
48
49 slp = (struct stringlist *) malloc( sizeof(struct stringlist));
50 if ( slp == (struct stringlist *) 0 ) {
51 fprintf( stderr, "gprof: ran out room for printlist\n" );
52 done();
53 }
a441395b 54 slp -> next = listp -> next;
98a06e30 55 slp -> string = funcname;
a441395b 56 listp -> next = slp;
98a06e30
PK
57}
58
59bool
a441395b
PK
60onlist( listp , funcname )
61 struct stringlist *listp;
62 char *funcname;
98a06e30
PK
63{
64 struct stringlist *slp;
65
a441395b 66 for ( slp = listp -> next ; slp ; slp = slp -> next ) {
98a06e30
PK
67 if ( ! strcmp( slp -> string , funcname ) ) {
68 return TRUE;
69 }
70 if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) {
71 return TRUE;
72 }
73 }
74 return FALSE;
75}