summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/symbols.c
diff options
context:
space:
mode:
authorIgor Gnatenko2016-01-21 17:09:16 +0100
committerIgor Gnatenko2016-01-21 17:09:16 +0100
commitcd32dc248cca891b872391d3472cafc8b8e23385 (patch)
tree1efce804517c1e33e6b5e37f17abe125f0a972c1 /libsmartcols/src/symbols.c
parentlibsmartcols: implement title of table (diff)
downloadkernel-qcow2-util-linux-cd32dc248cca891b872391d3472cafc8b8e23385.tar.gz
kernel-qcow2-util-linux-cd32dc248cca891b872391d3472cafc8b8e23385.tar.xz
kernel-qcow2-util-linux-cd32dc248cca891b872391d3472cafc8b8e23385.zip
libsmartcols: use symbols for title wrap
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Diffstat (limited to 'libsmartcols/src/symbols.c')
-rw-r--r--libsmartcols/src/symbols.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/libsmartcols/src/symbols.c b/libsmartcols/src/symbols.c
index c19df0255..dfe2ba7b6 100644
--- a/libsmartcols/src/symbols.c
+++ b/libsmartcols/src/symbols.c
@@ -2,6 +2,7 @@
* symbols.c - routines for symbol handling
*
* Copyright (C) 2014 Ondrej Oprala <ooprala@redhat.com>
+ * Copyright (C) 2016 Igor Gnatenko <i.gnatenko.brain@gmail.com>
*
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
@@ -61,6 +62,7 @@ void scols_unref_symbols(struct libscols_symbols *sy)
free(sy->branch);
free(sy->vert);
free(sy->right);
+ free(sy->title_wrap);
free(sy);
}
}
@@ -141,6 +143,31 @@ int scols_symbols_set_right(struct libscols_symbols *sb, const char *str)
}
/**
+ * scols_symbols_set_title_wrap:
+ * @sb: a pointer to a struct libscols_symbols instance
+ * @str: a string which will represent the symbols which wraps title output
+ *
+ * Returns: 0, a negative value in case of an error.
+ */
+int scols_symbols_set_title_wrap(struct libscols_symbols *sb, const char *str)
+{
+ char *p = NULL;
+
+ assert(sb);
+
+ if (!sb)
+ return -EINVAL;
+ if (str) {
+ p = strdup(str);
+ if (!p)
+ return -ENOMEM;
+ }
+ free(sb->title_wrap);
+ sb->title_wrap = p;
+ return 0;
+}
+
+/**
* scols_copy_symbols:
* @sb: a pointer to a struct libscols_symbols instance
*
@@ -165,11 +192,11 @@ struct libscols_symbols *scols_copy_symbols(const struct libscols_symbols *sb)
if (!rc)
rc = scols_symbols_set_right(ret, sb->right);
if (!rc)
+ rc = scols_symbols_set_title_wrap(ret, sb->title_wrap);
+ if (!rc)
return ret;
scols_unref_symbols(ret);
return NULL;
}
-
-