Make the command-line and alert-box failure messages more similar.

Change-Id: I94af221a0ce8b6b3ff8e0e1b94d5379351ac0962
Reviewed-on: https://code.wireshark.org/review/21251
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2017-04-20 10:14:50 -07:00
parent 46f0c351a9
commit d09ef61459
6 changed files with 50 additions and 30 deletions

View File

@ -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);

View 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);
}
}

View File

@ -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);

View 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;

View 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);

View 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,