Move merge.{h,c} into wiretap: these modules use wiretap to merge files.
[metze/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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #ifndef FILTERS_H
27 #define FILTERS_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 /*
34  * Filter lists.
35  */
36 typedef enum {
37         CFILTER_LIST,           /* capture filter list - saved */
38         DFILTER_LIST,           /* display filter list - saved */
39         CFILTER_EDITED_LIST,    /* capture filter list - currently edited */
40         DFILTER_EDITED_LIST     /* display filter list - currently edited */
41 } filter_list_type_t;
42
43 /*
44  * Item in a list of filters.
45  */
46 typedef struct {
47   char *name;           /* filter name */
48   char *strval;         /* filter expression */
49 } filter_def;
50
51 /*
52  * Read in a list of filters.
53  *
54  * On success, "*pref_path_return" is set to NULL.
55  * On error, "*pref_path_return" is set to point to the pathname of
56  * the file we tried to read - it should be freed by our caller -
57  * and "*errno_return" is set to the error.
58  */
59 void read_filter_list(filter_list_type_t list_type, char **pref_path_return,
60     int *errno_return);
61
62 /*
63  * Get a pointer to the first entry in a filter list.
64  */
65 GList *get_filter_list_first(filter_list_type_t list);
66
67 /*
68  * Add a new filter to the end of a list.
69  * Returns a pointer to the newly-added entry.
70  */
71 GList *add_to_filter_list(filter_list_type_t list, const char *name,
72     const char *expression);
73
74 /*
75  * Remove a filter from a list.
76  */
77 void remove_from_filter_list(filter_list_type_t list, GList *fl_entry);
78
79 /*
80  * Write out a list of filters.
81  *
82  * On success, "*pref_path_return" is set to NULL.
83  * On error, "*pref_path_return" is set to point to the pathname of
84  * the file we tried to read - it should be freed by our caller -
85  * and "*errno_return" is set to the error.
86  */
87 void save_filter_list(filter_list_type_t list_type, char **pref_path_return,
88     int *errno_return);
89
90 /*
91  * Clone the filter list so it can be edited.
92  */
93 void copy_filter_list(filter_list_type_t dest_type, filter_list_type_t src_type);
94
95 #ifdef __cplusplus
96 }
97 #endif /* __cplusplus */
98
99 #endif /* FILTERS_H */