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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/prefs.h>
32 #include "epan/filter_expressions.h"
34 static struct filter_expression
*_filter_expression_head
= NULL
;
35 struct filter_expression
**pfilter_expression_head
= &_filter_expression_head
;
38 * Create a new filter_expression and add it to the end of the list
39 * of filter_expressions.
41 struct filter_expression
*
42 filter_expression_new(const gchar
*label
, const gchar
*expr
,
43 const gboolean enabled
)
45 struct filter_expression
*expression
;
46 struct filter_expression
*prev
;
48 expression
= (struct filter_expression
*)g_malloc(sizeof(struct filter_expression
));
49 memset(expression
, '\0', sizeof(struct filter_expression
));
50 expression
->button
= NULL
;
51 expression
->label
= g_strdup(label
);
52 expression
->expression
= g_strdup(expr
);
53 expression
->enabled
= enabled
;
54 expression
->deleted
= FALSE
;
55 expression
->index
= 0;
57 expression
->next
= NULL
;
59 /* Add it at the end so the button order is always the same*/
60 if (*pfilter_expression_head
== NULL
) {
61 _filter_expression_head
= expression
;
63 prev
= *pfilter_expression_head
;
64 while (prev
->next
!= NULL
)
66 prev
->next
= expression
;
67 expression
->index
= prev
->index
+ 1;
74 filter_expression_init(gboolean enable_prefs
)
77 prefs
.filter_expressions
= pfilter_expression_head
;