| Wireshark 4.7.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 <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#include <stdio.h>
16#include "ws_symbol_export.h"
17#include <epan/wmem_scopes.h>
18
19#ifdef __cplusplus
20 extern "C" {
21#endif /* __cplusplus */
22
27 struct pref_module {
28 const char *name;
29 const char *title;
30 const char *description;
31 const char *help;
32 void (*apply_cb)(void);
33 wmem_allocator_t* scope;
34 GList *prefs;
35 struct pref_module *parent;
36 wmem_tree_t *submodules;
37 int numprefs;
38 unsigned int prefs_changed_flags;
39 bool obsolete;
42 bool use_gui;
49 unsigned int effect_flags;
52};
53
54 typedef struct {
55 module_t *module;
56 FILE *pf;
57} write_pref_arg_t;
58
59 typedef void (*pref_custom_free_cb) (pref_t* pref);
60 typedef void (*pref_custom_reset_cb) (pref_t* pref);
61 typedef prefs_set_pref_e (*pref_custom_set_cb) (pref_t* pref, const char* value, unsigned int* changed_flags);
62/* typedef void (*pref_custom_write_cb) (pref_t* pref, write_pref_arg_t* arg); Deprecated. */
63/* pref_custom_type_name_cb should return NULL for internal / hidden preferences. */
64 typedef const char * (*pref_custom_type_name_cb) (void);
65 typedef char * (*pref_custom_type_description_cb) (void);
66 typedef bool (*pref_custom_is_default_cb) (pref_t* pref);
67 typedef char * (*pref_custom_to_str_cb) (pref_t* pref, bool default_val);
68
70 struct pref_custom_cbs {
71 pref_custom_free_cb free_cb;
72 pref_custom_reset_cb reset_cb;
73 pref_custom_set_cb set_cb;
74 /* pref_custom_write_cb write_cb; Deprecated. */
75 pref_custom_type_name_cb type_name_cb;
76 pref_custom_type_description_cb type_description_cb;
77 pref_custom_is_default_cb is_default_cb;
78 pref_custom_to_str_cb to_str_cb;
79};
80
81 typedef enum {
82 PREF_UINT,
83 PREF_BOOL,
84 PREF_ENUM,
85 PREF_STRING,
86 PREF_RANGE,
87 PREF_STATIC_TEXT,
88 PREF_UAT,
89 PREF_SAVE_FILENAME,
90 PREF_COLOR, // (1)
91 PREF_CUSTOM, // (1)
92 PREF_DIRNAME,
93 PREF_DECODE_AS_RANGE, // (2)
94 PREF_OPEN_FILENAME,
95 PREF_PASSWORD, // (3)
96 PREF_PROTO_TCP_SNDAMB_ENUM, // (4)
97 PREF_DISSECTOR, // (5)
98 PREF_INT,
99 PREF_FLOAT
100} pref_type_e;
101
102/*
103 * (1) These are only supported for "internal" (non-protocol) use
104 * and not as a generic protocol preference.
105 * (2) Internal use only, not a generic protocol preference.
106 * (3) Like string, but never saved to prefs file.
107 * (4) Dedicated to TCP PROTOCOL for handling manual SEQ interpretation,
108 * and allow users manage the sender traffic ambiguities
109 * (5) Like string, but with dissector name syntax check.
110 */
111
112/* read_prefs_file: read in a generic config file and do a callback to */
113/* pref_set_pair_fct() for every key/value pair found */
121 typedef prefs_set_pref_e (*pref_set_pair_cb) (char *key, const char *value, void *private_data, bool return_range_errors);
122
123WS_DLL_PUBLIC
124 const char* prefs_get_description(pref_t *pref);
125
126WS_DLL_PUBLIC
127 const char* prefs_get_title(pref_t *pref);
128
129WS_DLL_PUBLIC
130 const char* prefs_get_name(pref_t *pref);
131
132WS_DLL_PUBLIC
133 int prefs_get_type(pref_t *pref);
134
135WS_DLL_PUBLIC uint32_t prefs_get_max_value(pref_t *pref);
136
144WS_DLL_PUBLIC
145 unsigned int prefs_get_effect_flags(pref_t *pref);
146
158WS_DLL_PUBLIC
159 void prefs_set_effect_flags(pref_t *pref, unsigned int flags);
160
163WS_DLL_PUBLIC
164 void prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags);
165
175WS_DLL_PUBLIC
176 unsigned int prefs_get_module_effect_flags(module_t * module);
177
188WS_DLL_PUBLIC
189 unsigned prefs_module_list_foreach(const wmem_tree_t* module_list, module_cb callback,
190 void* user_data, bool skip_obsolete);
191
205WS_DLL_PUBLIC
206 void prefs_set_module_effect_flags(module_t * module, unsigned int flags);
207
208WS_DLL_PUBLIC
209 bool prefs_set_range_value_work(pref_t *pref, const char *value,
210 bool return_range_errors, unsigned int *changed_flags);
211
212WS_DLL_PUBLIC
213 unsigned int
214prefs_set_stashed_range_value(pref_t *pref, const char *value);
215
217WS_DLL_PUBLIC
218 void
219 prefs_range_add_value(pref_t *pref, uint32_t val);
220
222WS_DLL_PUBLIC
223 void
224 prefs_range_remove_value(pref_t *pref, uint32_t val);
225
226
227WS_DLL_PUBLIC unsigned int prefs_set_bool_value(pref_t *pref, bool value, pref_source_t source);
228WS_DLL_PUBLIC bool prefs_get_bool_value(pref_t *pref, pref_source_t source);
229WS_DLL_PUBLIC void prefs_invert_bool_value(pref_t *pref, pref_source_t source);
230
231WS_DLL_PUBLIC unsigned int prefs_set_uint_value(pref_t *pref, unsigned value, pref_source_t source);
232WS_DLL_PUBLIC unsigned prefs_get_uint_base(pref_t *pref);
233WS_DLL_PUBLIC unsigned prefs_get_uint_value(pref_t *pref, pref_source_t source);
234
235WS_DLL_PUBLIC unsigned int prefs_set_int_value(pref_t* pref, int value, pref_source_t source);
236WS_DLL_PUBLIC int prefs_get_int_value(pref_t* pref, pref_source_t source);
237
238WS_DLL_PUBLIC unsigned int prefs_set_float_value(pref_t* pref, double value, pref_source_t source);
239WS_DLL_PUBLIC double prefs_get_float_value(pref_t* pref, pref_source_t source);
240
241WS_DLL_PUBLIC unsigned int prefs_set_enum_value(pref_t *pref, int value, pref_source_t source);
242WS_DLL_PUBLIC unsigned int prefs_set_enum_string_value(pref_t *pref, const char *value, pref_source_t source);
243WS_DLL_PUBLIC int prefs_get_enum_value(pref_t *pref, pref_source_t source);
244WS_DLL_PUBLIC const enum_val_t* prefs_get_enumvals(pref_t *pref);
245WS_DLL_PUBLIC bool prefs_get_enum_radiobuttons(pref_t *pref);
246
247WS_DLL_PUBLIC bool prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
248WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
249
250WS_DLL_PUBLIC unsigned int prefs_set_custom_value(pref_t *pref, const char *value, pref_source_t source);
251
252WS_DLL_PUBLIC unsigned int prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
253WS_DLL_PUBLIC const char *prefs_get_string_value(pref_t *pref, pref_source_t source);
254
255WS_DLL_PUBLIC struct epan_uat* prefs_get_uat_value(pref_t *pref);
256
257WS_DLL_PUBLIC bool prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source);
258WS_DLL_PUBLIC range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source);
259
260WS_DLL_PUBLIC bool prefs_add_decode_as_value(pref_t *pref, unsigned value, bool replace);
261WS_DLL_PUBLIC bool prefs_remove_decode_as_value(pref_t *pref, unsigned value, bool set_default);
262
263WS_DLL_PUBLIC unsigned int prefs_set_password_value(pref_t *pref, const char* value, pref_source_t source);
264WS_DLL_PUBLIC const char *prefs_get_password_value(pref_t *pref, pref_source_t source);
265
266WS_DLL_PUBLIC bool prefs_add_list_value(pref_t *pref, void *value, pref_source_t source);
267WS_DLL_PUBLIC GList* prefs_get_list_value(pref_t *pref, pref_source_t source);
268
269WS_DLL_PUBLIC void reset_pref(pref_t *pref);
270
273WS_DLL_PUBLIC const wmem_tree_t* prefs_get_module_tree(void);
274
278WS_DLL_PUBLIC
279 int
280 read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data);
281
288WS_DLL_PUBLIC
289 void
290 prefs_read_module(const char *name, const char* app_env_var_prefix);
291
292WS_DLL_PUBLIC
293 bool
294prefs_pref_is_default(pref_t *pref);
295
302WS_DLL_PUBLIC
303 unsigned pref_stash(pref_t *pref, void *unused);
304
305 typedef struct pref_unstash_data
306{
307 /* Used to set prefs_changed member to true if the preference
308 differs from its stashed values. */
309 module_t *module;
310 /* Qt uses stashed values to then "applies" them
311 during unstash. Use this flag for that behavior */
312 bool handle_decode_as;
313} pref_unstash_data_t;
314
323WS_DLL_PUBLIC
324 unsigned pref_unstash(pref_t *pref, void *unstash_data_p);
325
334WS_DLL_PUBLIC
335 unsigned pref_clean_stash(pref_t *pref, void *unused);
336
341WS_DLL_PUBLIC
342 void reset_stashed_pref(pref_t *pref);
343
353WS_DLL_PUBLIC
354 char *
355 join_string_list(GList *sl);
356
364WS_DLL_PUBLIC
365 char *
366 prefs_sanitize_string(const char* str);
367
368#ifdef __cplusplus
369}
370#endif /* __cplusplus */
371
372#endif /* prefs-int.h */
prefs_module_list_foreach
WS_DLL_PUBLIC unsigned prefs_module_list_foreach(const wmem_tree_t *module_list, module_cb callback, void *user_data, bool skip_obsolete)
Definition prefs.c:871
prefs_set_effect_flags
WS_DLL_PUBLIC void prefs_set_effect_flags(pref_t *pref, unsigned int flags)
Definition prefs.c:6468
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:6479
pref_unstash
WS_DLL_PUBLIC unsigned pref_unstash(pref_t *pref, void *unstash_data_p)
Definition prefs.c:2174
join_string_list
WS_DLL_PUBLIC char * join_string_list(GList *sl)
Definition prefs.c:4261
pref_set_pair_cb
prefs_set_pref_e(* pref_set_pair_cb)(char *key, const char *value, void *private_data, bool return_range_errors)
Definition prefs-int.h:121
prefs_set_module_effect_flags
WS_DLL_PUBLIC void prefs_set_module_effect_flags(module_t *module, unsigned int flags)
Definition prefs.c:6494
prefs_get_module_effect_flags
WS_DLL_PUBLIC unsigned int prefs_get_module_effect_flags(module_t *module)
Definition prefs.c:6485
prefs_get_module_tree
WS_DLL_PUBLIC const wmem_tree_t * prefs_get_module_tree(void)
Definition prefs.c:349
prefs_range_remove_value
WS_DLL_PUBLIC void prefs_range_remove_value(pref_t *pref, uint32_t val)
Definition prefs.c:1828
prefs_sanitize_string
WS_DLL_PUBLIC char * prefs_sanitize_string(const char *str)
Definition prefs.c:5141
pref_stash
WS_DLL_PUBLIC unsigned pref_stash(pref_t *pref, void *unused)
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:4906
reset_stashed_pref
WS_DLL_PUBLIC void reset_stashed_pref(pref_t *pref)
Definition prefs.c:2341
prefs_range_add_value
WS_DLL_PUBLIC void prefs_range_add_value(pref_t *pref, uint32_t val)
Definition prefs.c:1822
prefs_get_effect_flags
WS_DLL_PUBLIC unsigned int prefs_get_effect_flags(pref_t *pref)
Definition prefs.c:6459
pref_clean_stash
WS_DLL_PUBLIC unsigned pref_clean_stash(pref_t *pref, void *unused)
prefs_read_module
WS_DLL_PUBLIC void prefs_read_module(const char *name, const char *app_env_var_prefix)
Definition prefs.c:4755
module_cb
unsigned(* module_cb)(module_t *module, void *user_data)
Definition prefs.h:452
prefs_set_pref_e
prefs_set_pref_e
Definition prefs.h:1172
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
_wmem_tree_t
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81
color_t
RGB color representation with 16-bit precision per channel.
Definition color.h:27
enum_val_t
Definition params.h:23
epan_range
Definition range.h:41
epan_uat
Definition uat-int.h:40
pref_custom_cbs
Definition prefs-int.h:70
pref_module
Definition prefs-int.h:27
pref_module::effect_flags
unsigned int effect_flags
Definition prefs-int.h:49
pref_module::scope
wmem_allocator_t * scope
Definition prefs-int.h:33
pref_module::prefs
GList * prefs
Definition prefs-int.h:34
pref_module::use_gui
bool use_gui
Definition prefs-int.h:42
pref_module::submodules
wmem_tree_t * submodules
Definition prefs-int.h:36
pref_module::description
const char * description
Definition prefs-int.h:30
pref_module::name
const char * name
Definition prefs-int.h:28
pref_module::obsolete
bool obsolete
Definition prefs-int.h:39
pref_module::parent
struct pref_module * parent
Definition prefs-int.h:35
pref_module::prefs_changed_flags
unsigned int prefs_changed_flags
Definition prefs-int.h:38
pref_module::apply_cb
void(* apply_cb)(void)
Definition prefs-int.h:32
pref_module::numprefs
int numprefs
Definition prefs-int.h:37
pref_module::title
const char * title
Definition prefs-int.h:29
pref_module::help
const char * help
Definition prefs-int.h:31
pref_unstash_data
Definition prefs-int.h:306
preference
Definition prefs.c:216
write_pref_arg_t
Definition prefs-int.h:54
wmem_scopes.h