aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture.c8
-rw-r--r--capture_sync.c52
-rw-r--r--file.c222
-rw-r--r--file.h398
-rw-r--r--gtk/bootp_stat.c2
-rw-r--r--gtk/color_dlg.c6
-rw-r--r--gtk/conversations_table.c4
-rw-r--r--gtk/dcerpc_stat.c2
-rw-r--r--gtk/decode_as_dlg.c6
-rw-r--r--gtk/fc_stat.c2
-rw-r--r--gtk/file_dlg.c22
-rw-r--r--gtk/find_dlg.c22
-rw-r--r--gtk/goto_dlg.c8
-rw-r--r--gtk/graph_analysis.c2
-rw-r--r--gtk/h225_counter.c2
-rw-r--r--gtk/h225_ras_srt.c2
-rw-r--r--gtk/h323_analysis.c4
-rw-r--r--gtk/h323_conversations_dlg.c2
-rw-r--r--gtk/hostlist_table.c4
-rw-r--r--gtk/http_stat.c2
-rw-r--r--gtk/io_stat.c6
-rw-r--r--gtk/ldap_stat.c2
-rw-r--r--gtk/main.c38
-rw-r--r--gtk/main.h2
-rw-r--r--gtk/menu.c10
-rw-r--r--gtk/mgcp_stat.c2
-rw-r--r--gtk/packet_history.c4
-rw-r--r--gtk/packet_list.c10
-rw-r--r--gtk/prefs_dlg.c8
-rw-r--r--gtk/print_dlg.c14
-rw-r--r--gtk/proto_dlg.c8
-rw-r--r--gtk/proto_draw.c4
-rw-r--r--gtk/rpc_progs.c2
-rw-r--r--gtk/rpc_stat.c2
-rw-r--r--gtk/rtp_analysis.c8
-rw-r--r--gtk/rtp_stream.c8
-rw-r--r--gtk/rtp_stream_dlg.c2
-rw-r--r--gtk/sctp_error_dlg.c2
-rw-r--r--gtk/sctp_stat_dlg.c2
-rw-r--r--gtk/sip_stat.c2
-rw-r--r--gtk/smb_stat.c2
-rw-r--r--gtk/tcp_graph.c4
-rw-r--r--gtk/voip_calls_dlg.c2
-rw-r--r--gtk/wsp_stat.c2
-rw-r--r--tethereal.c16
45 files changed, 610 insertions, 324 deletions
diff --git a/capture.c b/capture.c
index 3355167038..39377a09ed 100644
--- a/capture.c
+++ b/capture.c
@@ -198,7 +198,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
return FALSE;
}
/* Capture succeeded; attempt to read in the capture file. */
- if ((err = cf_open(capture_opts->save_file, is_tempfile, capture_opts->cf)) != 0) {
+ if (cf_open(capture_opts->cf, capture_opts->save_file, is_tempfile, &err) != CF_OK) {
/* We're not doing a capture any more, so we don't have a save
file. */
if (capture_opts->multi_files_on) {
@@ -246,14 +246,14 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
}
switch (cf_read(capture_opts->cf)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
main_window_nested_quit();
diff --git a/capture_sync.c b/capture_sync.c
index 8dcf754ba7..d74e076bec 100644
--- a/capture_sync.c
+++ b/capture_sync.c
@@ -485,26 +485,32 @@ sync_pipe_do_capture(capture_options *capture_opts, gboolean is_tempfile) {
/* The child process started a capture.
Attempt to open the capture file and set up to read it. */
- err = cf_start_tail(capture_opts->save_file, is_tempfile, capture_opts->cf);
- if (err != 0) {
- /* We weren't able to open the capture file; user has been
- alerted. Close the sync pipe. */
+ switch(cf_start_tail(capture_opts->cf, capture_opts->save_file, is_tempfile, &err)) {
+ case CF_OK:
+ /* We were able to open and set up to read the capture file;
+ arrange that our callback be called whenever it's possible
+ to read from the sync pipe, so that it's called when
+ the child process wants to tell us something. */
+ pipe_input_set_handler(sync_pipe[PIPE_READ], (gpointer) capture_opts, &capture_opts->fork_child, sync_pipe_input_cb);
+
+ return TRUE;
+ break;
+ case CF_ERROR:
+ /* We weren't able to open the capture file; user has been
+ alerted. Close the sync pipe. */
- close(sync_pipe[PIPE_READ]);
+ close(sync_pipe[PIPE_READ]);
- /* Don't unlink the save file - leave it around, for debugging
- purposes. */
- g_free(capture_opts->save_file);
- capture_opts->save_file = NULL;
- return FALSE;
+ /* Don't unlink the save file - leave it around, for debugging
+ purposes. */
+ g_free(capture_opts->save_file);
+ capture_opts->save_file = NULL;
+ return FALSE;
+ break;
+ default:
+ g_assert_not_reached();
+ return FALSE;
}
- /* We were able to open and set up to read the capture file;
- arrange that our callback be called whenever it's possible
- to read from the sync pipe, so that it's called when
- the child process wants to tell us something. */
- pipe_input_set_handler(sync_pipe[PIPE_READ], (gpointer) capture_opts, &capture_opts->fork_child, sync_pipe_input_cb);
-
- return TRUE;
}
@@ -533,7 +539,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
XXX - do something if this fails? */
switch (cf_finish_tail(capture_opts->cf, &err)) {
- case READ_SUCCESS:
+ case CF_OK:
if(cf_packet_count(capture_opts->cf) == 0) {
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
"%sNo packets captured!%s\n\n"
@@ -543,13 +549,13 @@ sync_pipe_input_cb(gint source, gpointer user_data)
cf_close(capture_opts->cf);
}
break;
- case READ_ERROR:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
main_window_quit();
@@ -624,8 +630,8 @@ sync_pipe_input_cb(gint source, gpointer user_data)
XXX - do something if this fails? */
switch (cf_continue_tail(capture_opts->cf, to_read, &err)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file.
@@ -633,7 +639,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
XXX - abort on a read error? */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Kill the child capture process; the user wants to exit, and we
shouldn't just leave it running. */
kill_capture_child(capture_opts);
diff --git a/file.c b/file.c
index 7de1d489e6..fba0cdbf89 100644
--- a/file.c
+++ b/file.c
@@ -84,7 +84,6 @@
#include <epan/prefs.h>
#include <epan/dfilter/dfilter.h>
#include <epan/conversation.h>
-#include "globals.h"
#include <epan/epan_dissect.h>
#include <epan/tap.h>
#include "tap_dfilter_dlg.h"
@@ -143,23 +142,22 @@ static gboolean copy_binary_file(char *from_filename, char *to_filename);
#define FRAME_DATA_CHUNK_SIZE 1024
-int
-cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
+cf_status_t
+cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err)
{
wtap *wth;
- int err;
gchar *err_info;
int fd;
struct stat cf_stat;
- wth = wtap_open_offline(fname, &err, &err_info, TRUE);
+ wth = wtap_open_offline(fname, err, &err_info, TRUE);
if (wth == NULL)
goto fail;
/* Find the size of the file. */
fd = wtap_fd(wth);
if (fstat(fd, &cf_stat) < 0) {
- err = errno;
+ *err = errno;
wtap_close(wth);
goto fail;
}
@@ -213,11 +211,11 @@ cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
G_ALLOC_AND_FREE);
g_assert(cf->plist_chunk);
- return (0);
+ return CF_OK;
fail:
- cf_open_failure_alert_box(fname, err, err_info, FALSE, 0);
- return (err);
+ cf_open_failure_alert_box(fname, *err, err_info, FALSE, 0);
+ return CF_ERROR;
}
/* Reset everything to a pristine state */
@@ -256,7 +254,7 @@ cf_close(capture_file *cf)
}
cf->plist = NULL;
cf->plist_end = NULL;
- unselect_packet(cf); /* nothing to select */
+ cf_unselect_packet(cf); /* nothing to select */
cf->first_displayed = NULL;
cf->last_displayed = NULL;
@@ -342,7 +340,7 @@ set_display_filename(capture_file *cf)
g_free(win_name);
}
-read_status_t
+cf_status_t
cf_read(capture_file *cf)
{
int err;
@@ -432,13 +430,13 @@ cf_read(capture_file *cf)
if (stop_flag) {
/* Well, the user decided to abort the read. Destroy the progress
- bar, close the capture file, and return READ_ABORTED so our caller
+ bar, close the capture file, and return CF_ABORTED so our caller
can do whatever is appropriate when that happens. */
destroy_progress_dlg(progbar);
cf->state = FILE_READ_ABORTED; /* so that we're allowed to close it */
packet_list_thaw(); /* undo our freeze */
cf_close(cf);
- return (READ_ABORTED);
+ return CF_ABORTED;
}
read_packet(cf, data_offset);
}
@@ -525,20 +523,20 @@ cf_read(capture_file *cf)
}
snprintf(err_str, sizeof err_str, errmsg);
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_str);
- return (READ_ERROR);
+ return CF_ERROR;
} else
- return (READ_SUCCESS);
+ return CF_OK;
}
#ifdef HAVE_LIBPCAP
-int
-cf_start_tail(char *fname, gboolean is_tempfile, capture_file *cf)
+
+cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err)
{
- int err;
gchar *capture_msg;
+ cf_status_t cf_status;
- err = cf_open(fname, is_tempfile, cf);
- if (err == 0) {
+ cf_status = cf_open(cf, fname, is_tempfile, err);
+ if (cf_status == CF_OK) {
/* Disable menu items that make no sense if you're currently running
a capture. */
set_menus_for_capture_in_progress(TRUE);
@@ -552,11 +550,12 @@ cf_start_tail(char *fname, gboolean is_tempfile, capture_file *cf)
statusbar_push_file_msg(capture_msg);
g_free(capture_msg);
+
}
- return err;
+ return cf_status;
}
-read_status_t
+cf_status_t
cf_continue_tail(capture_file *cf, int to_read, int *err)
{
long data_offset = 0;
@@ -585,21 +584,21 @@ cf_continue_tail(capture_file *cf, int to_read, int *err)
packet_list_moveto_end();
if (cf->state == FILE_READ_ABORTED) {
- /* Well, the user decided to exit Ethereal. Return READ_ABORTED
+ /* Well, the user decided to exit Ethereal. Return CF_ABORTED
so that our caller can kill off the capture child process;
this will cause an EOF on the pipe from the child, so
"cf_finish_tail()" will be called, and it will clean up
and exit. */
- return READ_ABORTED;
+ return CF_ABORTED;
} else if (*err != 0) {
/* We got an error reading the capture file.
XXX - pop up a dialog box? */
- return (READ_ERROR);
+ return CF_ERROR;
} else
- return (READ_SUCCESS);
+ return CF_OK;
}
-read_status_t
+cf_status_t
cf_finish_tail(capture_file *cf, int *err)
{
gchar *err_info;
@@ -623,10 +622,10 @@ cf_finish_tail(capture_file *cf, int *err)
/* Well, the user decided to abort the read. We're only called
when the child capture process closes the pipe to us (meaning
it's probably exited), so we can just close the capture
- file; we return READ_ABORTED so our caller can do whatever
+ file; we return CF_ABORTED so our caller can do whatever
is appropriate when that happens. */
cf_close(cf);
- return READ_ABORTED;
+ return CF_ABORTED;
}
packet_list_thaw();
@@ -676,9 +675,9 @@ cf_finish_tail(capture_file *cf, int *err)
if (*err != 0) {
/* We got an error reading the capture file.
XXX - pop up a dialog box? */
- return (READ_ERROR);
+ return CF_ERROR;
} else {
- return (READ_SUCCESS);
+ return CF_OK;
}
}
#endif /* HAVE_LIBPCAP */
@@ -903,14 +902,14 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
XXX - we must do this before we add the row to the display,
as, if the display's GtkCList's selection mode is
GTK_SELECTION_BROWSE, when the first entry is added to it,
- "select_packet()" will be called, and it will fetch the row
+ "cf_select_packet()" will be called, and it will fetch the row
data for the 0th row, and will get a null pointer rather than
"fdata", as "gtk_clist_append()" won't yet have returned and
thus "gtk_clist_set_row_data()" won't yet have been called.
We thus need to leave behind bread crumbs so that
- "select_packet()" can find this frame. See the comment
- in "select_packet()". */
+ "cf_select_packet()" can find this frame. See the comment
+ in "cf_select_packet()". */
if (cf->first_displayed == NULL)
cf->first_displayed = fdata;
@@ -1198,8 +1197,8 @@ cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
return (!got_read_error && !got_write_error);
}
-gboolean
-filter_packets(capture_file *cf, gchar *dftext, gboolean force)
+cf_status_t
+cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force)
{
dfilter_t *dfcode;
char *filter_new = dftext ? dftext : "";
@@ -1207,7 +1206,7 @@ filter_packets(capture_file *cf, gchar *dftext, gboolean force)
/* if new filter equals old one, do nothing unless told to do so */
if (!force && strcmp(filter_new, filter_old) == 0) {
- return TRUE;
+ return CF_OK;
}
if (dftext == NULL) {
@@ -1234,7 +1233,7 @@ filter_packets(capture_file *cf, gchar *dftext, gboolean force)
g_free(safe_dfilter_error_msg);
g_free(safe_dftext);
g_free(dftext);
- return FALSE;
+ return CF_ERROR;
}
/* Was it empty? */
@@ -1260,23 +1259,23 @@ filter_packets(capture_file *cf, gchar *dftext, gboolean force)
} else {
rescan_packets(cf, "Filtering", dftext, TRUE, FALSE);
}
- return TRUE;
+ return CF_OK;
}
void
-colorize_packets(capture_file *cf)
+cf_colorize_packets(capture_file *cf)
{
rescan_packets(cf, "Colorizing", "all packets", FALSE, FALSE);
}
void
-reftime_packets(capture_file *cf)
+cf_reftime_packets(capture_file *cf)
{
rescan_packets(cf, "Updating Reftime", "all packets", FALSE, FALSE);
}
void
-redissect_packets(capture_file *cf)
+cf_redissect_packets(capture_file *cf)
{
rescan_packets(cf, "Reprocessing", "all packets", TRUE, TRUE);
}
@@ -1545,7 +1544,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
if (selected_row == -1) {
/* There are no frames displayed at all. */
- unselect_packet(cf);
+ cf_unselect_packet(cf);
} else {
/* Either the frame that was selected passed the filter, or we've
found the nearest displayed frame to that frame. Select it, make
@@ -1692,8 +1691,8 @@ retap_packet(capture_file *cf _U_, frame_data *fdata,
return TRUE;
}
-int
-retap_packets(capture_file *cf)
+cf_status_t
+cf_retap_packets(capture_file *cf)
{
packet_range_t range;
@@ -1714,14 +1713,14 @@ retap_packets(capture_file *cf)
case PSP_STOPPED:
/* Well, the user decided to abort the refiltering.
Return FALSE so our caller knows they did that. */
- return FALSE;
+ return CF_ERROR;
case PSP_FAILED:
/* Error while retapping. */
- return FALSE;
+ return CF_ERROR;
}
- return TRUE;
+ return CF_OK;
}
typedef struct {
@@ -1882,8 +1881,8 @@ fail:
return FALSE;
}
-pp_return_t
-print_packets(capture_file *cf, print_args_t *print_args)
+cf_status_t
+cf_print_packets(capture_file *cf, print_args_t *print_args)
{
int i;
print_callback_args_t callback_args;
@@ -1906,7 +1905,7 @@ print_packets(capture_file *cf, print_args_t *print_args)
if (!print_preamble(print_args->stream, cf->filename)) {
destroy_print_stream(print_args->stream);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
if (print_args->print_summary) {
@@ -2000,18 +1999,18 @@ print_packets(capture_file *cf, print_args_t *print_args)
have to write to a file and then hand that to the print
program to make it actually not print anything. */
destroy_print_stream(print_args->stream);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
if (!print_finale(print_args->stream)) {
destroy_print_stream(print_args->stream);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
if (!destroy_print_stream(print_args->stream))
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
- return PP_OK;
+ return CF_OK;
}
static gboolean
@@ -2034,20 +2033,20 @@ write_pdml_packet(capture_file *cf _U_, frame_data *fdata,
return !ferror(fh);
}
-pp_return_t
-write_pdml_packets(capture_file *cf, print_args_t *print_args)
+cf_status_t
+cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
{
FILE *fh;
psp_return_t ret;
fh = fopen(print_args->file, "w");
if (fh == NULL)
- return PP_OPEN_ERROR; /* attempt to open destination failed */
+ return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */
write_pdml_preamble(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* Iterate through the list of packets, printing the packets we were
@@ -2069,19 +2068,19 @@ write_pdml_packets(capture_file *cf, print_args_t *print_args)
case PSP_FAILED:
/* Error while printing. */
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
write_pdml_finale(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* XXX - check for an error */
fclose(fh);
- return PP_OK;
+ return CF_OK;
}
static gboolean
@@ -2104,20 +2103,20 @@ write_psml_packet(capture_file *cf, frame_data *fdata,
return !ferror(fh);
}
-pp_return_t
-write_psml_packets(capture_file *cf, print_args_t *print_args)
+cf_status_t
+cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
{
FILE *fh;
psp_return_t ret;
fh = fopen(print_args->file, "w");
if (fh == NULL)
- return PP_OPEN_ERROR; /* attempt to open destination failed */
+ return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */
write_psml_preamble(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* Iterate through the list of packets, printing the packets we were
@@ -2139,26 +2138,26 @@ write_psml_packets(capture_file *cf, print_args_t *print_args)
case PSP_FAILED:
/* Error while printing. */
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
write_psml_finale(fh);
if (ferror(fh)) {
fclose(fh);
- return PP_WRITE_ERROR;
+ return CF_PRINT_WRITE_ERROR;
}
/* XXX - check for an error */
fclose(fh);
- return PP_OK;
+ return CF_OK;
}
/* Scan through the packet list and change all columns that use the
"command-line-specified" time stamp format to use the current
value of that format. */
void
-change_time_formats(capture_file *cf)
+cf_change_time_formats(capture_file *cf)
{
frame_data *fdata;
progdlg_t *progbar = NULL;
@@ -2324,7 +2323,7 @@ typedef struct {
} match_data;
gboolean
-find_packet_protocol_tree(capture_file *cf, const char *string)
+cf_find_packet_protocol_tree(capture_file *cf, const char *string)
{
match_data mdata;
@@ -2408,7 +2407,7 @@ match_subtree_text(proto_node *node, gpointer data)
}
gboolean
-find_packet_summary_line(capture_file *cf, const char *string)
+cf_find_packet_summary_line(capture_file *cf, const char *string)
{
match_data mdata;
@@ -2469,7 +2468,7 @@ typedef struct {
} cbs_t; /* "Counted byte string" */
gboolean
-find_packet_data(capture_file *cf, const guint8 *string, size_t string_size)
+cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size)
{
cbs_t info;
@@ -2618,7 +2617,7 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion)
}
gboolean
-find_packet_dfilter(capture_file *cf, dfilter_t *sfcode)
+cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode)
{
return find_packet(cf, match_dfilter, sfcode);
}
@@ -2811,7 +2810,7 @@ find_packet(capture_file *cf,
}
gboolean
-goto_frame(capture_file *cf, guint fnumber)
+cf_goto_frame(capture_file *cf, guint fnumber)
{
frame_data *fdata;
int row;
@@ -2844,7 +2843,7 @@ goto_frame(capture_file *cf, guint fnumber)
}
gboolean
-goto_top_frame(capture_file *cf)
+cf_goto_top_frame(capture_file *cf)
{
frame_data *fdata;
int row;
@@ -2872,7 +2871,7 @@ goto_top_frame(capture_file *cf)
}
gboolean
-goto_bottom_frame(capture_file *cf)
+cf_goto_bottom_frame(capture_file *cf)
{
frame_data *fdata;
int row;
@@ -2901,8 +2900,8 @@ goto_bottom_frame(capture_file *cf)
/*
* Go to frame specified by currently selected protocol tree item.
*/
-void
-goto_framenum(capture_file *cf)
+gboolean
+cf_goto_framenum(capture_file *cf)
{
header_field_info *hfinfo;
guint32 framenum;
@@ -2913,14 +2912,16 @@ goto_framenum(capture_file *cf)
if (hfinfo->type == FT_FRAMENUM) {
framenum = fvalue_get_integer(&cf->finfo_selected->value);
if (framenum != 0)
- goto_frame(cf, framenum);
+ return cf_goto_frame(cf, framenum);
}
}
+
+ return FALSE;
}
/* Select the packet on a given row. */
void
-select_packet(capture_file *cf, int row)
+cf_select_packet(capture_file *cf, int row)
{
frame_data *fdata;
int err;
@@ -2936,10 +2937,10 @@ select_packet(capture_file *cf, int row)
our version and the vanilla GTK+ version).
This means that a "select-row" signal is emitted; this causes
- "packet_list_select_cb()" to be called, which causes "select_packet()"
+ "packet_list_select_cb()" to be called, which causes "cf_select_packet()"
to be called.
- "select_packet()" fetches, above, the data associated with the
+ "cf_select_packet()" fetches, above, the data associated with the
row that was selected; however, as "gtk_clist_append()", which
called "real_insert_row()", hasn't yet returned, we haven't yet
associated any data with that row, so we get back a null pointer.
@@ -2993,7 +2994,7 @@ select_packet(capture_file *cf, int row)
/* Unselect the selected packet, if any. */
void
-unselect_packet(capture_file *cf)
+cf_unselect_packet(capture_file *cf)
{
/* Destroy the epan_dissect_t for the unselected packet. */
if (cf->edt != NULL) {
@@ -3009,12 +3010,12 @@ unselect_packet(capture_file *cf)
set_menus_for_selected_packet(cf);
/* No protocol tree means no selected field. */
- unselect_field(cf);
+ cf_unselect_field(cf);
}
/* Unset the selected protocol tree field, if any. */
void
-unselect_field(capture_file *cf)
+cf_unselect_field(capture_file *cf)
{
statusbar_pop_field_msg();
cf->finfo_selected = NULL;
@@ -3025,7 +3026,7 @@ unselect_field(capture_file *cf)
* Mark a particular frame.
*/
void
-mark_frame(capture_file *cf, frame_data *frame)
+cf_mark_frame(capture_file *cf, frame_data *frame)
{
if (! frame->flags.marked) {
frame->flags.marked = TRUE;
@@ -3038,7 +3039,7 @@ mark_frame(capture_file *cf, frame_data *frame)
* Unmark a particular frame.
*/
void
-unmark_frame(capture_file *cf, frame_data *frame)
+cf_unmark_frame(capture_file *cf, frame_data *frame)
{
if (frame->flags.marked) {
frame->flags.marked = FALSE;
@@ -3083,8 +3084,8 @@ save_packet(capture_file *cf _U_, frame_data *fdata,
return TRUE;
}
-gboolean
-cf_save(char *fname, capture_file *cf, packet_range_t *range, guint save_format)
+cf_status_t
+cf_save(capture_file *cf, char *fname, packet_range_t *range, guint save_format)
{
gchar *from_filename;
const gchar *name_ptr;
@@ -3248,19 +3249,19 @@ cf_save(char *fname, capture_file *cf, packet_range_t *range, guint save_format)
time if the file is large. */
cf->user_saved = TRUE;
- if ((err = cf_open(fname, FALSE, cf)) == 0) {
+ if ((cf_open(cf, fname, FALSE, &err)) == CF_OK) {
/* XXX - report errors if this fails?
What should we return if it fails or is aborted? */
switch (cf_read(cf)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just return (without
changing any menu settings; "cf_close()" set them
@@ -3270,12 +3271,12 @@ cf_save(char *fname, capture_file *cf, packet_range_t *range, guint save_format)
set_menus_for_unsaved_capture_file(FALSE);
}
}
- return TRUE;
+ return CF_OK;
fail:
/* Pop the "Saving:" message off the status bar. */
statusbar_pop_file_msg();
- return FALSE;
+ return CF_ERROR;
}
static void
@@ -3507,9 +3508,10 @@ cf_close_failure_alert_box(const char *filename, int err)
/* Reload the current capture file. */
void
-cf_reload() {
+cf_reload(capture_file *cf) {
gchar *filename;
gboolean is_tempfile;
+ int err;
/* If the file could be opened, "cf_open()" calls "cf_close()"
to get rid of state for the old capture file before filling in state
@@ -3519,22 +3521,22 @@ cf_reload() {
a temporary file, mark it as not being a temporary file, and then
reopen it as the type of file it was.
- Also, "cf_close()" will free "cfile.filename", so we must make
+ Also, "cf_close()" will free "cf->filename", so we must make
a copy of it first. */
- filename = g_strdup(cfile.filename);
- is_tempfile = cfile.is_tempfile;
- cfile.is_tempfile = FALSE;
- if (cf_open(filename, is_tempfile, &cfile) == 0) {
- switch (cf_read(&cfile)) {
-
- case READ_SUCCESS:
- case READ_ERROR:
+ filename = g_strdup(cf->filename);
+ is_tempfile = cf->is_tempfile;
+ cf->is_tempfile = FALSE;
+ if (cf_open(cf, filename, is_tempfile, &err) == CF_OK) {
+ switch (cf_read(cf)) {
+
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
@@ -3543,13 +3545,13 @@ cf_reload() {
return;
}
} else {
- /* 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"
+ /* 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"
ourselves.
XXX - change the menu? Presumably "cf_open()" will do that;
make sure it does! */
- cfile.is_tempfile = is_tempfile;
+ cf->is_tempfile = is_tempfile;
}
/* "cf_open()" made a copy of the file name we handed it, so
we should free up our copy. */
diff --git a/file.h b/file.h
index 763c6b8d54..3dca5439a9 100644
--- a/file.h
+++ b/file.h
@@ -34,88 +34,364 @@
#include "cfile.h"
-/* Return values from "cf_read()", "cf_continue_tail()", and
- "cf_finish_tail()". */
+/** Return values from various cf_xxx functions. */
typedef enum {
- READ_SUCCESS, /* read succeeded */
- READ_ERROR, /* read got an error */
- READ_ABORTED /* read aborted by user */
-} read_status_t;
-
-int cf_open(char *, gboolean, capture_file *);
-void cf_close(capture_file *);
-void cf_reload(void);
-read_status_t cf_read(capture_file *);
-int cf_start_tail(char *, gboolean, capture_file *);
-read_status_t cf_continue_tail(capture_file *, int, int *);
-read_status_t cf_finish_tail(capture_file *, int *);
-/* size_t read_frame_header(capture_file *); */
-gboolean cf_save(char *fname, capture_file * cf, packet_range_t *range, guint save_format);
-const gchar *cf_get_display_name(capture_file *);
+ CF_OK, /**< operation succeeded */
+ CF_ERROR, /**< operation got an error (function may provide err with details) */
+ CF_ABORTED, /**< operation aborted by user */
+ CF_PRINT_OPEN_ERROR, /**< print operation failed while opening printer */
+ CF_PRINT_WRITE_ERROR /**< print operation failed while writing to the printer */
+} cf_status_t;
+
+/**
+ * Open a capture file.
+ *
+ * @param cf the capture file to be opened
+ * @param fname the filename to be opened
+ * @param is_tempfile is this a temporary file?
+ * @return one of cf_status_t
+ */
+cf_status_t cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err);
+
+/**
+ * Close a capture file.
+ *
+ * @param cf the capture file to be closed
+ */
+void cf_close(capture_file *cf);
+
+/**
+ * Reload a capture file.
+ *
+ * @param cf the capture file to be reloaded
+ */
+void cf_reload(capture_file *cf);
+
+/**
+ * Read all packets of a capture file into the internal structures.
+ *
+ * @param cf the capture file to be read
+ * @return one of cf_status_t
+ */
+cf_status_t cf_read(capture_file *cf);
+
+/**
+ * Start reading from the end of a capture file.
+ * This is used in "Update list of packets in Real-Time".
+ *
+ * @param cf the capture file to be read from
+ * @param fname the filename to be read from
+ * @param is_tempfile is this a temporary file?
+ * @param err the error code, if an error had occured
+ * @return one of cf_status_t
+ */
+cf_status_t cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err);
+
+/**
+ * Read packets from the "end" of a capture file.
+ *
+ * @param cf the capture file to be read from
+ * @param to_read the number of packets to read
+ * @param err the error code, if an error had occured
+ * @return one of cf_status_t
+ */
+cf_status_t cf_continue_tail(capture_file *cf, int to_read, int *err);
+
+/**
+ * Finish reading from "end" of a capture file.
+ *
+ * @param cf the capture file to be read from
+ * @param err the error code, if an error had occured
+ * @return one of cf_status_t
+ */
+cf_status_t cf_finish_tail(capture_file *cf, int *err);
+
+/**
+ * Save a capture file (or a range of it).
+ *
+ * @param cf the capture file to save to
+ * @param fname the filename to save to
+ * @param range the range of packets to save
+ * @param save_format the format of the file to save (libpcap, ...)
+ * @return one of cf_status_t
+ */
+cf_status_t cf_save(capture_file * cf, char *fname, packet_range_t *range, guint save_format);
+
+/**
+ * Get a displayable name of the capture file.
+ *
+ * @param cf the capture file
+ * @return the displayable name (don't have to be g_free'd)
+ */
+const gchar *cf_get_display_name(capture_file *cf);
+
+/**
+ * Get the number of packets in the capture file.
+ *
+ * @param cf the capture file
+ * @return the number of packets in the capture file
+ */
int cf_packet_count(capture_file *cf);
+
+/**
+ * Is this capture file a temporary file?
+ *
+ * @param cf the capture file
+ * @return TRUE if it's a temporary file, FALSE otherwise
+ */
gboolean cf_is_tempfile(capture_file *cf);
+
+/**
+ * Get the interface name to capture from.
+ *
+ * @param cf the capture file
+ * @return the interface name (don't have to be g_free'd)
+ */
+gchar *cf_get_iface(capture_file *cf);
+
+/**
+ * Get the capture filter of this capture file.
+ *
+ * @param cf the capture file
+ * @return the capture filter (don't have to be g_free'd)
+ */
+gchar *cf_get_cfilter(capture_file *cf);
+
+/**
+ * Set flag, if the number of packet drops while capturing are known or not.
+ *
+ * @param cf the capture file
+ * @param drops_known TRUE if the number of packet drops are known, FALSE otherwise
+ */
void cf_set_drops_known(capture_file *cf, gboolean drops_known);
+
+/**
+ * Set the number of packet drops while capturing.
+ *
+ * @param cf the capture file
+ * @param drops the number of packet drops occured while capturing
+ */
void cf_set_drops(capture_file *cf, guint32 drops);
-gchar *cf_get_iface(capture_file *cf);
+
+/**
+ * Set the read filter.
+ * @todo this shouldn't be required, remove it somehow
+ *
+ * @param cf the capture file
+ * @param rfcode the readfilter
+ */
void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode);
-gchar *cf_get_cfilter(capture_file *cf);
-gboolean
-cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
- char *const *in_filenames, int file_type, gboolean do_append);
+/**
+ * "Display Filter" packets in the capture file.
+ *
+ * @param cf the capture file
+ * @param dfilter the display filter
+ * @param force TRUE if do in any case, FALSE only if dfilter changed
+ * @return one of cf_status_t
+ */
+cf_status_t cf_filter_packets(capture_file *cf, gchar *dfilter, gboolean force);
-gboolean filter_packets(capture_file *cf, gchar *dfilter, gboolean force);
-void reftime_packets(capture_file *);
-void colorize_packets(capture_file *);
-void redissect_packets(capture_file *cf);
-int retap_packets(capture_file *cf);
-typedef enum {
- PP_OK,
- PP_OPEN_ERROR,
- PP_WRITE_ERROR
-} pp_return_t;
-pp_return_t print_packets(capture_file *cf, print_args_t *print_args);
-pp_return_t write_pdml_packets(capture_file *cf, print_args_t *print_args);
-pp_return_t write_psml_packets(capture_file *cf, print_args_t *print_args);
-
-void change_time_formats(capture_file *);
-
-gboolean find_packet_protocol_tree(capture_file *cf, const char *string);
-gboolean find_packet_summary_line(capture_file *cf, const char *string);
-gboolean find_packet_data(capture_file *cf, const guint8 *string,
+/**
+ * At least one "Refence Time" flag has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_reftime_packets(capture_file *cf);
+
+/**
+ * At least one "Refence Time" flag has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_colorize_packets(capture_file *cf);
+
+/**
+ * "Something" has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_redissect_packets(capture_file *cf);
+
+/**
+ * A tap listener want's to rescan all packets.
+ *
+ * @param cf the capture file
+ * @return one of cf_status_t
+ */
+cf_status_t cf_retap_packets(capture_file *cf);
+
+/**
+ * The time format has changed, rescan all packets.
+ *
+ * @param cf the capture file
+ */
+void cf_change_time_formats(capture_file *cf);
+
+/**
+ * Print the capture file.
+ *
+ * @param cf the capture file
+ * @param print_args the arguments what and how to print
+ * @return one of cf_status_t
+ */
+cf_status_t cf_print_packets(capture_file *cf, print_args_t *print_args);
+
+/**
+ * Print (export) the capture file into PDML format.
+ *
+ * @param cf the capture file
+ * @param print_args the arguments what and how to export
+ * @return one of cf_status_t
+ */
+cf_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args);
+
+/**
+ * Print (export) the capture file into PSML format.
+ *
+ * @param cf the capture file
+ * @param print_args the arguments what and how to export
+ * @return one of cf_status_t
+ */
+cf_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args);
+
+/**
+ * Find Packet in protocol tree.
+ *
+ * @param cf the capture file
+ * @param string the string to find
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_protocol_tree(capture_file *cf, const char *string);
+
+/**
+ * Find Packet in summary line.
+ *
+ * @param cf the capture file
+ * @param string the string to find
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_summary_line(capture_file *cf, const char *string);
+
+/**
+ * Find Packet in packet data.
+ *
+ * @param cf the capture file
+ * @param string the string to find
+ * @param string_size the size of the string to find
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_data(capture_file *cf, const guint8 *string,
size_t string_size);
-gboolean find_packet_dfilter(capture_file *cf, dfilter_t *sfcode);
-guint8 get_int_value(char char_val);
-gboolean find_ascii(capture_file *cf, char *ascii_text, gboolean ascii_search, char *ftype, gboolean case_type);
-gboolean find_in_gtk_data(capture_file *cf, gpointer *data, char *ascii_text, gboolean case_type, gboolean search_type);
-gboolean goto_frame(capture_file *cf, guint fnumber);
-gboolean goto_bottom_frame(capture_file *cf);
-gboolean goto_top_frame(capture_file *cf);
-void goto_framenum(capture_file *cf);
+/**
+ * Find Packet by display filter.
+ *
+ * @param cf the capture file
+ * @param sfcode the display filter to find a packet for
+ * @return TRUE if a packet was found, FALSE otherwise
+ */
+gboolean cf_find_packet_dfilter(capture_file *cf, dfilter_t *sfcode);
+/**
+ * GoTo Packet in first row.
+ *
+ * @param cf the capture file
+ * @return TRUE if the first row exists, FALSE otherwise
+ */
+gboolean cf_goto_top_frame(capture_file *cf);
-void select_packet(capture_file *, int);
-void unselect_packet(capture_file *);
+/**
+ * GoTo Packet in last row.
+ *
+ * @param cf the capture file
+ * @return TRUE if last row exists, FALSE otherwise
+ */
+gboolean cf_goto_bottom_frame(capture_file *cf);
-void unselect_field(capture_file *);
+/**
+ * GoTo Packet with the given row.
+ *
+ * @param cf the capture file
+ * @param row the row to go to
+ * @return TRUE if this row exists, FALSE otherwise
+ */
+gboolean cf_goto_frame(capture_file *cf, guint row);
+
+/**
+ * Go to frame specified by currently selected protocol tree field.
+ * (Go To Corresponding Packet)
+ * @todo this is ugly and should be improved!
+ *
+ * @param cf the capture file
+ * @return TRUE if this packet exists, FALSE otherwise
+ */
+gboolean cf_goto_framenum(capture_file *cf);
+
+/**
+ * Select the packet in the given row.
+ *
+ * @param cf the capture file
+ * @param row the row to select
+ */
+void cf_select_packet(capture_file *cf, int row);
+
+/**
+ * Unselect all packets, if any.
+ *
+ * @param cf the capture file
+ * @param row the row to select
+ */
+void cf_unselect_packet(capture_file *cf);
+
+/**
+ * Unselect all protocol tree fields, if any.
+ *
+ * @param cf the capture file
+ * @param row the row to select
+ */
+void cf_unselect_field(capture_file *cf);
-/*
+/**
* Mark a particular frame in a particular capture.
+ *
+ * @param cf the capture file
+ * @param frame the frame to be marked
*/
-void mark_frame(capture_file *, frame_data *);
+void cf_mark_frame(capture_file *cf, frame_data *frame);
-/*
+/**
* Unmark a particular frame in a particular capture.
+ *
+ * @param cf the capture file
+ * @param frame the frame to be unmarked
*/
-void unmark_frame(capture_file *, frame_data *);
+void cf_unmark_frame(capture_file *cf, frame_data *frame);
-/* Moves or copies a file. Returns 0 on failure, 1 on success */
-int file_mv(char *from, char *to);
+/**
+ * Convert error number and info to a complete message.
+ *
+ * @param err the error number
+ * @param err_info the additional info about this error (e.g. filename)
+ * @return statically allocated error message
+ */
+char *cf_read_error_message(int err, gchar *err_info);
-/* Copies a file. Returns 0 on failure, 1 on success */
-int file_cp(char *from, char *to);
+/**
+ * Merge two (or more) capture files into one.
+ * @todo is this the right place for this function? It doesn't have to do a lot with capture_file.
+ *
+ * @param out_filename output filename
+ * @param out_fd output file descriptor
+ * @param in_file_count the number of input files to merge
+ * @param in_filnames array of input filenames
+ * @param file_type the output filetype
+ * @param do_append FALSE to merge chronologically, TRUE simply append
+ * @return TRUE if merging suceeded, FALSE otherwise
+ */
+gboolean
+cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
+ char *const *in_filenames, int file_type, gboolean do_append);
-char *cf_read_error_message(int, gchar *);
#endif /* file.h */
diff --git a/gtk/bootp_stat.c b/gtk/bootp_stat.c
index d7b718e7ca..cf8e910ca9 100644
--- a/gtk/bootp_stat.c
+++ b/gtk/bootp_stat.c
@@ -268,7 +268,7 @@ dhcpstat_init(char *optarg)
window_present(sp->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg dhcp_stat_dlg = {
diff --git a/gtk/color_dlg.c b/gtk/color_dlg.c
index 6cb2b5dc64..99a4182a29 100644
--- a/gtk/color_dlg.c
+++ b/gtk/color_dlg.c
@@ -1073,7 +1073,7 @@ color_clear_cmd(GtkWidget *widget)
"Could not delete filter file: %s", strerror(errno));
/* colorize list */
- colorize_packets(&cfile);
+ cf_colorize_packets(&cfile);
/* Destroy the dialog box. */
/* XXX: is this useful? user might want to continue with editing new colors */
@@ -1113,7 +1113,7 @@ static void
color_ok_cb(GtkButton *button _U_, gpointer user_data _U_)
{
/* colorize list */
- colorize_packets(&cfile);
+ cf_colorize_packets(&cfile);
/* Destroy the dialog box. */
window_destroy(colorize_win);
@@ -1132,7 +1132,7 @@ color_cancel_cb(GtkWidget *widget _U_, gpointer user_data _U_)
static void
color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
{
- colorize_packets(&cfile);
+ cf_colorize_packets(&cfile);
}
/* Create an "Edit Color Filter" dialog for a given color filter, and
diff --git a/gtk/conversations_table.c b/gtk/conversations_table.c
index d1ae9785dc..e8766d26ae 100644
--- a/gtk/conversations_table.c
+++ b/gtk/conversations_table.c
@@ -1283,7 +1283,7 @@ init_conversation_table(gboolean hide_ports, char *table_name, char *tap_name, c
gtk_widget_show_all(conversations->win);
window_present(conversations->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Keep clist frozen to cause modifications to the clist (inserts, appends, others that are extremely slow
@@ -1471,7 +1471,7 @@ init_conversation_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_widget_show_all(win);
window_present(win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* after retapping, redraw table */
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
diff --git a/gtk/dcerpc_stat.c b/gtk/dcerpc_stat.c
index 34e95fee8f..3ef040435d 100644
--- a/gtk/dcerpc_stat.c
+++ b/gtk/dcerpc_stat.c
@@ -331,7 +331,7 @@ gtk_dcerpcstat_init(char *optarg)
gtk_widget_show_all(rs->win);
window_present(rs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
diff --git a/gtk/decode_as_dlg.c b/gtk/decode_as_dlg.c
index 59043eb203..0c0347ab37 100644
--- a/gtk/decode_as_dlg.c
+++ b/gtk/decode_as_dlg.c
@@ -437,7 +437,7 @@ decode_clear_all(void)
decode_dcerpc_reset_all();
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
@@ -905,7 +905,7 @@ decode_ok_cb (GtkWidget *ok_bt _U_, gpointer parent_w)
g_slist_free(decode_dimmable);
decode_dimmable = NULL;
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
/*
@@ -934,7 +934,7 @@ decode_apply_cb (GtkWidget *apply_bt _U_, gpointer parent_w)
func = OBJECT_GET_DATA(notebook_pg, E_PAGE_ACTION);
func(notebook_pg);
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
/*
diff --git a/gtk/fc_stat.c b/gtk/fc_stat.c
index c62b355bd3..376b8abf56 100644
--- a/gtk/fc_stat.c
+++ b/gtk/fc_stat.c
@@ -196,7 +196,7 @@ gtk_fcstat_init(char *optarg)
gtk_widget_show_all(fc->win);
window_present(fc->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index b4c3cf8546..8f35fd916f 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -676,7 +676,7 @@ file_open_ok_cb(GtkWidget *w, gpointer fs) {
}
/* Try to open the capture file. */
- if ((err = cf_open(cf_name, FALSE, &cfile)) != 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) != CF_OK) {
/* 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,
@@ -715,14 +715,14 @@ file_open_ok_cb(GtkWidget *w, gpointer fs) {
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
@@ -1069,7 +1069,7 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
window_destroy(GTK_WIDGET (fs));
/* Try to open the merged capture file. */
- if ((err = cf_open(tmpname, TRUE /* temporary file */, &cfile)) != 0) {
+ if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) != CF_OK) {
/* 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,
@@ -1086,14 +1086,14 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
@@ -1440,7 +1440,7 @@ file_save_as_ok_cb(GtkWidget *w _U_, gpointer fs) {
/* Write out the packets (all, or only the ones from the current
range) to the file with the specified name. */
- if (! cf_save(cf_name, &cfile, &range, filetype)) {
+ if (cf_save(&cfile, cf_name, &range, filetype) != CF_OK) {
/* The write failed; 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 error, try again. */
@@ -1458,7 +1458,7 @@ file_save_as_ok_cb(GtkWidget *w _U_, gpointer fs) {
}
/* The write succeeded; get rid of the file selection box. */
- /* cf_save might already closed our dialog! */
+ /* cf_save() might already closed our dialog! */
if (file_save_as_w)
window_destroy(GTK_WIDGET (fs));
@@ -1518,7 +1518,7 @@ file_save_as_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
/* Reload a file using the current read and display filters */
void
file_reload_cmd_cb(GtkWidget *w _U_, gpointer data _U_) {
- cf_reload();
+ cf_reload(&cfile);
}
/******************** Color Filters *********************************/
diff --git a/gtk/find_dlg.c b/gtk/find_dlg.c
index 44260c02d0..cfc5867495 100644
--- a/gtk/find_dlg.c
+++ b/gtk/find_dlg.c
@@ -633,7 +633,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
cfile.summary_data = summary_data;
if (cfile.hex) {
- found_packet = find_packet_data(&cfile, bytes, nbytes);
+ found_packet = cf_find_packet_data(&cfile, bytes, nbytes);
g_free(bytes);
if (!found_packet) {
/* We didn't find a packet */
@@ -648,7 +648,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
/* OK, what are we searching? */
if (cfile.decode_data) {
/* The text in the protocol tree */
- found_packet = find_packet_protocol_tree(&cfile, string);
+ found_packet = cf_find_packet_protocol_tree(&cfile, string);
g_free(string);
if (!found_packet) {
/* We didn't find the packet. */
@@ -660,7 +660,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
}
} else if (cfile.summary_data) {
/* The text in the summary line */
- found_packet = find_packet_summary_line(&cfile, string);
+ found_packet = cf_find_packet_summary_line(&cfile, string);
g_free(string);
if (!found_packet) {
/* We didn't find the packet. */
@@ -672,7 +672,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
}
} else {
/* The raw packet data */
- found_packet = find_packet_data(&cfile, string, strlen(string));
+ found_packet = cf_find_packet_data(&cfile, string, strlen(string));
g_free(string);
if (!found_packet) {
/* We didn't find the packet. */
@@ -684,7 +684,7 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
}
}
} else {
- found_packet = find_packet_dfilter(&cfile, sfcode);
+ found_packet = cf_find_packet_dfilter(&cfile, sfcode);
dfilter_free(sfcode);
if (!found_packet) {
/* We didn't find a packet */
@@ -732,20 +732,20 @@ find_previous_next(GtkWidget *w, gpointer d, gboolean sens)
*/
return;
}
- find_packet_data(&cfile, bytes, nbytes);
+ cf_find_packet_data(&cfile, bytes, nbytes);
g_free(bytes);
} else if (cfile.string) {
string = convert_string_case(cfile.sfilter, cfile.case_type);
/* OK, what are we searching? */
if (cfile.decode_data) {
/* The text in the protocol tree */
- find_packet_protocol_tree(&cfile, string);
+ cf_find_packet_protocol_tree(&cfile, string);
} else if (cfile.summary_data) {
/* The text in the summary line */
- find_packet_summary_line(&cfile, string);
+ cf_find_packet_summary_line(&cfile, string);
} else {
/* The raw packet data */
- find_packet_data(&cfile, string, strlen(string));
+ cf_find_packet_data(&cfile, string, strlen(string));
}
g_free(string);
} else {
@@ -763,7 +763,7 @@ find_previous_next(GtkWidget *w, gpointer d, gboolean sens)
*/
return;
}
- find_packet_dfilter(&cfile, sfcode);
+ cf_find_packet_dfilter(&cfile, sfcode);
dfilter_free(sfcode);
}
} else
@@ -807,7 +807,7 @@ find_previous_next_frame_with_filter(char *filter, gboolean backwards)
*/
return;
}
- find_packet_dfilter(&cfile, sfcode);
+ cf_find_packet_dfilter(&cfile, sfcode);
dfilter_free(sfcode);
cfile.sbackward=sbackwards_saved;
}
diff --git a/gtk/goto_dlg.c b/gtk/goto_dlg.c
index 8b60491606..259d8dd15e 100644
--- a/gtk/goto_dlg.c
+++ b/gtk/goto_dlg.c
@@ -134,7 +134,7 @@ goto_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
return;
}
- if (goto_frame(&cfile, fnumber)) {
+ if (cf_goto_frame(&cfile, fnumber)) {
/* We succeeded in going to that frame; we're done. */
window_destroy(GTK_WIDGET(parent_w));
}
@@ -146,19 +146,19 @@ goto_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
void
goto_framenum_cb(GtkWidget *w _U_, gpointer data _U_)
{
- goto_framenum(&cfile);
+ cf_goto_framenum(&cfile);
}
void
goto_top_frame_cb(GtkWidget *w _U_, gpointer d _U_)
{
- goto_top_frame(&cfile);
+ cf_goto_top_frame(&cfile);
}
void
goto_bottom_frame_cb(GtkWidget *w _U_, gpointer d _U_)
{
- goto_bottom_frame(&cfile);
+ cf_goto_bottom_frame(&cfile);
}
diff --git a/gtk/graph_analysis.c b/gtk/graph_analysis.c
index ed88a32c50..76342fef93 100644
--- a/gtk/graph_analysis.c
+++ b/gtk/graph_analysis.c
@@ -668,7 +668,7 @@ static gint button_press_event(GtkWidget *widget, GdkEventButton *event _U_)
user_data->dlg.needs_redraw=TRUE;
dialog_graph_draw(user_data);
- goto_frame(&cfile, user_data->dlg.items[item].frame_num);
+ cf_goto_frame(&cfile, user_data->dlg.items[item].frame_num);
return TRUE;
}
diff --git a/gtk/h225_counter.c b/gtk/h225_counter.c
index d746343eb7..df45102b1f 100644
--- a/gtk/h225_counter.c
+++ b/gtk/h225_counter.c
@@ -556,7 +556,7 @@ gtk_h225counter_init(char *optarg)
gtk_widget_show_all(hs->win);
window_present(hs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
void
diff --git a/gtk/h225_ras_srt.c b/gtk/h225_ras_srt.c
index 4aff0d1695..daedacccae 100644
--- a/gtk/h225_ras_srt.c
+++ b/gtk/h225_ras_srt.c
@@ -336,7 +336,7 @@ gtk_h225rassrt_init(char *optarg)
gtk_widget_show_all(hs->win);
window_present(hs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
void
diff --git a/gtk/h323_analysis.c b/gtk/h323_analysis.c
index 349d3cfafe..6f70b3cc35 100644
--- a/gtk/h323_analysis.c
+++ b/gtk/h323_analysis.c
@@ -333,7 +333,7 @@ static void on_goto_bt_clicked(GtkWidget *bt _U_, user_data_t *user_data _U_)
if (user_data->selected_clist1!=NULL) {
fnumber = GPOINTER_TO_UINT(gtk_clist_get_row_data(
GTK_CLIST(user_data->selected_clist1), user_data->selected_row) );
- goto_frame(&cfile, fnumber);
+ cf_goto_frame(&cfile, fnumber);
}
}
@@ -408,7 +408,7 @@ static void on_refresh_bt_clicked(GtkWidget *bt _U_, user_data_t *user_data _U_)
}
/* retap all packets */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* remove tap listener again */
protect_thread_critical_region();
diff --git a/gtk/h323_conversations_dlg.c b/gtk/h323_conversations_dlg.c
index dfcc0ecdba..84c5b5b0bc 100644
--- a/gtk/h323_conversations_dlg.c
+++ b/gtk/h323_conversations_dlg.c
@@ -570,7 +570,7 @@ h323conversations_init_tap(char *dummy _U_)
h245conversations_init_tap();
/* Scan for H323 conversations conversationss (redissect all packets) */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Show the dialog box with the list of conversationss */
h323conversations_dlg_show(h323conversations_get_info()->strinfo_list);
diff --git a/gtk/hostlist_table.c b/gtk/hostlist_table.c
index b9f2a21ac1..1bba285cdc 100644
--- a/gtk/hostlist_table.c
+++ b/gtk/hostlist_table.c
@@ -768,7 +768,7 @@ init_hostlist_table(gboolean hide_ports, char *table_name, char *tap_name, char
gtk_widget_show_all(hosttable->win);
window_present(hosttable->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Keep clist frozen to cause modifications to the clist (inserts, appends, others that are extremely slow
in GTK2) to not be drawn, allow refreshes to occur at strategic points for performance */
@@ -956,7 +956,7 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_widget_show_all(win);
window_present(win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* after retapping, redraw table */
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
diff --git a/gtk/http_stat.c b/gtk/http_stat.c
index 1aceaf69d8..d034c98ab3 100644
--- a/gtk/http_stat.c
+++ b/gtk/http_stat.c
@@ -502,7 +502,7 @@ gtk_httpstat_init(char *optarg)
window_present(sp->win);
http_init_hash(sp);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg http_stat_dlg = {
diff --git a/gtk/io_stat.c b/gtk/io_stat.c
index c05c22a450..8bb636789a 100644
--- a/gtk/io_stat.c
+++ b/gtk/io_stat.c
@@ -1110,7 +1110,7 @@ gtk_iostat_init(char *optarg _U_)
/* build the GUI */
init_io_stat_window(io);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
io_stat_redraw(io);
}
@@ -1270,7 +1270,7 @@ tick_interval_select(GtkWidget *item, gpointer key)
val=(int)OBJECT_GET_DATA(item, "tick_interval");
io->interval=val;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
io_stat_redraw(io);
}
@@ -1634,7 +1634,7 @@ filter_callback(GtkWidget *widget _U_, io_stat_graph_t *gio)
io_stat_reset(gio->io);
enable_graph(gio, filter, field);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
io_stat_redraw(gio->io);
return 0;
diff --git a/gtk/ldap_stat.c b/gtk/ldap_stat.c
index 595a26140e..2b6e638a43 100644
--- a/gtk/ldap_stat.c
+++ b/gtk/ldap_stat.c
@@ -231,7 +231,7 @@ gtk_ldapstat_init(char *optarg)
gtk_widget_show_all(ldap->win);
window_present(ldap->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
diff --git a/gtk/main.c b/gtk/main.c
index 26fe478a3d..215edd560b 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -501,7 +501,7 @@ dfilter_combo_add_recent(gchar *s) {
}
-/* call filter_packets() and add this filter string to the recent filter list */
+/* call cf_filter_packets() and add this filter string to the recent filter list */
gboolean
main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
{
@@ -511,14 +511,14 @@ main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
gboolean add_filter = TRUE;
gboolean free_filter = TRUE;
char *s;
- gboolean filter_packets_ret;
-
+ cf_status_t cf_status;
s = g_strdup(dftext);
/* 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_ret = filter_packets(cf, s, force))) {
+ cf_status = cf_filter_packets(cf, s, force);
+ if (cf_status == CF_OK) {
li = g_list_first(filter_list);
while (li) {
if (li->data && strcmp(s, li->data) == 0)
@@ -542,7 +542,11 @@ main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
if (free_filter)
g_free(s);
- return filter_packets_ret;
+ if (cf_status == CF_OK) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
@@ -580,7 +584,7 @@ set_frame_reftime(gboolean set, frame_data *frame, gint row) {
} else {
frame->flags.ref_time=0;
}
- reftime_packets(&cfile);
+ cf_reftime_packets(&cfile);
}
void
@@ -643,7 +647,7 @@ tree_view_selection_changed_cb(GtkTreeSelection *sel, gpointer user_data _U_)
if (byte_data == NULL)
return; /* none */
- unselect_field(&cfile);
+ cf_unselect_field(&cfile);
packet_hex_print(GTK_TEXT_VIEW(byte_view), byte_data,
cfile.current_frame, NULL, byte_len);
return;
@@ -740,7 +744,7 @@ tree_view_unselect_row_cb(GtkCTree *ctree _U_, GList *node _U_, gint column _U_,
if (data == NULL)
return; /* none */
- unselect_field(&cfile);
+ cf_unselect_field(&cfile);
packet_hex_print(GTK_TEXT(byte_view), data, cfile.current_frame,
NULL, len);
}
@@ -1432,7 +1436,7 @@ dnd_merge_files(int in_file_count, char **in_filenames)
cf_close(&cfile);
/* Try to open the merged capture file. */
- if ((err = cf_open(tmpname, TRUE /* temporary file */, &cfile)) != 0) {
+ if (cf_open(&cfile, tmpname, TRUE /* temporary file */, &err) != CF_OK) {
/* 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,
@@ -1442,14 +1446,14 @@ dnd_merge_files(int in_file_count, char **in_filenames)
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
@@ -1517,7 +1521,7 @@ dnd_open_file_cmd(GtkSelectionData *selection_data)
break;
case(1):
/* open and read the capture file (this will close an existing file) */
- if ((err = cf_open(in_filenames[0], FALSE, &cfile)) == 0) {
+ if (cf_open(&cfile, in_filenames[0], FALSE, &err) == CF_OK) {
cf_read(&cfile);
add_menu_recent_capture_file(in_filenames[0]);
} else {
@@ -2563,7 +2567,7 @@ main(int argc, char *argv[])
}
}
if (!rfilter_parse_failed) {
- if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
/* "cf_open()" succeeded, so it closed the previous
capture file, and thus destroyed any previous read filter
attached to "cf". */
@@ -2580,14 +2584,14 @@ main(int argc, char *argv[])
/* Read the capture file. */
switch (cf_read(&cfile)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Exit now. */
gtk_exit(0);
break;
diff --git a/gtk/main.h b/gtk/main.h
index 4d58bb7534..cad3fe317f 100644
--- a/gtk/main.h
+++ b/gtk/main.h
@@ -252,7 +252,7 @@ extern void main_widgets_rearrange(void);
extern void main_widgets_show_or_hide(void);
/** Apply a new filter string.
- * Call filter_packets() and add this filter string to the recent filter list.
+ * Call cf_filter_packets() and add this filter string to the recent filter list.
*
* @param cf the capture file
* @param dftext the new filter string
diff --git a/gtk/menu.c b/gtk/menu.c
index 45f201787c..8bab6c73bb 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -990,7 +990,7 @@ menu_open_recent_file_cmd(GtkWidget *w)
gtk_label_get(GTK_LABEL(menu_item_child), &cf_name);
/* open and read the capture file (this will close an existing file) */
- if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
cf_read(&cfile);
} else {
/* the capture file isn't existing any longer, remove menu item */
@@ -1245,7 +1245,7 @@ timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_)
if (recent.gui_time_format != TS_ABSOLUTE) {
set_timestamp_setting(TS_ABSOLUTE);
recent.gui_time_format = TS_ABSOLUTE;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
@@ -1255,7 +1255,7 @@ timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_)
if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) {
set_timestamp_setting(TS_ABSOLUTE_WITH_DATE);
recent.gui_time_format = TS_ABSOLUTE_WITH_DATE;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
@@ -1265,7 +1265,7 @@ timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_)
if (recent.gui_time_format != TS_RELATIVE) {
set_timestamp_setting(TS_RELATIVE);
recent.gui_time_format = TS_RELATIVE;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
@@ -1275,7 +1275,7 @@ timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_)
if (recent.gui_time_format != TS_DELTA) {
set_timestamp_setting(TS_DELTA);
recent.gui_time_format = TS_DELTA;
- change_time_formats(&cfile);
+ cf_change_time_formats(&cfile);
}
}
diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c
index 188b335db2..5e1b9215ae 100644
--- a/gtk/mgcp_stat.c
+++ b/gtk/mgcp_stat.c
@@ -311,7 +311,7 @@ gtk_mgcpstat_init(char *optarg)
gtk_widget_show_all(ms->win);
window_present(ms->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg mgcp_srt_dlg = {
diff --git a/gtk/packet_history.c b/gtk/packet_history.c
index 421a63a79c..b52a9f9ac6 100644
--- a/gtk/packet_history.c
+++ b/gtk/packet_history.c
@@ -142,7 +142,7 @@ void packet_history_back(void) {
/* goto that packet but don't change history */
ignore_jump = TRUE;
- goto_frame(&cfile, GPOINTER_TO_INT(previous->data) +1);
+ cf_goto_frame(&cfile, GPOINTER_TO_INT(previous->data) +1);
ignore_jump = FALSE;
}
}
@@ -163,7 +163,7 @@ void packet_history_forward(void) {
/* goto that packet but don't change history */
ignore_jump = TRUE;
- goto_frame(&cfile, GPOINTER_TO_INT(next->data) +1);
+ cf_goto_frame(&cfile, GPOINTER_TO_INT(next->data) +1);
ignore_jump = FALSE;
}
}
diff --git a/gtk/packet_list.c b/gtk/packet_list.c
index 7065fb41a6..56f1c9f9cf 100644
--- a/gtk/packet_list.c
+++ b/gtk/packet_list.c
@@ -268,7 +268,7 @@ packet_list_select_cb(GtkWidget *w _U_, gint row, gint col _U_, gpointer evt _U_
while( (gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), 0)))
gtk_notebook_remove_page( GTK_NOTEBOOK(byte_nb_ptr), 0);
- select_packet(&cfile, row);
+ cf_select_packet(&cfile, row);
gtk_widget_grab_focus(packet_list);
packet_history_add(row);
}
@@ -276,7 +276,7 @@ packet_list_select_cb(GtkWidget *w _U_, gint row, gint col _U_, gpointer evt _U_
static void
packet_list_unselect_cb(GtkWidget *w _U_, gint row _U_, gint col _U_, gpointer evt _U_) {
- unselect_packet(&cfile);
+ cf_unselect_packet(&cfile);
}
/* mark packets */
@@ -287,7 +287,7 @@ set_frame_mark(gboolean set, frame_data *frame, gint row) {
if (row == -1)
return;
if (set) {
- mark_frame(&cfile, frame);
+ cf_mark_frame(&cfile, frame);
color_t_to_gdkcolor(&fg, &prefs.gui_marked_fg);
color_t_to_gdkcolor(&bg, &prefs.gui_marked_bg);
eth_clist_set_foreground(ETH_CLIST(packet_list), row, &fg);
@@ -295,7 +295,7 @@ set_frame_mark(gboolean set, frame_data *frame, gint row) {
} else {
color_filter_t *cfilter = frame->color_filter;
- unmark_frame(&cfile, frame);
+ cf_unmark_frame(&cfile, frame);
/* Restore the color from the matching color filter if any */
if (cfilter) { /* The packet matches a color filter */
color_t_to_gdkcolor(&fg, &cfilter->fg_color);
@@ -446,7 +446,7 @@ set_plist_sel_browse(gboolean val)
}
if (cfile.finfo_selected)
- unselect_packet(&cfile);
+ cf_unselect_packet(&cfile);
mode = new_mode;
eth_clist_set_selection_mode(ETH_CLIST(packet_list), mode);
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 39b82b801b..6c42bfba18 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1216,7 +1216,7 @@ prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
@@ -1232,7 +1232,7 @@ prefs_main_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
@@ -1283,7 +1283,7 @@ prefs_main_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
@@ -1379,7 +1379,7 @@ prefs_main_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c
index 114917a3f9..5163db6fbc 100644
--- a/gtk/print_dlg.c
+++ b/gtk/print_dlg.c
@@ -769,7 +769,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
#ifdef _WIN32
gboolean win_printer = FALSE;
#endif
- pp_return_t status;
+ cf_status_t status;
args = (print_args_t *)OBJECT_GET_DATA(ok_bt, PRINT_ARGS_KEY);
@@ -857,9 +857,9 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
/* Now print/export the packets */
if (export_as_pdml)
- status = write_pdml_packets(&cfile, args);
+ status = cf_write_pdml_packets(&cfile, args);
else if (export_as_psml)
- status = write_psml_packets(&cfile, args);
+ status = cf_write_psml_packets(&cfile, args);
else {
switch (args->format) {
@@ -899,14 +899,14 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
g_assert_not_reached();
return;
}
- status = print_packets(&cfile, args);
+ status = cf_print_packets(&cfile, args);
}
switch (status) {
- case PP_OK:
+ case CF_OK:
break;
- case PP_OPEN_ERROR:
+ case CF_PRINT_OPEN_ERROR:
if (args->to_file)
open_failure_alert_box(args->file, errno, TRUE);
else
@@ -914,7 +914,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
args->cmd);
break;
- case PP_WRITE_ERROR:
+ case CF_PRINT_WRITE_ERROR:
if (args->to_file)
write_failure_alert_box(args->file, errno);
else
diff --git a/gtk/proto_dlg.c b/gtk/proto_dlg.c
index a173131917..446eeeaf83 100644
--- a/gtk/proto_dlg.c
+++ b/gtk/proto_dlg.c
@@ -416,14 +416,14 @@ proto_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
redissect = set_proto_selection(GTK_WIDGET(parent_w));
window_destroy(GTK_WIDGET(parent_w));
if (redissect)
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static void
proto_apply_cb(GtkWidget *apply_bt _U_, gpointer parent_w)
{
if (set_proto_selection(GTK_WIDGET(parent_w)))
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static void
@@ -458,7 +458,7 @@ proto_save_cb(GtkWidget *save_bt _U_, gpointer parent_w)
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
}
@@ -470,7 +470,7 @@ proto_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
redissect = revert_proto_selection();
window_destroy(GTK_WIDGET(parent_w));
if (redissect)
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static gboolean
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index b2ddfb9a6c..7c14c98f08 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -235,7 +235,7 @@ redraw_hex_dump_all(void)
The only workaround is to freshly select the frame, which will remove any
existing notebook tabs and "restart" the whole byte view again. */
if (cfile.current_frame != NULL)
- goto_frame(&cfile, cfile.current_frame->num);
+ cf_goto_frame(&cfile, cfile.current_frame->num);
#endif
}
@@ -1768,7 +1768,7 @@ void
tree_view_follow_link(field_info *fi)
{
if(fi->hfinfo->type == FT_FRAMENUM) {
- goto_frame(&cfile, fi->value.value.integer);
+ cf_goto_frame(&cfile, fi->value.value.integer);
}
}
diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c
index 2567b8b898..f585c49070 100644
--- a/gtk/rpc_progs.c
+++ b/gtk/rpc_progs.c
@@ -406,7 +406,7 @@ gtk_rpcprogs_init(char *optarg _U_)
gtk_widget_show_all(win);
window_present(win);
- redissect_packets(&cfile);
+ cf_redissect_packets(&cfile);
}
static void
diff --git a/gtk/rpc_stat.c b/gtk/rpc_stat.c
index 2c192976b8..5da4615889 100644
--- a/gtk/rpc_stat.c
+++ b/gtk/rpc_stat.c
@@ -307,7 +307,7 @@ gtk_rpcstat_init(char *optarg)
gtk_widget_show_all(rs->win);
window_present(rs->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c
index d63070d4cf..d8c9231f90 100644
--- a/gtk/rtp_analysis.c
+++ b/gtk/rtp_analysis.c
@@ -1832,7 +1832,7 @@ static gint filter_callback(GtkWidget *widget _U_, dialog_graph_graph_t *dgg)
}
enable_graph(dgg);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
dialog_graph_redraw(dgg->ud);
return 0;
@@ -1951,7 +1951,7 @@ static void tick_interval_select(GtkWidget *item, gpointer key)
val=(int)OBJECT_GET_DATA(item, "tick_interval");
user_data->dlg.dialog_graph.interval=val;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
dialog_graph_redraw(user_data);
}
@@ -2156,7 +2156,7 @@ static void on_goto_bt_clicked(GtkWidget *bt _U_, user_data_t *user_data _U_)
if (user_data->dlg.selected_clist!=NULL) {
fnumber = GPOINTER_TO_UINT(gtk_clist_get_row_data(
GTK_CLIST(user_data->dlg.selected_clist), user_data->dlg.selected_row) );
- goto_frame(&cfile, fnumber);
+ cf_goto_frame(&cfile, fnumber);
}
}
@@ -2244,7 +2244,7 @@ static void on_refresh_bt_clicked(GtkWidget *bt _U_, user_data_t *user_data _U_)
}
/* retap all packets */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* draw statistics info */
draw_stat(user_data);
diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c
index 7d58c16d97..7861870d9d 100644
--- a/gtk/rtp_stream.c
+++ b/gtk/rtp_stream.c
@@ -286,7 +286,7 @@ static int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _
if (rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_fwd)==0
|| rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_rev)==0)
{
- mark_frame(&cfile, pinfo->fd);
+ cf_mark_frame(&cfile, pinfo->fd);
}
}
@@ -302,7 +302,7 @@ void rtpstream_scan(void)
register_tap_listener_rtp_stream();
the_tapinfo_struct.mode = TAP_ANALYSE;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
if (!was_registered)
remove_tap_listener_rtp_stream();
@@ -333,7 +333,7 @@ gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename)
the_tapinfo_struct.mode = TAP_SAVE;
the_tapinfo_struct.filter_stream_fwd = stream;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
the_tapinfo_struct.mode = TAP_ANALYSE;
if (!was_registered)
@@ -364,7 +364,7 @@ void rtpstream_mark(rtp_stream_info_t* stream_fwd, rtp_stream_info_t* stream_rev
the_tapinfo_struct.mode = TAP_MARK;
the_tapinfo_struct.filter_stream_fwd = stream_fwd;
the_tapinfo_struct.filter_stream_rev = stream_rev;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
the_tapinfo_struct.mode = TAP_ANALYSE;
if (!was_registered)
diff --git a/gtk/rtp_stream_dlg.c b/gtk/rtp_stream_dlg.c
index 0476e7f21d..f585a68c21 100644
--- a/gtk/rtp_stream_dlg.c
+++ b/gtk/rtp_stream_dlg.c
@@ -261,7 +261,7 @@ rtpstream_on_goto (GtkButton *button _U_,
{
if (selected_stream_fwd)
{
- goto_frame(&cfile, selected_stream_fwd->first_frame_num);
+ cf_goto_frame(&cfile, selected_stream_fwd->first_frame_num);
}
}
*/
diff --git a/gtk/sctp_error_dlg.c b/gtk/sctp_error_dlg.c
index 53f6fc8a07..95be56d2c4 100644
--- a/gtk/sctp_error_dlg.c
+++ b/gtk/sctp_error_dlg.c
@@ -136,7 +136,7 @@ sctp_error_on_frame (GtkButton *button _U_, gpointer user_data _U_)
return;
if (selected_packet)
- goto_frame(&cfile, selected_packet->frame_number);
+ cf_goto_frame(&cfile, selected_packet->frame_number);
}
diff --git a/gtk/sctp_stat_dlg.c b/gtk/sctp_stat_dlg.c
index 7cedb5ca6c..3cbdaac2d9 100644
--- a/gtk/sctp_stat_dlg.c
+++ b/gtk/sctp_stat_dlg.c
@@ -535,7 +535,7 @@ int i;
SIGNAL_CONNECT(bt_close, "clicked", sctp_stat_on_close, NULL);
sctp_stat_dlg = sctp_stat_dlg_w;
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
diff --git a/gtk/sip_stat.c b/gtk/sip_stat.c
index ca43e640ef..9560bf321b 100644
--- a/gtk/sip_stat.c
+++ b/gtk/sip_stat.c
@@ -648,7 +648,7 @@ gtk_sipstat_init(char *optarg)
window_present(sp->win);
sip_init_hash(sp);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg sip_stat_dlg = {
diff --git a/gtk/smb_stat.c b/gtk/smb_stat.c
index 4c36dea76b..240cbfb0d7 100644
--- a/gtk/smb_stat.c
+++ b/gtk/smb_stat.c
@@ -234,7 +234,7 @@ gtk_smbstat_init(char *optarg)
gtk_widget_show_all(ss->win);
window_present(ss->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c
index 37d2b7c0b8..a244f1d2d4 100644
--- a/gtk/tcp_graph.c
+++ b/gtk/tcp_graph.c
@@ -2613,11 +2613,11 @@ static void graph_select_segment (struct graph *g, int x, int y)
break;
case ELMT_LINE:
if (line_detect_collision (e, x, y))
- goto_frame(&cfile, e->parent->num);
+ cf_goto_frame(&cfile, e->parent->num);
break;
case ELMT_ARC:
if (arc_detect_collision (e, x, y))
- goto_frame(&cfile, e->parent->num);
+ cf_goto_frame(&cfile, e->parent->num);
break;
default:
break;
diff --git a/gtk/voip_calls_dlg.c b/gtk/voip_calls_dlg.c
index dc388d359f..e5a1cae037 100644
--- a/gtk/voip_calls_dlg.c
+++ b/gtk/voip_calls_dlg.c
@@ -688,7 +688,7 @@ voip_calls_init_tap(char *dummy _U_)
}
/* Scan for VoIP calls calls (redissect all packets) */
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
/* Tap listener will be removed and cleaned up in voip_calls_on_destroy */
}
diff --git a/gtk/wsp_stat.c b/gtk/wsp_stat.c
index 9319a12bde..6a9e143f19 100644
--- a/gtk/wsp_stat.c
+++ b/gtk/wsp_stat.c
@@ -412,7 +412,7 @@ gtk_wspstat_init(char *optarg)
gtk_widget_show_all(sp->win);
window_present(sp->win);
- retap_packets(&cfile);
+ cf_retap_packets(&cfile);
}
static tap_dfilter_dlg wsp_stat_dlg = {
diff --git a/tethereal.c b/tethereal.c
index b5b9584cc6..26b30b5bf5 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1578,8 +1578,7 @@ main(int argc, char *argv[])
setgid(getgid());
#endif
- err = cf_open(cf_name, FALSE, &cfile);
- if (err != 0) {
+ if (cf_open(&cfile, cf_name, FALSE, &err) != CF_OK) {
epan_cleanup();
exit(2);
}
@@ -3197,15 +3196,14 @@ open_failure_message(const char *filename, int err, gboolean for_writing)
fprintf(stderr, "\n");
}
-int
-cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
+cf_status_t
+cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err)
{
wtap *wth;
- int err;
gchar *err_info;
char err_msg[2048+1];
- wth = wtap_open_offline(fname, &err, &err_info, FALSE);
+ wth = wtap_open_offline(fname, err, &err_info, FALSE);
if (wth == NULL)
goto fail;
@@ -3245,13 +3243,13 @@ cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
firstsec = 0, firstusec = 0;
prevsec = 0, prevusec = 0;
- return (0);
+ return CF_OK;
fail:
snprintf(err_msg, sizeof err_msg,
- cf_open_error_message(err, err_info, FALSE, 0), fname);
+ cf_open_error_message(*err, err_info, FALSE, 0), fname);
fprintf(stderr, "tethereal: %s\n", err_msg);
- return (err);
+ return CF_ERROR;
}
#ifdef HAVE_LIBPCAP