wireshark/epan/prefs-int.h

117 lines
3.7 KiB
C
Raw Normal View History

/* prefs-int.h
* Definitions for implementation of preference handling routines;
* used by "friends" of the preferences type.
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PREFS_INT_H__
#define __PREFS_INT_H__
#include <stdio.h>
struct pref_module {
const char *name; /* name of module */
const char *title; /* title of module (displayed in preferences list) */
const char *description;/* Description of module (displayed in preferences notebook) */
void (*apply_cb)(void); /* routine to call when preferences applied */
This change allows a structure to be created under the "Protocols" section of the preferences. A new function is introduced, prefs_register_protocol_subtree(), that allows the subtree the protocol should appear under to be specified. The subtree is specified as a string, with a '/' delimiting each subtree element. For example, prefs_register_protocol(proto_dap, prefs_register_dap); becomes prefs_register_protocol_subtree("OSI/X.500", proto_dap, prefs_register_dap); The function will create all the intermediate subtree nodes that are required, if they don't already exist. This allows the grouping of procotols which should make the list of protocols more manageable as even more are added. The current aim is to group by protocol family e.g. + OSI + X.400 X.411 X.420 + X.500 DISP DAP DOP DSP + X.509 X509AF X509CE ... but others grouping could be envisioned (e.g. by first letter). As the intermediate nodes may already have preferences (e.g. OSI), then modules are now allowed to have submodules. Previously each node was either a subtree or held preferences. This is consistent with the "User Interface" node. The subtree structure has no effect on how the preferences are saved to file, and the "Protocol Preferences..." menu option will bring up the preferences expanded to the correct node. In addition, a new "blank page" has been introduced for intermediate nodes that have no preferences (and is also used when the "Protocols" node itself is chosen). This prevents confusion when the user moves from a node with preferences to a node without preferences, but the page old page is still shown. There is also a change to prevent '#' characters in a value being treated as a comment when parsing the preferences file. (There is nothing that adds comments when writing the preferences file.) svn path=/trunk/; revision=21066
2007-03-19 19:08:22 +00:00
GList *prefs; /* list of its preferences */
emem_tree_t *submodules;/* list of its submodules */
int numprefs; /* number of non-obsolete preferences */
Turn the code of "colorize_packet()" into a static routine that is given a word to use in the progress dialog, and a flag indicating whether the display filter is to be reevaluated or not, and: have "colorize_packet()" call that routine with "Colorizing" and FALSE as those arguments; have the filtering code call that routine with "Filtering" and TRUE as those arguments; add an exported routine to call that routine with "Reprocessing" and TRUE as those arguments, to use to re-generate the packet list and to re-filter the packets if a protocol preference has been changed. Keep track of whether preferences are changed from their initial value by a preferences file or a command-line option, or from their previous value by the "Preferences" dialog box; have "prefs_apply_all()" only call the "apply" callback for a module if they have. Call "prefs_apply_all()" after the command-line arguments have been parsed and after "OK" has been clicked in the "Preferences" dialog box, to notify modules of preference changes if they've registered a callback for that. After "OK" has been clicked in the "Preferences" dialog box, if any preferences have changed, call the reprocessing routine, as the summary line for some frames and/or the current display filter's value when applied to some frames may have changed as a result of a preference change. Do the same after "OK" or "Apply" has been clicked in the "Display Options" dialog box (as it controls a protocol preferences item. svn path=/trunk/; revision=2126
2000-07-09 03:29:42 +00:00
gboolean prefs_changed; /* if TRUE, a preference has changed since we last checked */
gboolean obsolete; /* if TRUE, this is a module that used to
exist but no longer does */
};
/*
* Module used for protocol preferences.
* With MSVC and a libwireshark.dll, we need a special declaration.
*/
WS_VAR_IMPORT module_t *protocols_module;
/*
* PREF_OBSOLETE is used for preferences that a module used to support
* but no longer supports; we give different error messages for them.
*/
typedef enum {
PREF_UINT,
PREF_BOOL,
PREF_ENUM,
PREF_STRING,
PREF_RANGE,
PREF_STATIC_TEXT,
PREF_UAT,
PREF_OBSOLETE
} pref_type_t;
struct preference {
const char *name; /* name of preference */
const char *title; /* title to use in GUI */
const char *description; /* human-readable description of preference */
int ordinal; /* ordinal number of this preference */
pref_type_t type; /* type of that preference */
union {
guint *uint;
gboolean *boolp;
gint *enump;
const char **string;
range_t **range;
void* uat;
} varp; /* pointer to variable storing the value */
union {
guint uint;
gboolean boolval;
gint enumval;
char *string;
range_t *range;
} saved_val; /* original value, when editing from the GUI */
union {
guint uint;
gboolean boolval;
gint enumval;
char *string;
range_t *range;
} default_val; /* the default value of the preference */
union {
guint base; /* input/output base, for PREF_UINT */
guint32 max_value; /* maximum value of a range */
struct {
const enum_val_t *enumvals; /* list of name & values */
gboolean radio_buttons; /* TRUE if it should be shown as
radio buttons rather than as an
option menu or combo box in
the preferences tab */
} enum_info; /* for PREF_ENUM */
} info; /* display/text file information */
void *control; /* handle for GUI control for this preference */
};
/* read_prefs_file: read in a generic config file and do a callback to */
/* pref_set_pair_fct() for every key/value pair found */
typedef prefs_set_pref_e (*pref_set_pair_cb) (gchar *key, gchar *value, void *private_data);
int
read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data);
#endif /* prefs-int.h */