huge cleanup of capture file API (functions in file.c/file.h).
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 4 Feb 2005 18:44:44 +0000 (18:44 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 4 Feb 2005 18:44:44 +0000 (18:44 +0000)
This includes: all functions in file.h now have a cf_ prefix, will have doxygen tags, will have the capture_file *cf as the first parameter and I tried to generalize the return values for non trivial functions.

Hopefully, I didn't introduced any new bugs, as I had to change a lot of files...

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13289 f5534014-38df-0310-8fa8-9805f1628bb7

45 files changed:
capture.c
capture_sync.c
file.c
file.h
gtk/bootp_stat.c
gtk/color_dlg.c
gtk/conversations_table.c
gtk/dcerpc_stat.c
gtk/decode_as_dlg.c
gtk/fc_stat.c
gtk/file_dlg.c
gtk/find_dlg.c
gtk/goto_dlg.c
gtk/graph_analysis.c
gtk/h225_counter.c
gtk/h225_ras_srt.c
gtk/h323_analysis.c
gtk/h323_conversations_dlg.c
gtk/hostlist_table.c
gtk/http_stat.c
gtk/io_stat.c
gtk/ldap_stat.c
gtk/main.c
gtk/main.h
gtk/menu.c
gtk/mgcp_stat.c
gtk/packet_history.c
gtk/packet_list.c
gtk/prefs_dlg.c
gtk/print_dlg.c
gtk/proto_dlg.c
gtk/proto_draw.c
gtk/rpc_progs.c
gtk/rpc_stat.c
gtk/rtp_analysis.c
gtk/rtp_stream.c
gtk/rtp_stream_dlg.c
gtk/sctp_error_dlg.c
gtk/sctp_stat_dlg.c
gtk/sip_stat.c
gtk/smb_stat.c
gtk/tcp_graph.c
gtk/voip_calls_dlg.c
gtk/wsp_stat.c
tethereal.c

index 3355167038e572bdb0fa0610b9396f271c9905bb..39377a09edc960b8c8aefbc833c3a288163a3642 100644 (file)
--- 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();
index 8dcf754ba739a32e6112551441b6b585d84dd598..d74e076bec38c44c685d9626b9c688fec21d7e44 100644 (file)
@@ -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 7de1d489e69e6576c1749cd9de1b81d2a9848066..fba0cdbf8919442f57c935865a9f3f9100abf559 100644 (file)
--- 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 763c6b8d54632a10b3c8da03c18330091dc6fe5e..3dca5439a90c3887ecdfab0a5e91aec8781fcc40 100644 (file)
--- a/file.h
+++ b/file.h
 
 #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 */
index d7b718e7caa5b6a311607d10aade70b73e0e10d1..cf8e910ca91617fd89af6e9d8257bcc1139975da 100644 (file)
@@ -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 = {
index 6cb2b5dc64e3abcecc4966898820a5ef963b4925..99a4182a290f6d427702d2f3fa70e6421e3ee001 100644 (file)
@@ -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
index d1ae9785dc3e9d1265e00a39b0821e7cd7ec0dc8..e8766d26ae95ae9b77ad1cca64743eb795d963e9 100644 (file)
@@ -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++) {
index 34e95fee8f6611cac7a3da1f55698d9dcc279156..3ef040435d27a351d9128391c96432160035f2c8 100644 (file)
@@ -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);
 }
 
 
index 59043eb203e601d0d5564af34c53b038211089e8..0c0347ab3799e0065e8eef85bdbd618d9bcfd0b7 100644 (file)
@@ -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);
 }
 
 /*
index c62b355bd383eefebb4798c2643fd43698f6ada9..376b8abf56057013ce7d1d78f8f66d16d3bcf92b 100644 (file)
@@ -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);
 }
 
 
index b4c3cf854676b855dd662cf6f96b0307ed22a813..8f35fd916fdd3c37c4b9d34e1649a5fa35d96494 100644 (file)
@@ -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 *********************************/
index 44260c02d067653c778db180c3ba864dfb1a9599..cfc5867495f8bc9cf7c2cfd29a03abdb24bdca37 100644 (file)
@@ -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;
 }
index 8b60491606c33c9d0c90050df13baecbd2896823..259d8dd15ee559c17b73dd4d1226902bc6d08b00 100644 (file)
@@ -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);
 }
 
 
index ed88a32c501c8d5f26714c8fed54f8921b83c96c..76342fef9390dd1049d022623056c752b95976cf 100644 (file)
@@ -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;
 }
index d746343eb71ce9851b206674dc47b194d6269e73..df45102b1fdd49c57a2c75e078e898c277fad1e0 100644 (file)
@@ -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
index 4aff0d1695e584866dc84030164e671fb5bcbaa1..daedacccaeb71b065398049f688fb11064a246a8 100644 (file)
@@ -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
index 349d3cfafeb85c44143ea47d191a8ba335e5338d..6f70b3cc35e58d0de4dab68ca10ac181b3aa9fb5 100644 (file)
@@ -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();
index dfcc0ecdba0c1a61ce0ae64f0aa5f69b3f02e16f..84c5b5b0bc2200ef5516f4133090be9d0b86c371 100644 (file)
@@ -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);
index b9f2a21ac12845c67d8862748fb94a283cd0c4fc..1bba285cdc97eadf3e689a1c1199c4063e209e4e 100644 (file)
@@ -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++) {
index 1aceaf69d8bff5a9e920a71467a3e90e13c10911..d034c98ab3687e5f0dcac69b36aa641365d5ed0d 100644 (file)
@@ -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 = {
index c05c22a45018cd831edbf8fceaf7e07e8d68c66a..8bb636789a6a4d21e631d5902337faae2ddfa633 100644 (file)
@@ -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;
index 595a26140efb61a850780a34826ca14c74d0d864..2b6e638a4382b5752f0fb9f2ec667b82975ef12b 100644 (file)
@@ -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);
 }
 
 
index 26fe478a3d41caa5f7d7a374040b74fd39eeb0db..215edd560bd9a5cfb8d2ec68ec51a00437c9c8df 100644 (file)
@@ -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;
index 4d58bb7534c8da4e9428cf1799408d693ca66397..cad3fe317ff92d104f6578674516b3974776f52f 100644 (file)
@@ -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
index 45f201787cdb7ea119020b75c1df9bb811aa5a7f..8bab6c73bb7d3c1bc1998e1b7b0dbc4af513c3e4 100644 (file)
@@ -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);
     }
 }
 
index 188b335db258acbbe084d21b418e7047cf22ad1d..5e1b9215aef64564953de4b622011698d815149e 100644 (file)
@@ -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 = {
index 421a63a79cbb9d1055ac6b288a446c2bef9a7d37..b52a9f9ac66f47a3e22426b016b1ef0db2f69525 100644 (file)
@@ -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;
         }
     }
index 7065fb41a6f1578c7366b68fa57332a7be1cc5b3..56f1c9f9cf185182de27e391cb9332905fe538f1 100644 (file)
@@ -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);
index 39b82b801b824d68c9f5e86dd0c7df4635052d63..6c42bfba18dde38cd7a05f8666f5bffae22e8fbf 100644 (file)
@@ -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);
   }
 }
 
index 114917a3f9358e4686eaac27888d780cd754e7ae..5163db6fbc97d4b5e79e13ee8197e40fa27622e1 100644 (file)
@@ -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
index a17313191759198a5bb55063c6ad112a4f257c48..446eeeaf831d2f7c0cc3137b137eb25da27fb29e 100644 (file)
@@ -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
index b2ddfb9a6c806bc4c5c93e0d237f7afbe8c6f207..7c14c98f089564b90b482d0383b3fee49c40746a 100644 (file)
@@ -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);
     }
 }
 
index 2567b8b898f248f767d29d6cef911f6513949e8d..f585c4907025784803f4f50e71fad079bfcf877c 100644 (file)
@@ -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
index 2c192976b8b974a27291775e31a104a6897eface..5da4615889c8159be0aad23deebbc7d58ee96131 100644 (file)
@@ -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);
 }
 
 
index d63070d4cfdc92a35bc1edcb6963846d2ef96b41..d8c9231f900b9c7b7538750b30b3dbb846f02a05 100644 (file)
@@ -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);
index 7d58c16d97b73fc7339b7252b15cc9c34453a2e8..7861870d9d93156e0800e30f52787dcc502aa100 100644 (file)
@@ -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)
index 0476e7f21d2f7e92e3657b106d2968b35723b660..f585a68c21afe05b461cf4c47ce757be5e3675f4 100644 (file)
@@ -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);
        }
 }
 */
index 53f6fc8a07addf9ea3c24f3e18c76871712a9755..95be56d2c411551af7b0d151688d553292a4d174 100644 (file)
@@ -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);
 }
 
 
index 7cedb5ca6c6a4e74fd0cef2fb7f5668b3cd16244..3cbdaac2d94ebfd3619516180ca5002ff2195695 100644 (file)
@@ -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);
 
 }
 
index ca43e640efe220b06ad1263fc25beedf3fdc0469..9560bf321b197c875d11a33b310da00f7d071ea8 100644 (file)
@@ -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 = {
index 4c36dea76b1a0cfdc2a651cd67c87049aa636744..240cbfb0d724584da31b6d96eb7c8b7b2a3f78f6 100644 (file)
@@ -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);
 }
 
 
index 37d2b7c0b88f0872763ec3000e1ca2dd8af9b1e1..a244f1d2d4195ca223f0b9fba3e4a23bfd8d0013 100644 (file)
@@ -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;
index dc388d359f5adaa110d2bb0b4a00df3b5f4b982c..e5a1cae037de8525a4c96bd2b20a7f6daa5c603b 100644 (file)
@@ -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 */
 }
index 9319a12bdeec3916069c12405ba190707df051b0..6a9e143f1951aed11abf9648bf12cfbb8af8172d 100644 (file)
@@ -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 = {
index b5b9584cc61a914e7fa9527cda62cc0120e04b5c..26b30b5bf5b611e3aa9c0c343a516a5b69c6b3da 100644 (file)
@@ -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