ssize_t fr_pair_print_value_quoted(fr_sbuff_t *out, fr_pair_t const *vp, fr_token_t quote)
{
fr_sbuff_t our_out;
+ ssize_t slen;
PAIR_VERIFY(vp);
+ our_out = FR_SBUFF(out);
+
switch (vp->vp_type) {
/*
* For structural types descend down
*/
case FR_TYPE_STRUCTURAL:
- our_out = FR_SBUFF(out);
if (fr_pair_list_empty(&vp->vp_group)) {
FR_SBUFF_IN_CHAR_RETURN(&our_out, '{', ' ', '}');
* For simple types just print the box
*/
default:
- return fr_value_box_print_quoted(out, &vp->data, quote);
+ /*
+ * If it's raw / unknown and not octets, print the cast before the type.
+ *
+ * Otherwise on parsing, we don't know how to interpret the value. :(
+ */
+ if ((vp->da->flags.is_raw || vp->da->flags.is_unknown) &&
+ (vp->vp_type != FR_TYPE_OCTETS)) {
+ FR_SBUFF_IN_SPRINTF_RETURN(&our_out, "(%s) ", fr_type_to_str(vp->vp_type));
+ }
+
+ slen = fr_value_box_print_quoted(&our_out, &vp->data, quote);
+ if (slen <= 0) return slen;
}
+
+ FR_SBUFF_SET_RETURN(out, &our_out);
}
/** Print one attribute and value to a string
# But because CBOR is typed, we can decode typed data.
#
decode-pair 9f a1 18 1a 9f a1 19 19 7f 9f a1 18 ff d9 03 ea a2 01 19 0e 10 28 1a 1d cd 65 00 ff ff ff
-match Vendor-Specific = { Nokia-SR = { raw.255 = 3600.5 } }
+match Vendor-Specific = { Nokia-SR = { raw.255 = (time_delta) 3600.5 } }
#
# Note that we have to add a cast here :(