Next: , Previous: , Up: Input and Output Formats   [Contents][Index]

2.2.2 Format Utility Functions

These functions work with struct fmt_specs.

Function: int fmt_var_width (const struct fmt_spec *format)

Returns the width for values associated with format. If format is a numeric format, the width is 0; if format is an A format, then the width format->w; otherwise, format is an AHEX format and its width is format->w / 2.

Function: char *fmt_to_string (const struct fmt_spec *format, char s[FMT_STRING_LEN_MAX + 1])

Converts format to a human-readable format specifier in s and returns s. format need not be a valid input or output format specifier, e.g. it is allowed to have an excess width or decimal places. In particular, if format has decimals, they are included in the output string, even if format’s type does not allow decimals, to allow accurately presenting incorrect formats to the user.

Function: bool fmt_equal (const struct fmt_spec *a, const struct fmt_spec *b)

Compares a and b memberwise and returns true if they are identical, false otherwise. format need not be a valid input or output format specifier.

Function: void fmt_resize (struct fmt_spec *fmt, int width)

Sets the width of fmt to a valid format for a union value of size width.