Licepnse -> License
[obnox/wireshark/wip.git] / epan / 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$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifndef __PREFS_INT_H__
27 #define __PREFS_INT_H__
28
29 struct pref_module {
30         const char *name;       /* name of module */
31         const char *title;      /* title of module (displayed in preferences notebook) */
32         gboolean is_subtree;    /* if TRUE, this has other modules, not preferences, under it */
33         void (*apply_cb)(void); /* routine to call when preferences applied */
34         GList   *prefs;         /* list of its preferences or submodules */
35         int     numprefs;       /* number of non-obsolete preferences */
36         gboolean prefs_changed; /* if TRUE, a preference has changed since we last checked */
37         gboolean obsolete;      /* if TRUE, this is a module that used to
38                                    exist but no longer does */
39 };
40
41 /*
42  * Module used for protocol preferences. With MSVC and a 
43  * libwireshark.dll, we need a special declaration.
44  */
45 WS_VAR_IMPORT module_t *protocols_module;
46
47 /*
48  * PREF_OBSOLETE is used for preferences that a module used to support
49  * but no longer supports; we give different error messages for them.
50  */
51 typedef enum {
52         PREF_UINT,
53         PREF_BOOL,
54         PREF_ENUM,
55         PREF_STRING,
56         PREF_RANGE,
57         PREF_OBSOLETE
58 } pref_type_t;
59
60 struct preference {
61         const char *name;       /* name of preference */
62         const char *title;      /* title to use in GUI */
63         const char *description; /* human-readable description of preference */
64         int     ordinal;        /* ordinal number of this preference */
65         pref_type_t type;       /* type of that preference */
66         union {
67                 guint *uint;
68                 gboolean *boolp;
69                 gint *enump;
70                 const char **string;
71                 range_t **range;
72         } varp;                 /* pointer to variable storing the value */
73         union {
74                 guint uint;
75                 gboolean boolval;
76                 gint enumval;
77                 char *string;
78                 range_t *range;
79         } saved_val;            /* original value, when editing from the GUI */
80         union {
81           guint base;                   /* input/output base, for PREF_UINT */
82           guint32 max_value;            /* maximum value of a range */
83           struct {
84             const enum_val_t *enumvals; /* list of name & values */
85             gboolean radio_buttons;     /* TRUE if it should be shown as
86                                            radio buttons rather than as an
87                                            option menu or combo box in
88                                            the preferences tab */
89           } enum_info;                  /* for PREF_ENUM */
90         } info;                 /* display/text file information */
91         void    *control;       /* handle for GUI control for this preference */
92 };
93
94 gint find_val_for_string(const char *needle, const enum_val_t *haystack,
95     gint default_value);
96
97
98 /* read_prefs_file: read in a generic config file and do a callback to */
99 /* pref_set_pair_fct() for every key/value pair found */
100 typedef int (*pref_set_pair_cb) (gchar *key, gchar *value);
101
102 int
103 read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct);
104
105
106
107 #endif /* prefs-int.h */