summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/table.c
diff options
context:
space:
mode:
authorKarel Zak2016-02-09 11:21:21 +0100
committerKarel Zak2016-02-09 11:21:21 +0100
commite865838d6ddcb0fed74e3819b503c6f7ccad452b (patch)
treeca7c032bcdc799177db7ab5781cb6e95bdf756dc /libsmartcols/src/table.c
parentlibfdisk: add missing break (diff)
downloadkernel-qcow2-util-linux-e865838d6ddcb0fed74e3819b503c6f7ccad452b.tar.gz
kernel-qcow2-util-linux-e865838d6ddcb0fed74e3819b503c6f7ccad452b.tar.xz
kernel-qcow2-util-linux-e865838d6ddcb0fed74e3819b503c6f7ccad452b.zip
libsmartcols: use libscols_cell for title
References: https://github.com/karelzak/util-linux/issues/270 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/table.c')
-rw-r--r--libsmartcols/src/table.c78
1 files changed, 3 insertions, 75 deletions
diff --git a/libsmartcols/src/table.c b/libsmartcols/src/table.c
index 23fc2bc1f..f91526bbd 100644
--- a/libsmartcols/src/table.c
+++ b/libsmartcols/src/table.c
@@ -88,6 +88,7 @@ void scols_unref_table(struct libscols_table *tb)
scols_table_remove_lines(tb);
scols_table_remove_columns(tb);
scols_unref_symbols(tb->symbols);
+ scols_reset_cell(&tb->title);
free(tb->linesep);
free(tb->colsep);
free(tb->name);
@@ -125,53 +126,6 @@ int scols_table_set_name(struct libscols_table *tb, const char *name)
}
/**
- * scols_table_set_title:
- * @tb: a pointer to a struct libscols_table instance
- * @title: a title
- * @position: a position
- * @color: color name or ESC sequence
- *
- * The table title is used to print header of table.
- *
- * Returns: 0, a negative number in case of an error.
- *
- * Since: 2.28
- */
-int scols_table_set_title(struct libscols_table *tb, const char *title, unsigned int position, const char *color)
-{
- char *p = NULL;
- char *q = NULL;
-
- if (!tb)
- return -EINVAL;
-
- if (title) {
- p = strdup(title);
- if (!p)
- return -ENOMEM;
- }
-
- if (color) {
- if (isalpha(*color)) {
- color = color_sequence_from_colorname(color);
-
- if (!color)
- return -EINVAL;
- }
- q = strdup(color);
- if (!q)
- return -ENOMEM;
- }
-
- free(tb->title);
- free(tb->title_color);
- tb->title = p;
- tb->title_color = q;
- tb->title_pos = position;
- return 0;
-}
-
-/**
* scols_table_get_title:
* @tb: a pointer to a struct libscols_table instance
*
@@ -179,35 +133,9 @@ int scols_table_set_title(struct libscols_table *tb, const char *title, unsigned
*
* Since: 2.28
*/
-const char *scols_table_get_title(struct libscols_table *tb)
-{
- return tb->title;
-}
-
-/**
- * scols_table_get_title_position:
- * @tb: a pointer to a struct libscols_table instance
- *
- * Returns: Title's position of the table.
- *
- * Since: 2.28
- */
-unsigned int scols_table_get_title_position(struct libscols_table *tb)
-{
- return tb->title_pos;
-}
-
-/**
- * scols_table_get_title_color:
- * @tb: a pointer to a struct libscols_table instance
- *
- * Returns: Title's color of the table, or %NULL in case of not set color.
- *
- * Since: 2.28
- */
-const char *scols_table_get_title_color(struct libscols_table *tb)
+struct libscols_cell *scols_table_get_title(struct libscols_table *tb)
{
- return tb->title_color;
+ return &tb->title;
}
/**