-static void
-cfile_open_failure_message(const char *filename, int err, gchar *err_info,
- gboolean for_writing, int file_type)
-{
- char *file_description;
-
- /* Get a string that describes what we're opening */
- if (strcmp(filename, "-") == 0) {
- /* We're opening the standard input/output */
- file_description = g_strdup(for_writing ? "standard output" : "standard input");
- } else {
- /* We're opening a file with the name in filename */
- file_description = g_strdup_printf("file \"%s\"", filename);
- }
- if (err < 0) {
- /* Wiretap error. */
- switch (err) {
-
- case WTAP_ERR_NOT_REGULAR_FILE:
- cmdarg_err("The %s is a \"special file\" or socket or other non-regular file.",
- file_description);
- break;
-
- case WTAP_ERR_RANDOM_OPEN_PIPE:
- /* Seen only when opening a capture file for reading. */
- cmdarg_err("The %s is a pipe or FIFO; TShark can't read pipe or FIFO files in two-pass mode.",
- file_description);
- break;
-
- case WTAP_ERR_FILE_UNKNOWN_FORMAT:
- /* Seen only when opening a capture file for reading. */
- cmdarg_err("The %s isn't a capture file in a format TShark understands.",
- file_description);
- break;
-
- case WTAP_ERR_UNSUPPORTED:
- /* Seen only when opening a capture file for reading. */
- cmdarg_err("The %s contains record data that TShark doesn't support.\n"
- "(%s)",
- file_description,
- err_info != NULL ? err_info : "no information supplied");
- g_free(err_info);
- break;
-
- case WTAP_ERR_CANT_WRITE_TO_PIPE:
- /* Seen only when opening a capture file for writing. */
- cmdarg_err("The %s is a pipe, and \"%s\" capture files can't be written to a pipe.",
- file_description,
- wtap_file_type_subtype_short_string(file_type));
- break;
-
- case WTAP_ERR_UNWRITABLE_FILE_TYPE:
- /* Seen only when opening a capture file for writing. */
- cmdarg_err("TShark doesn't support writing capture files in that format.");
- break;
-
- case WTAP_ERR_UNWRITABLE_ENCAP:
- /* Seen only when opening a capture file for writing. */
- cmdarg_err("The capture file being read can't be written as a \"%s\" file.",
- wtap_file_type_subtype_short_string(file_type));
- break;
-
- case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
- if (for_writing) {
- cmdarg_err("The capture file being read can't be written as a \"%s\" file.",
- wtap_file_type_subtype_short_string(file_type));
- } else {
- cmdarg_err("The %s is a capture for a network type that TShark doesn't support.",
- file_description);
- }
- break;
-
- case WTAP_ERR_BAD_FILE:
- /* Seen only when opening a capture file for reading. */
- cmdarg_err("The %s appears to be damaged or corrupt.\n"
- "(%s)",
- file_description,
- err_info != NULL ? err_info : "no information supplied");
- g_free(err_info);
- break;
-
- case WTAP_ERR_CANT_OPEN:
- if (for_writing) {
- cmdarg_err("The %s could not be created for some unknown reason.",
- file_description);
- } else {
- cmdarg_err("The %s could not be opened for some unknown reason.",
- file_description);
- }
- break;
-
- case WTAP_ERR_SHORT_READ:
- cmdarg_err("The %s appears to have been cut short in the middle of a packet or other data.",
- file_description);
- break;
-
- case WTAP_ERR_SHORT_WRITE:
- cmdarg_err("A full header couldn't be written to the %s.",
- file_description);
- break;
-
- case WTAP_ERR_COMPRESSION_NOT_SUPPORTED:
- cmdarg_err("This file type cannot be written as a compressed file.");
- break;
-
- 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"
- "(%s)",
- file_description,
- err_info != NULL ? err_info : "no information supplied");
- g_free(err_info);
- break;
-
- default:
- cmdarg_err("The %s could not be %s: %s.",
- file_description,
- for_writing ? "created" : "opened",
- wtap_strerror(err));
- break;
- }
- g_free(file_description);
- } else
- cmdarg_err(file_open_error_message(err, for_writing), filename);
-}
-