1 /* filter_expressions.c
2 * Submitted by Edwin Groothuis <wireshark@mavetju.org>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <epan/prefs.h>
34 #include "epan/filter_expressions.h"
36 static struct filter_expression *_filter_expression_head = NULL;
37 struct filter_expression **pfilter_expression_head = &_filter_expression_head;
40 * Create a new filter_expression and add it to the end of the list
41 * of filter_expressions.
43 struct filter_expression *
44 filter_expression_new(const gchar *label, const gchar *expr,
45 const gboolean enabled)
47 struct filter_expression *expression;
48 struct filter_expression *prev;
50 expression = (struct filter_expression *)g_malloc(sizeof(struct filter_expression));
51 memset(expression, '\0', sizeof(struct filter_expression));
52 expression->button = NULL;
53 expression->label = g_strdup(label);
54 expression->expression = g_strdup(expr);
55 expression->enabled = enabled;
56 expression->deleted = FALSE;
57 expression->index = 0;
59 expression->next = NULL;
61 /* Add it at the end so the button order is always the same*/
62 if (*pfilter_expression_head == NULL) {
63 _filter_expression_head = expression;
65 prev = *pfilter_expression_head;
66 while (prev->next != NULL)
68 prev->next = expression;
69 expression->index = prev->index + 1;
76 filter_expression_init(gboolean enable_prefs)
79 prefs.filter_expressions = pfilter_expression_head;