Free the string you "g_strdup()"ed, rather than handing "g_free()" the
[obnox/wireshark/wip.git] / prefs.h
diff --git a/prefs.h b/prefs.h
index ab628c0eb56af3f48211c16ce511ee1d2be9d911..580012a02ce2f44039c2806cbd822eb0ff486fcb 100644 (file)
--- a/prefs.h
+++ b/prefs.h
@@ -1,7 +1,7 @@
 /* prefs.h
  * Definitions for preference handling routines
  *
- * $Id: prefs.h,v 1.16 2000/07/05 09:40:42 guy Exp $
+ * $Id: prefs.h,v 1.29 2001/04/15 03:37:13 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
 #ifndef __PREFS_H__
 #define __PREFS_H__
 
+#include <glib.h>
+
+#include "color.h"
+
 #define PR_DEST_CMD  0
 #define PR_DEST_FILE 1
 
-#ifndef __GTK_H__
-#include <gtk/gtk.h>
-#endif
-
 typedef struct _e_prefs {
   gint     pr_format;
   gint     pr_dest;
@@ -40,12 +40,21 @@ typedef struct _e_prefs {
   gchar   *pr_cmd;
   GList   *col_list;
   gint     num_cols;
-  GdkColor st_client_fg, st_client_bg, st_server_fg, st_server_bg;
-  gboolean     gui_scrollbar_on_right;
-  gboolean     gui_plist_sel_browse;
-  gboolean     gui_ptree_sel_browse;
-  gint         gui_ptree_line_style;
-  gint         gui_ptree_expander_style;
+  color_t  st_client_fg, st_client_bg, st_server_fg, st_server_bg;
+  gboolean gui_scrollbar_on_right;
+  gboolean gui_plist_sel_browse;
+  gboolean gui_ptree_sel_browse;
+  gint     gui_ptree_line_style;
+  gint     gui_ptree_expander_style;
+  gboolean gui_hex_dump_highlight_style;
+  gchar   *gui_font_name;
+  color_t  gui_marked_fg;
+  color_t  gui_marked_bg;
+  gboolean name_resolve;
+  gboolean capture_prom_mode;
+  gboolean capture_real_time;
+  gboolean capture_auto_scroll;
+
 } e_prefs;
 
 extern e_prefs prefs;
@@ -64,19 +73,31 @@ typedef struct pref_module module_t;
  * Specify the name used for the module in the preferences file, the
  * title used in the tab for it in a preferences dialog box, and a
  * routine to call back when we apply the preferences.
+ * Note:
+ * In case of dissectors, the specified name should be the protocol
+ * name specified at the proto_register_protocol() call in order to
+ * make the "Protocol Properties..." menu item work.
  */
 module_t *prefs_register_module(const char *name, const char *title,
     void (*apply_cb)(void));
 
 typedef void (*module_cb)(module_t *module, gpointer user_data);
 
+/*
+ * Register that a protocol has preferences.
+ */
+module_t *prefs_register_protocol(int id, void (*apply_cb)(void));
+
 /*
  * Call a callback function, with a specified argument, for each module.
  */
 void prefs_module_foreach(module_cb callback, gpointer user_data);
 
 /*
- * Call the "apply" callback function for each module.
+ * Call the "apply" callback function for each module if any of its
+ * preferences have changed, and then clear the flag saying its
+ * preferences have changed, as the module has been notified of that
+ * fact.
  */
 void prefs_apply_all(void);
 
@@ -84,6 +105,16 @@ struct preference;
 
 typedef struct preference pref_t;
 
+/*
+ * Returns TRUE if the given protocol has registered preferences
+ */
+gboolean prefs_is_registered_protocol(char *name);
+
+/*
+ * Returns the module title of a registered protocol (or NULL if unknown)
+ */
+const char *prefs_get_title_by_name(char *name);
+
 /*
  * Register a preference with an unsigned integral value.
  */
@@ -102,11 +133,11 @@ void prefs_register_bool_preference(module_t *module, const char *name,
 typedef struct {
        char    *name;
        gint    value;
-} enum_val;
+} enum_val_t;
 
 void prefs_register_enum_preference(module_t *module, const char *name,
     const char *title, const char *description, gint *var,
-    const enum_val *enumvals, gboolean radio_buttons);
+    const enum_val_t *enumvals, gboolean radio_buttons);
 
 /*
  * Register a preference with a character-string value.
@@ -127,9 +158,31 @@ void prefs_pref_foreach(module_t *module, pref_cb callback, gpointer user_data);
  */
 void prefs_register_modules(void);
 
+/* Read the preferences file, fill in "prefs", and return a pointer to it.
+
+   If we got an error (other than "it doesn't exist") trying to read
+   the global preferences file, stuff the errno into "*gpf_errno_return"
+   and a pointer to the path of the file into "*gpf_path_return", and
+   return NULL.
+
+   If we got an error (other than "it doesn't exist") trying to read
+   the user's preferences file, stuff the errno into "*pf_errno_return"
+   and a pointer to the path of the file into "*pf_path_return", and
+   return NULL. */
 e_prefs *read_prefs(int *, char **, int *, char **);
+
+/* Write out "prefs" to the user's preferences file, and return 0.
+
+   If we got an error, stuff a pointer to the path of the preferences file
+   into "*pf_path_return", and return the errno. */
 int write_prefs(char **);
 
+/* Copy a set of preferences. */
+void copy_prefs(e_prefs *dest, e_prefs *src);
+
+/* Free a set of preferences. */
+void free_prefs(e_prefs *pr);
+
 /*
  * Given a string of the form "<pref name>:<pref value>", as might appear
  * as an argument to a "-o" option, parse it and set the preference in