bc8e7972586f94e443217218561d0164f12cb095
[metze/wireshark/wip.git] / ui / filters.h
1 /* filters.h
2  * Declarations of routines for reading and writing the filters file.
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __UI_FILTERS_H__
24 #define __UI_FILTERS_H__
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
29
30 /*
31  * Filter lists.
32  */
33 typedef enum {
34         CFILTER_LIST,           /* capture filter list - saved */
35         DFILTER_LIST,           /* display filter list - saved */
36         CFILTER_EDITED_LIST,    /* capture filter list - currently edited */
37         DFILTER_EDITED_LIST     /* display filter list - currently edited */
38 } filter_list_type_t;
39
40 /*
41  * Item in a list of filters.
42  */
43 typedef struct {
44   char *name;           /* filter name */
45   char *strval;         /* filter expression */
46 } filter_def;
47
48 /*
49  * Read in a list of filters.
50  *
51  * On success, "*pref_path_return" is set to NULL.
52  * On error, "*pref_path_return" is set to point to the pathname of
53  * the file we tried to read - it should be freed by our caller -
54  * and "*errno_return" is set to the error.
55  */
56 void read_filter_list(filter_list_type_t list_type, char **pref_path_return,
57     int *errno_return);
58
59 /*
60  * Get a pointer to the first entry in a filter list.
61  */
62 GList *get_filter_list_first(filter_list_type_t list);
63
64 /*
65  * Add a new filter to the end of a list.
66  * Returns a pointer to the newly-added entry.
67  */
68 GList *add_to_filter_list(filter_list_type_t list, const char *name,
69     const char *expression);
70
71 /*
72  * Remove a filter from a list.
73  */
74 void remove_from_filter_list(filter_list_type_t list, GList *fl_entry);
75
76 /*
77  * Write out a list of filters.
78  *
79  * On success, "*pref_path_return" is set to NULL.
80  * On error, "*pref_path_return" is set to point to the pathname of
81  * the file we tried to read - it should be freed by our caller -
82  * and "*errno_return" is set to the error.
83  */
84 void save_filter_list(filter_list_type_t list_type, char **pref_path_return,
85     int *errno_return);
86
87 /*
88  * Clone the filter list so it can be edited.
89  */
90 void copy_filter_list(filter_list_type_t dest_type, filter_list_type_t src_type);
91
92 #ifdef __cplusplus
93 }
94 #endif /* __cplusplus */
95
96 #endif /* __UI_FILTERS_H__ */