1 /* This file is part of the program psim.
3 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
23 #include "build-config.h"
43 new_filter(const char *filt
,
46 while (strlen(filt
) > 0) {
48 /* break up the filt list */
49 char *end
= strchr(filt
, ',');
53 end
= strchr(filt
, '\0');
60 /* add to filter list */
61 new_filter
= ZALLOC(filter
);
62 new_filter
->flag
= (char*)zalloc(len
+ 1);
63 strncpy(new_filter
->flag
, filt
, len
);
64 new_filter
->next
= filters
;
73 is_filtered_out(const char *flags
,
76 while (strlen(flags
) > 0) {
78 filter
*filt
= filters
;
79 /* break the string up */
80 char *end
= strchr(flags
, ',');
84 end
= strchr(flags
, '\0');
91 /* check that it is present */
94 while (filt
!= NULL
) {
95 if (strncmp(flags
, filt
->flag
, len
) == 0
96 && strlen(filt
->flag
) == len
) {
111 it_is(const char *flag
,
114 int flag_len
= strlen(flag
);
115 while (*flags
!= '\0') {
116 if (!strncmp(flags
, flag
, flag_len
)
117 && (flags
[flag_len
] == ',' || flags
[flag_len
] == '\0'))
119 while (*flags
!= ',') {
132 main(int argc
, char **argv
)
134 filter
*filters
= NULL
;
137 printf("Usage: filter <flags> <filter> ...\n");
140 /* load the filter up */
141 for (i
= 2; i
< argc
; i
++)
142 filters
= new_filter(argv
[i
], filters
);
143 if (is_filtered_out(argv
[1], filters
))