diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2011-06-21 00:57:08 +0200 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2011-06-21 00:57:08 +0200 |
commit | fa45333391cae255e5d9c9da72ebc0fd81a56ea0 (patch) | |
tree | 1ae3636f5c7bd25e25a103b0e39641c85be5e16c /regulator.c | |
parent | 0a8cc5880b9ba3fa8ef257329017f9d6d81e35b5 (diff) |
Factor out display code
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'regulator.c')
-rw-r--r-- | regulator.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/regulator.c b/regulator.c index 696ed10..4151fdb 100644 --- a/regulator.c +++ b/regulator.c @@ -138,13 +138,31 @@ static int regulator_display_cb(struct tree *t, void *data) return 0; } +static int regulator_print_header(void) +{ + char *buf; + int ret; + + if (asprintf(&buf, "%-11s %-11s %-11s %-11s %-11s %-11s %-11s %-12s", + "Name", "Status", "State", "Type", "Users", "Microvolts", + "Min u-volts", "Max u-volts") < 0) + return -1; + + ret = display_header_footer(REGULATOR, buf); + + free(buf); + + return ret; + +} + int regulator_display(void) { int ret, line = 0; display_reset_cursor(REGULATOR); - print_regulator_header(); + regulator_print_header(); ret = tree_for_each(reg_tree, regulator_display_cb, &line); |