IP Prefix field support in CDP, from Paul Ionescu.
[obnox/wireshark/wip.git] / prefs-int.h
1 /* prefs-int.h
2  * Definitions for implementation of preference handling routines;
3  * used by "friends" of the preferences type.
4  *
5  * $Id: prefs-int.h,v 1.3 2000/11/18 21:41:36 guy Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@zing.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * 
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  * 
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef __PREFS_INT_H__
28 #define __PREFS_INT_H__
29
30 struct pref_module {
31         const char *name;       /* name of module */
32         const char *title;      /* title of module (displayed in preferences notebook) */
33         void (*apply_cb)(void); /* routine to call when preferences applied */
34         GList   *prefs;         /* list of its preferences */
35         int     numprefs;       /* number of preferences */
36         gboolean prefs_changed; /* if TRUE, a preference has changed since we last checked */
37 };
38
39 typedef enum {
40         PREF_UINT,
41         PREF_BOOL,
42         PREF_ENUM,
43         PREF_STRING
44 } pref_type_t;
45
46 struct preference {
47         const char *name;       /* name of preference */
48         const char *title;      /* title to use in GUI */
49         const char *description; /* human-readable description of preference */
50         int     ordinal;        /* ordinal number of this preference */
51         pref_type_t type;       /* type of that preference */
52         union {
53                 guint *uint;
54                 gboolean *bool;
55                 gint *enump;
56                 char **string;
57         } varp;                 /* pointer to variable storing the value */
58         union {
59                 guint uint;
60                 gboolean bool;
61                 gint enumval;
62                 char *string;
63         } saved_val;            /* original value, when editing from the GUI */
64         union {
65           guint base;                   /* input/output base, for PREF_UINT */
66           struct {
67             const enum_val_t *enumvals; /* list of name & values */
68             gboolean radio_buttons;     /* TRUE if it should be shown as
69                                            radio buttons rather than as an
70                                            option menu or combo box in
71                                            the preferences tab */
72           } enum_info;                  /* for PREF_ENUM */
73         } info;                 /* display/text file information */
74         void    *control;       /* handle for GUI control for this preference */
75 };
76
77 gint find_val_for_string(const char *needle, const enum_val_t *haystack,
78     gint default_value);
79
80 #endif /* prefs-int.h */