Annotation of embedaddon/iftop/screenfilter.c, revision 1.1.1.1
1.1 misho 1: /*
2: * screenfilter.c:
3: *
4: * Copyright (c) 2002 DecisionSoft Ltd.
5: * Paul Warren (pdw) Fri Oct 25 10:21:00 2002
6: *
7: */
8:
9: #include "config.h"
10:
11: #ifdef HAVE_REGCOMP
12:
13: #include <sys/types.h>
14: #include <regex.h>
15: #include <stdio.h>
16: #include "iftop.h"
17: #include "options.h"
18:
19: static const char rcsid[] = "$Id: screenfilter.c,v 1.3 2002/11/04 12:27:35 chris Exp $";
20:
21: extern options_t options ;
22:
23: regex_t preg;
24:
25: int screen_filter_set(char* s) {
26: int r;
27:
28: if(options.screenfilter != NULL) {
29: xfree(options.screenfilter);
30: options.screenfilter = NULL;
31: regfree(&preg);
32: }
33:
34: r = regcomp(&preg, s, REG_ICASE|REG_EXTENDED);
35:
36: if(r == 0) {
37: options.screenfilter = s;
38: return 1;
39: }
40: else {
41: xfree(s);
42: return 0;
43: }
44: }
45:
46: int screen_filter_match(char *s) {
47: int r;
48: if(options.screenfilter == NULL) {
49: return 1;
50: }
51:
52: r = regexec(&preg, s, 0, NULL, 0);
53: if(r == 0) {
54: return 1;
55: }
56: else {
57: return 0;
58: }
59: }
60:
61: #endif /* HAVE_REGCOMP */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>