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 */
111 /** Struct to hold preference data */
113 const char *name
; /**< name of preference */
114 const char *title
; /**< title to use in GUI */
115 const char *description
; /**< human-readable description of preference */
116 int ordinal
; /**< ordinal number of this preference */
117 pref_type_t type
; /**< type of that preference */
118 union { /* The Qt preference code assumes that these will all be pointers (and unique) */
127 } varp
; /**< pointer to variable storing the value */
136 } stashed_val
; /**< original value, when editing from the GUI */
145 } default_val
; /**< the default value of the preference */
147 guint base
; /**< input/output base, for PREF_UINT */
148 guint32 max_value
; /**< maximum value of a range */
150 const enum_val_t
*enumvals
; /**< list of name & values */
151 gboolean radio_buttons
; /**< TRUE if it should be shown as
152 radio buttons rather than as an
153 option menu or combo box in
154 the preferences tab */
155 } enum_info
; /**< for PREF_ENUM */
156 } info
; /**< display/text file information */
157 struct pref_custom_cbs custom_cbs
; /**< for PREF_CUSTOM */
158 void *control
; /**< handle for GUI control for this preference */
161 /* read_prefs_file: read in a generic config file and do a callback to */
162 /* pref_set_pair_fct() for every key/value pair found */
164 * Given a string of the form "<pref name>:<pref value>", as might appear
165 * as an argument to a "-o" option, parse it and set the preference in
167 * @return an indication of whether it succeeded or failed
170 typedef prefs_set_pref_e (*pref_set_pair_cb
) (gchar
*key
, const gchar
*value
, void *private_data
, gboolean return_range_errors
);
172 /** read the preferences file (or similiar) and call the callback
173 * function to set each key/value pair found
177 read_prefs_file(const char *pf_path
, FILE *pf
, pref_set_pair_cb pref_set_pair_fct
, void *private_data
);
179 #endif /* prefs-int.h */