2 * Definitions for preference handling routines
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/params.h>
17 #include <epan/range.h>
19 #include <wsutil/color.h>
21 #include "ws_symbol_export.h"
25 #endif /* __cplusplus */
28 #define DEF_HEIGHT 550
30 #define MAX_VAL_LEN 1024
32 #define TAP_UPDATE_DEFAULT_INTERVAL 3000
33 #define ST_DEF_BURSTRES 5
34 #define ST_DEF_BURSTLEN 100
35 #define ST_MAX_BURSTRES 600000 /* somewhat arbitrary limit of 10 minutes */
36 #define ST_MAX_BURSTBUCKETS 100 /* somewhat arbitrary limit - more buckets degrade performance */
37 #define DEF_GUI_DECIMAL_PLACES1 2
38 #define DEF_GUI_DECIMAL_PLACES2 4
39 #define DEF_GUI_DECIMAL_PLACES3 6
41 #define CONV_DEINT_KEY_CAPFILE 0x01 /* unused yet */
42 #define CONV_DEINT_KEY_INTERFACE 0x02
43 #define CONV_DEINT_KEY_MAC 0x04
44 #define CONV_DEINT_KEY_VLAN 0x08
47 struct _e_addr_resolve
;
50 * Convert a string listing name resolution types to a bitmask of
53 * Set "*name_resolve" to the bitmask, and return '\0', on success;
54 * return the bad character in the string on error.
56 * @param string a list of name resolution types
57 * @param name_resolve the bitmap of names to resolve to set
58 * @return '\0' on success, the bad character in the string on error
61 char string_to_name_resolve(const char *string
, struct _e_addr_resolve
*name_resolve
);
64 * Modes for the starting directory in File Open dialogs.
66 #define FO_STYLE_LAST_OPENED 0 /* start in last directory we looked at */
67 #define FO_STYLE_SPECIFIED 1 /* start in specified directory */
68 #define FO_STYLE_CWD 2 /* start in current working directory at startup */
73 #define TB_STYLE_ICONS 0
74 #define TB_STYLE_TEXT 1
75 #define TB_STYLE_BOTH 2
80 #define COLOR_STYLE_DEFAULT 0
81 #define COLOR_STYLE_FLAT 1
82 #define COLOR_STYLE_GRADIENT 2
84 #define COLOR_STYLE_ALPHA 0.25
86 #define COLOR_SCHEME_DEFAULT 0
87 #define COLOR_SCHEME_LIGHT 1
88 #define COLOR_SCHEME_DARK 2
91 * Types of layout of summary/details/hex panes.
94 layout_unused
, /* entry currently unused */
108 layout_pane_content_none
,
109 layout_pane_content_plist
,
110 layout_pane_content_pdetails
,
111 layout_pane_content_pbytes
,
112 layout_pane_content_pdiagram
,
113 } layout_pane_content_e
;
116 * Places version information will show up
119 version_welcome_only
,
151 ABS_TIME_ASCII_NEVER
,
153 ABS_TIME_ASCII_COLUMN
,
154 ABS_TIME_ASCII_ALWAYS
,
161 UPDATE_CHANNEL_DEVELOPMENT
,
162 UPDATE_CHANNEL_STABLE
163 } software_update_channel_e
;
165 typedef struct _e_prefs
{
168 color_t st_client_fg
, st_client_bg
, st_server_fg
, st_server_bg
;
169 color_t gui_text_valid
, gui_text_invalid
, gui_text_deprecated
;
170 bool restore_filter_after_following_stream
;
171 int gui_toolbar_main_style
;
173 int gui_color_scheme
;
174 color_t gui_active_fg
;
175 color_t gui_active_bg
;
176 int gui_active_style
;
177 color_t gui_inactive_fg
;
178 color_t gui_inactive_bg
;
179 int gui_inactive_style
;
180 color_t gui_marked_fg
;
181 color_t gui_marked_bg
;
182 color_t gui_ignored_fg
;
183 color_t gui_ignored_bg
;
184 char *gui_colorized_fg
;
185 char *gui_colorized_bg
;
186 bool gui_geometry_save_position
;
187 bool gui_geometry_save_size
;
188 bool gui_geometry_save_maximized
;
189 unsigned gui_recent_df_entries_max
;
190 unsigned gui_recent_files_count_max
;
191 unsigned gui_fileopen_style
;
192 char *gui_fileopen_dir
;
193 unsigned gui_fileopen_preview
;
194 char *gui_tlskeylog_command
;
195 bool gui_ask_unsaved
;
196 bool gui_autocomplete_filter
;
198 char *gui_window_title
;
199 char *gui_prepend_window_title
;
200 char *gui_start_title
;
201 version_info_e gui_version_placement
;
202 unsigned gui_max_export_objects
;
203 unsigned gui_max_tree_items
;
204 unsigned gui_max_tree_depth
;
205 bool gui_welcome_page_show_recent
;
206 layout_type_e gui_layout_type
;
207 layout_pane_content_e gui_layout_content_1
;
208 layout_pane_content_e gui_layout_content_2
;
209 layout_pane_content_e gui_layout_content_3
;
210 splitter_layout_e gui_packet_dialog_layout
;
211 char *gui_interfaces_hide_types
;
212 bool gui_interfaces_show_hidden
;
213 bool gui_interfaces_remote_display
;
214 bool gui_io_graph_automatic_update
;
215 bool gui_io_graph_enable_legend
;
216 bool gui_packet_details_show_byteview
;
217 char *capture_device
;
218 char *capture_devices_linktypes
;
219 char *capture_devices_descr
;
220 char *capture_devices_hide
;
221 char *capture_devices_monitor_mode
;
222 char *capture_devices_buffersize
;
223 char *capture_devices_snaplen
;
224 char *capture_devices_pmode
;
225 char *capture_devices_filter
; /* XXX - Mostly unused. Deprecate? */
226 bool capture_prom_mode
;
227 bool capture_monitor_mode
;
228 bool capture_pcap_ng
;
229 bool capture_real_time
;
230 unsigned capture_update_interval
;
231 bool capture_no_interface_load
;
232 bool capture_no_extcap
;
233 bool capture_show_info
;
234 GList
*capture_columns
;
235 unsigned tap_update_interval
;
236 bool display_hidden_proto_items
;
237 bool display_byte_fields_with_spaces
;
238 abs_time_format_e display_abs_time_ascii
;
239 bool enable_incomplete_dissectors_check
;
240 bool incomplete_dissectors_check_debug
;
241 bool strict_conversation_tracking_heuristics
;
242 int conversation_deinterlacing_key
;
243 bool ignore_dup_frames
;
244 unsigned ignore_dup_frames_cache_entries
;
245 bool filter_expressions_old
; /* true if old filter expressions preferences were loaded. */
246 bool cols_hide_new
; /* true if the new (index-based) gui.column.hide preference was loaded. */
247 bool gui_update_enabled
;
248 software_update_channel_e gui_update_channel
;
249 int gui_update_interval
;
250 int gui_debounce_timer
;
251 char *saved_at_version
;
252 bool unknown_prefs
; /* unknown or obsolete pref(s) */
253 bool gui_packet_list_separator
;
254 bool gui_packet_header_column_definition
;
255 bool gui_packet_list_hover_style
; /* Enable/Disable mouse-over colorization */
256 bool gui_show_selected_packet
;
257 bool gui_show_file_load_time
;
258 elide_mode_e gui_packet_list_elide_mode
;
259 copy_format_e gui_packet_list_copy_format_options_for_keyboard_shortcut
;
260 bool gui_packet_list_copy_text_with_aligned_columns
;
261 bool gui_packet_list_show_related
;
262 bool gui_packet_list_show_minimap
;
263 bool gui_packet_list_sortable
;
264 unsigned gui_packet_list_cached_rows_max
;
265 int gui_decimal_places1
; /* Used for type 1 calculations */
266 int gui_decimal_places2
; /* Used for type 2 calculations */
267 int gui_decimal_places3
; /* Used for type 3 calculations */
268 bool gui_rtp_player_use_disk1
;
269 bool gui_rtp_player_use_disk2
;
270 unsigned flow_graph_max_export_items
;
271 bool st_enable_burstinfo
;
272 bool st_burst_showcount
;
273 int st_burst_resolution
;
274 int st_burst_windowlen
;
275 bool st_sort_casesensitve
;
276 bool st_sort_rng_fixorder
;
277 bool st_sort_rng_nameonly
;
278 int st_sort_defcolflag
;
279 bool st_sort_defdescending
;
280 bool st_sort_showfullname
;
281 bool extcap_save_on_start
;
284 WS_DLL_PUBLIC e_prefs prefs
;
287 * Routines to let modules that have preference settings register
288 * themselves by name, and to let them register preference settings
293 struct pref_custom_cbs
;
295 typedef struct pref_module module_t
;
297 /** Sets up memory used by proto routines. Called at program startup */
298 void prefs_init(void);
300 /** Reset preferences to default values. Called at profile change */
301 WS_DLL_PUBLIC
void prefs_reset(void);
303 /** Frees memory used by proto routines. Called at program shutdown */
304 void prefs_cleanup(void);
306 /** Store whether the current UI theme is dark so that we can adjust colors
307 * @param is_dark set to true if the UI's theme is dark
309 WS_DLL_PUBLIC
void prefs_set_gui_theme_is_dark(bool is_dark
);
312 * Register that a protocol has preferences.
313 * @param id the value returned by "proto_register_protocol()" when
314 * the protocol was registered.
315 * @param apply_cb callback routine that is called when preferences are
316 * applied. It may be NULL, which inhibits the callback.
317 * @return a preferences module which can be used to register a user 'preference'
319 WS_DLL_PUBLIC module_t
*prefs_register_protocol(int id
, void (*apply_cb
)(void));
322 * Register an alias for a preference module.
323 * @param name the preference module's alias. Only ASCII letters, numbers,
324 * underscores, hyphens, and dots may appear in the name
325 * @param module the module to create an alias for
327 WS_DLL_PUBLIC
void prefs_register_module_alias(const char *name
, module_t
*module
);
330 * Deregister preferences from a protocol.
331 * @param id the value returned by "proto_register_protocol()" when
332 * the protocol was registered.
334 void prefs_deregister_protocol(int id
);
337 * Register that a statistical tap has preferences.
339 * @param name the name for the tap to use on the command line with "-o"
340 * and in preference files.
341 * @param title is a short human-readable name for the tap.
342 * @param description is a longer human-readable description of the tap.
343 * @param apply_cb routine to call back after we apply the preferences
344 * @return a preferences module which can be used to register a user 'preference'
346 WS_DLL_PUBLIC module_t
*prefs_register_stat(const char *name
, const char *title
,
347 const char *description
, void (*apply_cb
)(void));
350 * Register that a codec has preferences.
352 * @param name is a name for the codec to use on the command line with "-o"
353 * and in preference files.
354 * @param title is a short human-readable name for the codec.
355 * @param description is a longer human-readable description of the codec.
356 * @param apply_cb routine to call back after we apply the preferences
357 * @return a preferences module which can be used to register a user 'preference'
359 WS_DLL_PUBLIC module_t
*prefs_register_codec(const char *name
, const char *title
,
360 const char *description
, void (*apply_cb
)(void));
363 * Register that a protocol has preferences and group it under a single
365 * @param subtree the tree node name for grouping preferences
366 * the protocol was registered.
367 * @param id the value returned by "proto_register_protocol()" when
368 * the protocol was registered.
369 * @param apply_cb Callback routine that is called when preferences are
370 * applied. It may be NULL, which inhibits the callback.
371 * @return a preferences module which can be used to register a user 'preference'
373 WS_DLL_PUBLIC module_t
*prefs_register_protocol_subtree(const char *subtree
, int id
,
374 void (*apply_cb
)(void));
377 * Register that a protocol used to have preferences but no longer does,
378 * by creating an "obsolete" module for it.
379 * @param id the value returned by "proto_register_protocol()" when
380 * the protocol was registered.
381 * @return a preferences module which can be used to register a user 'preference'
383 WS_DLL_PUBLIC module_t
*prefs_register_protocol_obsolete(int id
);
386 * Callback function for module list scanners.
388 typedef unsigned (*module_cb
)(module_t
*module
, void *user_data
);
391 * Returns true if a preferences module has any submodules
392 * @param module a preferences module which can be used to register a user 'preference'
393 * @return true if a preferences module has any submodules, otherwise false
395 WS_DLL_PUBLIC
bool prefs_module_has_submodules(module_t
*module
);
398 * Call a callback function, with a specified argument, for each module
399 * in the list of all modules. (This list does not include subtrees.)
401 * Ignores "obsolete" modules; their sole purpose is to allow old
402 * preferences for dissectors that no longer have preferences to be
403 * silently ignored in preference files.
405 * @param callback the callback to call
406 * @param user_data additional data to pass to the callback
408 WS_DLL_PUBLIC
unsigned prefs_modules_foreach(module_cb callback
, void *user_data
);
411 * Call a callback function, with a specified argument, for each submodule
412 * of a specified module. If the module is NULL, goes through the top-level
413 * list in the display tree of modules.
415 * Ignores "obsolete" modules; their sole purpose is to allow old
416 * preferences for dissectors that no longer have preferences to be
417 * silently ignored in preference files. Does not ignore subtrees,
418 * as this can be used when walking the display tree of modules.
420 * @param module the top-level module to walk through the submodules,
421 * or NULL for the top-level list in the display tree of modules
422 * @param callback the callback to call
423 * @param user_data additional data to pass to the callback
425 WS_DLL_PUBLIC
unsigned prefs_modules_foreach_submodules(module_t
*module
, module_cb callback
, void *user_data
);
428 * Call the "apply" callback function for each module if any of its
429 * preferences have changed, and then clear the flag saying its
430 * preferences have changed, as the module has been notified of that
433 WS_DLL_PUBLIC
void prefs_apply_all(void);
436 * Call the "apply" callback function for a specific module if any of
437 * its preferences have changed, and then clear the flag saying its
438 * preferences have changed, as the module has been notified of that
440 * @param module the module to call the 'apply' callback function for
442 WS_DLL_PUBLIC
void prefs_apply(module_t
*module
);
447 typedef struct preference pref_t
;
450 * Returns true if the provided protocol has registered preferences.
451 * @param name the name of the protocol to look up
452 * @return true if the given protocol has registered preferences, otherwise false
454 WS_DLL_PUBLIC
bool prefs_is_registered_protocol(const char *name
);
457 * Returns the module title of a registered protocol (or NULL if unknown).
458 * @param name the name of the protocol to look up
459 * @return the module title of a registered protocol, otherwise NULL
461 WS_DLL_PUBLIC
const char *prefs_get_title_by_name(const char *name
);
463 /** Given a module name, return a pointer to its pref_module struct,
464 * or NULL if it's not found.
466 * @param name The preference module name. Usually the same as the protocol
468 * @return A pointer to the corresponding preference module, or NULL if it
471 WS_DLL_PUBLIC module_t
*prefs_find_module(const char *name
);
473 /** Given a module and a preference name, return a pointer to the given
474 * module's given preference or NULL if it's not found.
476 * @param module The preference module name. Usually the same as the protocol
478 * @param pref The preference name, e.g. "desegment".
479 * @return A pointer to the corresponding preference, or NULL if it
482 WS_DLL_PUBLIC pref_t
*prefs_find_preference(module_t
* module
, const char *pref
);
485 * Register a preference with an unsigned integral value.
486 * @param module the preferences module returned by prefs_register_protocol() or
487 * prefs_register_protocol_subtree()
488 * @param name the preference's identifier. This is appended to the name of the
489 * protocol, with a "." between them, to create a unique identifier.
490 * The identifier should not include the protocol name, as
491 * the preference file will already have it. Make sure that
492 * only lower-case ASCII letters, numbers, underscores and
493 * dots appear in the preference name.
494 * @param title the title in the preferences dialog
495 * @param description the description included in the preferences file
496 * and shown as tooltip in the GUI, or NULL
497 * @param base the base the unsigned integer is expected to be in. See strtoul(3)
498 * @param var pointer to the storage location that is updated when the
499 * field is changed in the preference dialog box
501 WS_DLL_PUBLIC
void prefs_register_uint_preference(module_t
*module
, const char *name
,
502 const char *title
, const char *description
, unsigned base
, unsigned *var
);
505 * prefs_register_ callers must conform to the following:
507 * Names must be in lowercase letters only (underscore allowed).
508 * Titles and descriptions must be valid UTF-8 or NULL.
509 * Titles must be short (less than 80 characters)
510 * Titles must not contain newlines.
514 * Register a preference with an Boolean value.
515 * @param module the preferences module returned by prefs_register_protocol() or
516 * prefs_register_protocol_subtree()
517 * @param name the preference's identifier. This is appended to the name of the
518 * protocol, with a "." between them, to create a unique identifier.
519 * The identifier should not include the protocol name, as the name in
520 * the preference file will already have it. Make sure that
521 * only lower-case ASCII letters, numbers, underscores and
522 * dots appear in the preference name.
523 * @param title Field's title in the preferences dialog
524 * @param description description to include in the preferences file
525 * and shown as tooltip in the GUI, or NULL
526 * @param var pointer to the storage location that is updated when the
527 * field is changed in the preference dialog box
529 WS_DLL_PUBLIC
void prefs_register_bool_preference(module_t
*module
, const char *name
,
530 const char *title
, const char *description
, bool *var
);
533 * Register a preference with an enumerated value.
534 * @param module the preferences module returned by prefs_register_protocol() or
535 * prefs_register_protocol_subtree()
536 * @param name the preference's identifier. This is appended to the name of the
537 * protocol, with a "." between them, to create a unique identifier.
538 * The identifier should not include the protocol name, as the name in
539 * the preference file will already have it. Make sure that
540 * only lower-case ASCII letters, numbers, underscores and
541 * dots appear in the preference name.
542 * @param title Field's title in the preferences dialog
543 * @param description description to include in the preferences file
544 * and shown as tooltip in the GUI, or NULL
545 * @param var pointer to the storage location that is updated when the
546 * field is changed in the preference dialog box
547 * @param enumvals a null-terminated array of enum_val_t structures
548 * @param radio_buttons true if the field is to be displayed in the
549 * preferences dialog as a set of radio buttons,
550 * false if it is to be displayed as an option menu
552 WS_DLL_PUBLIC
void prefs_register_enum_preference(module_t
*module
, const char *name
,
553 const char *title
, const char *description
, int *var
,
554 const enum_val_t
*enumvals
, bool radio_buttons
);
557 * Register a preference with a character-string value.
558 * @param module the preferences module returned by prefs_register_protocol() or
559 * prefs_register_protocol_subtree()
560 * @param name the preference's identifier. This is appended to the name of the
561 * protocol, with a "." between them, to create a unique identifier.
562 * The identifier should not include the protocol name, as the name in
563 * the preference file will already have it. Make sure that
564 * only lower-case ASCII letters, numbers, underscores and
565 * dots appear in the preference name.
566 * @param title Field's title in the preferences dialog
567 * @param description description to include in the preferences file
568 * and shown as tooltip in the GUI, or NULL
569 * @param var pointer to the storage location that is updated when the
570 * field is changed in the preference dialog box. Note that
571 * with string preferences the given pointer is overwritten
572 * with a pointer to a new copy of the string during the
573 * preference registration. The passed-in string may be
574 * freed, but you must keep another pointer to the string
575 * in order to free it
577 WS_DLL_PUBLIC
void prefs_register_string_preference(module_t
*module
, const char *name
,
578 const char *title
, const char *description
, const char **var
);
581 * Register a preference with a file name (string) value.
583 * File name preferences are basically like string preferences
584 * except that the GUI gives the user the ability to browse for the
587 * @param module the preferences module returned by prefs_register_protocol() or
588 * prefs_register_protocol_subtree()
589 * @param name the preference's identifier. This is appended to the name of the
590 * protocol, with a "." between them, to create a unique identifier.
591 * The identifier should not include the protocol name, as the name in
592 * the preference file will already have it. Make sure that
593 * only lower-case ASCII letters, numbers, underscores and
594 * dots appear in the preference name.
595 * @param title Field's title in the preferences dialog
596 * @param description description to include in the preferences file
597 * and shown as tooltip in the GUI, or NULL
598 * @param var pointer to the storage location that is updated when the
599 * field is changed in the preference dialog box. Note that
600 * the given pointer is overwritten
601 * with a pointer to a new copy of the string during the
602 * preference registration. The passed-in string may be
603 * freed, but you must keep another pointer to the string
604 * in order to free it
605 * @param for_writing true to display a Save dialog, false to display an Open dialog.
607 WS_DLL_PUBLIC
void prefs_register_filename_preference(module_t
*module
, const char *name
,
608 const char *title
, const char *description
, const char **var
, bool for_writing
);
611 * Register a preference with a directory name (string) value.
612 * Directory name preferences are basically like string preferences
613 * except that the GUI gives the user the ability to browse for a
615 * @param module the preferences module returned by prefs_register_protocol() or
616 * prefs_register_protocol_subtree()
617 * @param name the preference's identifier. This is appended to the name of the
618 * protocol, with a "." between them, to create a unique identifier.
619 * The identifier should not include the protocol name, as the name in
620 * the preference file will already have it. Make sure that
621 * only lower-case ASCII letters, numbers, underscores and
622 * dots appear in the preference name.
623 * @param title Field's title in the preferences dialog
624 * @param description description to include in the preferences file
625 * and shown as tooltip in the GUI, or NULL
626 * @param var pointer to the storage location that is updated when the
627 * field is changed in the preference dialog box. Note that
628 * the given pointer is overwritten
629 * with a pointer to a new copy of the string during the
630 * preference registration. The passed-in string may be
631 * freed, but you must keep another pointer to the string
632 * in order to free it
634 WS_DLL_PUBLIC
void prefs_register_directory_preference(module_t
*module
, const char *name
,
635 const char *title
, const char *description
, const char **var
);
638 * Register a preference with a ranged value.
639 * @param module the preferences module returned by prefs_register_protocol() or
640 * prefs_register_protocol_subtree()
641 * @param name the preference's identifier. This is appended to the name of the
642 * protocol, with a "." between them, to create a unique identifier.
643 * The identifier should not include the protocol name, as the name in
644 * the preference file will already have it. Make sure that
645 * only lower-case ASCII letters, numbers, underscores and
646 * dots appear in the preference name.
647 * @param title Field's title in the preferences dialog
648 * @param description description to include in the preferences file
649 * and shown as tooltip in the GUI, or NULL
650 * @param var pointer to the storage location that is updated when the
651 * field is changed in the preference dialog box.
652 * @param max_value the maximum allowed value for a range (0 is the minimum)
654 WS_DLL_PUBLIC
void prefs_register_range_preference(module_t
*module
, const char *name
,
655 const char *title
, const char *description
, range_t
**var
,
659 * Register a static text 'preference'. It can be used to add some info/explanation.
660 * @param module the preferences module returned by prefs_register_protocol() or
661 * prefs_register_protocol_subtree()
662 * @param name the preference's identifier. This is appended to the name of the
663 * protocol, with a "." between them, to create a unique identifier.
664 * The identifier should not include the protocol name, as the name in
665 * the preference file will already have it. Make sure that
666 * only lower-case ASCII letters, numbers, underscores and
667 * dots appear in the preference name.
668 * @param title Field's title in the preferences dialog
669 * @param description description to include in the preferences file
670 * and shown as tooltip in the GUI, or NULL
672 WS_DLL_PUBLIC
void prefs_register_static_text_preference(module_t
*module
, const char *name
,
673 const char *title
, const char *description
);
676 * Register a uat (User Accessible Table) 'preference'. It adds a button that opens the uat's window in the
677 * preferences tab of the module.
678 * @param module the preferences module returned by prefs_register_protocol() or
679 * prefs_register_protocol_subtree()
680 * @param name the preference's identifier. This is appended to the name of the
681 * protocol, with a "." between them, to create a unique identifier.
682 * The identifier should not include the protocol name, as the name in
683 * the preference file will already have it. Make sure that
684 * only lower-case ASCII letters, numbers, underscores and
685 * dots appear in the preference name.
686 * @param title Field's title in the preferences dialog
687 * @param description description to include in the preferences file
688 * and shown as tooltip in the GUI, or NULL
689 * @param uat the uat object that will be updated when the
690 * field is changed in the preference dialog box
692 WS_DLL_PUBLIC
void prefs_register_uat_preference(module_t
*module
,
693 const char *name
, const char* title
, const char *description
, struct epan_uat
* uat
);
696 * Register a uat 'preference' for QT only. It adds a button that opens the uat's window in the
697 * preferences tab of the module.
698 * @param module the preferences module returned by prefs_register_protocol() or
699 * prefs_register_protocol_subtree()
700 * @param name the preference's identifier. This is appended to the name of the
701 * protocol, with a "." between them, to create a unique identifier.
702 * The identifier should not include the protocol name, as the name in
703 * the preference file will already have it. Make sure that
704 * only lower-case ASCII letters, numbers, underscores and
705 * dots appear in the preference name.
706 * @param title Field's title in the preferences dialog
707 * @param description description to include in the preferences file
708 * and shown as tooltip in the GUI, or NULL
709 * @param uat the uat object that will be updated when the
710 * field is changed in the preference dialog box
712 WS_DLL_PUBLIC
void prefs_register_uat_preference_qt(module_t
*module
,
713 const char *name
, const char* title
, const char *description
, struct epan_uat
* uat
);
717 * Register a color preference. Currently does not have any "GUI Dialog" support
718 * so the color data needs to be managed independently. Currently used by the
719 * "GUI preferences" to aid in reading/writing the preferences file, but the
720 * "data" is still managed by the specific "GUI preferences" dialog.
722 * @param module the preferences module returned by prefs_register_protocol() or
723 * prefs_register_protocol_subtree()
724 * @param name the preference's identifier. This is appended to the name of the
725 * protocol, with a "." between them, to create a unique identifier.
726 * The identifier should not include the protocol name, as the name in
727 * the preference file will already have it. Make sure that
728 * only lower-case ASCII letters, numbers, underscores and
729 * dots appear in the preference name.
730 * @param title Field's title in the preferences dialog
731 * @param description description to include in the preferences file
732 * and shown as tooltip in the GUI, or NULL
733 * @param color the color object that will be updated when the
734 * field is changed in the preference dialog box
736 void prefs_register_color_preference(module_t
*module
, const char *name
,
737 const char *title
, const char *description
, color_t
*color
);
740 * Register a custom preference. Currently does not have any "GUI Dialog" support
741 * so data needs to be managed independently. Currently used by the
742 * "GUI preferences" to aid in reading/writing the preferences file, but the
743 * "data" is still managed by the specific "GUI preferences" dialog.
745 * @param module the preferences module returned by prefs_register_protocol() or
746 * prefs_register_protocol_subtree()
747 * @param name the preference's identifier. This is appended to the name of the
748 * protocol, with a "." between them, to create a unique identifier.
749 * The identifier should not include the protocol name, as the name in
750 * the preference file will already have it. Make sure that
751 * only lower-case ASCII letters, numbers, underscores and
752 * dots appear in the preference name.
753 * @param title Field's title in the preferences dialog
754 * @param description description to include in the preferences file
755 * and shown as tooltip in the GUI, or NULL
756 * @param custom_cbs a structure with the custom preference's callbacks
757 * @param custom_data currently unused
759 void prefs_register_custom_preference(module_t
*module
, const char *name
,
760 const char *title
, const char *description
, struct pref_custom_cbs
* custom_cbs
,
764 * Register a (internal) "Decode As" preference with a ranged value.
765 * @param module the preferences module returned by prefs_register_protocol() or
766 * prefs_register_protocol_subtree()
767 * @param name the preference's identifier. This is appended to the name of the
768 * protocol, with a "." between them, to create a unique identifier.
769 * The identifier should not include the protocol name, as the name in
770 * the preference file will already have it. Make sure that
771 * only lower-case ASCII letters, numbers, underscores and
772 * dots appear in the preference name.
773 * @param title Field's title in the preferences dialog
774 * @param description description to include in the preferences file
775 * and shown as tooltip in the GUI, or NULL
776 * @param var pointer to the storage location that is updated when the
777 * field is changed in the preference dialog box.
778 * @param max_value the maximum allowed value for a range (0 is the minimum)
779 * @param dissector_table the name of the dissector table
780 * @param dissector_description the handle description
782 void prefs_register_decode_as_range_preference(module_t
*module
, const char *name
,
783 const char *title
, const char *description
, range_t
**var
,
784 uint32_t max_value
, const char *dissector_table
, const char *dissector_description
);
787 * Register a preference with an password (password is never stored).
788 * @param module the preferences module returned by prefs_register_protocol() or
789 * prefs_register_protocol_subtree()
790 * @param name the preference's identifier. This is appended to the name of the
791 * protocol, with a "." between them, to create a unique identifier.
792 * The identifier should not include the protocol name, as
793 * the preference file will already have it. Make sure that
794 * only lower-case ASCII letters, numbers, underscores and
795 * dots appear in the preference name.
796 * @param title the title in the preferences dialog
797 * @param description the description included in the preferences file
798 * and shown as tooltip in the GUI, or NULL
799 * @param var pointer to the storage location that is updated when the
800 * field is changed in the preference dialog box
802 WS_DLL_PUBLIC
void prefs_register_password_preference(module_t
*module
, const char *name
,
803 const char *title
, const char *description
, const char **var
);
806 * Register a preference with a dissector name.
807 * @param module the preferences module returned by prefs_register_protocol() or
808 * prefs_register_protocol_subtree()
809 * @param name the preference's identifier. This is appended to the name of the
810 * protocol, with a "." between them, to create a unique identifier.
811 * The identifier should not include the protocol name, as the name in
812 * the preference file will already have it. Make sure that
813 * only lower-case ASCII letters, numbers, underscores and
814 * dots appear in the preference name.
815 * @param title Field's title in the preferences dialog
816 * @param description description to include in the preferences file
817 * and shown as tooltip in the GUI, or NULL
818 * @param var pointer to the storage location that is updated when the
819 * field is changed in the preference dialog box. Note that
820 * with string preferences the given pointer is overwritten
821 * with a pointer to a new copy of the string during the
822 * preference registration. The passed-in string may be
823 * freed, but you must keep another pointer to the string
824 * in order to free it
826 WS_DLL_PUBLIC
void prefs_register_dissector_preference(module_t
*module
, const char *name
,
827 const char *title
, const char *description
, const char **var
);
830 * Register a preference that used to be supported but no longer is.
832 * Note that a warning will pop up if you've saved such preference to the
833 * preference file and you subsequently take the code out. The way to make
834 * a preference obsolete is to register it with prefs_register_obsolete_preference()
836 * @param module the preferences module returned by prefs_register_protocol() or
837 * prefs_register_protocol_subtree()
838 * @param name the preference's identifier. This is appended to the name of the
839 * protocol, with a "." between them, to create a unique identifier.
840 * The identifier should not include the protocol name, as the name in
841 * the preference file will already have it. Make sure that
842 * only lower-case ASCII letters, numbers, underscores and
843 * dots appear in the preference name.
845 WS_DLL_PUBLIC
void prefs_register_obsolete_preference(module_t
*module
,
849 * Register a preference with an enumerated value.
850 * @param module the preferences module returned by prefs_register_protocol() or
851 * prefs_register_protocol_subtree()
852 * @param name the preference's identifier. This is appended to the name of the
853 * protocol, with a "." between them, to create a unique identifier.
854 * The identifier should not include the protocol name, as the name in
855 * the preference file will already have it. Make sure that
856 * only lower-case ASCII letters, numbers, underscores and
857 * dots appear in the preference name.
858 * @param title Field's title in the preferences dialog
859 * @param description description to include in the preferences file
860 * and shown as tooltip in the GUI, or NULL
861 * @param var pointer to the storage location that is updated when the
862 * field is changed in the preference dialog box
863 * @param enumvals a null-terminated array of enum_val_t structures
864 * @param radio_buttons true if the field is to be displayed in the
865 * preferences dialog as a set of radio buttons,
866 * false if it is to be displayed as an option menu
868 WS_DLL_PUBLIC
void prefs_register_custom_preference_TCP_Analysis(module_t
*module
, const char *name
,
869 const char *title
, const char *description
, int *var
,
870 const enum_val_t
*enumvals
, bool radio_buttons
);
873 * Mark a preference that affects fields change. This works for bool, enum,
874 * int, string (containing filename), range preferences. UAT is not included,
875 * because you can specified UAT_AFFECTS_FIELDS at uat_new().
877 * @param module the preferences module returned by prefs_register_protocol() or
878 * prefs_register_protocol_subtree()
879 * @param name the preference's identifier. This is appended to the name of the
880 * protocol, with a "." between them, to create a unique identifier.
881 * The identifier should not include the protocol name, as the name in
882 * the preference file will already have it. Make sure that
883 * only lower-case ASCII letters, numbers, underscores and
884 * dots appear in the preference name.
886 WS_DLL_PUBLIC
void prefs_set_preference_effect_fields(module_t
*module
,
890 typedef unsigned (*pref_cb
)(pref_t
*pref
, void *user_data
);
893 * Call a callback function, with a specified argument, for each preference
896 * If any of the callbacks return a non-zero value, stop and return that
897 * value, otherwise return 0.
899 * @param module the preferences module returned by prefs_register_protocol() or
900 * prefs_register_protocol_subtree()
901 * @param callback the callback to call
902 * @param user_data additional data to pass to the callback
903 * @return If any of the callbacks return a non-zero value, stop and return that
904 * value, otherwise return 0.
906 WS_DLL_PUBLIC
unsigned prefs_pref_foreach(module_t
*module
, pref_cb callback
,
910 * Parse through a list of comma-separated, possibly quoted strings.
911 * Return a list of the string data.
913 * Commas, whitespace, and the quotes surrounding entries are removed.
914 * Quotes and backslashes escaped with a backslash (\") will remain.
916 * @param str a list of comma-separated, possibly quoted strings
917 * @return a list of the string data, or NULL if there's an error
919 WS_DLL_PUBLIC GList
*prefs_get_string_list(const char *str
);
922 * Clear the given list of string data.
923 * @param sl the GList to clear
925 WS_DLL_PUBLIC
void prefs_clear_string_list(GList
*sl
);
927 /** Fetch a short preference type name, e.g. "Integer".
929 * @param pref A preference.
931 * @return The preference type name. May be NULL.
934 const char *prefs_pref_type_name(pref_t
*pref
);
936 /** Fetch a long description of the preference type
938 * @param pref A preference.
940 * @return A description of the preference type including allowed
941 * values for enums. The description may include newlines. Must be
945 char *prefs_pref_type_description(pref_t
*pref
);
947 /** Fetch a string representation of the preference.
949 * @param pref A preference.
950 * @param source Which value of the preference to return, see pref_source_t.
952 * @return A string representation of the preference. Must be g_free()d.
955 char *prefs_pref_to_str(pref_t
*pref
, pref_source_t source
);
958 * Read the preferences file, fill in "prefs", and return a pointer to it.
959 * If we got an error (other than "it doesn't exist") we report it through
962 * This is called by epan_load_settings(); programs should call that
963 * rather than individually calling the routines it calls.
965 * @return a pointer to the filled in prefs object
967 extern e_prefs
*read_prefs(void);
970 * Write out "prefs" to the user's preferences file, and return 0.
972 * If we got an error, stuff a pointer to the path of the preferences file
973 * into "*pf_path_return", and return the errno.
975 * @param pf_path_return The path to write preferences to or NULL for stdout
976 * @return 0 if success, otherwise errno
978 WS_DLL_PUBLIC
int write_prefs(char **pf_path_return
);
981 * Result of setting a preference.
984 PREFS_SET_OK
, /* succeeded */
985 PREFS_SET_SYNTAX_ERR
, /* syntax error in string */
986 PREFS_SET_NO_SUCH_PREF
, /* no such preference */
987 PREFS_SET_OBSOLETE
/* preference used to exist but no longer does */
991 * Given a string of the form "<pref name>:<pref value>", as might appear
992 * as an argument to a "-o" option, parse it and set the preference in
993 * question. Return an indication of whether it succeeded or failed
996 * For syntax errors (return value PREFS_SET_SYNTAX_ERR), details (when
997 * available) are written into "errmsg" which must be freed with g_free.
999 * @param prefarg a string of the form "<pref name>:<pref value>"
1000 * @param errmsg storage for syntax error details
1001 * @return the result from attempting to set the preference
1003 WS_DLL_PUBLIC prefs_set_pref_e
prefs_set_pref(char *prefarg
, char **errmsg
);
1006 * Get or set a preference's obsolete status. These can be used to make a
1007 * preference obsolete after startup so that we can fetch its value but
1008 * keep it from showing up in the prefrences dialog.
1010 * @param pref A preference.
1011 * @return true if the preference is obsolete, otherwise false
1013 bool prefs_get_preference_obsolete(pref_t
*pref
);
1016 * Make a preference obsolete
1018 * @param pref a preference.
1019 * @return the result from attempting to set the preference
1021 prefs_set_pref_e
prefs_set_preference_obsolete(pref_t
*pref
);
1024 * Get the current range preference value (maintained by pref, so it doesn't need to be freed). This allows the
1025 * preference structure to remain hidden from those that doesn't really need it.
1027 * @param module_name the preference module name. Usually the same as the protocol
1029 * @param pref_name the preference name, e.g. "desegment".
1030 * @return the preference's value
1032 WS_DLL_PUBLIC range_t
* prefs_get_range_value(const char *module_name
, const char* pref_name
);
1035 * Returns true if the specified capture device is hidden
1036 * @param name the name of the capture device
1037 * @return true if the specified capture device is hidden, otherwise false
1039 WS_DLL_PUBLIC
bool prefs_is_capture_device_hidden(const char *name
);
1042 * Returns true if the given device should capture in monitor mode by default
1043 * @param name the name of the capture device
1044 * @return true if the specified capture device should capture in monitor mode by default, otherwise false
1046 WS_DLL_PUBLIC
bool prefs_capture_device_monitor_mode(const char *name
);
1049 * Returns true if the user has marked this column as visible
1051 * @param column the name of the column
1052 * @return true if this column as visible, otherwise false
1054 WS_DLL_PUBLIC
bool prefs_capture_options_dialog_column_is_visible(const char *column
);
1057 * Returns true if the layout pane content is enabled
1059 * @param layout_pane_content the layout pane content to check
1060 * @return true if the layout pane content is enabled, otherwise false
1062 WS_DLL_PUBLIC
bool prefs_has_layout_pane_content (layout_pane_content_e layout_pane_content
);
1066 #endif /* __cplusplus */
1068 #endif /* prefs.h */
1071 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1076 * indent-tabs-mode: nil
1079 * vi: set shiftwidth=4 tabstop=8 expandtab:
1080 * :indentSize=4:tabSize=8:noTabs=true: