diff options
-rw-r--r-- | file.c | 50 | ||||
-rw-r--r-- | file.h | 61 | ||||
-rw-r--r-- | gtk/main.c | 13 | ||||
-rw-r--r-- | gtk/print_dlg.c | 18 | ||||
-rw-r--r-- | tethereal.c | 6 |
5 files changed, 75 insertions, 73 deletions
@@ -142,7 +142,7 @@ static gboolean copy_binary_file(char *from_filename, char *to_filename); #define FRAME_DATA_CHUNK_SIZE 1024 -cf_status_t +gboolean cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err) { wtap *wth; @@ -211,11 +211,11 @@ cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err) G_ALLOC_AND_FREE); g_assert(cf->plist_chunk); - return CF_OK; + return TRUE; fail: cf_open_failure_alert_box(fname, *err, err_info, FALSE, 0); - return CF_ERROR; + return FALSE; } /* Reset everything to a pristine state */ @@ -340,7 +340,7 @@ set_display_filename(capture_file *cf) g_free(win_name); } -cf_status_t +cf_read_status_t cf_read(capture_file *cf) { int err; @@ -529,14 +529,14 @@ cf_read(capture_file *cf) } #ifdef HAVE_LIBPCAP -cf_status_t +gboolean cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err) { gchar *capture_msg; - cf_status_t cf_status; + gboolean status; - cf_status = cf_open(cf, fname, is_tempfile, err); - if (cf_status == CF_OK) { + status = cf_open(cf, fname, is_tempfile, err); + if (status) { /* Disable menu items that make no sense if you're currently running a capture. */ set_menus_for_capture_in_progress(TRUE); @@ -552,10 +552,10 @@ cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err) g_free(capture_msg); } - return cf_status; + return status; } -cf_status_t +cf_read_status_t cf_continue_tail(capture_file *cf, int to_read, int *err) { long data_offset = 0; @@ -598,7 +598,7 @@ cf_continue_tail(capture_file *cf, int to_read, int *err) return CF_OK; } -cf_status_t +cf_read_status_t cf_finish_tail(capture_file *cf, int *err) { gchar *err_info; @@ -1197,7 +1197,7 @@ cf_merge_files(const char *out_filename, int out_fd, int in_file_count, return (!got_read_error && !got_write_error); } -cf_status_t +gboolean cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force) { dfilter_t *dfcode; @@ -1206,7 +1206,7 @@ cf_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 CF_OK; + return TRUE; } if (dftext == NULL) { @@ -1233,7 +1233,7 @@ cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force) g_free(safe_dfilter_error_msg); g_free(safe_dftext); g_free(dftext); - return CF_ERROR; + return FALSE; } /* Was it empty? */ @@ -1259,7 +1259,7 @@ cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force) } else { rescan_packets(cf, "Filtering", dftext, TRUE, FALSE); } - return CF_OK; + return TRUE; } void @@ -1691,7 +1691,7 @@ retap_packet(capture_file *cf _U_, frame_data *fdata, return TRUE; } -cf_status_t +gboolean cf_retap_packets(capture_file *cf) { packet_range_t range; @@ -1713,14 +1713,14 @@ cf_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 CF_ERROR; + return FALSE; case PSP_FAILED: /* Error while retapping. */ - return CF_ERROR; + return FALSE; } - return CF_OK; + return TRUE; } typedef struct { @@ -1881,7 +1881,7 @@ fail: return FALSE; } -cf_status_t +cf_print_status_t cf_print_packets(capture_file *cf, print_args_t *print_args) { int i; @@ -2033,7 +2033,7 @@ write_pdml_packet(capture_file *cf _U_, frame_data *fdata, return !ferror(fh); } -cf_status_t +cf_print_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args) { FILE *fh; @@ -2103,7 +2103,7 @@ write_psml_packet(capture_file *cf, frame_data *fdata, return !ferror(fh); } -cf_status_t +cf_print_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args) { FILE *fh; @@ -3084,7 +3084,7 @@ save_packet(capture_file *cf _U_, frame_data *fdata, return TRUE; } -cf_status_t +gboolean cf_save(capture_file *cf, char *fname, packet_range_t *range, guint save_format) { gchar *from_filename; @@ -3271,12 +3271,12 @@ cf_save(capture_file *cf, char *fname, packet_range_t *range, guint save_format) set_menus_for_unsaved_capture_file(FALSE); } } - return CF_OK; + return TRUE; fail: /* Pop the "Saving:" message off the status bar. */ statusbar_pop_file_msg(); - return CF_ERROR; + return FALSE; } static void @@ -34,14 +34,19 @@ #include "cfile.h" -/** Return values from various cf_xxx functions. */ +/** Return values from functions that read capture files. */ typedef enum { - CF_OK, /**< operation succeeded */ - CF_ERROR, /**< operation got an error (function may provide err with details) */ - CF_ABORTED, /**< operation aborted by user */ + CF_OK, /**< operation succeeded */ + CF_ERROR, /**< operation got an error (function may provide err with details) */ + CF_ABORTED /**< operation aborted by user */ +} cf_read_status_t; + +/** Return values from functions that print sets of packets. */ +typedef enum { + CF_PRINT_OK, /**< operation succeeded */ 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; +} cf_print_status_t; /** * Open a capture file. @@ -49,9 +54,9 @@ typedef enum { * @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 + * @return TRUE on success, FALSE on failure */ -cf_status_t cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err); +gboolean cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err); /** * Close a capture file. @@ -71,9 +76,9 @@ 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 + * @return one of cf_read_status_t */ -cf_status_t cf_read(capture_file *cf); +cf_read_status_t cf_read(capture_file *cf); /** * Start reading from the end of a capture file. @@ -83,9 +88,9 @@ cf_status_t cf_read(capture_file *cf); * @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 + * @return TRUE on success, FALSE on failure */ -cf_status_t cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err); +gboolean cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, int *err); /** * Read packets from the "end" of a capture file. @@ -93,18 +98,18 @@ cf_status_t cf_start_tail(capture_file *cf, char *fname, gboolean is_tempfile, i * @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 + * @return one of cf_read_status_t */ -cf_status_t cf_continue_tail(capture_file *cf, int to_read, int *err); +cf_read_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 + * @return one of cf_read_status_t */ -cf_status_t cf_finish_tail(capture_file *cf, int *err); +cf_read_status_t cf_finish_tail(capture_file *cf, int *err); /** * Save a capture file (or a range of it). @@ -113,9 +118,9 @@ cf_status_t cf_finish_tail(capture_file *cf, int *err); * @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 + * @return TRUE on success, FALSE on failure */ -cf_status_t cf_save(capture_file * cf, char *fname, packet_range_t *range, guint save_format); +gboolean cf_save(capture_file * cf, char *fname, packet_range_t *range, guint save_format); /** * Get a displayable name of the capture file. @@ -188,9 +193,9 @@ void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode); * @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 + * @return TRUE on success, FALSE on failure */ -cf_status_t cf_filter_packets(capture_file *cf, gchar *dfilter, gboolean force); +gboolean cf_filter_packets(capture_file *cf, gchar *dfilter, gboolean force); /** * At least one "Refence Time" flag has changed, rescan all packets. @@ -214,12 +219,12 @@ void cf_colorize_packets(capture_file *cf); void cf_redissect_packets(capture_file *cf); /** - * A tap listener want's to rescan all packets. + * Rescan all packets and just run taps - don't reconstruct the display. * * @param cf the capture file - * @return one of cf_status_t + * @return TRUE on success, FALSE on failure */ -cf_status_t cf_retap_packets(capture_file *cf); +gboolean cf_retap_packets(capture_file *cf); /** * The time format has changed, rescan all packets. @@ -233,27 +238,27 @@ void cf_change_time_formats(capture_file *cf); * * @param cf the capture file * @param print_args the arguments what and how to print - * @return one of cf_status_t + * @return one of cf_print_status_t */ -cf_status_t cf_print_packets(capture_file *cf, print_args_t *print_args); +cf_print_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 + * @return one of cf_print_status_t */ -cf_status_t cf_write_pdml_packets(capture_file *cf, print_args_t *print_args); +cf_print_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 + * @return one of cf_print_status_t */ -cf_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args); +cf_print_status_t cf_write_psml_packets(capture_file *cf, print_args_t *print_args); /** * Find Packet in protocol tree. diff --git a/gtk/main.c b/gtk/main.c index 215edd560b..93d4224c36 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -511,14 +511,15 @@ main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force) gboolean add_filter = TRUE; gboolean free_filter = TRUE; char *s; - cf_status_t cf_status; + gboolean 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. */ - cf_status = cf_filter_packets(cf, s, force); - if (cf_status == CF_OK) { + status = cf_filter_packets(cf, s, force); + if (status) { li = g_list_first(filter_list); while (li) { if (li->data && strcmp(s, li->data) == 0) @@ -542,11 +543,7 @@ main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force) if (free_filter) g_free(s); - if (cf_status == CF_OK) { - return TRUE; - } else { - return FALSE; - } + return status; } diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c index 5163db6fbc..2856bf8cc8 100644 --- a/gtk/print_dlg.c +++ b/gtk/print_dlg.c @@ -760,16 +760,16 @@ print_cmd_toggle_detail(GtkWidget *widget _U_, gpointer data) static void print_ok_cb(GtkWidget *ok_bt, gpointer parent_w) { - GtkWidget *button; - print_args_t *args; - const gchar *g_dest; - gchar *f_name; - gchar *dirname; - gboolean export_as_pdml = FALSE, export_as_psml = FALSE; + GtkWidget *button; + print_args_t *args; + const gchar *g_dest; + gchar *f_name; + gchar *dirname; + gboolean export_as_pdml = FALSE, export_as_psml = FALSE; #ifdef _WIN32 - gboolean win_printer = FALSE; + gboolean win_printer = FALSE; #endif - cf_status_t status; + cf_print_status_t status; args = (print_args_t *)OBJECT_GET_DATA(ok_bt, PRINT_ARGS_KEY); @@ -903,7 +903,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w) } switch (status) { - case CF_OK: + case CF_PRINT_OK: break; case CF_PRINT_OPEN_ERROR: diff --git a/tethereal.c b/tethereal.c index 26b30b5bf5..3eebd27a72 100644 --- a/tethereal.c +++ b/tethereal.c @@ -3196,7 +3196,7 @@ open_failure_message(const char *filename, int err, gboolean for_writing) fprintf(stderr, "\n"); } -cf_status_t +gboolean cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err) { wtap *wth; @@ -3243,13 +3243,13 @@ cf_open(capture_file *cf, char *fname, gboolean is_tempfile, int *err) firstsec = 0, firstusec = 0; prevsec = 0, prevusec = 0; - return CF_OK; + return TRUE; fail: snprintf(err_msg, sizeof err_msg, cf_open_error_message(*err, err_info, FALSE, 0), fname); fprintf(stderr, "tethereal: %s\n", err_msg); - return CF_ERROR; + return FALSE; } #ifdef HAVE_LIBPCAP |