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