2 * Definitions for implementation of preference handling routines;
3 * used by "friends" of the preferences type.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #ifndef __PREFS_INT_H__
27 #define __PREFS_INT_H__
30 #include "ws_symbol_export.h"
31 #include <epan/wmem/wmem.h>
38 const char *name; /**< name of module */
39 const char *title; /**< title of module (displayed in preferences list) */
40 const char *description; /**< Description of module (displayed in preferences notebook) */
41 void (*apply_cb)(void); /**< routine to call when preferences applied */
42 GList *prefs; /**< list of its preferences */
43 struct pref_module *parent; /**< parent module */
44 wmem_tree_t *submodules; /**< list of its submodules */
45 int numprefs; /**< number of non-obsolete preferences */
46 gboolean prefs_changed; /**< if TRUE, a preference has changed since we last checked */
47 gboolean obsolete; /**< if TRUE, this is a module that used to
48 * exist but no longer does
50 gboolean use_gui; /**< Determines whether or not the module will use the generic
51 * GUI interface/APIs with the preference value or if its own
52 * independent GUI will be provided. This allows all preferences
53 * to have a common API for reading/writing, but not require them to
54 * use simple GUI controls to change the options. In general, the "general"
55 * Wireshark preferences should have this set to FALSE, while the protocol
56 * modules will have this set to TRUE */
65 * Module used for protocol preferences.
66 * With MSVC and a libwireshark.dll, we need a special declaration.
68 WS_DLL_PUBLIC module_t *protocols_module;
70 typedef void (*pref_custom_free_cb) (pref_t* pref);
71 typedef void (*pref_custom_reset_cb) (pref_t* pref);
72 typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const gchar* value, gboolean* changed);
73 /* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
74 /* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
75 typedef const char * (*pref_custom_type_name_cb) (void);
76 typedef char * (*pref_custom_type_description_cb) (void);
77 typedef gboolean (*pref_custom_is_default_cb) (pref_t* pref);
78 typedef char * (*pref_custom_to_str_cb) (pref_t* pref, gboolean default_val);
80 /** Structure to hold callbacks for PREF_CUSTOM type */
81 struct pref_custom_cbs {
82 pref_custom_free_cb free_cb;
83 pref_custom_reset_cb reset_cb;
84 pref_custom_set_cb set_cb;
85 /* pref_custom_write_cb write_cb; Deprecated. */
86 pref_custom_type_name_cb type_name_cb;
87 pref_custom_type_description_cb type_description_cb;
88 pref_custom_is_default_cb is_default_cb;
89 pref_custom_to_str_cb to_str_cb;
93 * PREF_OBSOLETE is used for preferences that a module used to support
94 * but no longer supports; we give different error messages for them.
105 PREF_COLOR, /* XXX - These are only supported for "internal" (non-protocol) */
106 PREF_CUSTOM, /* use and not as a generic protocol preference */
117 /** Struct to hold preference data */
119 const char *name; /**< name of preference */
120 const char *title; /**< title to use in GUI */
121 const char *description; /**< human-readable description of preference */
122 int ordinal; /**< ordinal number of this preference */
123 pref_type_t type; /**< type of that preference */
124 gui_type_t gui; /**< type of the GUI (QT, GTK or both) the preference is registered for */
125 union { /* The Qt preference code assumes that these will all be pointers (and unique) */
131 struct epan_uat* uat;
134 } varp; /**< pointer to variable storing the value */
143 } stashed_val; /**< original value, when editing from the GUI */
152 } default_val; /**< the default value of the preference */
154 guint base; /**< input/output base, for PREF_UINT */
155 guint32 max_value; /**< maximum value of a range */
157 const enum_val_t *enumvals; /**< list of name & values */
158 gboolean radio_buttons; /**< TRUE if it should be shown as
159 radio buttons rather than as an
160 option menu or combo box in
161 the preferences tab */
162 } enum_info; /**< for PREF_ENUM */
163 } info; /**< display/text file information */
164 struct pref_custom_cbs custom_cbs; /**< for PREF_CUSTOM */
165 void *control; /**< handle for GUI control for this preference */
168 /* read_prefs_file: read in a generic config file and do a callback to */
169 /* pref_set_pair_fct() for every key/value pair found */
171 * Given a string of the form "<pref name>:<pref value>", as might appear
172 * as an argument to a "-o" option, parse it and set the preference in
174 * @return an indication of whether it succeeded or failed
177 typedef prefs_set_pref_e (*pref_set_pair_cb) (gchar *key, const gchar *value, void *private_data, gboolean return_range_errors);
179 /** read the preferences file (or similiar) and call the callback
180 * function to set each key/value pair found
184 read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data);
186 #endif /* prefs-int.h */