/*
 * Open/create errors are reported with an console message in "dftest".
 */
static void
open_failure_message(const char *filename, int err, gboolean for_writing)
{
	fprintf(stderr, "dftest: ");
	fprintf(stderr, file_open_error_message(err, for_writing), filename);
	fprintf(stderr, "\n");
}
Exemple #2
0
/*
 * Alert box for a failed attempt to open or create a file.
 * "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if
 * the file is being opened for writing and FALSE if it's being opened
 * for reading.
 *
 * XXX - add explanatory secondary text for at least some of the errors;
 * various HIGs suggest that you should, for example, suggest that the
 * user remove files if the file system is full.  Perhaps that's because
 * they're providing guidelines for people less sophisticated than the
 * typical Wireshark user is, but....
 */
void
open_failure_alert_box(const char *filename, int err, gboolean for_writing)
{
    gchar *display_basename;

    display_basename = g_filename_display_basename(filename);
    simple_message_box(ESD_TYPE_ERROR, NULL, NULL,
                        file_open_error_message(err, for_writing),
                        display_basename);
    g_free(display_basename);
}
Exemple #3
0
/*
 * Alert box for a failed attempt to open or create a file.
 * "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if
 * the file is being opened for writing and FALSE if it's being opened
 * for reading.
 *
 * XXX - add explanatory secondary text for at least some of the errors;
 * various HIGs suggest that you should, for example, suggest that the
 * user remove files if the file system is full.  Perhaps that's because
 * they're providing guidelines for people less sophisticated than the
 * typical Wireshark user is, but....
 */
void
open_failure_alert_box(const char *filename, int err, gboolean for_writing)
{
  simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                file_open_error_message(err, for_writing), filename);
}
static const char *cf_open_error_message(int err, gchar *err_info, int file_type)
{
  const char *errmsg;
  static char errmsg_errno[1024+1];

  if (err < 0)
    {
      /* Wiretap error. */
      switch (err)
	{
	  
	case WTAP_ERR_NOT_REGULAR_FILE:
	  errmsg = "The file \"%s\" is a \"special file\" or socket or other non-regular file.";
	  break;
	  
	case WTAP_ERR_FILE_UNKNOWN_FORMAT:
	  /* Seen only when opening a capture file for reading. */
	  errmsg = "The file \"%s\" isn't a capture file in a format Sharktools understands.";
	  break;
	  
	case WTAP_ERR_UNSUPPORTED:
	  /* Seen only when opening a capture file for reading. */
	  g_snprintf(errmsg_errno, sizeof(errmsg_errno),
		     "The file \"%%s\" isn't a capture file in a format Sharktools understands.\n"
		     "(%s)", err_info);
	  g_free(err_info);
	  errmsg = errmsg_errno;
	  break;
	  
	case WTAP_ERR_CANT_WRITE_TO_PIPE:
	  /* Seen only when opening a capture file for writing. */
	  g_snprintf(errmsg_errno, sizeof(errmsg_errno),
		     "The file \"%%s\" is a pipe, and %s capture files can't be "
		     "written to a pipe.", wtap_file_type_string(file_type));
	  errmsg = errmsg_errno;
	  break;
	  
	case WTAP_ERR_UNSUPPORTED_FILE_TYPE:
	  /* Seen only when opening a capture file for writing. */
	  errmsg = "Sharktools doesn't support writing capture files in that format.";
	  break;
	  
	case WTAP_ERR_UNSUPPORTED_ENCAP:
	  g_snprintf(errmsg_errno, sizeof(errmsg_errno),
		     "The file \"%%s\" is a capture for a network type that Sharktools doesn't support.\n"
		     "(%s)", err_info);
	  g_free(err_info);
	  errmsg = errmsg_errno;
	  break;
	  
	case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
	  errmsg = "The file \"%s\" is a capture for a network type that Sharktools doesn't support.";
	  break;
	  
	case WTAP_ERR_BAD_RECORD:
	  /* Seen only when opening a capture file for reading. */
	  g_snprintf(errmsg_errno, sizeof(errmsg_errno),
		     "The file \"%%s\" appears to be damaged or corrupt.\n"
		     "(%s)", err_info);
	  g_free(err_info);
	  errmsg = errmsg_errno;
	  break;
	  
	case WTAP_ERR_CANT_OPEN:
	  errmsg = "The file \"%s\" could not be opened for some unknown reason.";
	  break;
	  
	case WTAP_ERR_SHORT_READ:
	  errmsg = "The file \"%s\" appears to have been cut short"
	    " in the middle of a packet or other data.";
	  break;
	  
	case WTAP_ERR_SHORT_WRITE:
	  errmsg = "A full header couldn't be written to the file \"%s\".";
	  break;
	  
	default:
	  g_snprintf(errmsg_errno, sizeof(errmsg_errno),
		     "The file \"%%s\" could not be opened: %s.",
		     wtap_strerror(err));
	  errmsg = errmsg_errno;
	  break;
	}
    }
  else
    // FALSE == for_writing == FALSE
    errmsg = file_open_error_message(err, FALSE);
  return errmsg;
}
Exemple #5
0
static const char *
cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
                      int file_type)
{
    const char *errmsg;
    static char errmsg_errno[1024+1];

    if (err < 0) {
        /* Wiretap error. */
        switch (err) {

        case WTAP_ERR_NOT_REGULAR_FILE:
            errmsg = "The file \"%s\" is a \"special file\" or socket or other non-regular file.";
            break;

        case WTAP_ERR_FILE_UNKNOWN_FORMAT:
            /* Seen only when opening a capture file for reading. */
            errmsg = "The file \"%s\" isn't a capture file in a format Wireshark understands.";
            break;

        case WTAP_ERR_UNSUPPORTED:
            /* Seen only when opening a capture file for reading. */
            g_snprintf(errmsg_errno, sizeof(errmsg_errno),
                       "The file \"%%s\" contains record data that Wireshark doesn't support.\n"
                       "(%s)", err_info != NULL ? err_info : "no information supplied");
            g_free(err_info);
            errmsg = errmsg_errno;
            break;

        case WTAP_ERR_CANT_WRITE_TO_PIPE:
            /* Seen only when opening a capture file for writing. */
            g_snprintf(errmsg_errno, sizeof(errmsg_errno),
                       "The file \"%%s\" is a pipe, and %s capture files can't be "
                       "written to a pipe.", wtap_file_type_subtype_string(file_type));
            errmsg = errmsg_errno;
            break;

        case WTAP_ERR_UNWRITABLE_FILE_TYPE:
            /* Seen only when opening a capture file for writing. */
            errmsg = "Wireshark doesn't support writing capture files in that format.";
            break;

        case WTAP_ERR_UNWRITABLE_ENCAP:
            /* Seen only when opening a capture file for writing. */
            errmsg = "Wireshark can't save this capture in that format.";
            break;

        case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
            if (for_writing)
                errmsg = "Wireshark can't save this capture in that format.";
            else
                errmsg = "The file \"%s\" is a capture for a network type that Wireshark doesn't support.";
            break;

        case WTAP_ERR_BAD_FILE:
            /* Seen only when opening a capture file for reading. */
            g_snprintf(errmsg_errno, sizeof(errmsg_errno),
                       "The file \"%%s\" appears to be damaged or corrupt.\n"
                       "(%s)", err_info != NULL ? err_info : "no information supplied");
            g_free(err_info);
            errmsg = errmsg_errno;
            break;

        case WTAP_ERR_CANT_OPEN:
            if (for_writing)
                errmsg = "The file \"%s\" could not be created for some unknown reason.";
            else
                errmsg = "The file \"%s\" could not be opened for some unknown reason.";
            break;

        case WTAP_ERR_SHORT_READ:
            errmsg = "The file \"%s\" appears to have been cut short"
                " in the middle of a packet or other data.";
            break;

        case WTAP_ERR_SHORT_WRITE:
            errmsg = "A full header couldn't be written to the file \"%s\".";
            break;

        case WTAP_ERR_DECOMPRESS:
            g_snprintf(errmsg_errno, sizeof(errmsg_errno),
                       "The compressed file \"%%s\" appears to be damaged or corrupt.\n"
                       "(%s)", err_info != NULL ? err_info : "no information supplied");
            g_free(err_info);
            errmsg = errmsg_errno;
            break;

        default:
            g_snprintf(errmsg_errno, sizeof(errmsg_errno),
                       "The file \"%%s\" could not be %s: %s.",
                       for_writing ? "created" : "opened",
                       wtap_strerror(err));
            errmsg = errmsg_errno;
            break;
        }
    } else
        errmsg = file_open_error_message(err, for_writing);
    return errmsg;
}