}
}
+static const char *
+hfinfo_format_text(const header_field_info *hfinfo, const guchar *string)
+{
+ switch (hfinfo->display) {
+ case STR_ASCII:
+ return format_text(string, strlen(string));
+/*
+ case STR_ASCII_WSP
+ return format_text_wsp(string, strlen(string));
+ */
+ case STR_UNICODE:
+ /* XXX, format_unicode_text() */
+ return string;
+ }
+
+ return format_text(string, strlen(string));
+}
+
static int
protoo_strlcpy(gchar *dest, const gchar *src, gsize dest_size)
{
case FT_UINT_STRING:
bytes = (guint8 *)fvalue_get(&finfo->value);
offset_r += protoo_strlcpy(result+offset_r,
- format_text(bytes, strlen(bytes)),
+ hfinfo_format_text(hfinfo, bytes),
size-offset_r);
break;
{ BASE_DEC_HEX|BASE_VAL64_STRING, "BASE_DEC_HEX|BASE_VAL64_STRING" },
{ BASE_HEX_DEC|BASE_VAL64_STRING, "BASE_HEX_DEC|BASE_VAL64_STRING" },
{ BASE_CUSTOM|BASE_VAL64_STRING, "BASE_CUSTOM|BASE_VAL64_STRING" },
+ /* { STR_ASCII, "STR_ASCII" }, */
+ { STR_UNICODE, "STR_UNICODE" },
{ ABSOLUTE_TIME_LOCAL, "ABSOLUTE_TIME_LOCAL" },
{ ABSOLUTE_TIME_UTC, "ABSOLUTE_TIME_UTC" },
{ ABSOLUTE_TIME_DOY_UTC, "ABSOLUTE_TIME_DOY_UTC" },
val_to_str(hfinfo->type, hf_types, "(Unknown: %d)"));
break;
+ case FT_STRING:
+ case FT_STRINGZ:
+ case FT_UINT_STRING:
+ switch (hfinfo->display) {
+ case STR_ASCII:
+ case STR_UNICODE:
+ break;
+
+ default:
+ g_error("Field '%s' (%s) is an string value (%s)"
+ " but is being displayed as %s\n",
+ hfinfo->name, hfinfo->abbrev,
+ val_to_str(hfinfo->type, hf_types, "(Unknown: %d)"),
+ val_to_str(hfinfo->display, hf_display, "(Unknown: 0x%x)"));
+ }
+
+ if (hfinfo->bitmask != 0)
+ g_error("Field '%s' (%s) is an %s but has a bitmask\n",
+ hfinfo->name, hfinfo->abbrev,
+ val_to_str(hfinfo->type, hf_types, "(Unknown: %d)"));
+ if (hfinfo->strings != NULL)
+ g_error("Field '%s' (%s) is an %s but has a strings value\n",
+ hfinfo->name, hfinfo->abbrev,
+ val_to_str(hfinfo->type, hf_types, "(Unknown: %d)"));
+ break;
+
default:
if (hfinfo->display != BASE_NONE)
g_error("Field '%s' (%s) is an %s but is being displayed as %s instead of BASE_NONE\n",
case FT_STRINGZ:
case FT_UINT_STRING:
bytes = (guint8 *)fvalue_get(&fi->value);
- label_fill(label_str, 0, hfinfo, format_text(bytes, strlen(bytes)));
+ label_fill(label_str, 0, hfinfo, hfinfo_format_text(hfinfo, bytes));
break;
default:
#define FIELD_DISPLAY_E_MASK 0x0F
typedef enum {
- BASE_NONE, /**< none */
- BASE_DEC, /**< decimal */
- BASE_HEX, /**< hexadecimal */
- BASE_OCT, /**< octal */
- BASE_DEC_HEX, /**< decimal (hexadecimal) */
- BASE_HEX_DEC, /**< hexadecimal (decimal) */
- BASE_CUSTOM /**< call custom routine (in ->strings) to format */
+/* Integral types */
+ BASE_NONE = 0, /**< none */
+ BASE_DEC = 1, /**< decimal */
+ BASE_HEX = 2, /**< hexadecimal */
+ BASE_OCT = 3, /**< octal */
+ BASE_DEC_HEX = 4, /**< decimal (hexadecimal) */
+ BASE_HEX_DEC = 5, /**< hexadecimal (decimal) */
+ BASE_CUSTOM = 6, /**< call custom routine (in ->strings) to format */
+
+/* String types */
+ STR_ASCII = BASE_NONE, /**< shows non-printable ASCII characters as C-style escapes */
+ /* XXX, support for format_text_wsp() ? */
+ STR_UNICODE = 7 /**< shows non-printable UNICODE characters as \uXXXX (XXX for now non-printable characters display depends on UI) */
} field_display_e;
/* Following constants have to be ORed with a field_display_e when dissector