2 * Definitions for implementation of preference handling routines;
3 * used by "friends" of the preferences type.
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #ifndef __PREFS_INT_H__
25 #define __PREFS_INT_H__
28 #include "ws_symbol_export.h"
29 #include <epan/wmem/wmem.h>
36 const char *name; /**< name of module */
37 const char *title; /**< title of module (displayed in preferences list) */
38 const char *description; /**< Description of module (displayed in preferences notebook) */
39 void (*apply_cb)(void); /**< routine to call when preferences applied */
40 GList *prefs; /**< list of its preferences */
41 struct pref_module *parent; /**< parent module */
42 wmem_tree_t *submodules; /**< list of its submodules */
43 int numprefs; /**< number of non-obsolete preferences */
44 gboolean prefs_changed; /**< if TRUE, a preference has changed since we last checked */
45 gboolean obsolete; /**< if TRUE, this is a module that used to
46 * exist but no longer does
48 gboolean use_gui; /**< Determines whether or not the module will use the generic
49 * GUI interface/APIs with the preference value or if its own
50 * independent GUI will be provided. This allows all preferences
51 * to have a common API for reading/writing, but not require them to
52 * use simple GUI controls to change the options. In general, the "general"
53 * Wireshark preferences should have this set to FALSE, while the protocol
54 * modules will have this set to TRUE */
63 * Module used for protocol preferences.
64 * With MSVC and a libwireshark.dll, we need a special declaration.
66 WS_DLL_PUBLIC module_t *protocols_module;
68 typedef void (*pref_custom_free_cb) (pref_t* pref);
69 typedef void (*pref_custom_reset_cb) (pref_t* pref);
70 typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const gchar* value, gboolean* changed);
71 /* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
72 /* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
73 typedef const char * (*pref_custom_type_name_cb) (void);
74 typedef char * (*pref_custom_type_description_cb) (void);
75 typedef gboolean (*pref_custom_is_default_cb) (pref_t* pref);
76 typedef char * (*pref_custom_to_str_cb) (pref_t* pref, gboolean default_val);
78 /** Structure to hold callbacks for PREF_CUSTOM type */
79 struct pref_custom_cbs {
80 pref_custom_free_cb free_cb;
81 pref_custom_reset_cb reset_cb;
82 pref_custom_set_cb set_cb;
83 /* pref_custom_write_cb write_cb; Deprecated. */
84 pref_custom_type_name_cb type_name_cb;
85 pref_custom_type_description_cb type_description_cb;
86 pref_custom_is_default_cb is_default_cb;
87 pref_custom_to_str_cb to_str_cb;
91 * PREF_OBSOLETE is used for preferences that a module used to support
92 * but no longer supports; we give different error messages for them.
103 PREF_COLOR, /* XXX - These are only supported for "internal" (non-protocol) */
104 PREF_CUSTOM, /* use and not as a generic protocol preference */
115 /** Struct to hold preference data */
117 const char *name; /**< name of preference */
118 const char *title; /**< title to use in GUI */
119 const char *description; /**< human-readable description of preference */
120 int ordinal; /**< ordinal number of this preference */
121 pref_type_t type; /**< type of that preference */
122 gui_type_t gui; /**< type of the GUI (QT, GTK or both) the preference is registered for */
123 union { /* The Qt preference code assumes that these will all be pointers (and unique) */
129 struct epan_uat* uat;
132 } varp; /**< pointer to variable storing the value */
141 } stashed_val; /**< original value, when editing from the GUI */
150 } default_val; /**< the default value of the preference */
152 guint base; /**< input/output base, for PREF_UINT */
153 guint32 max_value; /**< maximum value of a range */
155 const enum_val_t *enumvals; /**< list of name & values */
156 gboolean radio_buttons; /**< TRUE if it should be shown as
157 radio buttons rather than as an
158 option menu or combo box in
159 the preferences tab */
160 } enum_info; /**< for PREF_ENUM */
161 } info; /**< display/text file information */
162 struct pref_custom_cbs custom_cbs; /**< for PREF_CUSTOM */
163 void *control; /**< handle for GUI control for this preference */
166 /* read_prefs_file: read in a generic config file and do a callback to */
167 /* pref_set_pair_fct() for every key/value pair found */
169 * Given a string of the form "<pref name>:<pref value>", as might appear
170 * as an argument to a "-o" option, parse it and set the preference in
172 * @return an indication of whether it succeeded or failed
175 typedef prefs_set_pref_e (*pref_set_pair_cb) (gchar *key, const gchar *value, void *private_data, gboolean return_range_errors);
177 /** read the preferences file (or similiar) and call the callback
178 * function to set each key/value pair found
182 read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data);
184 #endif /* prefs-int.h */