Make the command-line and alert-box failure messages more similar.
authorGuy Harris <guy@alum.mit.edu>
Thu, 20 Apr 2017 17:14:50 +0000 (10:14 -0700)
committerGuy Harris <guy@alum.mit.edu>
Thu, 20 Apr 2017 17:15:22 +0000 (17:15 +0000)
Change-Id: I94af221a0ce8b6b3ff8e0e1b94d5379351ac0962
Reviewed-on: https://code.wireshark.org/review/21251
Reviewed-by: Guy Harris <guy@alum.mit.edu>
editcap.c
reordercap.c
tshark.c
ui/alert_box.c
ui/failure_message.c
ui/failure_message.h

index 3e684fe234a711cd9636376d4db273384fdf39e3..6f3e804a36fc8cd8f5f616fd5863c8017a1d8bee 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -1776,7 +1776,8 @@ main(int argc, char *argv[])
 
                 /* Attempt to dump out current frame to the output file */
                 if (!wtap_dump(pdh, phdr, buf, &write_err, &write_err_info)) {
-                    cfile_write_failure_message(argv[optind], filename,
+                    cfile_write_failure_message("editcap", argv[optind],
+                                                filename,
                                                 write_err, write_err_info,
                                                 read_count,
                                                 out_file_type_subtype);
index 7b44527ecef216e467f0afaaa96aec4386dacf26..a66f928fbc722ba1904efa1b1230f688fbcc0ef1 100644 (file)
@@ -123,8 +123,9 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
 
     /* Dump frame to outfile */
     if (!wtap_dump(pdh, phdr, ws_buffer_start_ptr(buf), &err, &err_info)) {
-        cfile_write_failure_message(infile, outfile, err, err_info,
-                                    frame->num, wtap_file_type_subtype(wth));
+        cfile_write_failure_message("reordercap", infile, outfile, err,
+                                    err_info, frame->num,
+                                    wtap_file_type_subtype(wth));
         exit(1);
     }
 }
index 960ab68577d409c3396ebce191642b82e57978aa..b25f80c03b42044ee7ab37a1210686a36fa3bd6d 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -3160,8 +3160,9 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
               /* Report the error.
                  XXX - framenum is not necessarily the frame number in
                  the input file if there was a read filter. */
-              cfile_write_failure_message(cf->filename, save_file, err,
-                                          err_info, framenum, out_file_type);
+              cfile_write_failure_message("TShark", cf->filename, save_file,
+                                          err, err_info, framenum,
+                                          out_file_type);
               wtap_dump_close(pdh, &err);
               wtap_block_array_free(shb_hdrs);
               wtap_block_array_free(nrb_hdrs);
@@ -3239,8 +3240,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
           if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err, &err_info)) {
             /* Error writing to a capture file */
             tshark_debug("tshark: error writing to a capture file (%d)", err);
-            cfile_write_failure_message(cf->filename, save_file, err, err_info,
-                                        framenum, out_file_type);
+            cfile_write_failure_message("TShark", cf->filename, save_file,
+                                        err, err_info, framenum, out_file_type);
             wtap_dump_close(pdh, &err);
             wtap_block_array_free(shb_hdrs);
             wtap_block_array_free(nrb_hdrs);
index 327bf61cc2d80d2283c805275c3d8bc441a27a8c..9701654c8349f8cebb86ac61b13bd1f945db3f79 100644 (file)
@@ -187,7 +187,7 @@ cfile_open_failure_alert_box(const char *filename, int err, gchar *err_info,
 
         case WTAP_ERR_DECOMPRESS:
             simple_error_message_box(
-                        "The compressed file \"%s\" appears to be damaged or corrupt.\n"
+                        "The file \"%s\" cannot be decompressed; it may be damaged or corrupt.\n"
                         "(%s)", display_basename,
                         err_info != NULL ? err_info : "no information supplied");
             g_free(err_info);
@@ -225,7 +225,7 @@ cfile_read_failure_alert_box(const char *filename, int err, gchar *err_info)
         gchar *display_basename;
 
         display_basename = g_filename_display_basename(filename);
-        display_name = g_strdup_printf("capture file %s", display_basename);
+        display_name = g_strdup_printf("capture file \"%s\"", display_basename);
         g_free(display_basename);
     }
 
@@ -233,7 +233,8 @@ cfile_read_failure_alert_box(const char *filename, int err, gchar *err_info)
 
     case WTAP_ERR_UNSUPPORTED:
         simple_error_message_box(
-                    "The %s contains record data that Wireshark doesn't support.\n(%s)",
+                    "The %s contains record data that Wireshark doesn't support.\n"
+                    "(%s)",
                    display_name,
                     err_info != NULL ? err_info : "no information supplied");
         g_free(err_info);
@@ -247,7 +248,8 @@ cfile_read_failure_alert_box(const char *filename, int err, gchar *err_info)
 
     case WTAP_ERR_BAD_FILE:
         simple_error_message_box(
-                    "The %s appears to be damaged or corrupt.\n(%s)",
+                    "The %s appears to be damaged or corrupt.\n"
+                    "(%s)",
                     display_name,
                     err_info != NULL ? err_info : "no information supplied");
         g_free(err_info);
@@ -255,7 +257,8 @@ cfile_read_failure_alert_box(const char *filename, int err, gchar *err_info)
 
     case WTAP_ERR_DECOMPRESS:
         simple_error_message_box(
-                    "The compressed %s appears to be damaged or corrupt.\n(%s)",
+                    "The %s cannot be decompressed; it may be damaged or corrupt.\n"
+                    "(%s)",
                     display_name,
                     err_info != NULL ? err_info : "no information supplied");
         g_free(err_info);
@@ -330,12 +333,21 @@ cfile_write_failure_alert_box(const char *filename, int err, gchar *err_info,
              * the frame number and file type/subtype.
              */
             simple_error_message_box(
-                        "Record %u has data that can't be saved in a \"%s\" file.\n(%s)",
+                        "Record %u has data that can't be saved in a \"%s\" file.\n"
+                        "(%s)",
                         framenum, wtap_file_type_subtype_string(file_type_subtype),
                         err_info != NULL ? err_info : "no information supplied");
             g_free(err_info);
             break;
 
+        case WTAP_ERR_SHORT_WRITE:
+            display_basename = g_filename_display_basename(filename);
+            simple_error_message_box(
+                        "A full write couldn't be done to the file \"%s\".",
+                        display_basename);
+            g_free(display_basename);
+            break;
+
         default:
             display_basename = g_filename_display_basename(filename);
             simple_error_message_box(
@@ -396,7 +408,7 @@ cfile_close_failure_alert_box(const char *filename, int err)
 
         case WTAP_ERR_SHORT_WRITE:
             simple_error_message_box(
-                        "Not all the packets could be written to the file \"%s\".",
+                        "A full write couldn't be done to the file \"%s\".",
                         display_basename);
             break;
 
index ea73946530a849d2a23c83cc7544da1fd3e4b39e..74c56ce5a2b74edc4317e8211de04a38638a402b 100644 (file)
@@ -179,7 +179,7 @@ cfile_open_failure_message(const char *progname, const char *filename,
 
         case WTAP_ERR_DECOMPRESS:
             /* Seen only when opening a capture file for reading. */
-            cmdarg_err("The %s is compressed and appears to be damaged or corrupt.\n"
+            cmdarg_err("The %s cannot be decompressed; it may be damaged or corrupt."
                        "(%s)",
                        file_description,
                        err_info != NULL ? err_info : "no information supplied");
@@ -216,7 +216,8 @@ cfile_read_failure_message(const char *progname, const char *filename,
     switch (err) {
 
     case WTAP_ERR_UNSUPPORTED:
-        cmdarg_err("The %s contains record data that %s doesn't support.\n(%s)",
+        cmdarg_err("The %s contains record data that %s doesn't support.\n"
+                   "(%s)",
                    file_string, progname,
                    err_info != NULL ? err_info : "no information supplied");
         g_free(err_info);
@@ -228,15 +229,17 @@ cfile_read_failure_message(const char *progname, const char *filename,
         break;
 
     case WTAP_ERR_BAD_FILE:
-        cmdarg_err("The %s appears to be damaged or corrupt.\n(%s)",
+        cmdarg_err("The %s appears to be damaged or corrupt.\n"
+                   "(%s)",
                    file_string,
                    err_info != NULL ? err_info : "no information supplied");
         g_free(err_info);
         break;
 
     case WTAP_ERR_DECOMPRESS:
-        cmdarg_err("The %s is compressed and appears to be damaged or corrupt.\n"
-                   "(%s)", file_string,
+        cmdarg_err("The %s cannot be decompressed; it may be damaged or corrupt.\n"
+                   "(%s)",
+                   file_string,
                    err_info != NULL ? err_info : "no information supplied");
         g_free(err_info);
         break;
@@ -259,9 +262,9 @@ cfile_read_failure_message(const char *progname, const char *filename,
  * written.
  */
 void
-cfile_write_failure_message(const char *in_filename, const char *out_filename,
-                            int err, gchar *err_info, guint32 framenum,
-                            int file_type_subtype)
+cfile_write_failure_message(const char *progname, const char *in_filename,
+                            const char *out_filename, int err, gchar *err_info,
+                            guint32 framenum, int file_type_subtype)
 {
     char *in_file_string;
     char *out_file_string;
@@ -280,7 +283,7 @@ cfile_write_failure_message(const char *in_filename, const char *out_filename,
          * and the file type and subtype we're writing; note that,
          * and report the frame number and file type/subtype.
          */
-        cmdarg_err("Frame %u of %s has a network type that can't be saved in a \"%s\" file.\n",
+        cmdarg_err("Frame %u of %s has a network type that can't be saved in a \"%s\" file.",
                    framenum, in_file_string,
                    wtap_file_type_subtype_short_string(file_type_subtype));
         break;
@@ -291,8 +294,8 @@ cfile_write_failure_message(const char *in_filename, const char *out_filename,
          * and the file type and subtype we're writing; note that,
          * and report the frame number and file type/subtype.
          */
-        cmdarg_err("Frame %u of %s is too large for a \"%s\" file.\n",
-                   framenum, in_file_string,
+        cmdarg_err("Frame %u of %s is larger than %s supports in a \"%s\" file.",
+                   framenum, in_file_string, progname,
                    wtap_file_type_subtype_short_string(file_type_subtype));
         break;
 
@@ -302,7 +305,7 @@ cfile_write_failure_message(const char *in_filename, const char *out_filename,
          * and the file type and subtype we're writing; note that,
          * and report the record number and file type/subtype.
          */
-        cmdarg_err("Record %u of %s has a record type that can't be saved in a \"%s\" file.\n",
+        cmdarg_err("Record %u of %s has a record type that can't be saved in a \"%s\" file.",
                    framenum, in_file_string,
                    wtap_file_type_subtype_short_string(file_type_subtype));
         break;
@@ -313,7 +316,8 @@ cfile_write_failure_message(const char *in_filename, const char *out_filename,
          * and the file type and subtype we're writing; note that,
          * and report the record number and file type/subtype.
          */
-        cmdarg_err("Record %u of %s has data that can't be saved in a \"%s\" file.\n(%s)\n",
+        cmdarg_err("Record %u of %s has data that can't be saved in a \"%s\" file.\n"
+                   "(%s)",
                    framenum, in_file_string,
                    wtap_file_type_subtype_short_string(file_type_subtype),
                    err_info != NULL ? err_info : "no information supplied");
@@ -405,8 +409,8 @@ cfile_close_failure_message(const char *filename, int err)
         break;
 
     default:
-        cmdarg_err("The %s could not be closed: %s.", file_string,
-                   wtap_strerror(err));
+        cmdarg_err("An error occurred while closing the file %s: %s.",
+                   file_string, wtap_strerror(err));
         break;
     }
     g_free(file_string);
index 95814ff3ff05eeacb7ff29dceeddf5ccca558377..1f9c48732bd26070f61d82f3f5ff59438396638b 100644 (file)
@@ -62,7 +62,8 @@ extern void cfile_read_failure_message(const char *progname,
  * WTAP_FILE_TYPE_SUBTYPE_ value for the type and subtype of file being
  * written.
  */
-extern void cfile_write_failure_message(const char *in_filename,
+extern void cfile_write_failure_message(const char *progname,
+                                        const char *in_filename,
                                         const char *out_filename,
                                         int err, gchar *err_info,
                                         guint32 framenum,