Use #defines for vtype values, rather than numbers.
[obnox/wireshark/wip.git] / prefs.c
diff --git a/prefs.c b/prefs.c
index 257d91d336afaf5a82af4a7e201abec5d8e715d5..0d31bfd077b7f922bb1f45bcedad69a83f74109d 100644 (file)
--- a/prefs.c
+++ b/prefs.c
@@ -1,22 +1,22 @@
 /* prefs.c
  * Routines for handling preferences
  *
- * $Id: prefs.c,v 1.70 2001/11/04 02:50:19 guy Exp $
+ * $Id: prefs.c,v 1.91 2002/09/28 15:23:13 gerald Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
  * 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.
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
 #include <glib.h>
 
-#include <filesystem.h>
+#include <epan/filesystem.h>
 #include "globals.h"
-#include "packet.h"
+#include <epan/resolv.h>
+#include <epan/packet.h>
 #include "file.h"
 #include "prefs.h"
-#include "proto.h"
+#include <epan/proto.h>
 #include "column.h"
 #include "print.h"
 
@@ -121,10 +118,11 @@ prefs_register_module(const char *name, const char *title,
        module->prefs = NULL;   /* no preferences, to start */
        module->numprefs = 0;
        module->prefs_changed = FALSE;
+       module->obsolete = FALSE;
 
        /*
-        * Make sure that only lower-case ASCII letters, numbers, and
-        * underscores appear in the module name.
+        * Make sure that only lower-case ASCII letters, numbers,
+        * underscores, and dots appear in the module name.
         *
         * Crash if there is, as that's an error in the code;
         * you can make the title a nice string with capitalization,
@@ -134,7 +132,7 @@ prefs_register_module(const char *name, const char *title,
         */
        for (p = name; *p != '\0'; p++)
                g_assert(isascii(*p) &&
-                   (islower(*p) || isdigit(*p) || *p == '_'));
+                   (islower(*p) || isdigit(*p) || *p == '_' || *p == '.'));
 
        /*
         * Make sure there's not already a module with that
@@ -160,6 +158,22 @@ prefs_register_protocol(int id, void (*apply_cb)(void))
                                     apply_cb);
 }
 
+/*
+ * Register that a protocol used to have preferences but no longer does,
+ * by creating an "obsolete" module for it.
+ */
+module_t *
+prefs_register_protocol_obsolete(int id)
+{
+       module_t *module;
+
+       module = prefs_register_module(proto_get_protocol_filter_name(id),
+                                      proto_get_protocol_short_name(id),
+                                      NULL);
+       module->obsolete = TRUE;
+       return module;
+}
+
 /*
  * Find a module, given its name.
  */
@@ -194,11 +208,15 @@ do_module_callback(gpointer data, gpointer user_data)
        module_t *module = data;
        module_cb_arg_t *arg = user_data;
 
-       (*arg->callback)(module, arg->user_data);
+       if (!module->obsolete)
+               (*arg->callback)(module, arg->user_data);
 }
 
 /*
  * Call a callback function, with a specified argument, for each module.
+ * Ignores "obsolete" modules; their sole purpose is to allow old
+ * preferences for dissectors that no longer have preferences to be
+ * silently ignored in preference files.
  */
 void
 prefs_module_foreach(module_cb callback, gpointer user_data)
@@ -211,10 +229,12 @@ prefs_module_foreach(module_cb callback, gpointer user_data)
 }
 
 static void
-call_apply_cb(gpointer data, gpointer user_data)
+call_apply_cb(gpointer data, gpointer user_data _U_)
 {
        module_t *module = data;
 
+       if (module->obsolete)
+               return;
        if (module->prefs_changed) {
                if (module->apply_cb != NULL)
                        (*module->apply_cb)();
@@ -236,6 +256,10 @@ prefs_apply_all(void)
 
 /*
  * Register a preference in a module's list of preferences.
+ * If it has a title, give it an ordinal number; otherwise, it's a
+ * preference that won't show up in the UI, so it shouldn't get an
+ * ordinal number (the ordinal should be the ordinal in the set of
+ * *visible* preferences).
  */
 static pref_t *
 register_preference(module_t *module, const char *name, const char *title,
@@ -248,7 +272,10 @@ register_preference(module_t *module, const char *name, const char *title,
        preference->name = name;
        preference->title = title;
        preference->description = description;
-       preference->ordinal = module->numprefs;
+       if (title != NULL)
+               preference->ordinal = module->numprefs;
+       else
+               preference->ordinal = -1;       /* no ordinal for you */
 
        /*
         * Make sure that only lower-case ASCII letters, numbers,
@@ -258,7 +285,7 @@ register_preference(module_t *module, const char *name, const char *title,
         * you can make the title and description nice strings
         * with capitalization, white space, punctuation, etc.,
         * but the name can be used on the command line,
-        * and shouldn't require quoting, Shifting, etc.
+        * and shouldn't require quoting, shifting, etc.
         */
        for (p = name; *p != '\0'; p++)
                g_assert(isascii(*p) &&
@@ -277,7 +304,8 @@ register_preference(module_t *module, const char *name, const char *title,
         * preference.
         */
        module->prefs = g_list_append(module->prefs, preference);
-       module->numprefs++;
+       if (title != NULL)
+               module->numprefs++;
 
        return preference;
 }
@@ -313,7 +341,9 @@ find_preference(module_t *module, const char *name)
 gboolean
 prefs_is_registered_protocol(char *name)
 {
-       return (find_module(name) != NULL);
+       module_t *m = find_module(name);
+
+       return (m != NULL && !m->obsolete);
 }
 
 /*
@@ -323,7 +353,8 @@ const char *
 prefs_get_title_by_name(char *name)
 {
        module_t *m = find_module(name);
-       return  (m) ? m->title : NULL;
+
+       return (m != NULL && !m->obsolete) ? m->title : NULL;
 }
 
 /*
@@ -352,7 +383,7 @@ prefs_register_bool_preference(module_t *module, const char *name,
 
        preference = register_preference(module, name, title, description);
        preference->type = PREF_BOOL;
-       preference->varp.bool = var;
+       preference->varp.boolp = var;
 }
 
 /*
@@ -596,13 +627,13 @@ put_string_list(GList *sl)
     pref_str[cur_len - 2] = '\0';
 
   return(pref_str);
-}    
+}
 
 static void
 clear_string_list(GList *sl)
 {
   GList *l = sl;
-  
+
   while (l) {
     g_free(l->data);
     l = g_list_remove_link(l, l);
@@ -627,7 +658,7 @@ find_val_for_string(const char *needle, const enum_val_t *haystack,
                if (strcasecmp(needle, haystack[i].name) == 0) {
                        return haystack[i].value;
                }
-               i++;    
+               i++;
        }
        return default_value;
 }
@@ -646,13 +677,13 @@ find_index_from_string_array(char *needle, char **haystack, int default_value)
                if (strcmp(needle, haystack[i]) == 0) {
                        return i;
                }
-               i++;    
+               i++;
        }
        return default_value;
 }
 
 /* Preferences file format:
- * - Configuration directives start at the beginning of the line, and 
+ * - Configuration directives start at the beginning of the line, and
  *   are terminated with a colon.
  * - Directives can be continued on the next line by preceding them with
  *   whitespace.
@@ -686,10 +717,10 @@ static void read_prefs_file(const char *pf_path, FILE *pf);
    return NULL. */
 e_prefs *
 read_prefs(int *gpf_errno_return, char **gpf_path_return,
-          int *pf_errno_return, const char **pf_path_return)
+          int *pf_errno_return, char **pf_path_return)
 {
   int         i;
-  const char *pf_path;
+  char       *pf_path;
   FILE       *pf;
   fmt_data   *cfmt;
   gchar      *col_fmt[] = {"No.",      "%m", "Time",        "%t",
@@ -732,6 +763,7 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
     prefs.gui_scrollbar_on_right = TRUE;
     prefs.gui_plist_sel_browse = FALSE;
     prefs.gui_ptree_sel_browse = FALSE;
+    prefs.gui_altern_colors = FALSE;
     prefs.gui_ptree_line_style = 0;
     prefs.gui_ptree_expander_style = 1;
     prefs.gui_hex_dump_highlight_style = 1;
@@ -785,20 +817,27 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
      */
     prefs.gui_font_name = g_strdup("-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-iso8859-1");
 #endif
-    prefs.gui_marked_fg.pixel = 65535;
-    prefs.gui_marked_fg.red   = 65535;
-    prefs.gui_marked_fg.green = 65535;
-    prefs.gui_marked_fg.blue  = 65535;
-    prefs.gui_marked_bg.pixel =     0;
-    prefs.gui_marked_bg.red   =     0;
-    prefs.gui_marked_bg.green =     0;
-    prefs.gui_marked_bg.blue  =     0;
+    prefs.gui_marked_fg.pixel        =     65535;
+    prefs.gui_marked_fg.red          =     65535;
+    prefs.gui_marked_fg.green        =     65535;
+    prefs.gui_marked_fg.blue         =     65535;
+    prefs.gui_marked_bg.pixel        =         0;
+    prefs.gui_marked_bg.red          =         0;
+    prefs.gui_marked_bg.green        =         0;
+    prefs.gui_marked_bg.blue         =         0;
+    prefs.gui_geometry_save_position =         0;
+    prefs.gui_geometry_save_size     =         1;
+    prefs.gui_geometry_main_x        =        20;
+    prefs.gui_geometry_main_y        =        20;
+    prefs.gui_geometry_main_width    = DEF_WIDTH;
+    prefs.gui_geometry_main_height   =        -1;
 
 /* set the default values for the capture dialog box */
-    prefs.capture_prom_mode   =  TRUE;
+    prefs.capture_device      = NULL;
+    prefs.capture_prom_mode   = TRUE;
     prefs.capture_real_time   = FALSE;
     prefs.capture_auto_scroll = FALSE;
-    prefs.name_resolve        = PREFS_RESOLV_ALL;
+    prefs.name_resolve        = RESOLV_ALL ^ RESOLV_NETWORK;
   }
 
   /* Construct the pathname of the global preferences file. */
@@ -827,13 +866,15 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
 
   /* Construct the pathname of the user's preferences file. */
   pf_path = get_persconffile_path(PF_NAME, FALSE);
-    
+
   /* Read the user's preferences file, if it exists. */
   *pf_path_return = NULL;
   if ((pf = fopen(pf_path, "r")) != NULL) {
     /* We succeeded in opening it; read it. */
     read_prefs_file(pf_path, pf);
     fclose(pf);
+    g_free(pf_path);
+    pf_path = NULL;
   } else {
     /* We failed to open it.  If we failed for some reason other than
        "it doesn't exist", return the errno and the pathname, so our
@@ -843,7 +884,7 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
       *pf_path_return = pf_path;
     }
   }
-  
+
   return &prefs;
 }
 
@@ -881,7 +922,7 @@ read_prefs_file(const char *pf_path, FILE *pf)
       var_len = 0;
       continue;
     }
-    
+
     switch (state) {
       case START:
         if (isalnum(got_c)) {
@@ -989,7 +1030,7 @@ read_prefs_file(const char *pf_path, FILE *pf)
 int
 prefs_set_pref(char *prefarg)
 {
-       u_char *p, *colonp;
+       guchar *p, *colonp;
        int ret;
 
        /*
@@ -1043,12 +1084,19 @@ prefs_set_pref(char *prefarg)
 #define PRS_GUI_SCROLLBAR_ON_RIGHT "gui.scrollbar_on_right"
 #define PRS_GUI_PLIST_SEL_BROWSE "gui.packet_list_sel_browse"
 #define PRS_GUI_PTREE_SEL_BROWSE "gui.protocol_tree_sel_browse"
+#define PRS_GUI_ALTERN_COLORS "gui.tree_view_altern_colors"
 #define PRS_GUI_PTREE_LINE_STYLE "gui.protocol_tree_line_style"
 #define PRS_GUI_PTREE_EXPANDER_STYLE "gui.protocol_tree_expander_style"
 #define PRS_GUI_HEX_DUMP_HIGHLIGHT_STYLE "gui.hex_dump_highlight_style"
 #define PRS_GUI_FONT_NAME "gui.font_name"
 #define PRS_GUI_MARKED_FG "gui.marked_frame.fg"
 #define PRS_GUI_MARKED_BG "gui.marked_frame.bg"
+#define PRS_GUI_GEOMETRY_SAVE_POSITION "gui.geometry.save.position"
+#define PRS_GUI_GEOMETRY_SAVE_SIZE     "gui.geometry.save.size"
+#define PRS_GUI_GEOMETRY_MAIN_X        "gui.geometry.main.x"
+#define PRS_GUI_GEOMETRY_MAIN_Y        "gui.geometry.main.y"
+#define PRS_GUI_GEOMETRY_MAIN_WIDTH    "gui.geometry.main.width"
+#define PRS_GUI_GEOMETRY_MAIN_HEIGHT   "gui.geometry.main.height"
 
 /*
  * This applies to more than just captures, so it's not "capture.name_resolve";
@@ -1061,8 +1109,9 @@ prefs_set_pref(char *prefarg)
 #define PRS_CAP_NAME_RESOLVE "capture.name_resolve"
 
 /*  values for the capture dialog box */
-#define PRS_CAP_REAL_TIME "capture.real_time_update"
-#define PRS_CAP_PROM_MODE "capture.prom_mode"
+#define PRS_CAP_DEVICE      "capture.device"
+#define PRS_CAP_PROM_MODE   "capture.prom_mode"
+#define PRS_CAP_REAL_TIME   "capture.real_time_update"
 #define PRS_CAP_AUTO_SCROLL "capture.auto_scroll"
 
 #define RED_COMPONENT(x)   ((((x) >> 16) & 0xff) * 65535 / 255)
@@ -1078,9 +1127,9 @@ typedef struct {
 } name_resolve_opt_t;
 
 static name_resolve_opt_t name_resolve_opt[] = {
-  { 'm', PREFS_RESOLV_MAC },
-  { 'n', PREFS_RESOLV_NETWORK },
-  { 't', PREFS_RESOLV_TRANSPORT },
+  { 'm', RESOLV_MAC },
+  { 'n', RESOLV_NETWORK },
+  { 't', RESOLV_TRANSPORT },
 };
 
 #define N_NAME_RESOLVE_OPT     (sizeof name_resolve_opt / sizeof name_resolve_opt[0])
@@ -1093,7 +1142,7 @@ name_resolve_to_string(guint32 name_resolve)
   unsigned int i;
   gboolean all_opts_set = TRUE;
 
-  if (name_resolve == PREFS_RESOLV_NONE)
+  if (name_resolve == RESOLV_NONE)
     return "FALSE";
   p = &string[0];
   for (i = 0; i < N_NAME_RESOLVE_OPT; i++) {
@@ -1143,9 +1192,10 @@ set_pref(gchar *pref_name, gchar *value)
   gboolean bval;
   gint     enum_val;
   char     *p;
-  gchar    *dotp;
+  gchar    *dotp, *last_dotp;
   module_t *module;
   pref_t   *pref;
+  gboolean had_a_dot;
 
   if (strcmp(pref_name, PRS_PRINT_FMT) == 0) {
     if (strcmp(value, pr_formats[PR_FMT_TEXT]) == 0) {
@@ -1260,6 +1310,13 @@ set_pref(gchar *pref_name, gchar *value)
     else {
            prefs.gui_ptree_sel_browse = FALSE;
     }
+  } else if (strcmp(pref_name, PRS_GUI_ALTERN_COLORS) == 0) {
+    if (strcasecmp(value, "true") == 0) {
+            prefs.gui_altern_colors = TRUE;
+    }
+    else {
+            prefs.gui_altern_colors = FALSE;
+    }
   } else if (strcmp(pref_name, PRS_GUI_PTREE_LINE_STYLE) == 0) {
          prefs.gui_ptree_line_style =
                  find_index_from_string_array(value, gui_ptree_line_style_text, 0);
@@ -1285,54 +1342,108 @@ set_pref(gchar *pref_name, gchar *value)
     prefs.gui_marked_bg.red   = RED_COMPONENT(cval);
     prefs.gui_marked_bg.green = GREEN_COMPONENT(cval);
     prefs.gui_marked_bg.blue  = BLUE_COMPONENT(cval);
-
-/* handle the capture options */ 
+  } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_POSITION) == 0) {
+    if (strcasecmp(value, "true") == 0) {
+           prefs.gui_geometry_save_position = TRUE;
+    }
+    else {
+           prefs.gui_geometry_save_position = FALSE;
+    }
+  } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_SIZE) == 0) {
+    if (strcasecmp(value, "true") == 0) {
+           prefs.gui_geometry_save_size = TRUE;
+    }
+    else {
+           prefs.gui_geometry_save_size = FALSE;
+    }
+  } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_X) == 0) {
+    prefs.gui_geometry_main_x = strtol(value, NULL, 10);
+  } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_Y) == 0) {
+    prefs.gui_geometry_main_y = strtol(value, NULL, 10);
+  } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_WIDTH) == 0) {
+    prefs.gui_geometry_main_width = strtol(value, NULL, 10);
+  } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_HEIGHT) == 0) {
+    prefs.gui_geometry_main_height = strtol(value, NULL, 10);
+
+/* handle the capture options */
+  } else if (strcmp(pref_name, PRS_CAP_DEVICE) == 0) {
+    if (prefs.capture_device != NULL)
+      g_free(prefs.capture_device);
+    prefs.capture_device = g_strdup(value);
   } else if (strcmp(pref_name, PRS_CAP_PROM_MODE) == 0) {
-    prefs.capture_prom_mode = ((strcasecmp(value, "true") == 0)?TRUE:FALSE); 
+    prefs.capture_prom_mode = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
   } else if (strcmp(pref_name, PRS_CAP_REAL_TIME) == 0) {
-    prefs.capture_real_time = ((strcasecmp(value, "true") == 0)?TRUE:FALSE); 
-
+    prefs.capture_real_time = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
   } else if (strcmp(pref_name, PRS_CAP_AUTO_SCROLL) == 0) {
-    prefs.capture_auto_scroll = ((strcasecmp(value, "true") == 0)?TRUE:FALSE); 
+    prefs.capture_auto_scroll = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
+
 /* handle the global options */
   } else if (strcmp(pref_name, PRS_NAME_RESOLVE) == 0 ||
             strcmp(pref_name, PRS_CAP_NAME_RESOLVE) == 0) {
     /*
      * "TRUE" and "FALSE", for backwards compatibility, are synonyms for
-     * PREFS_RESOLV_ALL and PREFS_RESOLV_NONE.
+     * RESOLV_ALL and RESOLV_NONE.
      *
      * Otherwise, we treat it as a list of name types we want to resolve.
      */
     if (strcasecmp(value, "true") == 0)
-      prefs.name_resolve = PREFS_RESOLV_ALL;
+      prefs.name_resolve = RESOLV_ALL;
     else if (strcasecmp(value, "false") == 0)
-      prefs.name_resolve = PREFS_RESOLV_NONE;
+      prefs.name_resolve = RESOLV_NONE;
     else {
-      prefs.name_resolve = PREFS_RESOLV_NONE;  /* start out with none set */
+      prefs.name_resolve = RESOLV_NONE;        /* start out with none set */
       if (string_to_name_resolve(value, &prefs.name_resolve) != '\0')
         return PREFS_SET_SYNTAX_ERR;
     }
   } else {
     /* To which module does this preference belong? */
-    dotp = strchr(pref_name, '.');
-    if (dotp == NULL)
-      return PREFS_SET_SYNTAX_ERR;     /* no ".", so no module/name separator */
-    *dotp = '\0';              /* separate module and preference name */
-    module = find_module(pref_name);
+    module = NULL;
+    last_dotp = pref_name;
+    had_a_dot = FALSE;
+    while (!module) {
+        dotp = strchr(last_dotp, '.');
+        if (dotp == NULL) {
+            if (had_a_dot) {
+              /* no such module */
+              return PREFS_SET_NO_SUCH_PREF;
+            }
+            else {
+              /* no ".", so no module/name separator */
+              return PREFS_SET_SYNTAX_ERR;
+            }
+        }
+        else {
+            had_a_dot = TRUE;
+        }
+        *dotp = '\0';          /* separate module and preference name */
+        module = find_module(pref_name);
+
+        /*
+         * XXX - "Diameter" rather than "diameter" was used in earlier
+         * versions of Ethereal; if we didn't find the module, and its name
+         * was "Diameter", look for "diameter" instead.
+         *
+         * In addition, the BEEP protocol used to be the BXXP protocol,
+         * so if we didn't find the module, and its name was "bxxp",
+         * look for "beep" instead.
+         *
+         * Also, the preferences for GTP v0 and v1 were combined under
+         * a single "gtp" heading.
+         */
+        if (module == NULL) {
+          if (strcmp(pref_name, "Diameter") == 0)
+            module = find_module("diameter");
+          else if (strcmp(pref_name, "bxxp") == 0)
+            module = find_module("beep");
+          else if (strcmp(pref_name, "gtpv0") == 0 ||
+                   strcmp(pref_name, "gtpv1") == 0)
+            module = find_module("gtp");
+        }
+        *dotp = '.';           /* put the preference string back */
+        dotp++;                        /* skip past separator to preference name */
+        last_dotp = dotp;
+    }
 
-    /*
-     * XXX - "Diameter" rather than "diameter" was used in earlier
-     * versions of Ethereal; if we didn't find the module, and its name
-     * was "Diameter", look for "diameter" instead.
-     */
-    if (module == NULL && strcmp(pref_name, "Diameter") == 0)
-      module = find_module("diameter");
-    *dotp = '.';               /* put the preference string back */
-    if (module == NULL)
-      return PREFS_SET_NO_SUCH_PREF;   /* no such module */
-    dotp++;                    /* skip past separator to preference name */
     pref = find_preference(module, dotp);
 
     if (pref == NULL) {
@@ -1383,6 +1494,20 @@ set_pref(gchar *pref_name, gchar *value)
           /* Otherwise it's from the command line, and we don't bother
              mapping it. */
        }
+      } else if (strncmp(pref_name, "smb.", 4) == 0) {
+        /* Handle old names for SMB preferences. */
+        if (strcmp(dotp, "smb.trans.reassembly") == 0)
+          pref = find_preference(module, "trans_reassembly");
+        else if (strcmp(dotp, "smb.dcerpc.reassembly") == 0)
+          pref = find_preference(module, "dcerpc_reassembly");
+      } else if (strncmp(pref_name, "ndmp.", 5) == 0) {
+        /* Handle old names for NDMP preferences. */
+        if (strcmp(dotp, "ndmp.desegment") == 0)
+          pref = find_preference(module, "desegment");
+      } else if (strncmp(pref_name, "diameter.", 9) == 0) {
+        /* Handle old names for Diameter preferences. */
+        if (strcmp(dotp, "diameter.desegment") == 0)
+          pref = find_preference(module, "desegment");
       }
     }
     if (pref == NULL)
@@ -1406,9 +1531,9 @@ set_pref(gchar *pref_name, gchar *value)
         bval = TRUE;
       else
         bval = FALSE;
-      if (*pref->varp.bool != bval) {
+      if (*pref->varp.boolp != bval) {
        module->prefs_changed = TRUE;
-       *pref->varp.bool = bval;
+       *pref->varp.boolp = bval;
       }
       break;
 
@@ -1435,7 +1560,7 @@ set_pref(gchar *pref_name, gchar *value)
       return PREFS_SET_OBSOLETE;       /* no such preference any more */
     }
   }
-  
+
   return PREFS_SET_OK;
 }
 
@@ -1495,7 +1620,7 @@ write_pref(gpointer data, gpointer user_data)
        case PREF_BOOL:
                fprintf(arg->pf, "# TRUE or FALSE (case-insensitive).\n");
                fprintf(arg->pf, "%s.%s: %s\n", arg->module->name, pref->name,
-                   *pref->varp.bool ? "TRUE" : "FALSE");
+                   *pref->varp.boolp ? "TRUE" : "FALSE");
                break;
 
        case PREF_ENUM:
@@ -1544,9 +1669,9 @@ write_module_prefs(gpointer data, gpointer user_data)
    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(const char **pf_path_return)
+write_prefs(char **pf_path_return)
 {
-  const char  *pf_path;
+  char        *pf_path;
   FILE        *pf;
   GList       *clp, *col_l;
   fmt_data    *cfmt;
@@ -1562,7 +1687,7 @@ write_prefs(const char **pf_path_return)
     *pf_path_return = pf_path;
     return errno;
   }
-    
+
   fputs("# Configuration file for Ethereal " VERSION ".\n"
     "#\n"
     "# This file is regenerated each time preferences are saved within\n"
@@ -1632,9 +1757,13 @@ write_prefs(const char **pf_path_return)
   fprintf(pf, PRS_GUI_PTREE_SEL_BROWSE ": %s\n",
                  prefs.gui_ptree_sel_browse == TRUE ? "TRUE" : "FALSE");
 
+  fprintf(pf, "\n# Alternating colors in TreeViews\n");
+  fprintf(pf, PRS_GUI_ALTERN_COLORS ": %s\n",
+                 prefs.gui_altern_colors == TRUE ? "TRUE" : "FALSE");
+
   fprintf(pf, "\n# Protocol-tree line style. One of: NONE, SOLID, DOTTED, TABBED\n");
   fprintf(pf, PRS_GUI_PTREE_LINE_STYLE ": %s\n",
-                 gui_ptree_line_style_text[prefs.gui_ptree_line_style]);
+          gui_ptree_line_style_text[prefs.gui_ptree_line_style]);
 
   fprintf(pf, "\n# Protocol-tree expander style. One of: NONE, SQUARE, TRIANGLE, CIRCULAR\n");
   fprintf(pf, PRS_GUI_PTREE_EXPANDER_STYLE ": %s\n",
@@ -1658,11 +1787,32 @@ write_prefs(const char **pf_path_return)
     (prefs.gui_marked_bg.green * 255 / 65535),
     (prefs.gui_marked_bg.blue * 255 / 65535));
 
+  fprintf(pf, "\n# Save window position at exit? TRUE/FALSE\n");
+  fprintf(pf, PRS_GUI_GEOMETRY_SAVE_POSITION ": %s\n",
+                 prefs.gui_geometry_save_position == TRUE ? "TRUE" : "FALSE");
+
+  fprintf(pf, "\n# Save window size at exit? TRUE/FALSE\n");
+  fprintf(pf, PRS_GUI_GEOMETRY_SAVE_SIZE ": %s\n",
+                 prefs.gui_geometry_save_size == TRUE ? "TRUE" : "FALSE");
+
+  fprintf(pf, "\n# Main window geometry. Decimal integers.\n");
+  fprintf(pf, PRS_GUI_GEOMETRY_MAIN_X ": %d\n", prefs.gui_geometry_main_x);
+  fprintf(pf, PRS_GUI_GEOMETRY_MAIN_Y ": %d\n", prefs.gui_geometry_main_y);
+  fprintf(pf, PRS_GUI_GEOMETRY_MAIN_WIDTH ": %d\n",
+                 prefs.gui_geometry_main_width);
+  fprintf(pf, PRS_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
+                 prefs.gui_geometry_main_height);
+
   fprintf(pf, "\n# Resolve addresses to names? TRUE/FALSE/{list of address types to resolve}\n");
   fprintf(pf, PRS_NAME_RESOLVE ": %s\n",
                  name_resolve_to_string(prefs.name_resolve));
 
 /* write the capture options */
+  if (prefs.capture_device != NULL) {
+    fprintf(pf, "\n# Default capture device\n");
+    fprintf(pf, PRS_CAP_DEVICE ": %s\n", prefs.capture_device);
+  }
+
   fprintf(pf, "\n# Capture in promiscuous mode? TRUE/FALSE\n");
   fprintf(pf, PRS_CAP_PROM_MODE ": %s\n",
                  prefs.capture_prom_mode == TRUE ? "TRUE" : "FALSE");
@@ -1713,13 +1863,21 @@ copy_prefs(e_prefs *dest, e_prefs *src)
   dest->gui_scrollbar_on_right = src->gui_scrollbar_on_right;
   dest->gui_plist_sel_browse = src->gui_plist_sel_browse;
   dest->gui_ptree_sel_browse = src->gui_ptree_sel_browse;
+  dest->gui_altern_colors = src->gui_altern_colors;
   dest->gui_ptree_line_style = src->gui_ptree_line_style;
   dest->gui_ptree_expander_style = src->gui_ptree_expander_style;
   dest->gui_hex_dump_highlight_style = src->gui_hex_dump_highlight_style;
   dest->gui_font_name = g_strdup(src->gui_font_name);
   dest->gui_marked_fg = src->gui_marked_fg;
   dest->gui_marked_bg = src->gui_marked_bg;
+  dest->gui_geometry_save_position = src->gui_geometry_save_position;
+  dest->gui_geometry_save_size = src->gui_geometry_save_size;
+  dest->gui_geometry_main_x = src->gui_geometry_main_x;
+  dest->gui_geometry_main_y = src->gui_geometry_main_y;
+  dest->gui_geometry_main_width = src->gui_geometry_main_width;
+  dest->gui_geometry_main_height = src->gui_geometry_main_height;
 /*  values for the capture dialog box */
+  dest->capture_device = g_strdup(src->capture_device);
   dest->capture_prom_mode = src->capture_prom_mode;
   dest->capture_real_time = src->capture_real_time;
   dest->capture_auto_scroll = src->capture_auto_scroll;
@@ -1744,6 +1902,10 @@ free_prefs(e_prefs *pr)
     g_free(pr->gui_font_name);
     pr->gui_font_name = NULL;
   }
+  if (pr->capture_device != NULL) {
+    g_free(pr->capture_device);
+    pr->capture_device = NULL;
+  }
 }
 
 static void