diff options
author | Karel Zak | 2014-08-13 10:10:11 +0200 |
---|---|---|
committer | Karel Zak | 2014-08-13 10:10:11 +0200 |
commit | d44115f3b5866f76ceaefd0d145468e68d7e2688 (patch) | |
tree | d7d83433edd97bbefaf9539c10f95b42937b4145 /libfdisk/src/table.c | |
parent | lib/colors: add function to return color from scheme (diff) | |
download | kernel-qcow2-util-linux-d44115f3b5866f76ceaefd0d145468e68d7e2688.tar.gz kernel-qcow2-util-linux-d44115f3b5866f76ceaefd0d145468e68d7e2688.tar.xz kernel-qcow2-util-linux-d44115f3b5866f76ceaefd0d145468e68d7e2688.zip |
libfdisk: remove dependence on libsmartcols
It's application business to convert libfdisk_table to string.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/table.c')
-rw-r--r-- | libfdisk/src/table.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c index acdb365d0..61876d0ef 100644 --- a/libfdisk/src/table.c +++ b/libfdisk/src/table.c @@ -1,5 +1,4 @@ -#include <libsmartcols.h> #include "fdiskP.h" /** @@ -547,96 +546,3 @@ int fdisk_table_wrong_order(struct fdisk_table *tb) } return 0; } - -/** - * fdisk_table_to_string - * @tb: table - * @cxt: fdisk context - * @cols: array with wanted FDISK_COL_* columns - * @ncols: number of items in the cols array - * @data: returns table as a newlly allocated string or NULL for empty PT - * - * If no @cols are specified then the default is printed (see - * fdisk_get_columns() for the default columns). - - * Returns 0 on success, otherwise, a corresponding error. - */ -int fdisk_table_to_string(struct fdisk_table *tb, - struct fdisk_context *cxt, - int *cols, - size_t ncols, - char **data) -{ - int *org_cols = cols, rc = 0; - struct libscols_table *table = NULL; - const struct fdisk_column *col; - struct fdisk_partition *pa = NULL; - struct fdisk_iter itr; - size_t j; - - if (!cxt || !tb || !data) - return -EINVAL; - - DBG(TAB, ul_debugobj(tb, "generate string")); - *data = NULL; - - if (!fdisk_table_get_nents(tb)) - return 0; - - if (!cols || !ncols) { - rc = fdisk_get_columns(cxt, 0, &cols, &ncols); - if (rc) - return rc; - } - - table = scols_new_table(); - if (!table) { - rc = -ENOMEM; - goto done; - } - - /* define columns */ - for (j = 0; j < ncols; j++) { - col = fdisk_label_get_column(cxt->label, cols[j]); - if (col) - if (!scols_table_new_column(table, col->name, col->width, col->scols_flags)) - goto done; - } - - fdisk_reset_iter(&itr, FDISK_ITER_FORWARD); - - /* convert partition to string and add to table */ - while (fdisk_table_next_partition(tb, &itr, &pa) == 0) { - struct libscols_line *ln = scols_table_new_line(table, NULL); - if (!ln) { - rc = -ENOMEM; - goto done; - } - - DBG(TAB, ul_debugobj(tb, " string from part #%zu [%p]", - pa->partno + 1, pa)); - - /* set data for the columns */ - for (j = 0; j < ncols; j++) { - char *cdata = NULL; - - col = fdisk_label_get_column(cxt->label, cols[j]); - if (!col) - continue; - if (fdisk_partition_to_string(pa, cxt, col->id, &cdata)) - continue; - scols_line_refer_data(ln, j, cdata); - } - } - - rc = 0; - if (!scols_table_is_empty(table)) - rc = scols_print_table_to_string(table, data); - else - DBG(TAB, ul_debugobj(tb, "table empty")); -done: - if (org_cols != cols) - free(cols); - scols_unref_table(table); - return rc; -} |