From 0c870c1c73985a5e153a35209a650bcacce94c5b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 29 Apr 2013 15:29:48 +0200 Subject: libfdisk: add new 'ask' type TABLE The new type could be used to print table-like output (for example list of the partitions). Signed-off-by: Karel Zak --- libfdisk/src/ask.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libfdisk/src/ask.c') diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c index 1b4791af3..a95d54233 100644 --- a/libfdisk/src/ask.c +++ b/libfdisk/src/ask.c @@ -408,6 +408,33 @@ int fdisk_ask_yesno_set_result(struct fdisk_ask *ask, uint64_t result) return 0; } +struct tt *fdisk_ask_get_table(struct fdisk_ask *ask) +{ + assert(ask); + assert(fdisk_is_ask(ask, TABLE)); + return ask->data.table; +} + +int fdisk_print_table(struct fdisk_context *cxt, struct tt *tb) +{ + struct fdisk_ask *ask; + int rc; + + assert(cxt); + assert(tb); + + ask = fdisk_new_ask(); + if (!ask) + return -ENOMEM; + + fdisk_ask_set_type(ask, FDISK_ASKTYPE_TABLE); + ask->data.table = tb; + + rc = fdisk_do_ask(cxt, ask); + + fdisk_free_ask(ask); + return rc; +} #define is_print_ask(a) (fdisk_is_ask(a, WARN) || fdisk_is_ask(a, WARNX) || fdisk_is_ask(a, INFO)) -- cgit v1.2.3-55-g7522