aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/ethereal.pod49
-rw-r--r--gtk/main.c63
-rw-r--r--gtk/recent.c138
-rw-r--r--gtk/recent.h31
4 files changed, 195 insertions, 86 deletions
diff --git a/doc/ethereal.pod b/doc/ethereal.pod
index d2525198ae..2e62a40bfe 100644
--- a/doc/ethereal.pod
+++ b/doc/ethereal.pod
@@ -8,7 +8,6 @@ ethereal - Interactively browse network traffic
B<ethereal>
S<[ B<-a> capture autostop condition ] ...>
S<[ B<-b> ring buffer options] ...>
-S<[ B<-B> byte view height ]>
S<[ B<-c> count ]>
S<[ B<-f> capture filter expression ]>
S<[ B<-h> ]>
@@ -19,15 +18,13 @@ S<[ B<-L> ]>
S<[ B<-m> font ]>
S<[ B<-n> ]>
S<[ B<-N> resolving flags ] >
-S<[ B<-o> preference setting ] ...>
+S<[ B<-o> preference/recent setting ] ...>
S<[ B<-p> ]>
-S<[ B<-P> packet list height ]>
S<[ B<-Q> ]>
S<[ B<-r> infile ]>
S<[ B<-R> display filter expression ]>
S<[ B<-S> ]>
S<[ B<-s> snaplen ]>
-S<[ B<-T> details view height ]>
S<[ B<-t> time stamp format ]>
S<[ B<-v> ]>
S<[ B<-w> savefile]>
@@ -172,28 +169,14 @@ Specify a criterion that specifies when B<Ethereal> is to stop writing
to a capture file. The criterion is of the form I<test>B<:>I<value>,
where I<test> is one of:
-=for man .RS
+B<duration>:I<value> Stop writing to a capture file after I<value> seconds have elapsed.
-=for html <P><DL>
-
-=item duration
-
-Stop writing to a capture file after I<value> seconds have elapsed.
-
-=item filesize
-
-Stop writing to a capture file after it reaches a size of I<value>
+B<filesize>:I<value> Stop writing to a capture file after it reaches a size of I<value>
kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes). If this option
is used together with the -b option, Ethereal will stop writing to the
current capture file and switch to the next one if filesize is reached.
-=item files
-
-Stop writing to capture files after I<value> number of files were written.
-
-=for man .RE
-
-=for html </DL>
+B<files>:I<value> Stop writing to capture files after I<value> number of files were written.
=item -b
@@ -224,10 +207,6 @@ I<value> kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes).
B<files>:I<value> begin again with the first file after I<value> number of
files were written (form a ring buffer).
-=item -B
-
-Set the initial height of the byte view (bottom) pane.
-
=item -c
Set the default number of packets to read when capturing live
@@ -299,11 +278,13 @@ The letter B<C> enables concurrent (asynchronous) DNS lookups.
=item -o
-Set a preference value, overriding the default value and any value read
-from a preference file. The argument to the flag is a string of the
-form I<prefname>B<:>I<value>, where I<prefname> is the name of the
-preference (which is the same name that would appear in the preference
-file), and I<value> is the value to which it should be set.
+Set a preference or recent value, overriding the default value and any value
+read from a preference/recent file. The argument to the flag is a string of
+the form I<prefname>B<:>I<value>, where I<prefname> is the name of the
+preference/recent value (which is the same name that would appear in the
+preference/recent file), and I<value> is the value to which it should be set.
+Using the recent settings now replaces the formerly used -B, -P and -T
+parameters to manipulate the GUI dimensions.
=item -p
@@ -314,10 +295,6 @@ traffic sent to or from the machine on which B<Ethereal> is running,
broadcast traffic, and multicast traffic to addresses received by that
machine.
-=item -P
-
-Set the initial height of the packet list (top) pane.
-
=item -Q
Cause B<Ethereal> to exit after the end of capture session (useful in
@@ -346,10 +323,6 @@ Set the default snapshot length to use when capturing live data.
No more than I<snaplen> bytes of each network packet will be read into
memory, or saved to disk.
-=item -T
-
-Set the initial height of the packet details (middle) pane.
-
=item -t
Set the format of the packet timestamp displayed in the packet list
diff --git a/gtk/main.c b/gtk/main.c
index 00cc466e2c..8c81ecbe69 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1000,15 +1000,12 @@ main_load_window_geometry(GtkWidget *widget)
window_set_geometry(widget, &geom);
-#if GTK_MAJOR_VERSION >= 2
- /* XXX - rename recent settings? */
- if (recent.gui_geometry_main_upper_pane)
+ if (recent.has_gui_geometry_main_upper_pane && recent.gui_geometry_main_upper_pane)
gtk_paned_set_position(GTK_PANED(main_first_pane), recent.gui_geometry_main_upper_pane);
- if (recent.gui_geometry_main_lower_pane)
+ if (recent.has_gui_geometry_main_lower_pane && recent.gui_geometry_main_lower_pane)
gtk_paned_set_position(GTK_PANED(main_second_pane), recent.gui_geometry_main_lower_pane);
- if (recent.gui_geometry_status_pane)
+ if (recent.has_gui_geometry_main_lower_pane && recent.gui_geometry_status_pane)
gtk_paned_set_position(GTK_PANED(status_pane), recent.gui_geometry_status_pane);
-#endif
}
@@ -1608,7 +1605,7 @@ main(int argc, char *argv[])
gboolean capture_child; /* True if this is the child for "-S" */
GLogLevelFlags log_flags;
-#define OPTSTRING_INIT "a:b:B:c:f:Hhi:klLm:nN:o:pP:Qr:R:Ss:t:T:w:vy:z:"
+#define OPTSTRING_INIT "a:b:c:f:Hhi:klLm:nN:o:pQr:R:Ss:t:w:vy:z:"
#ifdef HAVE_LIBPCAP
#ifdef _WIN32
@@ -1895,6 +1892,11 @@ main(int argc, char *argv[])
g_free(dp_path);
}
+ /* Read the (static part) of the recent file. Only the static part of it will be read, */
+ /* as we don't have the gui now to fill the recent lists which is done in the dynamic part. */
+ /* We have to do this already here, so command line parameters can overwrite these values. */
+ recent_read_static(&rf_path, &rf_open_errno);
+
init_cap_file(&cfile);
#ifdef _WIN32
@@ -1964,9 +1966,6 @@ main(int argc, char *argv[])
#endif
/*** all non capture option specific ***/
- case 'B': /* Byte view pane height */
- bv_size = get_positive_int("ethereal", optarg, "byte view pane height");
- break;
case 'h': /* Print help and exit */
print_usage(TRUE);
exit(0);
@@ -2007,23 +2006,41 @@ main(int argc, char *argv[])
break;
case 'o': /* Override preference from command line */
switch (prefs_set_pref(optarg)) {
-
- case PREFS_SET_SYNTAX_ERR:
+ case PREFS_SET_OK:
+ break;
+ case PREFS_SET_SYNTAX_ERR:
fprintf(stderr, "ethereal: Invalid -o flag \"%s\"\n", optarg);
exit(1);
break;
-
case PREFS_SET_NO_SUCH_PREF:
+ /* not a preference, might be a recent setting */
+ switch (recent_set_arg(optarg)) {
+ case PREFS_SET_OK:
+ break;
+ case PREFS_SET_SYNTAX_ERR:
+ /* shouldn't happen, checked already above */
+ fprintf(stderr, "ethereal: Invalid -o flag \"%s\"\n", optarg);
+ exit(1);
+ break;
+ case PREFS_SET_NO_SUCH_PREF:
+ case PREFS_SET_OBSOLETE:
+ fprintf(stderr, "ethereal: -o flag \"%s\" specifies unknown preference/recent value\n",
+ optarg);
+ exit(1);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ break;
case PREFS_SET_OBSOLETE:
- fprintf(stderr, "ethereal: -o flag \"%s\" specifies unknown preference\n",
+ fprintf(stderr, "ethereal: -o flag \"%s\" specifies obsolete preference\n",
optarg);
exit(1);
break;
+ default:
+ g_assert_not_reached();
}
break;
- case 'P': /* Packet list pane height */
- pl_size = get_positive_int("ethereal", optarg, "packet list pane height");
- break;
case 'r': /* Read capture file xxx */
/* We may set "last_open_dir" to "cf_name", and if we change
"last_open_dir" later, we free the old value, so we have to
@@ -2050,9 +2067,6 @@ main(int argc, char *argv[])
exit(1);
}
break;
- case 'T': /* Tree view pane height */
- tv_size = get_positive_int("ethereal", optarg, "tree view pane height");
- break;
case 'v': /* Show version and exit */
show_version();
#ifdef _WIN32
@@ -2342,15 +2356,14 @@ main(int argc, char *argv[])
/* Everything is prepared now, preferences and command line was read in,
we are NOT a child window for a synced capture. */
- /* Pop up the main window, and read in a capture file if
- we were told to. */
+ /* Pop up the main window. */
create_main_window(pl_size, tv_size, bv_size, prefs);
- /* Read the recent file, as we have the gui now ready for it. */
- read_recent(&rf_path, &rf_open_errno);
+ /* Read the dynamic part of the recent file, as we have the gui now ready for it. */
+ recent_read_dynamic(&rf_path, &rf_open_errno);
color_filters_enable(recent.packet_list_colorize);
- /* rearrange all the widgets as we now have the recent settings for this */
+ /* rearrange all the widgets as we now have all recent settings ready for this */
main_widgets_rearrange();
/* Fill in column titles. This must be done after the top level window
diff --git a/gtk/recent.c b/gtk/recent.c
index db480f980e..0651dbe00a 100644
--- a/gtk/recent.c
+++ b/gtk/recent.c
@@ -133,19 +133,19 @@ write_recent(void)
"# This file is regenerated each time Ethereal is quit.\n"
"# So be careful, if you want to make manual changes here.\n"
"\n"
- "######## Recent capture files (latest last) ########\n"
+ "######## Recent capture files (latest last), cannot be altered through command line ########\n"
"\n", rf);
menu_recent_file_write_all(rf);
fputs("\n"
- "######## Recent capture filters (latest last) ########\n"
+ "######## Recent capture filters (latest last), cannot be altered through command line ########\n"
"\n", rf);
cfilter_combo_recent_write_all(rf);
fputs("\n"
- "######## Recent display filters (latest last) ########\n"
+ "######## Recent display filters (latest last), cannot be altered through command line ########\n"
"\n", rf);
dfilter_recent_combo_write_all(rf);
@@ -204,24 +204,27 @@ write_recent(void)
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
recent.gui_geometry_main_height);
- fprintf(rf, "\n# Main window maximized (GTK2 only).\n");
+ fprintf(rf, "\n# Main window maximized (GTK2 only!).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED ": %s\n",
recent.gui_geometry_main_maximized == TRUE ? "TRUE" : "FALSE");
- fprintf(rf, "\n# Main window upper (or leftmost) pane size (GTK2 only).\n");
+ fprintf(rf, "\n# Main window upper (or leftmost) 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_main_upper_pane != 0) {
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE ": %d\n",
recent.gui_geometry_main_upper_pane);
}
- fprintf(rf, "\n# Main window middle pane size (GTK2 only).\n");
+ fprintf(rf, "\n# Main window 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_main_lower_pane != 0) {
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE ": %d\n",
recent.gui_geometry_main_lower_pane);
}
- fprintf(rf, "\n# Statusbar left pane size (GTK2 only).\n");
+ fprintf(rf, "\n# Statusbar left 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 != 0) {
fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE ": %d\n",
@@ -269,18 +272,12 @@ write_recent_geom(gpointer key _U_, gpointer value, gpointer rf)
/* set one user's recent file key/value pair */
static int
-read_set_recent_pair(gchar *key, gchar *value)
+read_set_recent_pair_static(gchar *key, gchar *value)
{
long num;
char *p;
- if (strcmp(key, RECENT_KEY_CAPTURE_FILE) == 0) {
- add_menu_recent_capture_file(value);
- } 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);
- } else if (strcmp(key, RECENT_KEY_MAIN_TOOLBAR_SHOW) == 0) {
+ if (strcmp(key, RECENT_KEY_MAIN_TOOLBAR_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.main_toolbar_show = TRUE;
}
@@ -376,6 +373,7 @@ read_set_recent_pair(gchar *key, gchar *value)
if (num <= 0)
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
recent.gui_geometry_main_upper_pane = num;
+ recent.has_gui_geometry_main_upper_pane = TRUE;
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE) == 0) {
num = strtol(value, &p, 0);
if (p == value || *p != '\0')
@@ -383,6 +381,7 @@ read_set_recent_pair(gchar *key, gchar *value)
if (num <= 0)
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
recent.gui_geometry_main_lower_pane = num;
+ recent.has_gui_geometry_main_lower_pane = TRUE;
} else if (strcmp(key, RECENT_GUI_GEOMETRY_STATUS_PANE) == 0) {
num = strtol(value, &p, 0);
if (p == value || *p != '\0')
@@ -390,6 +389,7 @@ read_set_recent_pair(gchar *key, gchar *value)
if (num <= 0)
return PREFS_SET_SYNTAX_ERR; /* number must be positive */
recent.gui_geometry_status_pane = num;
+ recent.has_gui_geometry_status_pane = TRUE;
} else if (strcmp(key, RECENT_GUI_FILEOPEN_REMEMBERED_DIR) == 0) {
set_last_open_dir(value);
} else if (strncmp(key, RECENT_GUI_GEOMETRY, sizeof(RECENT_GUI_GEOMETRY)-1) == 0) {
@@ -407,9 +407,67 @@ read_set_recent_pair(gchar *key, gchar *value)
}
-/* opens the user's recent file and read it out */
+/* set one user's recent file key/value pair */
+static int
+read_set_recent_pair_dynamic(gchar *key, gchar *value)
+{
+ if (strcmp(key, RECENT_KEY_CAPTURE_FILE) == 0) {
+ add_menu_recent_capture_file(value);
+ } 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)
+{
+ guchar *p, *colonp;
+ int ret;
+
+ colonp = strchr(prefarg, ':');
+ 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).
+ */
+ while (isspace(*p))
+ 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;
+ }
+
+ ret = read_set_recent_pair_static(prefarg, p);
+ *colonp = ':'; /* put the colon back */
+ return ret;
+}
+
+
+/* opens the user's recent file and read the first part */
void
-read_recent(char **rf_path_return, int *rf_errno_return)
+recent_read_static(char **rf_path_return, int *rf_errno_return)
{
char *rf_path;
FILE *rf;
@@ -437,6 +495,50 @@ read_recent(char **rf_path_return, int *rf_errno_return)
recent.gui_geometry_main_lower_pane = 0;
recent.gui_geometry_status_pane = 0;
+ /* 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
+
+ /* Construct the pathname of the user's recent file. */
+ rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE);
+
+ /* Read the user's recent file, if it exists. */
+ *rf_path_return = NULL;
+ if ((rf = fopen(rf_path, "r")) != NULL) {
+ /* We succeeded in opening it; read it. */
+ read_prefs_file(rf_path, rf, read_set_recent_pair_static);
+ 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;
+
+
/* Construct the pathname of the user's recent file. */
rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE);
@@ -444,7 +546,7 @@ read_recent(char **rf_path_return, int *rf_errno_return)
*rf_path_return = NULL;
if ((rf = fopen(rf_path, "r")) != NULL) {
/* We succeeded in opening it; read it. */
- read_prefs_file(rf_path, rf, read_set_recent_pair);
+ read_prefs_file(rf_path, rf, read_set_recent_pair_dynamic);
/* set dfilter combobox to have an empty line */
dfilter_combo_add_empty();
fclose(rf);
diff --git a/gtk/recent.h b/gtk/recent.h
index 109dda478f..4584ee18da 100644
--- a/gtk/recent.h
+++ b/gtk/recent.h
@@ -58,9 +58,12 @@ typedef struct recent_settings_tag {
gboolean gui_geometry_main_maximized; /* this is valid in GTK2 only */
- gint gui_geometry_main_upper_pane; /* this is valid in GTK2 only */
- gint gui_geometry_main_lower_pane; /* this is valid in GTK2 only */
- gint gui_geometry_status_pane; /* this is valid in GTK2 only */
+ gboolean has_gui_geometry_main_upper_pane; /* gui_geometry_main_upper_pane is valid */
+ gint gui_geometry_main_upper_pane; /* this is autodetected in GTK2 only */
+ gboolean has_gui_geometry_main_lower_pane; /* gui_geometry_main_lower_pane is valid */
+ gint gui_geometry_main_lower_pane; /* this is autodetected in GTK2 only */
+ gboolean has_gui_geometry_status_pane; /* gui_geometry_status_pane is valid */
+ gint gui_geometry_status_pane; /* this is autodetected in GTK2 only */
} recent_settings_t;
/** Global recent settings. */
@@ -72,12 +75,19 @@ extern recent_settings_t recent;
*/
extern gboolean write_recent(void);
-/** Read recent settings file.
+/** Read recent settings file (static part).
*
* @param rf_path_return path to recent file if function failed
* @param rf_errno_return if failed
*/
-extern void read_recent(char **rf_path_return, int *rf_errno_return);
+extern void recent_read_static(char **rf_path_return, int *rf_errno_return);
+
+/** Read recent settings file (dynamic part).
+ *
+ * @param rf_path_return path to recent file if function failed
+ * @param rf_errno_return if failed
+ */
+extern void recent_read_dynamic(char **rf_path_return, int *rf_errno_return);
/** Write the geometry values of a single window to the recent file.
*
@@ -87,4 +97,15 @@ extern void read_recent(char **rf_path_return, int *rf_errno_return);
*/
extern void write_recent_geom(gpointer key, gpointer value, gpointer rf);
+/**
+ * Given a -o command line string, parse it and set the recent value in
+ * question. Return an indication of whether it succeeded or failed
+ * in some fashion.
+ *
+ * @param a string of the form "<recent name>:<recent value>", as might appear
+ * as an argument to a "-o" command line option
+ * @return PREFS_SET_OK or PREFS_SET_SYNTAX_ERR
+ */
+extern int recent_set_arg(char *prefarg);
+
#endif /* recent.h */