minor enhancements to Guy's last update
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 5 Feb 2005 13:44:27 +0000 (13:44 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 5 Feb 2005 13:44:27 +0000 (13:44 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13304 f5534014-38df-0310-8fa8-9805f1628bb7

capture_sync.c
file.c
file.h
gtk/file_dlg.c

index 3ca4403ee87b490eb9cf78370c5e0389eb8f910a..998acc4873a522e87482ad948c4bd4bf96b68d16 100644 (file)
@@ -507,10 +507,10 @@ sync_pipe_do_capture(capture_options *capture_opts, gboolean is_tempfile) {
         capture_opts->save_file = NULL;
         return FALSE;
         break;
-    default:
-        g_assert_not_reached();
-        return FALSE;
     }
+
+    g_assert_not_reached();
+    return FALSE;
 }
 
 
diff --git a/file.c b/file.c
index 589d6ed7cb302b8014f74cfc5a81a6e5ebfcb0f4..01fa09fa245fce4922bfa60b5c9110fd2eb18536 100644 (file)
--- a/file.c
+++ b/file.c
@@ -430,7 +430,7 @@ 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 CF_ABORTED so our caller
+         bar, close the capture file, and return CF_READ_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 */
@@ -584,7 +584,7 @@ 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 CF_ABORTED
+    /* Well, the user decided to exit Ethereal.  Return CF_READ_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
@@ -622,7 +622,7 @@ 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 CF_ABORTED so our caller can do whatever
+       file; we return CF_READ_ABORTED so our caller can do whatever
        is appropriate when that happens. */
     cf_close(cf);
     return CF_READ_ABORTED;
@@ -1014,7 +1014,7 @@ read_packet(capture_file *cf, long offset)
   }
 }
 
-gboolean
+cf_status_t
 cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
                char *const *in_filenames, int file_type, gboolean do_append)
 {
@@ -1050,7 +1050,7 @@ cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
     free(in_files);
     cf_open_failure_alert_box(in_filenames[err_fileno], open_err, err_info,
                               FALSE, 0);
-    return FALSE;
+    return CF_ERROR;
   }
 
   pdh = wtap_dump_fdopen(out_fd, file_type,
@@ -1061,7 +1061,7 @@ cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
     free(in_files);
     cf_open_failure_alert_box(out_filename, open_err, err_info, TRUE,
                               file_type);
-    return FALSE;
+    return CF_ERROR;
   }
 
   /* Get the sum of the sizes of all the files. */
@@ -1194,7 +1194,7 @@ cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
     cf_write_failure_alert_box(out_filename, write_err);
   }
 
-  return (!got_read_error && !got_write_error);
+  return (!got_read_error && !got_write_error) ? CF_OK : CF_ERROR;
 }
 
 cf_status_t
@@ -1708,18 +1708,19 @@ cf_retap_packets(capture_file *cf)
                                     NULL)) {
   case PSP_FINISHED:
     /* Completed successfully. */
-    break;
+    return CF_OK;
 
   case PSP_STOPPED:
     /* Well, the user decided to abort the refiltering.
        Return CF_READ_ABORTED so our caller knows they did that. */
-    return FALSE;
+    return CF_READ_ABORTED;
 
   case PSP_FAILED:
     /* Error while retapping. */
     return CF_READ_ERROR;
   }
 
+  g_assert_not_reached();
   return CF_READ_OK;
 }
 
@@ -2010,7 +2011,7 @@ cf_print_packets(capture_file *cf, print_args_t *print_args)
   if (!destroy_print_stream(print_args->stream))
     return CF_PRINT_WRITE_ERROR;
 
-  return CF_OK;
+  return CF_PRINT_OK;
 }
 
 static gboolean
@@ -2080,7 +2081,7 @@ cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
   /* XXX - check for an error */
   fclose(fh);
 
-  return CF_OK;
+  return CF_PRINT_OK;
 }
 
 static gboolean
@@ -2150,7 +2151,7 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
   /* XXX - check for an error */
   fclose(fh);
 
-  return CF_OK;
+  return CF_PRINT_OK;
 }
 
 /* Scan through the packet list and change all columns that use the
diff --git a/file.h b/file.h
index eb7086e8b46257618332951fc461598e396b115a..8e92d4f7a33b88683e81cd77d9a8f831e1a0e31d 100644 (file)
--- a/file.h
+++ b/file.h
 
 #include "cfile.h"
 
-/** Return values from functions that read capture files. */
+
+/** Return values from functions that only can succeed or fail. */
 typedef enum {
-       CF_OK,          /**< operation succeeded */
+       CF_OK,                      /**< operation succeeded */
        CF_ERROR        /**< operation got an error (function may provide err with details) */
 } cf_status_t;
 
+/** Return values from functions that read capture files. */
 typedef enum {
        CF_READ_OK,             /**< operation succeeded */
        CF_READ_ERROR,          /**< operation got an error (function may provide err with details) */
@@ -48,7 +50,7 @@ typedef enum {
 
 /** Return values from functions that print sets of packets. */
 typedef enum {
-       CF_PRINT_OK,            /**< operation succeeded */
+       CF_PRINT_OK,                /**< print 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_print_status_t;
@@ -399,7 +401,7 @@ char *cf_read_error_message(int err, const gchar *err_info);
  * @param do_append FALSE to merge chronologically, TRUE simply append
  * @return TRUE if merging suceeded, FALSE otherwise
  */
-gboolean
+cf_status_t
 cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
                char *const *in_filenames, int file_type, gboolean do_append);
 
index 53b12959900927f7ea35f11d31450d628ed79f3a..54864ec3668076a57e1dd1d9e30f34efdf49f10b 100644 (file)
@@ -998,7 +998,7 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
   GtkWidget   *filter_te, *rb;
   dfilter_t   *rfcode = NULL;
   int          err;
-  gboolean     merge_ok;
+  cf_status_t  merge_status;
   char        *in_filenames[2];
   int          out_fd;
   char         tmpname[128+1];
@@ -1035,7 +1035,7 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
       /* chronological order */
       in_filenames[0] = cfile.filename;
       in_filenames[1] = cf_name;
-      merge_ok = cf_merge_files(tmpname, out_fd, 2, in_filenames,
+      merge_status = cf_merge_files(tmpname, out_fd, 2, in_filenames,
                                 filetype, FALSE);
   } else {
       rb = OBJECT_GET_DATA(w, E_MERGE_PREPEND_KEY);
@@ -1043,20 +1043,20 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
           /* prepend file */
           in_filenames[0] = cfile.filename;
           in_filenames[1] = cf_name;
-          merge_ok = cf_merge_files(tmpname, out_fd, 2, in_filenames,
+          merge_status = cf_merge_files(tmpname, out_fd, 2, in_filenames,
                                     filetype, TRUE);
       } else {
           /* append file */
           in_filenames[0] = cf_name;
           in_filenames[1] = cfile.filename;
-          merge_ok = cf_merge_files(tmpname, out_fd, 2, in_filenames,
+          merge_status = cf_merge_files(tmpname, out_fd, 2, in_filenames,
                                     filetype, TRUE);
       }
   }
 
   g_free(cf_name);
   
-  if (!merge_ok) {
+  if (merge_status != CF_OK) {
     close(out_fd);     /* XXX - it's already closed, right? */
     if (rfcode != NULL)
       dfilter_free(rfcode);