diff options
author | Jean Delvare <jdelvare@suse.de> | 2020-04-01 09:57:56 +0200 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2020-04-01 10:00:14 +0200 |
commit | 5893721859b73354a935135b4aee297bd41a5b1a (patch) | |
tree | fa96dcb1bd07701c5bb1d9fc4dee9cfa1da46274 /dmioutput.c | |
parent | 07968a8a578d34137eb6db0c26b860c567f60903 (diff) | |
download | dmidecode-git-5893721859b73354a935135b4aee297bd41a5b1a.tar.gz |
dmidecode: Add helper functions pr_list_start/item/end
Print lists through helper functions. pr_list_start() starts the
list, with an optional value. pr_list_item() prints a single item.
pr_list_end() is a no-op for plain text output, but is in place in
anticipation of supporting other output formats such as HTML.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Diffstat (limited to 'dmioutput.c')
-rw-r--r-- | dmioutput.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dmioutput.c b/dmioutput.c index 2330b65..4c8a32a 100644 --- a/dmioutput.c +++ b/dmioutput.c @@ -71,3 +71,38 @@ void pr_attr(const char *name, const char *format, ...) va_end(args); printf("\n"); } + +void pr_list_start(const char *name, const char *format, ...) +{ + va_list args; + + printf("\t%s:", name); + + /* format is optional, skip value if not provided */ + if (format) + { + printf(" "); + va_start(args, format); + vprintf(format, args); + va_end(args); + } + printf("\n"); + +} + +void pr_list_item(const char *format, ...) +{ + va_list args; + + printf("\t\t"); + + va_start(args, format); + vprintf(format, args); + va_end(args); + printf("\n"); +} + +void pr_list_end(void) +{ + /* a no-op for text output */ +} |