Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
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 <[email protected]>
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#include <stdio.h>
16#include "ws_symbol_export.h"
17#include <epan/wmem_scopes.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
28 const char *name;
29 const char *title;
30 const char *description;
31 const char *help;
32 void (*apply_cb)(void);
33 GList *prefs;
37 unsigned int prefs_changed_flags;
38 bool obsolete;
41 bool use_gui;
48 unsigned int effect_flags;
51};
52
53typedef struct {
54 module_t *module;
55 FILE *pf;
57
63
64typedef void (*pref_custom_free_cb) (pref_t* pref);
65typedef void (*pref_custom_reset_cb) (pref_t* pref);
66typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const char* value, unsigned int* changed_flags);
67/* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
68/* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
69typedef const char * (*pref_custom_type_name_cb) (void);
70typedef char * (*pref_custom_type_description_cb) (void);
71typedef bool (*pref_custom_is_default_cb) (pref_t* pref);
72typedef char * (*pref_custom_to_str_cb) (pref_t* pref, bool default_val);
73
76 pref_custom_free_cb free_cb;
77 pref_custom_reset_cb reset_cb;
78 pref_custom_set_cb set_cb;
79 /* pref_custom_write_cb write_cb; Deprecated. */
80 pref_custom_type_name_cb type_name_cb;
81 pref_custom_type_description_cb type_description_cb;
82 pref_custom_is_default_cb is_default_cb;
83 pref_custom_to_str_cb to_str_cb;
84};
85
90#define PREF_UINT (1u << 0)
91#define PREF_BOOL (1u << 1)
92#define PREF_ENUM (1u << 2)
93#define PREF_STRING (1u << 3)
94#define PREF_RANGE (1u << 4)
95#define PREF_STATIC_TEXT (1u << 5)
96#define PREF_UAT (1u << 6)
97#define PREF_SAVE_FILENAME (1u << 7)
98#define PREF_COLOR (1u << 8) /* XXX - These are only supported for "internal" (non-protocol) */
99#define PREF_CUSTOM (1u << 9) /* use and not as a generic protocol preference */
100#define PREF_OBSOLETE (1u << 10)
101#define PREF_DIRNAME (1u << 11)
102// Was PREF_DECODE_AS_UINT (1u << 12)
103#define PREF_DECODE_AS_RANGE (1u << 13) /* XXX - Internal use only, not a generic protocol preference */
104#define PREF_OPEN_FILENAME (1u << 14)
105#define PREF_PASSWORD (1u << 15) /* like string, but never saved to prefs file */
110#define PREF_PROTO_TCP_SNDAMB_ENUM (1u << 16)
111
112#define PREF_DISSECTOR (1u << 17) /* like string, but with dissector name syntax check */
113
114/* read_prefs_file: read in a generic config file and do a callback to */
115/* pref_set_pair_fct() for every key/value pair found */
123typedef prefs_set_pref_e (*pref_set_pair_cb) (char *key, const char *value, void *private_data, bool return_range_errors);
124
125WS_DLL_PUBLIC
126const char* prefs_get_description(pref_t *pref);
127
128WS_DLL_PUBLIC
129const char* prefs_get_title(pref_t *pref);
130
131WS_DLL_PUBLIC
132const char* prefs_get_name(pref_t *pref);
133
134WS_DLL_PUBLIC
135int prefs_get_type(pref_t *pref);
136
137WS_DLL_PUBLIC uint32_t 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_LAYOUT (1u << 2)
143#define PREF_EFFECT_FIELDS (1u << 3)
144#define PREF_EFFECT_GUI (1u << 4)
145#define PREF_EFFECT_GUI_COLOR (1u << 5)
146
154WS_DLL_PUBLIC
155unsigned int prefs_get_effect_flags(pref_t *pref);
156
168WS_DLL_PUBLIC
169void prefs_set_effect_flags(pref_t *pref, unsigned int flags);
170
173WS_DLL_PUBLIC
174void prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags);
175
185WS_DLL_PUBLIC
186unsigned int prefs_get_module_effect_flags(module_t * module);
187
201WS_DLL_PUBLIC
202void prefs_set_module_effect_flags(module_t * module, unsigned int flags);
203
204WS_DLL_PUBLIC
205bool prefs_set_range_value_work(pref_t *pref, const char *value,
206 bool return_range_errors, unsigned int *changed_flags);
207
208WS_DLL_PUBLIC
209unsigned int
210prefs_set_stashed_range_value(pref_t *pref, const char *value);
211
213WS_DLL_PUBLIC
214void
215prefs_range_add_value(pref_t *pref, uint32_t val);
216
218WS_DLL_PUBLIC
219void
220prefs_range_remove_value(pref_t *pref, uint32_t val);
221
222
223WS_DLL_PUBLIC unsigned int prefs_set_bool_value(pref_t *pref, bool value, pref_source_t source);
224WS_DLL_PUBLIC bool prefs_get_bool_value(pref_t *pref, pref_source_t source);
225WS_DLL_PUBLIC void prefs_invert_bool_value(pref_t *pref, pref_source_t source);
226
227WS_DLL_PUBLIC unsigned int prefs_set_uint_value(pref_t *pref, unsigned value, pref_source_t source);
228WS_DLL_PUBLIC unsigned prefs_get_uint_base(pref_t *pref);
229WS_DLL_PUBLIC unsigned prefs_get_uint_value_real(pref_t *pref, pref_source_t source);
230
231
232WS_DLL_PUBLIC unsigned int prefs_set_enum_value(pref_t *pref, int value, pref_source_t source);
233WS_DLL_PUBLIC unsigned int prefs_set_enum_string_value(pref_t *pref, const char *value, pref_source_t source);
234WS_DLL_PUBLIC int prefs_get_enum_value(pref_t *pref, pref_source_t source);
235WS_DLL_PUBLIC const enum_val_t* prefs_get_enumvals(pref_t *pref);
236WS_DLL_PUBLIC bool prefs_get_enum_radiobuttons(pref_t *pref);
237
238WS_DLL_PUBLIC bool prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
239WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
240
241WS_DLL_PUBLIC unsigned int prefs_set_custom_value(pref_t *pref, const char *value, pref_source_t source);
242
243WS_DLL_PUBLIC unsigned int prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
244WS_DLL_PUBLIC char* prefs_get_string_value(pref_t *pref, pref_source_t source);
245
246WS_DLL_PUBLIC struct epan_uat* prefs_get_uat_value(pref_t *pref);
247
248WS_DLL_PUBLIC bool prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source);
249WS_DLL_PUBLIC range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source);
250
251WS_DLL_PUBLIC bool prefs_add_decode_as_value(pref_t *pref, unsigned value, bool replace);
252WS_DLL_PUBLIC bool prefs_remove_decode_as_value(pref_t *pref, unsigned value, bool set_default);
253
254WS_DLL_PUBLIC unsigned int prefs_set_password_value(pref_t *pref, const char* value, pref_source_t source);
255WS_DLL_PUBLIC char* prefs_get_password_value(pref_t *pref, pref_source_t source);
256
257WS_DLL_PUBLIC bool prefs_add_list_value(pref_t *pref, void *value, pref_source_t source);
258WS_DLL_PUBLIC GList* prefs_get_list_value(pref_t *pref, pref_source_t source);
259
260WS_DLL_PUBLIC void reset_pref(pref_t *pref);
261
265WS_DLL_PUBLIC
266int
267read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data);
268
275WS_DLL_PUBLIC
276void
277prefs_read_module(const char *name);
278
279WS_DLL_PUBLIC
280bool
281prefs_pref_is_default(pref_t *pref);
282
289WS_DLL_PUBLIC
290unsigned pref_stash(pref_t *pref, void *unused);
291
292typedef struct pref_unstash_data
293{
294 /* Used to set prefs_changed member to true if the preference
295 differs from its stashed values. */
296 module_t *module;
297 /* Qt uses stashed values to then "applies" them
298 during unstash. Use this flag for that behavior */
299 bool handle_decode_as;
301
310WS_DLL_PUBLIC
311unsigned pref_unstash(pref_t *pref, void *unstash_data_p);
312
321WS_DLL_PUBLIC
322unsigned pref_clean_stash(pref_t *pref, void *unused);
323
328WS_DLL_PUBLIC
329void reset_stashed_pref(pref_t *pref);
330
340WS_DLL_PUBLIC
341char *
342join_string_list(GList *sl);
343
344#ifdef __cplusplus
345}
346#endif /* __cplusplus */
347
348#endif /* prefs-int.h */
WS_DLL_PUBLIC void prefs_set_effect_flags(pref_t *pref, unsigned int flags)
Definition prefs.c:6624
WS_DLL_PUBLIC void prefs_set_effect_flags_by_name(module_t *module, const char *pref, unsigned int flags)
Definition prefs.c:6635
WS_DLL_PUBLIC unsigned pref_unstash(pref_t *pref, void *unstash_data_p)
Definition prefs.c:2190
WS_DLL_PUBLIC char * join_string_list(GList *sl)
Definition prefs.c:4168
WS_DLL_PUBLIC module_t * protocols_module
Definition prefs-int.h:62
prefs_set_pref_e(* pref_set_pair_cb)(char *key, const char *value, void *private_data, bool return_range_errors)
Definition prefs-int.h:123
WS_DLL_PUBLIC void prefs_set_module_effect_flags(module_t *module, unsigned int flags)
Definition prefs.c:6650
WS_DLL_PUBLIC unsigned int prefs_get_module_effect_flags(module_t *module)
Definition prefs.c:6641
WS_DLL_PUBLIC void prefs_range_remove_value(pref_t *pref, uint32_t val)
Definition prefs.c:1823
WS_DLL_PUBLIC void prefs_read_module(const char *name)
Definition prefs.c:4677
WS_DLL_PUBLIC unsigned pref_stash(pref_t *pref, void *unused)
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:4843
WS_DLL_PUBLIC void reset_stashed_pref(pref_t *pref)
Definition prefs.c:2338
WS_DLL_PUBLIC void prefs_range_add_value(pref_t *pref, uint32_t val)
Definition prefs.c:1817
WS_DLL_PUBLIC unsigned int prefs_get_effect_flags(pref_t *pref)
Definition prefs.c:6615
WS_DLL_PUBLIC unsigned pref_clean_stash(pref_t *pref, void *unused)
prefs_set_pref_e
Definition prefs.h:983
Definition wmem_tree-int.h:48
Definition color.h:23
Definition params.h:23
Definition range.h:41
Definition uat-int.h:40
Definition prefs-int.h:75
Definition prefs-int.h:27
unsigned int effect_flags
Definition prefs-int.h:48
GList * prefs
Definition prefs-int.h:33
bool use_gui
Definition prefs-int.h:41
wmem_tree_t * submodules
Definition prefs-int.h:35
const char * description
Definition prefs-int.h:30
const char * name
Definition prefs-int.h:28
bool obsolete
Definition prefs-int.h:38
struct pref_module * parent
Definition prefs-int.h:34
unsigned int prefs_changed_flags
Definition prefs-int.h:37
void(* apply_cb)(void)
Definition prefs-int.h:32
int numprefs
Definition prefs-int.h:36
const char * title
Definition prefs-int.h:29
const char * help
Definition prefs-int.h:31
Definition prefs-int.h:293
Definition prefs.c:248
Definition prefs-int.h:53