Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

prefs-int.h
Go to the documentation of this file.
1 /* prefs-int.h
2 * Definitions for implementation of preference handling routines;
3 * used by "friends" of the preferences type.
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12 #ifndef __PREFS_INT_H__
13 #define __PREFS_INT_H__
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif /* __cplusplus */
18
19 #include <stdio.h>
20 #include "ws_symbol_export.h"
21 #include <epan/wmem/wmem.h>
22
27 struct pref_module {
28 const char *name;
29 const char *title;
30 const char *description;
31 void (*apply_cb)(void);
32 GList *prefs;
33 struct pref_module *parent;
34 wmem_tree_t *submodules;
35 int numprefs;
36 unsigned int prefs_changed_flags;
37 gboolean obsolete;
40 gboolean use_gui;
47 unsigned int effect_flags;
50 };
51
52 typedef struct {
53 module_t *module;
54 FILE *pf;
55 } write_pref_arg_t;
56
61 WS_DLL_PUBLIC module_t *protocols_module;
62
63 typedef void (*pref_custom_free_cb) (pref_t* pref);
64 typedef void (*pref_custom_reset_cb) (pref_t* pref);
65 typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const gchar* value, unsigned int* changed_flags);
66 /* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
67 /* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
68 typedef const char * (*pref_custom_type_name_cb) (void);
69 typedef char * (*pref_custom_type_description_cb) (void);
70 typedef gboolean (*pref_custom_is_default_cb) (pref_t* pref);
71 typedef char * (*pref_custom_to_str_cb) (pref_t* pref, gboolean default_val);
72
74 struct pref_custom_cbs {
75 pref_custom_free_cb free_cb;
76 pref_custom_reset_cb reset_cb;
77 pref_custom_set_cb set_cb;
78 /* pref_custom_write_cb write_cb; Deprecated. */
79 pref_custom_type_name_cb type_name_cb;
80 pref_custom_type_description_cb type_description_cb;
81 pref_custom_is_default_cb is_default_cb;
82 pref_custom_to_str_cb to_str_cb;
83 };
84
89 #define PREF_UINT (1u << 0)
90 #define PREF_BOOL (1u << 1)
91 #define PREF_ENUM (1u << 2)
92 #define PREF_STRING (1u << 3)
93 #define PREF_RANGE (1u << 4)
94 #define PREF_STATIC_TEXT (1u << 5)
95 #define PREF_UAT (1u << 6)
96 #define PREF_SAVE_FILENAME (1u << 7)
97 #define PREF_COLOR (1u << 8) /* XXX - These are only supported for "internal" (non-protocol) */
98 #define PREF_CUSTOM (1u << 9) /* use and not as a generic protocol preference */
99 #define PREF_OBSOLETE (1u << 10)
100 #define PREF_DIRNAME (1u << 11)
101 #define PREF_DECODE_AS_UINT (1u << 12) /* XXX - These are only supported for "internal" (non-protocol) */
102 #define PREF_DECODE_AS_RANGE (1u << 13) /* use and not as a generic protocol preference */
103 #define PREF_OPEN_FILENAME (1u << 14)
104
105 typedef enum {
106 GUI_ALL,
107 GUI_GTK,
108 GUI_QT
109 } gui_type_t;
110
111 /* read_prefs_file: read in a generic config file and do a callback to */
112 /* pref_set_pair_fct() for every key/value pair found */
120 typedef prefs_set_pref_e (*pref_set_pair_cb) (gchar *key, const gchar *value, void *private_data, gboolean return_range_errors);
121
122 WS_DLL_PUBLIC
123 const char* prefs_get_description(pref_t *pref);
124
125 WS_DLL_PUBLIC
126 const char* prefs_get_title(pref_t *pref);
127
128 WS_DLL_PUBLIC
129 const char* prefs_get_name(pref_t *pref);
130
131 WS_DLL_PUBLIC
132 int prefs_get_type(pref_t *pref);
133
134 WS_DLL_PUBLIC
135 gui_type_t prefs_get_gui_type(pref_t *pref);
136
137 WS_DLL_PUBLIC guint32 prefs_get_max_value(pref_t *pref);
138
139 /* Bitmask of flags for the effect of a preference in Wireshark */
140 #define PREF_EFFECT_DISSECTION (1u << 0)
141 #define PREF_EFFECT_CAPTURE (1u << 1)
142 #define PREF_EFFECT_GUI (1u << 2)
143 #define PREF_EFFECT_FONT (1u << 3)
144 #define PREF_EFFECT_GUI_LAYOUT (1u << 4)
145 #define PREF_EFFECT_CUSTOM (1u << 31)
146
154 WS_DLL_PUBLIC
155 unsigned int prefs_get_effect_flags(pref_t *pref);
156
168 WS_DLL_PUBLIC
169 void prefs_set_effect_flags(pref_t *pref, unsigned int flags);
170
173 WS_DLL_PUBLIC
174 void prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags);
175
185 WS_DLL_PUBLIC
186 unsigned int prefs_get_module_effect_flags(module_t * module);
187
201 WS_DLL_PUBLIC
202 void prefs_set_module_effect_flags(module_t * module, unsigned int flags);
203
204 WS_DLL_PUBLIC
205 gboolean prefs_set_range_value_work(pref_t *pref, const gchar *value,
206 gboolean return_range_errors, unsigned int *changed_flags);
207
208 WS_DLL_PUBLIC
209 unsigned int
210 prefs_set_stashed_range_value(pref_t *pref, const gchar *value);
211
213 WS_DLL_PUBLIC
214 void
215 prefs_range_add_value(pref_t *pref, guint32 val);
216
218 WS_DLL_PUBLIC
219 void
220 prefs_range_remove_value(pref_t *pref, guint32 val);
221
222
223 WS_DLL_PUBLIC unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source);
224 WS_DLL_PUBLIC gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source);
225 WS_DLL_PUBLIC void prefs_invert_bool_value(pref_t *pref, pref_source_t source);
226
227 WS_DLL_PUBLIC unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source);
228 WS_DLL_PUBLIC guint prefs_get_uint_base(pref_t *pref);
229 WS_DLL_PUBLIC guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source);
230
231
232 WS_DLL_PUBLIC unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source);
233 WS_DLL_PUBLIC gint prefs_get_enum_value(pref_t *pref, pref_source_t source);
234 WS_DLL_PUBLIC const enum_val_t* prefs_get_enumvals(pref_t *pref);
235 WS_DLL_PUBLIC gboolean prefs_get_enum_radiobuttons(pref_t *pref);
236
237 WS_DLL_PUBLIC gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
238 WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
239
240 WS_DLL_PUBLIC unsigned int prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
241 WS_DLL_PUBLIC char* prefs_get_string_value(pref_t *pref, pref_source_t source);
242
243 WS_DLL_PUBLIC struct epan_uat* prefs_get_uat_value(pref_t *pref);
244
245 WS_DLL_PUBLIC gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source);
246 WS_DLL_PUBLIC range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source);
247
248 WS_DLL_PUBLIC gboolean prefs_add_decode_as_value(pref_t *pref, guint value, gboolean replace);
249 WS_DLL_PUBLIC gboolean prefs_remove_decode_as_value(pref_t *pref, guint value, gboolean set_default);
250
251 WS_DLL_PUBLIC void reset_pref(pref_t *pref);
252
256 WS_DLL_PUBLIC
257 int
258 read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data);
259
260 WS_DLL_PUBLIC
261 gboolean
262 prefs_pref_is_default(pref_t *pref);
263
270 WS_DLL_PUBLIC
271 guint pref_stash(pref_t *pref, gpointer unused _U_);
272
273 typedef struct pref_unstash_data
274 {
275 /* Used to set prefs_changed member to TRUE if the preference
276 differs from its stashed values. Also used by "decode as" types
277 to look up dissector short name */
278 module_t *module;
279 /* Qt uses stashed values to then "applies" them
280 during unstash. Use this flag for that behavior */
281 gboolean handle_decode_as;
282 } pref_unstash_data_t;
283
292 WS_DLL_PUBLIC
293 guint pref_unstash(pref_t *pref, gpointer unstash_data_p);
294
303 WS_DLL_PUBLIC
304 guint pref_clean_stash(pref_t *pref, gpointer unused _U_);
305
310 WS_DLL_PUBLIC
311 void reset_stashed_pref(pref_t *pref);
312
322 WS_DLL_PUBLIC
323 char *
324 join_string_list(GList *sl);
325
326 #ifdef __cplusplus
327 }
328 #endif /* __cplusplus */
329
330 #endif /* prefs-int.h */
pref_stash
WS_DLL_PUBLIC guint pref_stash(pref_t *pref, gpointer unused _U_)
Definition: prefs.c:1924
_wmem_tree_t
Definition: wmem_tree-int.h:47
prefs_get_effect_flags
WS_DLL_PUBLIC unsigned int prefs_get_effect_flags(pref_t *pref)
Definition: prefs.c:6020
reset_stashed_pref
WS_DLL_PUBLIC void reset_stashed_pref(pref_t *pref)
Definition: prefs.c:2116
pref_clean_stash
WS_DLL_PUBLIC guint pref_clean_stash(pref_t *pref, gpointer unused _U_)
Definition: prefs.c:2165
prefs_range_add_value
WS_DLL_PUBLIC void prefs_range_add_value(pref_t *pref, guint32 val)
Definition: prefs.c:1639
pref_module::use_gui
gboolean use_gui
Definition: prefs-int.h:40
prefs_set_module_effect_flags
WS_DLL_PUBLIC void prefs_set_module_effect_flags(module_t *module, unsigned int flags)
Definition: prefs.c:6052
pref_set_pair_cb
prefs_set_pref_e(* pref_set_pair_cb)(gchar *key, const gchar *value, void *private_data, gboolean return_range_errors)
Definition: prefs-int.h:120
pref_module::description
const char * description
Definition: prefs-int.h:30
pref_module
Definition: prefs-int.h:27
pref_module::title
const char * title
Definition: prefs-int.h:29
pref_module::submodules
wmem_tree_t * submodules
Definition: prefs-int.h:34
prefs_set_effect_flags
WS_DLL_PUBLIC void prefs_set_effect_flags(pref_t *pref, unsigned int flags)
Definition: prefs.c:6029
pref_custom_cbs
Definition: prefs-int.h:74
pref_unstash_data
Definition: prefs-int.h:273
write_pref_arg_t
Definition: prefs-int.h:52
prefs_range_remove_value
WS_DLL_PUBLIC void prefs_range_remove_value(pref_t *pref, guint32 val)
Definition: prefs.c:1645
pref_module::prefs_changed_flags
unsigned int prefs_changed_flags
Definition: prefs-int.h:36
prefs_set_effect_flags_by_name
WS_DLL_PUBLIC void prefs_set_effect_flags_by_name(module_t *module, const char *pref, unsigned int flags)
Definition: prefs.c:6037
color_t
Definition: color.h:20
range_t
Definition: sttype-range.c:22
preference
Definition: prefs.c:192
prefs_get_module_effect_flags
WS_DLL_PUBLIC unsigned int prefs_get_module_effect_flags(module_t *module)
Definition: prefs.c:6043
pref_unstash
WS_DLL_PUBLIC guint pref_unstash(pref_t *pref, gpointer unstash_data_p)
Definition: prefs.c:1975
enum_val_t
Definition: params.h:22
join_string_list
WS_DLL_PUBLIC char * join_string_list(GList *sl)
Definition: prefs.c:3713
read_prefs_file
WS_DLL_PUBLIC int read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data)
Definition: prefs.c:4355
pref_module::prefs
GList * prefs
Definition: prefs-int.h:32
pref_module::obsolete
gboolean obsolete
Definition: prefs-int.h:37
protocols_module
WS_DLL_PUBLIC module_t * protocols_module
Definition: prefs-int.h:61
pref_module::numprefs
int numprefs
Definition: prefs-int.h:35
pref_module::parent
struct pref_module * parent
Definition: prefs-int.h:33
epan_uat
Definition: uat-int.h:39
pref_module::effect_flags
unsigned int effect_flags
Definition: prefs-int.h:47
pref_module::name
const char * name
Definition: prefs-int.h:28
pref_module::apply_cb
void(* apply_cb)(void)
Definition: prefs-int.h:31