diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-06-27 04:36:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-06-27 04:36:03 +0000 |
commit | 7fbf320b8a93553285f702c88440c0822c66ba4d (patch) | |
tree | 862b7499b86746778e8e8441220d609f4e3cf1f6 | |
parent | 85a7f56ac0d6f6488986cb8c0139874349e1c070 (diff) | |
download | wireshark-7fbf320b8a93553285f702c88440c0822c66ba4d.tar.gz wireshark-7fbf320b8a93553285f702c88440c0822c66ba4d.tar.bz2 wireshark-7fbf320b8a93553285f702c88440c0822c66ba4d.zip |
Patch from Ben Fowler to rename the global variable "cf" to "cfile", to
make it easier to use grep to find all references to it without getting
a lot of false hits and to check, after allocating the memory chunk for
"frame_data" structures, that the allocation succeeded.
svn path=/trunk/; revision=2092
-rw-r--r-- | capture.c | 130 | ||||
-rw-r--r-- | file.c | 3 | ||||
-rw-r--r-- | globals.h | 4 | ||||
-rw-r--r-- | gtk/capture_dlg.c | 40 | ||||
-rw-r--r-- | gtk/color_dlg.c | 16 | ||||
-rw-r--r-- | gtk/display_opts.c | 10 | ||||
-rw-r--r-- | gtk/file_dlg.c | 44 | ||||
-rw-r--r-- | gtk/find_dlg.c | 18 | ||||
-rw-r--r-- | gtk/goto_dlg.c | 4 | ||||
-rw-r--r-- | gtk/main.c | 151 | ||||
-rw-r--r-- | gtk/packet_win.c | 16 | ||||
-rw-r--r-- | gtk/print_dlg.c | 8 | ||||
-rw-r--r-- | packet.c | 4 | ||||
-rw-r--r-- | summary.c | 30 | ||||
-rw-r--r-- | tethereal.c | 120 |
15 files changed, 300 insertions, 298 deletions
@@ -1,7 +1,7 @@ /* capture.c * Routines for packet capture windows * - * $Id: capture.c,v 1.108 2000/06/15 08:02:20 guy Exp $ + * $Id: capture.c,v 1.109 2000/06/27 04:35:42 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -163,23 +163,23 @@ do_capture(char *capfile_name) if (capfile_name != NULL) { /* Try to open/create the specified file for use as a capture buffer. */ - cf.save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT, 0600); + cfile.save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT, 0600); is_tempfile = FALSE; } else { /* Choose a random name for the capture buffer */ - cf.save_file_fd = create_tempfile(tmpname, sizeof tmpname, "ether"); + cfile.save_file_fd = create_tempfile(tmpname, sizeof tmpname, "ether"); capfile_name = g_strdup(tmpname); is_tempfile = TRUE; } - if (cf.save_file_fd == -1) { + if (cfile.save_file_fd == -1) { simple_dialog(ESD_TYPE_WARN, NULL, "The file to which the capture would be saved (\"%s\")" "could not be opened: %s.", capfile_name, strerror(errno)); return; } - close_cap_file(&cf, info_bar); - g_assert(cf.save_file == NULL); - cf.save_file = capfile_name; + close_cap_file(&cfile, info_bar); + g_assert(cfile.save_file == NULL); + cfile.save_file = capfile_name; if (sync_mode) { /* do the capture in a child process */ int fork_child; @@ -193,9 +193,9 @@ do_capture(char *capfile_name) char *filterstring; #endif - sprintf(ssnap,"%d",cf.snap); /* in lieu of itoa */ - sprintf(scount,"%d",cf.count); - sprintf(save_file_fd,"%d",cf.save_file_fd); + sprintf(ssnap,"%d",cfile.snap); /* in lieu of itoa */ + sprintf(scount,"%d",cfile.count); + sprintf(save_file_fd,"%d",cfile.save_file_fd); #ifdef _WIN32 /* Create a pipe for the child process */ @@ -203,9 +203,9 @@ do_capture(char *capfile_name) if(_pipe(sync_pipe, 512, O_BINARY) < 0) { /* Couldn't create the pipe between parent and child. */ error = errno; - unlink(cf.save_file); - g_free(cf.save_file); - cf.save_file = NULL; + unlink(cfile.save_file); + g_free(cfile.save_file); + cfile.save_file = NULL; simple_dialog(ESD_TYPE_WARN, NULL, "Couldn't create sync pipe: %s", strerror(error)); return; @@ -214,16 +214,16 @@ do_capture(char *capfile_name) /* Convert pipe write handle to a string and pass to child */ itoa(sync_pipe[WRITE], sync_pipe_fd, 10); /* Convert filter string to a quote delimited string */ - filterstring = g_new(char, strlen(cf.cfilter) + 3); - sprintf(filterstring, "\"%s\"", cf.cfilter); - filterstring[strlen(cf.cfilter) + 2] = 0; + filterstring = g_new(char, strlen(cfile.cfilter) + 3); + sprintf(filterstring, "\"%s\"", cfile.cfilter); + filterstring[strlen(cfile.cfilter) + 2] = 0; /* Spawn process */ - fork_child = spawnlp(_P_NOWAIT, ethereal_path, CHILD_NAME, "-i", cf.iface, - "-w", cf.save_file, "-W", save_file_fd, + fork_child = spawnlp(_P_NOWAIT, ethereal_path, CHILD_NAME, "-i", cfile.iface, + "-w", cfile.save_file, "-W", save_file_fd, "-c", scount, "-s", ssnap, "-Z", sync_pipe_fd, - strlen(cf.cfilter) == 0 ? (const char *)NULL : "-f", - strlen(cf.cfilter) == 0 ? (const char *)NULL : filterstring, + strlen(cfile.cfilter) == 0 ? (const char *)NULL : "-f", + strlen(cfile.cfilter) == 0 ? (const char *)NULL : filterstring, (const char *)NULL); g_free(filterstring); /* Keep a copy for later evaluation by _cwait() */ @@ -233,9 +233,9 @@ do_capture(char *capfile_name) if (pipe(sync_pipe) < 0) { /* Couldn't create the pipe between parent and child. */ error = errno; - unlink(cf.save_file); - g_free(cf.save_file); - cf.save_file = NULL; + unlink(cfile.save_file); + g_free(cfile.save_file); + cfile.save_file = NULL; simple_dialog(ESD_TYPE_WARN, NULL, "Couldn't create sync pipe: %s", strerror(error)); return; @@ -257,12 +257,12 @@ do_capture(char *capfile_name) close(1); dup(sync_pipe[WRITE]); close(sync_pipe[READ]); - execlp(ethereal_path, CHILD_NAME, "-i", cf.iface, - "-w", cf.save_file, "-W", save_file_fd, + execlp(ethereal_path, CHILD_NAME, "-i", cfile.iface, + "-w", cfile.save_file, "-W", save_file_fd, "-c", scount, "-s", ssnap, "-m", medium_font, "-b", bold_font, - (cf.cfilter == NULL)? 0 : "-f", - (cf.cfilter == NULL)? 0 : cf.cfilter, + (cfile.cfilter == NULL)? 0 : "-f", + (cfile.cfilter == NULL)? 0 : cfile.cfilter, (const char *)NULL); snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s", ethereal_path, strerror(errno)); @@ -287,15 +287,15 @@ do_capture(char *capfile_name) /* Close the save file FD, as we won't be using it - we'll be opening it and reading the save file through Wiretap. */ - close(cf.save_file_fd); + close(cfile.save_file_fd); if (fork_child == -1) { /* We couldn't even create the child process. */ error = errno; close(sync_pipe[READ]); - unlink(cf.save_file); - g_free(cf.save_file); - cf.save_file = NULL; + unlink(cfile.save_file); + g_free(cfile.save_file); + cfile.save_file = NULL; simple_dialog(ESD_TYPE_WARN, NULL, "Couldn't create child process: %s", strerror(error)); return; @@ -315,9 +315,9 @@ do_capture(char *capfile_name) and report the failure. XXX - reap the child process and report the status in detail. */ close(sync_pipe[READ]); - unlink(cf.save_file); - g_free(cf.save_file); - cf.save_file = NULL; + unlink(cfile.save_file); + g_free(cfile.save_file); + cfile.save_file = NULL; simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process died"); return; } @@ -328,9 +328,9 @@ do_capture(char *capfile_name) Close the read side of the sync pipe, remove the capture file, and report the failure. */ close(sync_pipe[READ]); - unlink(cf.save_file); - g_free(cf.save_file); - cf.save_file = NULL; + unlink(cfile.save_file); + g_free(cfile.save_file); + cfile.save_file = NULL; simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process sent us a bad message"); return; @@ -339,7 +339,7 @@ do_capture(char *capfile_name) } if (byte_count == 0) { /* Success. Open the capture file, and set up to read it. */ - err = start_tail_cap_file(cf.save_file, is_tempfile, &cf); + err = start_tail_cap_file(cfile.save_file, is_tempfile, &cfile); if (err == 0) { /* We were able to open and set up to read the capture file; arrange that our callback be called whenever it's possible @@ -357,22 +357,22 @@ do_capture(char *capfile_name) GDK_INPUT_READ|GDK_INPUT_EXCEPTION, cap_file_input_cb, NULL, - (gpointer) &cf, + (gpointer) &cfile, NULL); #endif } else { /* We weren't able to open the capture file; complain, and close the sync pipe. */ simple_dialog(ESD_TYPE_WARN, NULL, - file_open_error_message(err, FALSE), cf.save_file); + file_open_error_message(err, FALSE), cfile.save_file); /* Close the sync pipe. */ close(sync_pipe[READ]); /* Don't unlink the save file - leave it around, for debugging purposes. */ - g_free(cf.save_file); - cf.save_file = NULL; + g_free(cfile.save_file); + cfile.save_file = NULL; } } else { /* Failure - the child process sent us a message indicating @@ -398,9 +398,9 @@ do_capture(char *capfile_name) close(sync_pipe[READ]); /* Get rid of the save file - the capture never started. */ - unlink(cf.save_file); - g_free(cf.save_file); - cf.save_file = NULL; + unlink(cfile.save_file); + g_free(cfile.save_file); + cfile.save_file = NULL; } } } else { @@ -412,16 +412,16 @@ do_capture(char *capfile_name) } if (capture_succeeded) { /* Capture succeeded; read in the capture file. */ - if ((err = open_cap_file(cf.save_file, is_tempfile, &cf)) == 0) { + if ((err = open_cap_file(cfile.save_file, is_tempfile, &cfile)) == 0) { /* Set the read filter to NULL. */ - cf.rfcode = NULL; - err = read_cap_file(&cf); + cfile.rfcode = NULL; + err = read_cap_file(&cfile); } } /* We're not doing a capture any more, so we don't have a save file. */ - g_free(cf.save_file); - cf.save_file = NULL; + g_free(cfile.save_file); + cfile.save_file = NULL; } } @@ -453,7 +453,7 @@ cap_timer_cb(gpointer data) gtk_timeout_remove(cap_timer_id); /* And call the real handler */ - cap_file_input_cb((gpointer) &cf, 0, 0); + cap_file_input_cb((gpointer) &cfile, 0, 0); /* Return false so that the timer is not run again */ return FALSE; @@ -693,7 +693,7 @@ capture(void) ld.go = TRUE; ld.counts.total = 0; - ld.max = cf.count; + ld.max = cfile.count; ld.linktype = WTAP_ENCAP_UNKNOWN; ld.sync_packets = 0; ld.counts.sctp = 0; @@ -709,7 +709,7 @@ capture(void) ld.pdh = NULL; /* Open the network interface to capture from it. */ - pch = pcap_open_live(cf.iface, cf.snap, 1, CAP_READ_TIMEOUT, err_str); + pch = pcap_open_live(cfile.iface, cfile.snap, 1, CAP_READ_TIMEOUT, err_str); if (pch == NULL) { /* Well, we couldn't start the capture. @@ -727,19 +727,19 @@ capture(void) goto error; } - if (cf.cfilter) { + if (cfile.cfilter) { /* A capture filter was specified; set it up. */ - if (pcap_lookupnet (cf.iface, &netnum, &netmask, err_str) < 0) { + if (pcap_lookupnet (cfile.iface, &netnum, &netmask, err_str) < 0) { snprintf(errmsg, sizeof errmsg, "Can't use filter: Couldn't obtain netmask info (%s).", err_str); goto error; } - if (pcap_compile(pch, &cf.fcode, cf.cfilter, 1, netmask) < 0) { + if (pcap_compile(pch, &cfile.fcode, cfile.cfilter, 1, netmask) < 0) { snprintf(errmsg, sizeof errmsg, "Unable to parse filter string (%s).", pcap_geterr(pch)); goto error; } - if (pcap_setfilter(pch, &cf.fcode) < 0) { + if (pcap_setfilter(pch, &cfile.fcode) < 0) { snprintf(errmsg, sizeof errmsg, "Can't install filter (%s).", pcap_geterr(pch)); goto error; @@ -753,7 +753,7 @@ capture(void) " that Ethereal doesn't support."); goto error; } - ld.pdh = wtap_dump_fdopen(cf.save_file_fd, WTAP_FILE_PCAP, + ld.pdh = wtap_dump_fdopen(cfile.save_file_fd, WTAP_FILE_PCAP, ld.linktype, pcap_snapshot(pch), &err); if (ld.pdh == NULL) { @@ -774,11 +774,11 @@ capture(void) if (err < 0) { sprintf(errmsg, "The file to which the capture would be" " saved (\"%s\") could not be opened: Error %d.", - cf.save_file, err); + cfile.save_file, err); } else { sprintf(errmsg, "The file to which the capture would be" " saved (\"%s\") could not be opened: %s.", - cf.save_file, strerror(err)); + cfile.save_file, strerror(err)); } break; } @@ -994,7 +994,7 @@ capture(void) simple_dialog(ESD_TYPE_WARN, NULL, "The file to which the capture was being" " saved (\"%s\") could not be closed: %s.", - cf.save_file, wtap_strerror(err)); + cfile.save_file, wtap_strerror(err)); break; } } @@ -1008,13 +1008,13 @@ capture(void) error: /* We can't use the save file, and we have no wtap_dump stream to close in order to close it, so close the FD directly. */ - close(cf.save_file_fd); + close(cfile.save_file_fd); /* We couldn't even start the capture, so get rid of the capture file. */ - unlink(cf.save_file); /* silently ignore error */ - g_free(cf.save_file); - cf.save_file = NULL; + unlink(cfile.save_file); /* silently ignore error */ + g_free(cfile.save_file); + cfile.save_file = NULL; if (capture_child) { /* This is the child process for a sync mode capture. Send the error message to our parent, so they can display a @@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.189 2000/05/19 23:06:06 gram Exp $ + * $Id: file.c,v 1.190 2000/06/27 04:35:44 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -174,6 +174,7 @@ open_cap_file(char *fname, gboolean is_tempfile, capture_file *cf) sizeof(frame_data), FRAME_DATA_CHUNK_SIZE * sizeof(frame_data), G_ALLOC_AND_FREE); + g_assert(cf->plist_chunk); return (0); @@ -1,7 +1,7 @@ /* globals.h * Global defines, etc. * - * $Id: globals.h,v 1.17 2000/01/25 04:31:16 guy Exp $ + * $Id: globals.h,v 1.18 2000/06/27 04:35:45 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -76,7 +76,7 @@ extern FILE *data_out_file; extern packet_info pi; -extern capture_file cf; +extern capture_file cfile; extern guint main_ctx, file_ctx; extern gchar comp_info_str[256]; extern gchar *ethereal_path; diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c index ac26f4a5bb..4d9d106507 100644 --- a/gtk/capture_dlg.c +++ b/gtk/capture_dlg.c @@ -1,7 +1,7 @@ /* capture_dlg.c * Routines for packet capture windows * - * $Id: capture_dlg.c,v 1.26 2000/06/15 08:02:42 guy Exp $ + * $Id: capture_dlg.c,v 1.27 2000/06/27 04:35:57 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -160,8 +160,8 @@ capture_prep_cb(GtkWidget *w, gpointer d) if_cb = gtk_combo_new(); if (if_list != NULL) gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), if_list); - if (cf.iface) - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cf.iface); + if (cfile.iface) + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cfile.iface); else if (if_list) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_list->data); gtk_box_pack_start(GTK_BOX(if_hb), if_cb, FALSE, FALSE, 0); @@ -179,8 +179,8 @@ capture_prep_cb(GtkWidget *w, gpointer d) gtk_widget_show(count_lb); count_list = g_list_append(count_list, count_item1); - if (cf.count) { - snprintf(count_item2, 15, "%d", cf.count); + if (cfile.count) { + snprintf(count_item2, 15, "%d", cfile.count); count_list = g_list_append(count_list, count_item2); } @@ -204,7 +204,7 @@ capture_prep_cb(GtkWidget *w, gpointer d) gtk_widget_show(filter_bt); filter_te = gtk_entry_new(); - if (cf.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cf.cfilter); + if (cfile.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.cfilter); gtk_object_set_data(GTK_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te); gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 0); gtk_widget_show(filter_te); @@ -235,7 +235,7 @@ capture_prep_cb(GtkWidget *w, gpointer d) gtk_box_pack_start(GTK_BOX(caplen_hb), snap_lb, FALSE, FALSE, 6); gtk_widget_show(snap_lb); - adj = (GtkAdjustment *) gtk_adjustment_new((float) cf.snap, + adj = (GtkAdjustment *) gtk_adjustment_new((float) cfile.snap, MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0); snap_sb = gtk_spin_button_new (adj, 0, 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE); @@ -437,12 +437,12 @@ capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) { g_free(if_name); return; } - if (cf.iface) - g_free(cf.iface); - cf.iface = g_strdup(if_name); + if (cfile.iface) + g_free(cfile.iface); + cfile.iface = g_strdup(if_name); g_free(if_text); - /* XXX - don't try to get clever and set "cf.filter" to NULL if the + /* XXX - don't try to get clever and set "cfile.filter" to NULL if the filter string is empty, as an indication that we don't have a filter and thus don't have to set a filter when capturing - the version of libpcap in Red Hat Linux 6.1, and versions based on later patches @@ -451,10 +451,10 @@ capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) { no filter is set, which means no packets arrive as input on that socket, which means Ethereal never sees any packets. */ filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te)); - if (cf.cfilter) - g_free(cf.cfilter); + if (cfile.cfilter) + g_free(cfile.cfilter); g_assert(filter_text != NULL); - cf.cfilter = g_strdup(filter_text); + cfile.cfilter = g_strdup(filter_text); save_file = gtk_entry_get_text(GTK_ENTRY(file_te)); if (save_file && save_file[0]) { @@ -465,13 +465,13 @@ capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) { save_file = NULL; } - cf.count = atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(count_cb)->entry))); + cfile.count = atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(count_cb)->entry))); - cf.snap = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb)); - if (cf.snap < 1) - cf.snap = WTAP_MAX_PACKET_SIZE; - else if (cf.snap < MIN_PACKET_SIZE) - cf.snap = MIN_PACKET_SIZE; + cfile.snap = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb)); + if (cfile.snap < 1) + cfile.snap = WTAP_MAX_PACKET_SIZE; + else if (cfile.snap < MIN_PACKET_SIZE) + cfile.snap = MIN_PACKET_SIZE; sync_mode = GTK_TOGGLE_BUTTON (sync_cb)->active; diff --git a/gtk/color_dlg.c b/gtk/color_dlg.c index 00eed8bed4..a858a08632 100644 --- a/gtk/color_dlg.c +++ b/gtk/color_dlg.c @@ -1,7 +1,7 @@ /* color_dlg.c * Definitions for dialog boxes for color filters * - * $Id: color_dlg.c,v 1.2 2000/02/12 08:42:26 guy Exp $ + * $Id: color_dlg.c,v 1.3 2000/06/27 04:35:58 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -95,7 +95,7 @@ color_display_cb(GtkWidget *w, gpointer d) reactivate_window(colorize_win); } else { /* Create a new "Colorize Display" dialog. */ - colorize_win = colorize_dialog_new(cf.colors); + colorize_win = colorize_dialog_new(cfile.colors); } } @@ -575,7 +575,7 @@ color_ok_cb (GtkButton *button, gpointer user_data) { /* colorize list */ - colorize_packets(&cf); + colorize_packets(&cfile); /* Destroy the dialog box. */ gtk_widget_destroy(colorize_win); @@ -596,7 +596,7 @@ static void color_apply_cb (GtkButton *button, gpointer user_data) { - colorize_packets(&cf); + colorize_packets(&cfile); } /* Create an "Edit color filter" dialog for a given color filter, and @@ -916,17 +916,17 @@ edit_color_filter_ok_cb (GtkButton *button, colorf->fg_color = new_fg_color; colorf->bg_color = new_bg_color; gtk_clist_set_foreground(GTK_CLIST(color_filters), - cf.colors->row_selected, &new_fg_color); + cfile.colors->row_selected, &new_fg_color); gtk_clist_set_background(GTK_CLIST(color_filters), - cf.colors->row_selected, &new_bg_color); + cfile.colors->row_selected, &new_bg_color); if(colorf->c_colorfilter != NULL) dfilter_destroy(colorf->c_colorfilter); colorf->c_colorfilter = compiled_filter; /* gtk_clist_set_text frees old text (if any) and allocates new space */ gtk_clist_set_text(GTK_CLIST(color_filters), - cf.colors->row_selected, 0, filter_name); + cfile.colors->row_selected, 0, filter_name); gtk_clist_set_text(GTK_CLIST(color_filters), - cf.colors->row_selected, 1, filter_text); + cfile.colors->row_selected, 1, filter_text); /* Destroy the dialog box. */ gtk_widget_destroy(dialog); diff --git a/gtk/display_opts.c b/gtk/display_opts.c index 44addcd1f8..a74360051f 100644 --- a/gtk/display_opts.c +++ b/gtk/display_opts.c @@ -1,7 +1,7 @@ /* display_opts.c * Routines for packet display windows * - * $Id: display_opts.c,v 1.7 2000/05/08 05:51:37 guy Exp $ + * $Id: display_opts.c,v 1.8 2000/06/27 04:35:59 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -65,7 +65,7 @@ #include "ui_util.h" #include "dlg_utils.h" -extern capture_file cf; +extern capture_file cfile; extern GtkWidget *packet_list; /* Display callback data keys */ @@ -247,7 +247,7 @@ display_opt_ok_cb(GtkWidget *ok_bt, gpointer parent_w) { gtk_widget_destroy(GTK_WIDGET(parent_w)); - change_time_formats(&cf); + change_time_formats(&cfile); } static void @@ -281,7 +281,7 @@ display_opt_apply_cb(GtkWidget *ok_bt, gpointer parent_w) { E_DISPLAY_IP_DSCP_KEY); g_ip_dscp_actif = (GTK_TOGGLE_BUTTON (button)->active); - change_time_formats(&cf); + change_time_formats(&cfile); } static void @@ -289,7 +289,7 @@ display_opt_close_cb(GtkWidget *close_bt, gpointer parent_w) { if (timestamp_type != prev_timestamp_type) { timestamp_type = prev_timestamp_type; - change_time_formats(&cf); + change_time_formats(&cfile); } gtk_grab_remove(GTK_WIDGET(parent_w)); diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c index cf47e675ad..27f92e5631 100644 --- a/gtk/file_dlg.c +++ b/gtk/file_dlg.c @@ -1,7 +1,7 @@ /* file_dlg.c * Dialog boxes for handling files * - * $Id: file_dlg.c,v 1.24 2000/06/02 03:35:39 gram Exp $ + * $Id: file_dlg.c,v 1.25 2000/06/27 04:36:00 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -197,7 +197,7 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) { } /* Try to open the capture file. */ - if ((err = open_cap_file(cf_name, FALSE, &cf)) != 0) { + if ((err = open_cap_file(cf_name, FALSE, &cfile)) != 0) { /* We couldn't open it; don't dismiss the open dialog box, just leave it around so that the user can, after they dismiss the alert box popped up for the open error, @@ -211,7 +211,7 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) { /* Attach the new read filter to "cf" ("open_cap_file()" succeeded, so it closed the previous capture file, and thus destroyed any previous read filter attached to "cf"). */ - cf.rfcode = rfcode; + cfile.rfcode = rfcode; /* Set the global resolving variable */ resolv_cb = gtk_object_get_data(GTK_OBJECT(w), E_FILE_RESOLVE_KEY); @@ -221,7 +221,7 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) { gtk_widget_hide(GTK_WIDGET (fs)); gtk_widget_destroy(GTK_WIDGET (fs)); - err = read_cap_file(&cf); + err = read_cap_file(&cfile); /* Save the name of the containing directory specified in the path name, if any; we can write over cf_name, which is a good thing, given that "get_dirname()" does write over its argument. */ @@ -269,13 +269,13 @@ file_open_destroy_cb(GtkWidget *win, gpointer user_data) /* Close a file */ void file_close_cmd_cb(GtkWidget *widget, gpointer data) { - close_cap_file(&cf, info_bar); + close_cap_file(&cfile, info_bar); } void file_save_cmd_cb(GtkWidget *w, gpointer data) { /* If the file's already been saved, do nothing. */ - if (cf.user_saved) + if (cfile.user_saved) return; /* Do a "Save As". */ @@ -294,7 +294,7 @@ can_save_with_wiretap(int ft) /* To save a file with Wiretap, Wiretap has to handle that format, and its code to handle that format must be able to write a file with this file's encapsulation type. */ - return wtap_dump_can_open(ft) && wtap_dump_can_write_encap(ft, cf.lnk_t); + return wtap_dump_can_open(ft) && wtap_dump_can_write_encap(ft, cfile.lnk_t); } /* Generate a list of the file types we can save this file as. @@ -325,7 +325,7 @@ set_file_type_list(GtkWidget *option_menu) /* Check all file types. */ index = 0; for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) { - if (filtered || ft != cf.cd_t) { + if (filtered || ft != cfile.cd_t) { /* Filtered, or a different file type. We have to use Wiretap. */ if (!can_save_with_wiretap(ft)) continue; /* We can't. */ @@ -396,7 +396,7 @@ file_save_as_cmd_cb(GtkWidget *w, gpointer data) /* Default to saving all packets, in the file's current format. */ filtered = FALSE; - filetype = cf.cd_t; + filetype = cfile.cd_t; file_save_as_w = gtk_file_selection_new ("Ethereal: Save Capture File As"); gtk_signal_connect(GTK_OBJECT(file_save_as_w), "destroy", @@ -463,7 +463,7 @@ file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs) { /* Write out the packets (all, or only the ones that are currently displayed) to the file with the specified name. */ - save_cap_file(cf_name, &cf, filtered, filetype); + save_cap_file(cf_name, &cfile, filtered, filetype); /* If "save_cap_file()" saved the file name we handed it, it saved a copy, so we should free up our copy. */ @@ -487,9 +487,9 @@ file_reload_cmd_cb(GtkWidget *w, gpointer data) { filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY); - if (cf.dfilter) - g_free(cf.dfilter); - cf.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te))); + if (cfile.dfilter) + g_free(cfile.dfilter); + cfile.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te))); /* If the file could be opened, "open_cap_file()" calls "close_cap_file()" to get rid of state for the old capture file before filling in state @@ -499,21 +499,21 @@ file_reload_cmd_cb(GtkWidget *w, gpointer data) { a temporary file, mark it as not being a temporary file, and then reopen it as the type of file it was. - Also, "close_cap_file()" will free "cf.filename", so we must make + Also, "close_cap_file()" will free "cfile.filename", so we must make a copy of it first. */ - filename = strdup(cf.filename); - is_tempfile = cf.is_tempfile; - cf.is_tempfile = FALSE; - if (open_cap_file(filename, is_tempfile, &cf) == 0) - read_cap_file(&cf); + filename = strdup(cfile.filename); + is_tempfile = cfile.is_tempfile; + cfile.is_tempfile = FALSE; + if (open_cap_file(filename, is_tempfile, &cfile) == 0) + read_cap_file(&cfile); else { - /* The open failed, so "cf.is_tempfile" wasn't set to "is_tempfile". - Instead, the file was left open, so we should restore "cf.is_tempfile" + /* The open failed, so "cfile.is_tempfile" wasn't set to "is_tempfile". + Instead, the file was left open, so we should restore "cfile.is_tempfile" ourselves. XXX - change the menu? Presumably "open_cap_file()" will do that; make sure it does! */ - cf.is_tempfile = is_tempfile; + cfile.is_tempfile = is_tempfile; } /* "open_cap_file()" made a copy of the file name we handed it, so we should free up our copy. */ diff --git a/gtk/find_dlg.c b/gtk/find_dlg.c index b8acbeb389..69aa0a859e 100644 --- a/gtk/find_dlg.c +++ b/gtk/find_dlg.c @@ -1,7 +1,7 @@ /* find_dlg.c * Routines for "find frame" window * - * $Id: find_dlg.c,v 1.10 2000/05/08 04:53:20 guy Exp $ + * $Id: find_dlg.c,v 1.11 2000/06/27 04:36:00 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -112,7 +112,7 @@ find_frame_cb(GtkWidget *w, gpointer d) gtk_widget_show(filter_bt); filter_te = gtk_entry_new(); - if (cf.sfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cf.sfilter); + if (cfile.sfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.sfilter); gtk_object_set_data(GTK_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te); gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 0); gtk_widget_show(filter_te); @@ -124,14 +124,14 @@ find_frame_cb(GtkWidget *w, gpointer d) forward_rb = dlg_radio_button_new_with_label_with_mnemonic(NULL, "_Forward", accel_group); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(forward_rb), !cf.sbackward); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(forward_rb), !cfile.sbackward); gtk_box_pack_start(GTK_BOX(direction_hb), forward_rb, TRUE, TRUE, 0); gtk_widget_show(forward_rb); backward_rb = dlg_radio_button_new_with_label_with_mnemonic( gtk_radio_button_group(GTK_RADIO_BUTTON(forward_rb)), "_Backward", accel_group); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(backward_rb), cf.sbackward); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(backward_rb), cfile.sbackward); gtk_box_pack_start(GTK_BOX(direction_hb), backward_rb, TRUE, TRUE, 0); gtk_widget_show(backward_rb); @@ -210,13 +210,13 @@ find_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w) /* * Remember the filter. */ - if (cf.sfilter) - g_free(cf.sfilter); - cf.sfilter = g_strdup(filter_text); + if (cfile.sfilter) + g_free(cfile.sfilter); + cfile.sfilter = g_strdup(filter_text); - cf.sbackward = GTK_TOGGLE_BUTTON (backward_rb)->active; + cfile.sbackward = GTK_TOGGLE_BUTTON (backward_rb)->active; - if (!find_packet(&cf, sfcode)) { + if (!find_packet(&cfile, sfcode)) { /* We didn't find the packet. */ simple_dialog(ESD_TYPE_WARN, NULL, "No packet matched that filter."); return; diff --git a/gtk/goto_dlg.c b/gtk/goto_dlg.c index 9062a26dd6..627e9c0ba9 100644 --- a/gtk/goto_dlg.c +++ b/gtk/goto_dlg.c @@ -1,7 +1,7 @@ /* goto_dlg.c * Routines for "go to frame" window * - * $Id: goto_dlg.c,v 1.6 2000/05/02 08:04:31 guy Exp $ + * $Id: goto_dlg.c,v 1.7 2000/06/27 04:36:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -150,7 +150,7 @@ goto_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w) return; } - switch (goto_frame(&cf, fnumber)) { + switch (goto_frame(&cfile, fnumber)) { case NO_SUCH_FRAME: simple_dialog(ESD_TYPE_WARN, NULL, "There is no frame with that frame number."); diff --git a/gtk/main.c b/gtk/main.c index a93d8c3ecf..e99a2b7866 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.122 2000/06/24 05:06:29 guy Exp $ + * $Id: main.c,v 1.123 2000/06/27 04:36:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -119,7 +119,7 @@ FILE *data_out_file = NULL; packet_info pi; -capture_file cf; +capture_file cfile; GtkWidget *top_level, *packet_list, *tree_view, *byte_view, *prog_bar, *info_bar, *tv_scrollw, *pkt_scrollw; static GtkWidget *bv_scrollw; @@ -207,7 +207,7 @@ follow_stream_cb( GtkWidget *w, gpointer data ) { gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter); /* Run the display filter so it goes in effect. */ - filter_packets(&cf, follow_filter); + filter_packets(&cfile, follow_filter); /* the data_out_file should now be full of the streams information */ fclose( data_out_file ); @@ -692,7 +692,7 @@ match_selected_cb(GtkWidget *w, gpointer data) break; #endif default: - c = cf.pd + finfo_selected->start; + c = cfile.pd + finfo_selected->start; buf = g_malloc0(32 + finfo_selected->length * 3); ptr = buf; @@ -720,7 +720,7 @@ match_selected_cb(GtkWidget *w, gpointer data) gtk_entry_set_text(GTK_ENTRY(filter_te), buf); /* Run the display filter so it goes in effect. */ - filter_packets(&cf, buf); + filter_packets(&cfile, buf); /* Don't g_free(buf) here. filter_packets() will do it the next time it's called */ } @@ -796,7 +796,7 @@ filter_activate_cb(GtkWidget *w, gpointer data) /* GtkCombos don't let us get at their list contents easily, so we maintain our own filter list, and feed it to gtk_combo_set_popdown_strings when a new filter is added. */ - if (filter_packets(&cf, g_strdup(s))) { + if (filter_packets(&cfile, g_strdup(s))) { li = g_list_first(filter_list); while (li) { if (li->data && strcmp(s, li->data) == 0) @@ -827,7 +827,7 @@ filter_reset_cb(GtkWidget *w, gpointer data) gtk_entry_set_text(GTK_ENTRY(filter_te), ""); } - filter_packets(&cf, NULL); + filter_packets(&cfile, NULL); } /* GTKClist compare routine, overrides default to allow numeric comparison */ @@ -842,7 +842,7 @@ packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) double num1 = atof(text1); double num2 = atof(text2); - gint col_fmt = cf.cinfo.col_fmt[clist->sort_column]; + gint col_fmt = cfile.cinfo.col_fmt[clist->sort_column]; if ((col_fmt == COL_NUMBER) || (col_fmt == COL_REL_TIME) || (col_fmt == COL_DELTA_TIME) || ((col_fmt == COL_CLS_TIME) && (timestamp_type == RELATIVE)) || @@ -898,12 +898,12 @@ static void packet_list_select_cb(GtkWidget *w, gint row, gint col, gpointer evt) { blank_packetinfo(); - select_packet(&cf, row); + select_packet(&cfile, row); } static void packet_list_unselect_cb(GtkWidget *w, gint row, gint col, gpointer evt) { - unselect_packet(&cf); + unselect_packet(&cfile); } static void @@ -917,34 +917,34 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user finfo_selected = finfo; - packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.current_frame->cap_len, - finfo->start, finfo->length, cf.current_frame->flags.encoding); + packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len, + finfo->start, finfo->length, cfile.current_frame->flags.encoding); } static void tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user_data) { finfo_selected = NULL; - packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.current_frame->cap_len, - -1, -1, cf.current_frame->flags.encoding); + packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len, + -1, -1, cfile.current_frame->flags.encoding); } void collapse_all_cb(GtkWidget *widget, gpointer data) { - if (cf.protocol_tree) - collapse_all_tree(cf.protocol_tree, tree_view); + if (cfile.protocol_tree) + collapse_all_tree(cfile.protocol_tree, tree_view); } void expand_all_cb(GtkWidget *widget, gpointer data) { - if (cf.protocol_tree) - expand_all_tree(cf.protocol_tree, tree_view); + if (cfile.protocol_tree) + expand_all_tree(cfile.protocol_tree, tree_view); } void resolve_name_cb(GtkWidget *widget, gpointer data) { - if (cf.protocol_tree) { + if (cfile.protocol_tree) { int tmp = g_resolving_actif; g_resolving_actif = 1; gtk_clist_clear ( GTK_CLIST(tree_view) ); - proto_tree_draw(cf.protocol_tree, tree_view); + proto_tree_draw(cfile.protocol_tree, tree_view); g_resolving_actif = tmp; } } @@ -1001,7 +1001,7 @@ void set_plist_sel_browse(gboolean val) { if (finfo_selected) - unselect_packet(&cf); + unselect_packet(&cfile); /* Yeah, GTK uses "browse" in the case where we do not, but oh well. I think * "browse" in Ethereal makes more sense than "SINGLE" in GTK+ */ @@ -1116,8 +1116,9 @@ file_quit_cmd_cb (GtkWidget *widget, gpointer data) which we'd call here, and another routine that calls that routine and also cleans up the UI, which we'd call elsewhere? */ - close_cap_file(&cf, info_bar); + close_cap_file(&cfile, info_bar); + fprintf( stderr, "file_quit_cmd_cb: About to call gtk_main_quit()\n"); /* Exit by leaving the main loop, so that any quit functions we registered get called. */ gtk_main_quit(); @@ -1231,29 +1232,29 @@ main(int argc, char *argv[]) } /* Initialize the capture file struct */ - cf.plist = NULL; - cf.plist_end = NULL; - cf.wth = NULL; - cf.filename = NULL; - cf.user_saved = FALSE; - cf.is_tempfile = FALSE; - cf.rfcode = NULL; - cf.dfilter = NULL; - cf.dfcode = NULL; + cfile.plist = NULL; + cfile.plist_end = NULL; + cfile.wth = NULL; + cfile.filename = NULL; + cfile.user_saved = FALSE; + cfile.is_tempfile = FALSE; + cfile.rfcode = NULL; + cfile.dfilter = NULL; + cfile.dfcode = NULL; #ifdef HAVE_LIBPCAP - cf.cfilter = g_strdup(EMPTY_FILTER); + cfile.cfilter = g_strdup(EMPTY_FILTER); #endif - cf.iface = NULL; - cf.save_file = NULL; - cf.save_file_fd = -1; - cf.snap = WTAP_MAX_PACKET_SIZE; - cf.count = 0; - cf.cinfo.num_cols = prefs->num_cols; - cf.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols); - cf.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cf.cinfo.num_cols); - cf.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols); - cf.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols); - cf.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols); + cfile.iface = NULL; + cfile.save_file = NULL; + cfile.save_file_fd = -1; + cfile.snap = WTAP_MAX_PACKET_SIZE; + cfile.count = 0; + cfile.cinfo.num_cols = prefs->num_cols; + cfile.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols); + cfile.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cfile.cinfo.num_cols); + cfile.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols); + cfile.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols); + cfile.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols); /* Assemble the compile-time options */ snprintf(comp_info_str, 256, @@ -1309,7 +1310,7 @@ main(int argc, char *argv[]) break; case 'c': /* Capture xxx packets */ #ifdef HAVE_LIBPCAP - cf.count = atoi(optarg); + cfile.count = atoi(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -1320,9 +1321,9 @@ main(int argc, char *argv[]) break; case 'f': #ifdef HAVE_LIBPCAP - if (cf.cfilter) - g_free(cf.cfilter); - cf.cfilter = g_strdup(optarg); + if (cfile.cfilter) + g_free(cfile.cfilter); + cfile.cfilter = g_strdup(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -1334,7 +1335,7 @@ main(int argc, char *argv[]) break; case 'i': /* Use interface xxx */ #ifdef HAVE_LIBPCAP - cf.iface = g_strdup(optarg); + cfile.iface = g_strdup(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -1377,7 +1378,7 @@ main(int argc, char *argv[]) break; case 's': /* Set the snapshot (capture) length */ #ifdef HAVE_LIBPCAP - cf.snap = atoi(optarg); + cfile.snap = atoi(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -1423,7 +1424,7 @@ main(int argc, char *argv[]) break; case 'W': /* Write to capture file FD xxx */ #ifdef HAVE_LIBPCAP - cf.save_file_fd = atoi(optarg); + cfile.save_file_fd = atoi(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -1463,7 +1464,7 @@ main(int argc, char *argv[]) if (start_capture) { /* We're supposed to do a live capture; did the user specify an interface to use? */ - if (cf.iface == NULL) { + if (cfile.iface == NULL) { /* No - pick the first one from the list of interfaces. */ if_list = get_interface_list(&err, err_str); if (if_list == NULL) { @@ -1480,12 +1481,12 @@ main(int argc, char *argv[]) } exit(2); } - cf.iface = g_strdup(if_list->data); /* first interface */ + cfile.iface = g_strdup(if_list->data); /* first interface */ free_interface_list(if_list); } } if (capture_child) { - if (cf.save_file_fd == -1) { + if (cfile.save_file_fd == -1) { /* XXX - send this to the standard output as something our parent should put in an error message box? */ fprintf(stderr, "%s: \"-W\" flag not specified\n", CHILD_NAME); @@ -1495,22 +1496,22 @@ main(int argc, char *argv[]) #endif /* Build the column format array */ - for (i = 0; i < cf.cinfo.num_cols; i++) { - cf.cinfo.col_fmt[i] = get_column_format(i); - cf.cinfo.col_title[i] = g_strdup(get_column_title(i)); - cf.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) * + for (i = 0; i < cfile.cinfo.num_cols; i++) { + cfile.cinfo.col_fmt[i] = get_column_format(i); + cfile.cinfo.col_title[i] = g_strdup(get_column_title(i)); + cfile.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) * NUM_COL_FMTS); - get_column_format_matches(cf.cinfo.fmt_matx[i], cf.cinfo.col_fmt[i]); - if (cf.cinfo.col_fmt[i] == COL_INFO) - cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN); + get_column_format_matches(cfile.cinfo.fmt_matx[i], cfile.cinfo.col_fmt[i]); + if (cfile.cinfo.col_fmt[i] == COL_INFO) + cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN); else - cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); } - if (cf.snap < 1) - cf.snap = WTAP_MAX_PACKET_SIZE; - else if (cf.snap < MIN_PACKET_SIZE) - cf.snap = MIN_PACKET_SIZE; + if (cfile.snap < 1) + cfile.snap = WTAP_MAX_PACKET_SIZE; + else if (cfile.snap < MIN_PACKET_SIZE) + cfile.snap = MIN_PACKET_SIZE; rc_file = (gchar *) g_malloc(strlen(get_home_dir()) + strlen(RC_FILE) + 4); sprintf(rc_file, "%s/%s", get_home_dir(), RC_FILE); @@ -1546,7 +1547,7 @@ main(int argc, char *argv[]) gtk_widget_show(top_level); set_menus_for_capture_file(FALSE); - cf.colors = colfilter_new(); + cfile.colors = colfilter_new(); /* If we were given the name of a capture file, read it in now; we defer it until now, so that, if we can't open it, and pop @@ -1562,12 +1563,12 @@ main(int argc, char *argv[]) } } if (!rfilter_parse_failed) { - if ((err = open_cap_file(cf_name, FALSE, &cf)) == 0) { + if ((err = open_cap_file(cf_name, FALSE, &cfile)) == 0) { /* "open_cap_file()" succeeded, so it closed the previous capture file, and thus destroyed any previous read filter attached to "cf". */ - cf.rfcode = rfcode; - err = read_cap_file(&cf); + cfile.rfcode = rfcode; + err = read_cap_file(&cfile); /* Save the name of the containing directory specified in the path name, if any; we can write over cf_name, which is a good thing, given that "get_dirname()" does write over its @@ -1577,7 +1578,7 @@ main(int argc, char *argv[]) last_open_dir = s; } else { dfilter_destroy(rfcode); - cf.rfcode = NULL; + cfile.rfcode = NULL; } } } @@ -1706,7 +1707,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs) gtk_widget_show(pkt_scrollw); gtk_paned_add1(GTK_PANED(u_pane), pkt_scrollw); - packet_list = gtk_clist_new_with_titles(cf.cinfo.num_cols, cf.cinfo.col_title); + packet_list = gtk_clist_new_with_titles(cfile.cinfo.num_cols, cfile.cinfo.col_title); gtk_container_add(GTK_CONTAINER(pkt_scrollw), packet_list); set_plist_sel_browse(prefs->gui_plist_sel_browse); @@ -1721,18 +1722,18 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs) GTK_SIGNAL_FUNC(packet_list_select_cb), NULL); gtk_signal_connect(GTK_OBJECT(packet_list), "unselect_row", GTK_SIGNAL_FUNC(packet_list_unselect_cb), NULL); - for (i = 0; i < cf.cinfo.num_cols; i++) { - if (get_column_resize_type(cf.cinfo.col_fmt[i]) != RESIZE_MANUAL) + for (i = 0; i < cfile.cinfo.num_cols; i++) { + if (get_column_resize_type(cfile.cinfo.col_fmt[i]) != RESIZE_MANUAL) gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE); /* Right-justify the packet number column. */ - if (cf.cinfo.col_fmt[i] == COL_NUMBER) + if (cfile.cinfo.col_fmt[i] == COL_NUMBER) gtk_clist_set_column_justification(GTK_CLIST(packet_list), i, GTK_JUSTIFY_RIGHT); /* Save static column sizes to use during a "-S" capture, so that the columns don't resize during a live capture. */ - cf.cinfo.col_width[i] = gdk_string_width(pl_style->font, + cfile.cinfo.col_width[i] = gdk_string_width(pl_style->font, get_column_longest_string(get_column_format(i))); } gtk_widget_set_usize(packet_list, -1, pl_size); diff --git a/gtk/packet_win.c b/gtk/packet_win.c index ae100ae37d..423ea58d3d 100644 --- a/gtk/packet_win.c +++ b/gtk/packet_win.c @@ -3,7 +3,7 @@ * * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet_win.c,v 1.8 2000/05/19 23:06:32 gram Exp $ + * $Id: packet_win.c,v 1.9 2000/06/27 04:36:03 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -109,9 +109,9 @@ void new_window_cb(GtkWidget *w){ /* data from the packet_list GtkCList */ /* Find what row this packet is in. */ row = gtk_clist_find_row_from_data(GTK_CLIST(packet_list), - cf.current_frame); + cfile.current_frame); g_assert(row != -1); - for( i = 0; i < cf.cinfo.num_cols; ++i){ + for( i = 0; i < cfile.cinfo.num_cols; ++i){ if ( gtk_clist_get_text(GTK_CLIST( packet_list), row, i, &TextPtr)){ @@ -166,14 +166,14 @@ create_new_window ( char *Title, gint tv_size, gint bv_size){ /* Allocate data structure to represent this window. */ DataPtr = (struct PacketWinData *) g_malloc(sizeof(struct PacketWinData)); - DataPtr->cap_len = cf.current_frame->cap_len; - DataPtr->encoding = cf.current_frame->flags.encoding; - memcpy(&DataPtr->pseudo_header, &cf.pseudo_header, sizeof DataPtr->pseudo_header); + DataPtr->cap_len = cfile.current_frame->cap_len; + DataPtr->encoding = cfile.current_frame->flags.encoding; + memcpy(&DataPtr->pseudo_header, &cfile.pseudo_header, sizeof DataPtr->pseudo_header); DataPtr->pd = g_malloc(DataPtr->cap_len); - memcpy(DataPtr->pd, cf.pd, DataPtr->cap_len); + memcpy(DataPtr->pd, cfile.pd, DataPtr->cap_len); DataPtr->protocol_tree = proto_tree_create_root(); proto_tree_is_visible = TRUE; - dissect_packet(&DataPtr->pseudo_header, DataPtr->pd, cf.current_frame, + dissect_packet(&DataPtr->pseudo_header, DataPtr->pd, cfile.current_frame, DataPtr->protocol_tree); proto_tree_is_visible = FALSE; DataPtr->main = main_w; diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c index 4b1645cece..4bd191bb83 100644 --- a/gtk/print_dlg.c +++ b/gtk/print_dlg.c @@ -1,7 +1,7 @@ /* print_dlg.c * Dialog boxes for printing * - * $Id: print_dlg.c,v 1.17 2000/05/08 07:13:40 guy Exp $ + * $Id: print_dlg.c,v 1.18 2000/06/27 04:36:03 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -508,7 +508,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w) gtk_widget_destroy(GTK_WIDGET(parent_w)); /* Now print the packets */ - if (!print_packets(&cf, &print_args)) { + if (!print_packets(&cfile, &print_args)) { if (print_args.to_file) simple_dialog(ESD_TYPE_WARN, NULL, file_write_error_message(errno), print_args.dest); @@ -590,8 +590,8 @@ file_print_packet_cmd_cb(GtkWidget *widget, gpointer data) { print_args.print_summary = FALSE; print_args.print_hex = FALSE; print_args.expand_all = TRUE; - proto_tree_print(TRUE, &print_args, (GNode*) cf.protocol_tree, cf.pd, - cf.current_frame, fh); + proto_tree_print(TRUE, &print_args, (GNode*) cfile.protocol_tree, cfile.pd, + cfile.current_frame, fh); print_finale(fh, prefs.pr_format); close_print_dest(print_args.to_file, fh); } @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.94 2000/05/31 05:07:57 guy Exp $ + * $Id: packet.c,v 1.95 2000/06/27 04:35:45 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -96,7 +96,7 @@ #include "plugins.h" -extern capture_file cf; +extern capture_file cfile; static int proto_frame = -1; static int hf_frame_arrival_time = -1; @@ -1,7 +1,7 @@ /* summary.c * Routines for capture file summary info * - * $Id: summary.c,v 1.17 2000/04/13 20:39:18 gram Exp $ + * $Id: summary.c,v 1.18 2000/06/27 04:35:46 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -71,31 +71,31 @@ summary_fill_in(summary_tally *st) st->filtered_count = 0; /* initialize the tally */ - if (cf.plist != NULL) { - first_frame = cf.plist; + if (cfile.plist != NULL) { + first_frame = cfile.plist; st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs); st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs); - cur_glist = cf.plist; + cur_glist = cfile.plist; - for (i = 0; i < cf.count; i++) { + for (i = 0; i < cfile.count; i++) { cur_frame = cur_glist; tally_frame_data(cur_frame, st); cur_glist = cur_glist->next; } } - st->filename = cf.filename; - st->file_length = cf.f_len; - st->encap_type = cf.cd_t; - st->snap = cf.snap; - st->elapsed_time = secs_usecs(cf.esec, cf.eusec); - st->packet_count = cf.count; - st->drops = cf.drops; - st->iface = cf.iface; - st->dfilter = cf.dfilter; + st->filename = cfile.filename; + st->file_length = cfile.f_len; + st->encap_type = cfile.cd_t; + st->snap = cfile.snap; + st->elapsed_time = secs_usecs(cfile.esec, cfile.eusec); + st->packet_count = cfile.count; + st->drops = cfile.drops; + st->iface = cfile.iface; + st->dfilter = cfile.dfilter; #ifdef HAVE_LIBPCAP - st->cfilter = cf.cfilter; + st->cfilter = cfile.cfilter; #else st->cfilter = NULL; #endif diff --git a/tethereal.c b/tethereal.c index fdd473b3e4..7d859e351f 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.30 2000/06/15 07:49:25 guy Exp $ + * $Id: tethereal.c,v 1.31 2000/06/27 04:35:46 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -117,7 +117,7 @@ static void wtap_dispatch_cb_print(u_char *, const struct wtap_pkthdr *, int, static gchar *col_info(frame_data *, gint); packet_info pi; -capture_file cf; +capture_file cfile; FILE *data_out_file = NULL; guint main_ctx, file_ctx; ts_type timestamp_type = RELATIVE; @@ -194,29 +194,29 @@ main(int argc, char *argv[]) } /* Initialize the capture file struct */ - cf.plist = NULL; - cf.plist_end = NULL; - cf.wth = NULL; - cf.filename = NULL; - cf.user_saved = FALSE; - cf.is_tempfile = FALSE; - cf.rfcode = NULL; - cf.dfilter = NULL; - cf.dfcode = NULL; + cfile.plist = NULL; + cfile.plist_end = NULL; + cfile.wth = NULL; + cfile.filename = NULL; + cfile.user_saved = FALSE; + cfile.is_tempfile = FALSE; + cfile.rfcode = NULL; + cfile.dfilter = NULL; + cfile.dfcode = NULL; #ifdef HAVE_LIBPCAP - cf.cfilter = g_strdup(""); + cfile.cfilter = g_strdup(""); #endif - cf.iface = NULL; - cf.save_file = NULL; - cf.save_file_fd = -1; - cf.snap = WTAP_MAX_PACKET_SIZE; - cf.count = 0; - cf.cinfo.num_cols = prefs->num_cols; - cf.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols); - cf.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cf.cinfo.num_cols); - cf.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols); - cf.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols); - cf.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols); + cfile.iface = NULL; + cfile.save_file = NULL; + cfile.save_file_fd = -1; + cfile.snap = WTAP_MAX_PACKET_SIZE; + cfile.count = 0; + cfile.cinfo.num_cols = prefs->num_cols; + cfile.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols); + cfile.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cfile.cinfo.num_cols); + cfile.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols); + cfile.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols); + cfile.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols); /* Assemble the compile-time options */ snprintf(comp_info_str, 256, @@ -278,7 +278,7 @@ main(int argc, char *argv[]) case 'f': #ifdef HAVE_LIBPCAP capture_filter_specified = TRUE; - cf.cfilter = g_strdup(optarg); + cfile.cfilter = g_strdup(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -298,7 +298,7 @@ main(int argc, char *argv[]) break; case 'i': /* Use interface xxx */ #ifdef HAVE_LIBPCAP - cf.iface = g_strdup(optarg); + cfile.iface = g_strdup(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -315,7 +315,7 @@ main(int argc, char *argv[]) break; case 's': /* Set the snapshot (capture) length */ #ifdef HAVE_LIBPCAP - cf.snap = atoi(optarg); + cfile.snap = atoi(optarg); #else capture_option_specified = TRUE; arg_error = TRUE; @@ -341,7 +341,7 @@ main(int argc, char *argv[]) exit(0); break; case 'w': /* Write to capture file xxx */ - cf.save_file = g_strdup(optarg); + cfile.save_file = g_strdup(optarg); break; case 'V': /* Verbose */ verbose = TRUE; @@ -371,7 +371,7 @@ main(int argc, char *argv[]) "tethereal: Capture filters were specified both with \"-f\" and with additional command-line arguments\n"); exit(2); } - cf.cfilter = get_args_as_string(argc, argv, optind); + cfile.cfilter = get_args_as_string(argc, argv, optind); #else capture_option_specified = TRUE; #endif @@ -386,22 +386,22 @@ main(int argc, char *argv[]) print_usage(); /* Build the column format array */ - for (i = 0; i < cf.cinfo.num_cols; i++) { - cf.cinfo.col_fmt[i] = get_column_format(i); - cf.cinfo.col_title[i] = g_strdup(get_column_title(i)); - cf.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) * + for (i = 0; i < cfile.cinfo.num_cols; i++) { + cfile.cinfo.col_fmt[i] = get_column_format(i); + cfile.cinfo.col_title[i] = g_strdup(get_column_title(i)); + cfile.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) * NUM_COL_FMTS); - get_column_format_matches(cf.cinfo.fmt_matx[i], cf.cinfo.col_fmt[i]); - if (cf.cinfo.col_fmt[i] == COL_INFO) - cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN); + get_column_format_matches(cfile.cinfo.fmt_matx[i], cfile.cinfo.col_fmt[i]); + if (cfile.cinfo.col_fmt[i] == COL_INFO) + cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN); else - cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); } - if (cf.snap < 1) - cf.snap = WTAP_MAX_PACKET_SIZE; - else if (cf.snap < MIN_PACKET_SIZE) - cf.snap = MIN_PACKET_SIZE; + if (cfile.snap < 1) + cfile.snap = WTAP_MAX_PACKET_SIZE; + else if (cfile.snap < MIN_PACKET_SIZE) + cfile.snap = MIN_PACKET_SIZE; dissect_init(); /* Init anything that needs initializing */ @@ -412,14 +412,14 @@ main(int argc, char *argv[]) exit(2); } } - cf.rfcode = rfcode; + cfile.rfcode = rfcode; if (cf_name) { - err = open_cap_file(cf_name, FALSE, &cf); + err = open_cap_file(cf_name, FALSE, &cfile); if (err != 0) { dissect_cleanup(); exit(2); } - err = load_cap_file(&cf, out_file_type); + err = load_cap_file(&cfile, out_file_type); if (err != 0) { dissect_cleanup(); exit(2); @@ -430,7 +430,7 @@ main(int argc, char *argv[]) do we have support for live captures? */ #ifdef HAVE_LIBPCAP /* Yes; did the user specify an interface to use? */ - if (cf.iface == NULL) { + if (cfile.iface == NULL) { /* No - pick the first one from the list of interfaces. */ if_list = get_interface_list(&err, err_str); if (if_list == NULL) { @@ -447,7 +447,7 @@ main(int argc, char *argv[]) } exit(2); } - cf.iface = g_strdup(if_list->data); /* first interface */ + cfile.iface = g_strdup(if_list->data); /* first interface */ free_interface_list(if_list); } capture(packet_count, out_file_type); @@ -485,7 +485,7 @@ capture(int packet_count, int out_file_type) ld.pdh = NULL; /* Open the network interface to capture from it. */ - ld.pch = pcap_open_live(cf.iface, cf.snap, 1, 1000, err_str); + ld.pch = pcap_open_live(cfile.iface, cfile.snap, 1, 1000, err_str); if (ld.pch == NULL) { /* Well, we couldn't start the capture. @@ -500,19 +500,19 @@ capture(int packet_count, int out_file_type) goto error; } - if (cf.cfilter) { + if (cfile.cfilter) { /* A capture filter was specified; set it up. */ - if (pcap_lookupnet (cf.iface, &netnum, &netmask, err_str) < 0) { + if (pcap_lookupnet (cfile.iface, &netnum, &netmask, err_str) < 0) { snprintf(errmsg, sizeof errmsg, "Can't use filter: Couldn't obtain netmask info (%s).", err_str); goto error; } - if (pcap_compile(ld.pch, &cf.fcode, cf.cfilter, 1, netmask) < 0) { + if (pcap_compile(ld.pch, &cfile.fcode, cfile.cfilter, 1, netmask) < 0) { snprintf(errmsg, sizeof errmsg, "Unable to parse filter string (%s).", pcap_geterr(ld.pch)); goto error; } - if (pcap_setfilter(ld.pch, &cf.fcode) < 0) { + if (pcap_setfilter(ld.pch, &cfile.fcode) < 0) { snprintf(errmsg, sizeof errmsg, "Can't install filter (%s).", pcap_geterr(ld.pch)); goto error; @@ -520,14 +520,14 @@ capture(int packet_count, int out_file_type) } ld.linktype = wtap_pcap_encap_to_wtap_encap(pcap_datalink(ld.pch)); - if (cf.save_file != NULL) { + if (cfile.save_file != NULL) { /* Set up to write to the capture file. */ if (ld.linktype == WTAP_ENCAP_UNKNOWN) { strcpy(errmsg, "The network you're capturing from is of a type" " that Tethereal doesn't support."); goto error; } - ld.pdh = wtap_dump_open(cf.save_file, out_file_type, + ld.pdh = wtap_dump_open(cfile.save_file, out_file_type, ld.linktype, pcap_snapshot(ld.pch), &err); if (ld.pdh == NULL) { @@ -557,11 +557,11 @@ capture(int packet_count, int out_file_type) if (err < 0) { sprintf(errmsg, "The file to which the capture would be" " written (\"%s\") could not be opened: Error %d.", - cf.save_file, err); + cfile.save_file, err); } else { sprintf(errmsg, "The file to which the capture would be" " written (\"%s\") could not be opened: %s.", - cf.save_file, strerror(err)); + cfile.save_file, strerror(err)); } break; } @@ -581,7 +581,7 @@ capture(int packet_count, int out_file_type) #endif /* Let the user know what interface was chosen. */ - printf("Capturing on %s\n", cf.iface); + printf("Capturing on %s\n", cfile.iface); inpkts = pcap_loop(ld.pch, packet_count, capture_pcap_cb, (u_char *) &ld); pcap_close(ld.pch); @@ -589,8 +589,8 @@ capture(int packet_count, int out_file_type) return TRUE; error: - g_free(cf.save_file); - cf.save_file = NULL; + g_free(cfile.save_file); + cfile.save_file = NULL; fprintf(stderr, "tethereal: %s\n", errmsg); if (ld.pch != NULL) pcap_close(ld.pch); @@ -612,12 +612,12 @@ capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr, whdr.len = phdr->len; whdr.pkt_encap = ld->linktype; - args.cf = &cf; + args.cf = &cfile; args.pdh = ld->pdh; if (ld->pdh) { wtap_dispatch_cb_write((u_char *)&args, &whdr, 0, NULL, pd); - cf.count++; - printf("\r%u ", cf.count); + cfile.count++; + printf("\r%u ", cfile.count); fflush(stdout); } else { wtap_dispatch_cb_print((u_char *)&args, &whdr, 0, NULL, pd); |