1 /* filter_expressions.c
2 * Submitted by Edwin Groothuis <wireshark@mavetju.org>
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
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.
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.
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.
29 #include <epan/prefs.h>
31 #include "epan/filter_expressions.h"
33 static struct filter_expression *_filter_expression_head = NULL;
34 struct filter_expression **pfilter_expression_head = &_filter_expression_head;
37 * Create a new filter_expression and add it to the end of the list
38 * of filter_expressions.
40 struct filter_expression *
41 filter_expression_new(const gchar *label, const gchar *expr,
42 const gboolean enabled)
44 struct filter_expression *expression;
45 struct filter_expression *prev;
47 expression = (struct filter_expression *)g_malloc0(sizeof(struct filter_expression));
48 expression->label = g_strdup(label);
49 expression->expression = g_strdup(expr);
50 expression->enabled = enabled;
52 /* Add it at the end so the button order is always the same*/
53 if (*pfilter_expression_head == NULL) {
54 _filter_expression_head = expression;
56 prev = *pfilter_expression_head;
57 while (prev->next != NULL)
59 prev->next = expression;
60 expression->index = prev->index + 1;
67 filter_expression_init(gboolean enable_prefs)
70 prefs.filter_expressions = pfilter_expression_head;
74 filter_expression_free(struct filter_expression *list_head)
76 if (list_head == NULL)
78 filter_expression_free(list_head->next);
79 g_free(list_head->label);
80 g_free(list_head->expression);
86 * Editor modelines - http://www.wireshark.org/tools/modelines.html
94 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
95 * :indentSize=8:tabSize=8:noTabs=false: