xlat: add support for xlat_styles in printxval_dispatch
* defs.h (printxval_dispatch_ex): Rename from printxval_dispatch, add style argument. (printxval_dispatch): New static inline function, a thin wrapper around printxval_dispatch_ex. * xlat.c (printxval_dispatch): Rename to printxval_dispatch_ex, add style argument, handle it. Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
parent
947627ed15
commit
3869880887
13
defs.h
13
defs.h
@ -676,9 +676,16 @@ extern int sprintxval_ex(char *buf, size_t size, const struct xlat *xlat,
|
||||
sprintxval_ex((buf_), (size_), (xlat_), (val_), (dflt_), \
|
||||
XLAT_STYLE_DEFAULT)
|
||||
|
||||
extern void printxval_dispatch(const struct xlat *, size_t xlat_size,
|
||||
uint64_t val, const char *dflt,
|
||||
enum xlat_type);
|
||||
extern void printxval_dispatch_ex(const struct xlat *, size_t xlat_size,
|
||||
uint64_t val, const char *dflt,
|
||||
enum xlat_type, enum xlat_style);
|
||||
static inline void
|
||||
printxval_dispatch(const struct xlat *xlat, size_t xlat_size, uint64_t val,
|
||||
const char *dflt, enum xlat_type xt)
|
||||
{
|
||||
return printxval_dispatch_ex(xlat, xlat_size, val, dflt, xt,
|
||||
XLAT_STYLE_DEFAULT);
|
||||
}
|
||||
|
||||
/** Print a value in accordance with xlat formatting settings. */
|
||||
extern void print_xlat_ex(uint64_t val, const char *str, enum xlat_style style);
|
||||
|
11
xlat.c
11
xlat.c
@ -455,20 +455,21 @@ print_xlat_ex(const uint64_t val, const char *str, enum xlat_style style)
|
||||
}
|
||||
|
||||
void
|
||||
printxval_dispatch(const struct xlat *xlat, size_t xlat_size, uint64_t val,
|
||||
const char *dflt, enum xlat_type xt)
|
||||
printxval_dispatch_ex(const struct xlat *xlat, size_t xlat_size, uint64_t val,
|
||||
const char *dflt, enum xlat_type xt,
|
||||
enum xlat_style style)
|
||||
{
|
||||
switch (xt) {
|
||||
case XT_NORMAL:
|
||||
printxval64(xlat, val, dflt);
|
||||
printxvals_ex(val, dflt, style, xlat, NULL);
|
||||
break;
|
||||
|
||||
case XT_SORTED:
|
||||
printxval_searchn(xlat, xlat_size, val, dflt);
|
||||
printxval_searchn_ex(xlat, xlat_size, val, dflt, style);
|
||||
break;
|
||||
|
||||
case XT_INDEXED:
|
||||
printxval_indexn(xlat, xlat_size, val, dflt);
|
||||
printxval_indexn_ex(xlat, xlat_size, val, dflt, style);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user