2004-01-19 00:42:12 +00:00
|
|
|
/* recent.c
|
|
|
|
* Recent "preference" handling routines
|
|
|
|
* Copyright 2004, Ulf Lamping <ulf.lamping@web.de>
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2004-01-19 00:42:12 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-01-19 00:42:12 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <stdio.h>
|
2004-01-19 01:00:58 +00:00
|
|
|
#include <string.h>
|
2005-06-16 06:33:49 +00:00
|
|
|
#include <ctype.h>
|
2004-01-19 00:42:12 +00:00
|
|
|
|
|
|
|
#include "recent.h"
|
|
|
|
#include <epan/epan.h>
|
|
|
|
#include <epan/filesystem.h>
|
|
|
|
#include "menu.h"
|
|
|
|
#include "main.h"
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2004-10-01 08:33:53 +00:00
|
|
|
#include <epan/prefs-int.h>
|
2005-08-20 12:09:48 +00:00
|
|
|
#include "gui_utils.h"
|
2006-04-30 01:47:58 +00:00
|
|
|
#if 0
|
2004-06-01 17:33:37 +00:00
|
|
|
#include "dlg_utils.h"
|
2006-04-30 01:47:58 +00:00
|
|
|
#endif
|
|
|
|
#include "file_dlg.h"
|
2004-09-28 18:04:15 +00:00
|
|
|
#include "cfilter_combo_utils.h"
|
2005-03-26 01:05:29 +00:00
|
|
|
#include "simple_dialog.h"
|
2005-11-06 22:43:25 +00:00
|
|
|
#include "file_util.h"
|
2007-01-13 16:06:28 +00:00
|
|
|
#include "u3.h"
|
2004-02-01 20:28:11 +00:00
|
|
|
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
#ifdef NEED_G_ASCII_STRCASECMP_H
|
2007-11-28 01:23:09 +00:00
|
|
|
#include "../epan/g_ascii_strcasecmp.h"
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
#endif
|
|
|
|
|
2004-02-01 20:28:11 +00:00
|
|
|
#define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show"
|
|
|
|
#define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show"
|
2007-08-30 00:24:40 +00:00
|
|
|
#define RECENT_KEY_AIRPCAP_TOOLBAR_SHOW "gui.airpcap_toolbar_show"
|
|
|
|
#define RECENT_KEY_DRIVER_CHECK_SHOW "gui.airpcap_driver_check_show"
|
2004-02-01 20:28:11 +00:00
|
|
|
#define RECENT_KEY_PACKET_LIST_SHOW "gui.packet_list_show"
|
|
|
|
#define RECENT_KEY_TREE_VIEW_SHOW "gui.tree_view_show"
|
|
|
|
#define RECENT_KEY_BYTE_VIEW_SHOW "gui.byte_view_show"
|
|
|
|
#define RECENT_KEY_STATUSBAR_SHOW "gui.statusbar_show"
|
2005-03-27 02:19:51 +00:00
|
|
|
#define RECENT_KEY_PACKET_LIST_COLORIZE "gui.packet_list_colorize"
|
2004-02-01 20:28:11 +00:00
|
|
|
#define RECENT_GUI_TIME_FORMAT "gui.time_format"
|
2005-08-25 21:29:54 +00:00
|
|
|
#define RECENT_GUI_TIME_PRECISION "gui.time_precision"
|
2004-02-01 20:28:11 +00:00
|
|
|
#define RECENT_GUI_ZOOM_LEVEL "gui.zoom_level"
|
|
|
|
#define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x"
|
|
|
|
#define RECENT_GUI_GEOMETRY_MAIN_Y "gui.geometry_main_y"
|
|
|
|
#define RECENT_GUI_GEOMETRY_MAIN_WIDTH "gui.geometry_main_width"
|
|
|
|
#define RECENT_GUI_GEOMETRY_MAIN_HEIGHT "gui.geometry_main_height"
|
|
|
|
#define RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED "gui.geometry_main_maximized"
|
2004-04-25 23:45:12 +00:00
|
|
|
#define RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE "gui.geometry_main_upper_pane"
|
|
|
|
#define RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE "gui.geometry_main_lower_pane"
|
2008-01-14 16:40:23 +00:00
|
|
|
#define RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT "gui.geometry_status_pane"
|
|
|
|
#define RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT "gui.geometry_status_pane_right"
|
2004-02-01 20:28:11 +00:00
|
|
|
#define RECENT_GUI_FILEOPEN_REMEMBERED_DIR "gui.fileopen_remembered_dir"
|
2007-08-30 00:24:40 +00:00
|
|
|
#define RECENT_GUI_GEOMETRY "gui.geom."
|
|
|
|
#define RECENT_KEY_PRIVS_WARN_IF_ELEVATED "privs.warn_if_elevated"
|
2007-09-15 00:18:17 +00:00
|
|
|
#define RECENT_KEY_PRIVS_WARN_IF_NO_NPF "privs.warn_if_no_npf"
|
2004-02-01 20:28:11 +00:00
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
#define RECENT_FILE_NAME "recent"
|
|
|
|
|
|
|
|
recent_settings_t recent;
|
|
|
|
|
2005-08-05 20:59:08 +00:00
|
|
|
static const char *ts_type_text[] =
|
2006-12-05 03:19:51 +00:00
|
|
|
{ "RELATIVE", "ABSOLUTE", "ABSOLUTE_WITH_DATE", "DELTA", "EPOCH", NULL };
|
2004-01-19 03:46:43 +00:00
|
|
|
|
2005-08-25 21:29:54 +00:00
|
|
|
static const char *ts_precision_text[] =
|
|
|
|
{ "AUTO", "SEC", "DSEC", "CSEC", "MSEC", "USEC", "NSEC", NULL };
|
|
|
|
|
2004-01-19 03:46:43 +00:00
|
|
|
/* Takes an string and a pointer to an array of strings, and a default int value.
|
|
|
|
* The array must be terminated by a NULL string. If the string is found in the array
|
|
|
|
* of strings, the index of that string in the array is returned. Otherwise, the
|
|
|
|
* default value that was passed as the third argument is returned.
|
|
|
|
*/
|
|
|
|
static int
|
2005-08-05 20:59:08 +00:00
|
|
|
find_index_from_string_array(const char *needle, const char **haystack, int default_value)
|
2004-01-19 03:46:43 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (haystack[i] != NULL) {
|
|
|
|
if (strcmp(needle, haystack[i]) == 0) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return default_value;
|
|
|
|
}
|
|
|
|
|
2005-03-26 01:05:29 +00:00
|
|
|
/* Attempt to Write out "recent" to the user's recent file.
|
|
|
|
If we got an error report it with a dialog box and return FALSE,
|
|
|
|
otherwise return TRUE. */
|
|
|
|
gboolean
|
|
|
|
write_recent(void)
|
2004-01-19 00:42:12 +00:00
|
|
|
{
|
2005-03-26 01:05:29 +00:00
|
|
|
char *pf_dir_path;
|
2004-01-19 00:42:12 +00:00
|
|
|
char *rf_path;
|
|
|
|
FILE *rf;
|
|
|
|
|
|
|
|
/* To do:
|
|
|
|
* - Split output lines longer than MAX_VAL_LEN
|
|
|
|
* - Create a function for the preference directory check/creation
|
|
|
|
* so that duplication can be avoided with filter.c
|
|
|
|
*/
|
|
|
|
|
2005-03-26 01:05:29 +00:00
|
|
|
/* Create the directory that holds personal configuration files, if
|
|
|
|
necessary. */
|
|
|
|
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
|
|
"Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
|
|
|
|
strerror(errno));
|
|
|
|
g_free(pf_dir_path);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-01-14 16:40:23 +00:00
|
|
|
rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE, TRUE);
|
2005-11-06 22:43:25 +00:00
|
|
|
if ((rf = eth_fopen(rf_path, "w")) == NULL) {
|
2005-03-26 01:05:29 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
|
|
"Can't open recent file\n\"%s\": %s.", rf_path,
|
|
|
|
strerror(errno));
|
|
|
|
g_free(rf_path);
|
|
|
|
return FALSE;
|
2004-01-19 00:42:12 +00:00
|
|
|
}
|
|
|
|
|
2006-05-22 07:29:40 +00:00
|
|
|
fputs("# Recent settings file for Wireshark " VERSION ".\n"
|
2004-01-19 00:42:12 +00:00
|
|
|
"#\n"
|
2006-05-22 07:29:40 +00:00
|
|
|
"# This file is regenerated each time Wireshark is quit.\n"
|
2004-01-19 00:42:12 +00:00
|
|
|
"# So be careful, if you want to make manual changes here.\n"
|
|
|
|
"\n"
|
2005-05-30 04:06:22 +00:00
|
|
|
"######## Recent capture files (latest last), cannot be altered through command line ########\n"
|
2004-01-19 00:42:12 +00:00
|
|
|
"\n", rf);
|
|
|
|
|
|
|
|
menu_recent_file_write_all(rf);
|
|
|
|
|
2004-09-28 18:04:15 +00:00
|
|
|
fputs("\n"
|
2005-05-30 04:06:22 +00:00
|
|
|
"######## Recent capture filters (latest last), cannot be altered through command line ########\n"
|
2004-09-28 18:04:15 +00:00
|
|
|
"\n", rf);
|
|
|
|
|
|
|
|
cfilter_combo_recent_write_all(rf);
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
fputs("\n"
|
2005-05-30 04:06:22 +00:00
|
|
|
"######## Recent display filters (latest last), cannot be altered through command line ########\n"
|
2004-01-19 00:42:12 +00:00
|
|
|
"\n", rf);
|
|
|
|
|
|
|
|
dfilter_recent_combo_write_all(rf);
|
|
|
|
|
|
|
|
fprintf(rf, "\n# Main Toolbar show (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_MAIN_TOOLBAR_SHOW ": %s\n",
|
|
|
|
recent.main_toolbar_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
|
|
|
fprintf(rf, "\n# Filter Toolbar show (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_FILTER_TOOLBAR_SHOW ": %s\n",
|
|
|
|
recent.filter_toolbar_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
|
|
|
fprintf(rf, "\n# Wireless Settings Toolbar show (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_AIRPCAP_TOOLBAR_SHOW ": %s\n",
|
|
|
|
recent.airpcap_toolbar_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
#endif
|
|
|
|
|
2006-10-31 01:44:11 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
|
|
|
fprintf(rf, "\n# Show (hide) old AirPcap driver warning dialog box.\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_DRIVER_CHECK_SHOW ": %s\n",
|
|
|
|
recent.airpcap_driver_check_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
#endif
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
fprintf(rf, "\n# Packet list show (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_PACKET_LIST_SHOW ": %s\n",
|
|
|
|
recent.packet_list_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
|
|
|
fprintf(rf, "\n# Tree view show (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_TREE_VIEW_SHOW ": %s\n",
|
|
|
|
recent.tree_view_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
|
|
|
fprintf(rf, "\n# Byte view show (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_BYTE_VIEW_SHOW ": %s\n",
|
|
|
|
recent.byte_view_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
|
|
|
fprintf(rf, "\n# Statusbar show (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_STATUSBAR_SHOW ": %s\n",
|
|
|
|
recent.statusbar_show == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
2005-03-27 02:19:51 +00:00
|
|
|
fprintf(rf, "\n# Packet list colorize (hide).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_PACKET_LIST_COLORIZE ": %s\n",
|
|
|
|
recent.packet_list_colorize == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
2004-01-19 03:46:43 +00:00
|
|
|
fprintf(rf, "\n# Timestamp display format.\n");
|
2006-12-05 03:19:51 +00:00
|
|
|
fprintf(rf, "# One of: RELATIVE, ABSOLUTE, ABSOLUTE_WITH_DATE, DELTA, EPOCH\n");
|
2004-01-19 03:46:43 +00:00
|
|
|
fprintf(rf, RECENT_GUI_TIME_FORMAT ": %s\n",
|
|
|
|
ts_type_text[recent.gui_time_format]);
|
|
|
|
|
2005-08-25 21:29:54 +00:00
|
|
|
fprintf(rf, "\n# Timestamp display precision.\n");
|
|
|
|
fprintf(rf, "# One of: AUTO, SEC, DSEC, CSEC, MSEC, USEC, NSEC\n");
|
|
|
|
fprintf(rf, RECENT_GUI_TIME_PRECISION ": %s\n",
|
|
|
|
ts_precision_text[recent.gui_time_precision]);
|
|
|
|
|
2004-01-20 18:47:25 +00:00
|
|
|
fprintf(rf, "\n# Zoom level.\n");
|
|
|
|
fprintf(rf, "# A decimal number.\n");
|
|
|
|
fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n",
|
|
|
|
recent.gui_zoom_level);
|
|
|
|
|
2004-02-20 23:04:50 +00:00
|
|
|
fprintf(rf, "\n# Main window geometry.\n");
|
2005-05-29 14:09:58 +00:00
|
|
|
fprintf(rf, "# Decimal numbers.\n");
|
2004-02-20 23:04:50 +00:00
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_X ": %d\n", recent.gui_geometry_main_x);
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_Y ": %d\n", recent.gui_geometry_main_y);
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_WIDTH ": %d\n",
|
|
|
|
recent.gui_geometry_main_width);
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
|
|
|
|
recent.gui_geometry_main_height);
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2005-05-30 04:06:22 +00:00
|
|
|
fprintf(rf, "\n# Main window maximized (GTK2 only!).\n");
|
2004-02-20 23:04:50 +00:00
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED ": %s\n",
|
2004-02-01 20:28:11 +00:00
|
|
|
recent.gui_geometry_main_maximized == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
2005-05-30 04:06:22 +00:00
|
|
|
fprintf(rf, "\n# Main window upper (or leftmost) pane size.\n");
|
|
|
|
fprintf(rf, "# (GTK1: has no effect here, command line -o usage only).\n");
|
2005-05-29 14:09:58 +00:00
|
|
|
fprintf(rf, "# Decimal number.\n");
|
2004-07-18 19:54:07 +00:00
|
|
|
if (recent.gui_geometry_main_upper_pane != 0) {
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE ": %d\n",
|
2004-04-25 23:45:12 +00:00
|
|
|
recent.gui_geometry_main_upper_pane);
|
2004-07-18 19:54:07 +00:00
|
|
|
}
|
2005-05-30 04:06:22 +00:00
|
|
|
fprintf(rf, "\n# Main window middle pane size.\n");
|
|
|
|
fprintf(rf, "# (GTK1: has no effect here, command line -o usage only).\n");
|
2005-05-29 14:09:58 +00:00
|
|
|
fprintf(rf, "# Decimal number.\n");
|
2004-07-18 19:54:07 +00:00
|
|
|
if (recent.gui_geometry_main_lower_pane != 0) {
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE ": %d\n",
|
2004-04-25 23:45:12 +00:00
|
|
|
recent.gui_geometry_main_lower_pane);
|
2004-07-18 19:54:07 +00:00
|
|
|
}
|
2005-05-30 04:06:22 +00:00
|
|
|
fprintf(rf, "\n# Statusbar left pane size.\n");
|
|
|
|
fprintf(rf, "# (GTK1: has no effect here, command line -o usage only).\n");
|
2005-05-29 14:09:58 +00:00
|
|
|
fprintf(rf, "# Decimal number.\n");
|
2008-01-14 16:40:23 +00:00
|
|
|
if (recent.gui_geometry_status_pane_left != 0) {
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT ": %d\n",
|
|
|
|
recent.gui_geometry_status_pane_left);
|
|
|
|
}
|
|
|
|
fprintf(rf, "\n# Statusbar middle pane size.\n");
|
|
|
|
fprintf(rf, "# (GTK1: has no effect here, command line -o usage only).\n");
|
|
|
|
fprintf(rf, "# Decimal number.\n");
|
|
|
|
if (recent.gui_geometry_status_pane_right != 0) {
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT ": %d\n",
|
|
|
|
recent.gui_geometry_status_pane_right);
|
2004-07-18 19:54:07 +00:00
|
|
|
}
|
2004-04-25 23:45:12 +00:00
|
|
|
|
2007-08-30 00:24:40 +00:00
|
|
|
fprintf(rf, "\n# Warn if running with elevated permissions (e.g. as root).\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_PRIVS_WARN_IF_ELEVATED ": %s\n",
|
|
|
|
recent.privs_warn_if_elevated == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
2007-09-15 00:18:17 +00:00
|
|
|
fprintf(rf, "\n# Warn if npf.sys isn't loaded on Windows >= 6.0.\n");
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_KEY_PRIVS_WARN_IF_NO_NPF ": %s\n",
|
|
|
|
recent.privs_warn_if_no_npf == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
2004-06-01 17:33:37 +00:00
|
|
|
if (get_last_open_dir() != NULL) {
|
2004-02-01 20:28:11 +00:00
|
|
|
fprintf(rf, "\n# Last directory navigated to in File Open dialog.\n");
|
2007-01-13 16:06:28 +00:00
|
|
|
|
|
|
|
if(u3_active())
|
|
|
|
fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", u3_contract_device_path(get_last_open_dir()));
|
|
|
|
else
|
|
|
|
fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", get_last_open_dir());
|
2004-02-01 20:28:11 +00:00
|
|
|
}
|
|
|
|
|
2004-05-30 11:54:37 +00:00
|
|
|
window_geom_recent_write_all(rf);
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
fclose(rf);
|
|
|
|
|
|
|
|
/* XXX - catch I/O errors (e.g. "ran out of disk space") and return
|
2005-03-26 01:05:29 +00:00
|
|
|
an error indication, or maybe write to a new recent file and
|
2004-01-19 00:42:12 +00:00
|
|
|
rename that file on top of the old one only if there are not I/O
|
|
|
|
errors. */
|
2005-03-26 01:05:29 +00:00
|
|
|
return TRUE;
|
2004-01-19 00:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-30 11:54:37 +00:00
|
|
|
/* write the geometry values of a window to recent file */
|
2006-08-16 18:01:25 +00:00
|
|
|
void
|
2004-05-31 02:42:39 +00:00
|
|
|
write_recent_geom(gpointer key _U_, gpointer value, gpointer rf)
|
2004-05-30 11:54:37 +00:00
|
|
|
{
|
|
|
|
window_geometry_t *geom = value;
|
|
|
|
|
|
|
|
fprintf(rf, "\n# Geometry and maximized state (GTK2 only) of %s window.\n", geom->key);
|
|
|
|
fprintf(rf, "# Decimal integers.\n");
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY "%s.x: %d\n", geom->key, geom->x);
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY "%s.y: %d\n", geom->key, geom->y);
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY "%s.width: %d\n", geom->key,
|
|
|
|
geom->width);
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY "%s.height: %d\n", geom->key,
|
|
|
|
geom->height);
|
|
|
|
|
|
|
|
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
|
|
|
fprintf(rf, RECENT_GUI_GEOMETRY "%s.maximized: %s\n", geom->key,
|
|
|
|
geom->maximized == TRUE ? "TRUE" : "FALSE");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
/* set one user's recent file key/value pair */
|
2006-12-08 01:11:20 +00:00
|
|
|
static prefs_set_pref_e
|
2006-11-15 23:33:39 +00:00
|
|
|
read_set_recent_pair_static(gchar *key, gchar *value, void *private_data _U_)
|
2004-01-19 00:42:12 +00:00
|
|
|
{
|
2004-07-09 21:13:22 +00:00
|
|
|
long num;
|
|
|
|
char *p;
|
2004-01-19 00:42:12 +00:00
|
|
|
|
2005-05-30 04:06:22 +00:00
|
|
|
if (strcmp(key, RECENT_KEY_MAIN_TOOLBAR_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2004-01-19 00:42:12 +00:00
|
|
|
recent.main_toolbar_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.main_toolbar_show = FALSE;
|
|
|
|
}
|
|
|
|
} else if (strcmp(key, RECENT_KEY_FILTER_TOOLBAR_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2004-01-19 00:42:12 +00:00
|
|
|
recent.filter_toolbar_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.filter_toolbar_show = FALSE;
|
|
|
|
}
|
2006-08-16 18:01:25 +00:00
|
|
|
} else if (strcmp(key, RECENT_KEY_AIRPCAP_TOOLBAR_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2006-08-16 18:01:25 +00:00
|
|
|
recent.airpcap_toolbar_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.airpcap_toolbar_show = FALSE;
|
|
|
|
}
|
2006-10-31 01:44:11 +00:00
|
|
|
} else if (strcmp(key, RECENT_KEY_DRIVER_CHECK_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2006-10-31 01:44:11 +00:00
|
|
|
recent.airpcap_driver_check_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.airpcap_driver_check_show = FALSE;
|
|
|
|
}
|
|
|
|
}else if (strcmp(key, RECENT_KEY_PACKET_LIST_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2004-01-19 00:42:12 +00:00
|
|
|
recent.packet_list_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.packet_list_show = FALSE;
|
|
|
|
}
|
|
|
|
} else if (strcmp(key, RECENT_KEY_TREE_VIEW_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2004-01-19 00:42:12 +00:00
|
|
|
recent.tree_view_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.tree_view_show = FALSE;
|
|
|
|
}
|
|
|
|
} else if (strcmp(key, RECENT_KEY_BYTE_VIEW_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2004-01-19 00:42:12 +00:00
|
|
|
recent.byte_view_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.byte_view_show = FALSE;
|
|
|
|
}
|
|
|
|
} else if (strcmp(key, RECENT_KEY_STATUSBAR_SHOW) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2004-01-19 00:42:12 +00:00
|
|
|
recent.statusbar_show = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.statusbar_show = FALSE;
|
|
|
|
}
|
2005-03-27 02:19:51 +00:00
|
|
|
} else if (strcmp(key, RECENT_KEY_PACKET_LIST_COLORIZE) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2005-03-27 02:19:51 +00:00
|
|
|
recent.packet_list_colorize = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.packet_list_colorize = FALSE;
|
|
|
|
}
|
2004-01-19 03:46:43 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_TIME_FORMAT) == 0) {
|
2004-01-20 18:47:25 +00:00
|
|
|
recent.gui_time_format =
|
|
|
|
find_index_from_string_array(value, ts_type_text, TS_RELATIVE);
|
2005-08-25 21:29:54 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_TIME_PRECISION) == 0) {
|
|
|
|
recent.gui_time_precision =
|
|
|
|
find_index_from_string_array(value, ts_precision_text, TS_PREC_AUTO);
|
2004-01-20 18:47:25 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_ZOOM_LEVEL) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
recent.gui_zoom_level = num;
|
2004-02-01 20:28:11 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2004-02-01 20:28:11 +00:00
|
|
|
recent.gui_geometry_main_maximized = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.gui_geometry_main_maximized = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_X) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
recent.gui_geometry_main_x = num;
|
2004-02-01 20:28:11 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_Y) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
recent.gui_geometry_main_y = num;
|
2004-02-01 20:28:11 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_WIDTH) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
if (num <= 0)
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
|
|
|
|
recent.gui_geometry_main_width = num;
|
2004-02-01 20:28:11 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_HEIGHT) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
if (num <= 0)
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
|
|
|
|
recent.gui_geometry_main_height = num;
|
2004-04-25 23:45:12 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
if (num <= 0)
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
|
|
|
|
recent.gui_geometry_main_upper_pane = num;
|
2005-05-30 04:06:22 +00:00
|
|
|
recent.has_gui_geometry_main_upper_pane = TRUE;
|
2004-04-25 23:45:12 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
if (num <= 0)
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
|
|
|
|
recent.gui_geometry_main_lower_pane = num;
|
2005-05-30 04:06:22 +00:00
|
|
|
recent.has_gui_geometry_main_lower_pane = TRUE;
|
2008-01-14 16:40:23 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT) == 0) {
|
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
if (num <= 0)
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
|
|
|
|
recent.gui_geometry_status_pane_right = num;
|
|
|
|
recent.has_gui_geometry_status_pane = TRUE;
|
|
|
|
} else if (strcmp(key, RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT) == 0) {
|
2004-07-09 21:13:22 +00:00
|
|
|
num = strtol(value, &p, 0);
|
|
|
|
if (p == value || *p != '\0')
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
|
|
|
if (num <= 0)
|
|
|
|
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
|
2008-01-14 16:40:23 +00:00
|
|
|
recent.gui_geometry_status_pane_left = num;
|
2005-05-30 04:06:22 +00:00
|
|
|
recent.has_gui_geometry_status_pane = TRUE;
|
2004-02-01 20:28:11 +00:00
|
|
|
} else if (strcmp(key, RECENT_GUI_FILEOPEN_REMEMBERED_DIR) == 0) {
|
2007-01-13 16:06:28 +00:00
|
|
|
if(u3_active())
|
|
|
|
set_last_open_dir(u3_expand_device_path(value));
|
|
|
|
else
|
|
|
|
set_last_open_dir(value);
|
2004-05-30 11:54:37 +00:00
|
|
|
} else if (strncmp(key, RECENT_GUI_GEOMETRY, sizeof(RECENT_GUI_GEOMETRY)-1) == 0) {
|
|
|
|
/* now have something like "gui.geom.main.x", split it into win and sub_key */
|
|
|
|
char *win = &key[sizeof(RECENT_GUI_GEOMETRY)-1];
|
|
|
|
char *sub_key = strchr(win, '.');
|
|
|
|
if(sub_key) {
|
|
|
|
*sub_key = '\0';
|
|
|
|
sub_key++;
|
|
|
|
window_geom_recent_read_pair(win, sub_key, value);
|
|
|
|
}
|
2007-08-30 00:24:40 +00:00
|
|
|
} else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_ELEVATED) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2007-08-30 00:24:40 +00:00
|
|
|
recent.privs_warn_if_elevated = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.privs_warn_if_elevated = FALSE;
|
|
|
|
}
|
2007-09-15 00:18:17 +00:00
|
|
|
} else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_NO_NPF) == 0) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
if (g_ascii_strcasecmp(value, "true") == 0) {
|
2007-09-15 00:18:17 +00:00
|
|
|
recent.privs_warn_if_no_npf = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recent.privs_warn_if_no_npf = FALSE;
|
|
|
|
}
|
2004-01-19 00:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return PREFS_SET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-30 04:06:22 +00:00
|
|
|
/* set one user's recent file key/value pair */
|
2006-12-08 01:11:20 +00:00
|
|
|
static prefs_set_pref_e
|
2006-11-15 23:33:39 +00:00
|
|
|
read_set_recent_pair_dynamic(gchar *key, gchar *value, void *private_data _U_)
|
2005-05-30 04:06:22 +00:00
|
|
|
{
|
|
|
|
if (strcmp(key, RECENT_KEY_CAPTURE_FILE) == 0) {
|
2007-01-13 16:06:28 +00:00
|
|
|
if(u3_active())
|
|
|
|
add_menu_recent_capture_file(u3_expand_device_path(value));
|
|
|
|
else
|
|
|
|
add_menu_recent_capture_file(value);
|
2005-05-30 04:06:22 +00:00
|
|
|
} else if (strcmp(key, RECENT_KEY_DISPLAY_FILTER) == 0) {
|
|
|
|
dfilter_combo_add_recent(value);
|
|
|
|
} else if (strcmp(key, RECENT_KEY_CAPTURE_FILTER) == 0) {
|
|
|
|
cfilter_combo_add_recent(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return PREFS_SET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a string of the form "<recent name>:<recent value>", as might appear
|
|
|
|
* as an argument to a "-o" option, parse it and set the recent value in
|
|
|
|
* question. Return an indication of whether it succeeded or failed
|
|
|
|
* in some fashion.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
recent_set_arg(char *prefarg)
|
|
|
|
{
|
2008-01-14 09:39:55 +00:00
|
|
|
gchar *p, *colonp;
|
2005-05-30 04:06:22 +00:00
|
|
|
int ret;
|
|
|
|
|
2007-03-28 21:55:11 +00:00
|
|
|
colonp = strchr(prefarg, ':');
|
2005-05-30 04:06:22 +00:00
|
|
|
if (colonp == NULL)
|
|
|
|
return PREFS_SET_SYNTAX_ERR;
|
|
|
|
|
|
|
|
p = colonp;
|
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip over any white space (there probably won't be any, but
|
|
|
|
* as we allow it in the preferences file, we might as well
|
|
|
|
* allow it here).
|
|
|
|
*/
|
2008-01-14 19:19:47 +00:00
|
|
|
while (isspace((guchar)*p))
|
2005-05-30 04:06:22 +00:00
|
|
|
p++;
|
|
|
|
if (*p == '\0') {
|
|
|
|
/*
|
|
|
|
* Put the colon back, so if our caller uses, in an
|
|
|
|
* error message, the string they passed us, the message
|
|
|
|
* looks correct.
|
|
|
|
*/
|
|
|
|
*colonp = ':';
|
|
|
|
return PREFS_SET_SYNTAX_ERR;
|
|
|
|
}
|
|
|
|
|
2007-03-28 21:55:11 +00:00
|
|
|
ret = read_set_recent_pair_static(prefarg, p, NULL);
|
2005-05-30 04:06:22 +00:00
|
|
|
*colonp = ':'; /* put the colon back */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* opens the user's recent file and read the first part */
|
2004-01-19 00:42:12 +00:00
|
|
|
void
|
2005-05-30 04:06:22 +00:00
|
|
|
recent_read_static(char **rf_path_return, int *rf_errno_return)
|
2004-01-19 00:42:12 +00:00
|
|
|
{
|
|
|
|
char *rf_path;
|
|
|
|
FILE *rf;
|
|
|
|
|
|
|
|
|
|
|
|
/* set defaults */
|
2004-01-19 03:46:43 +00:00
|
|
|
recent.main_toolbar_show = TRUE;
|
|
|
|
recent.filter_toolbar_show = TRUE;
|
2006-08-16 18:01:25 +00:00
|
|
|
recent.airpcap_toolbar_show = FALSE;
|
2006-10-31 01:44:11 +00:00
|
|
|
recent.airpcap_driver_check_show = TRUE;
|
2004-01-19 03:46:43 +00:00
|
|
|
recent.packet_list_show = TRUE;
|
|
|
|
recent.tree_view_show = TRUE;
|
|
|
|
recent.byte_view_show = TRUE;
|
|
|
|
recent.statusbar_show = TRUE;
|
2005-03-27 02:19:51 +00:00
|
|
|
recent.packet_list_colorize = TRUE;
|
2004-01-19 03:46:43 +00:00
|
|
|
recent.gui_time_format = TS_RELATIVE;
|
2005-08-25 21:29:54 +00:00
|
|
|
recent.gui_time_precision = TS_PREC_AUTO;
|
2004-01-20 18:47:25 +00:00
|
|
|
recent.gui_zoom_level = 0;
|
2004-01-19 00:42:12 +00:00
|
|
|
|
2004-02-01 20:28:11 +00:00
|
|
|
recent.gui_geometry_main_x = 20;
|
|
|
|
recent.gui_geometry_main_y = 20;
|
|
|
|
recent.gui_geometry_main_width = DEF_WIDTH;
|
2004-07-09 21:13:22 +00:00
|
|
|
recent.gui_geometry_main_height = DEF_HEIGHT;
|
2004-02-01 20:28:11 +00:00
|
|
|
recent.gui_geometry_main_maximized= FALSE;
|
|
|
|
|
2004-04-27 19:16:11 +00:00
|
|
|
/* pane size of zero will autodetect */
|
|
|
|
recent.gui_geometry_main_upper_pane = 0;
|
|
|
|
recent.gui_geometry_main_lower_pane = 0;
|
2008-01-14 16:40:23 +00:00
|
|
|
recent.gui_geometry_status_pane_left = (DEF_WIDTH/3);
|
|
|
|
recent.gui_geometry_status_pane_right = (DEF_WIDTH/3);
|
2004-04-25 23:45:12 +00:00
|
|
|
|
2005-05-30 04:06:22 +00:00
|
|
|
/* the following are only used if GTK2 is used (as GTK1 cannot read these geometry values) */
|
|
|
|
/* or if set through command line */
|
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
recent.has_gui_geometry_main_upper_pane = TRUE;
|
|
|
|
recent.has_gui_geometry_main_lower_pane = TRUE;
|
|
|
|
recent.has_gui_geometry_status_pane = TRUE;
|
|
|
|
#else
|
|
|
|
recent.has_gui_geometry_main_upper_pane = FALSE;
|
|
|
|
recent.has_gui_geometry_main_lower_pane = FALSE;
|
|
|
|
recent.has_gui_geometry_status_pane = FALSE;
|
|
|
|
#endif
|
|
|
|
|
2007-08-30 00:24:40 +00:00
|
|
|
recent.privs_warn_if_elevated = TRUE;
|
2007-09-15 00:18:17 +00:00
|
|
|
recent.privs_warn_if_no_npf = TRUE;
|
2007-08-30 00:24:40 +00:00
|
|
|
|
2005-05-30 04:06:22 +00:00
|
|
|
/* Construct the pathname of the user's recent file. */
|
2008-01-14 16:40:23 +00:00
|
|
|
rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE, FALSE);
|
2005-05-30 04:06:22 +00:00
|
|
|
|
|
|
|
/* Read the user's recent file, if it exists. */
|
|
|
|
*rf_path_return = NULL;
|
2005-11-06 22:43:25 +00:00
|
|
|
if ((rf = eth_fopen(rf_path, "r")) != NULL) {
|
2005-05-30 04:06:22 +00:00
|
|
|
/* We succeeded in opening it; read it. */
|
2006-11-15 23:33:39 +00:00
|
|
|
read_prefs_file(rf_path, rf, read_set_recent_pair_static, NULL);
|
2005-05-30 04:06:22 +00:00
|
|
|
fclose(rf);
|
|
|
|
g_free(rf_path);
|
|
|
|
rf_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
|
|
|
|
caller can report the error. */
|
|
|
|
if (errno != ENOENT) {
|
|
|
|
*rf_errno_return = errno;
|
|
|
|
*rf_path_return = rf_path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* opens the user's recent file and read it out */
|
|
|
|
void
|
|
|
|
recent_read_dynamic(char **rf_path_return, int *rf_errno_return)
|
|
|
|
{
|
|
|
|
char *rf_path;
|
|
|
|
FILE *rf;
|
|
|
|
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
/* Construct the pathname of the user's recent file. */
|
2008-01-14 16:40:23 +00:00
|
|
|
rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE, FALSE);
|
2004-01-19 00:42:12 +00:00
|
|
|
|
|
|
|
/* Read the user's recent file, if it exists. */
|
|
|
|
*rf_path_return = NULL;
|
2005-11-06 22:43:25 +00:00
|
|
|
if ((rf = eth_fopen(rf_path, "r")) != NULL) {
|
2004-01-19 00:42:12 +00:00
|
|
|
/* We succeeded in opening it; read it. */
|
2006-11-15 23:33:39 +00:00
|
|
|
read_prefs_file(rf_path, rf, read_set_recent_pair_dynamic, NULL);
|
2004-01-25 18:51:26 +00:00
|
|
|
/* set dfilter combobox to have an empty line */
|
|
|
|
dfilter_combo_add_empty();
|
2004-01-19 00:42:12 +00:00
|
|
|
fclose(rf);
|
|
|
|
g_free(rf_path);
|
|
|
|
rf_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
|
|
|
|
caller can report the error. */
|
|
|
|
if (errno != ENOENT) {
|
|
|
|
*rf_errno_return = errno;
|
|
|
|
*rf_path_return = rf_path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|