summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/table.c
diff options
context:
space:
mode:
authorKarel Zak2017-07-31 11:45:23 +0200
committerKarel Zak2017-07-31 11:45:23 +0200
commit28a3cc83c56eca679302d8d51a5056b836e3c86e (patch)
treec3dd7e88405c2fd080c9ddd4bd078bd4ff39e81a /libsmartcols/src/table.c
parentagetty: fix --login-pause logic (diff)
downloadkernel-qcow2-util-linux-28a3cc83c56eca679302d8d51a5056b836e3c86e.tar.gz
kernel-qcow2-util-linux-28a3cc83c56eca679302d8d51a5056b836e3c86e.tar.xz
kernel-qcow2-util-linux-28a3cc83c56eca679302d8d51a5056b836e3c86e.zip
libsmartcols: add scols_table_enable_noencoding()
Now the library encode all output. It seems too strict and difficult to use the library for some use-cases -- for example if you want to use the library for already colorized output (by esc.sequences). Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/table.c')
-rw-r--r--libsmartcols/src/table.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libsmartcols/src/table.c b/libsmartcols/src/table.c
index 3306ff57c..81f4b8f2b 100644
--- a/libsmartcols/src/table.c
+++ b/libsmartcols/src/table.c
@@ -1107,6 +1107,39 @@ int scols_table_is_nowrap(const struct libscols_table *tb)
}
/**
+ * scols_table_enable_noencoding:
+ * @tb: table
+ * @enable: 1 or 0
+ *
+ * The library encode non-printable and control chars by \x<hex> by default.
+ *
+ * Returns: 0 on success, negative number in case of an error.
+ *
+ * Since: 2.31
+ */
+int scols_table_enable_noencoding(struct libscols_table *tb, int enable)
+{
+ if (!tb)
+ return -EINVAL;
+ DBG(TAB, ul_debugobj(tb, "encoding: %s", enable ? "ENABLE" : "DISABLE"));
+ tb->no_encode = enable ? 1 : 0;
+ return 0;
+}
+
+/**
+ * scols_table_is_noencoding:
+ * @tb: a pointer to a struct libscols_table instance
+ *
+ * Returns: 1 if encoding is disabled.
+ *
+ * Since: 2.31
+ */
+int scols_table_is_noencoding(const struct libscols_table *tb)
+{
+ return tb->no_encode;
+}
+
+/**
* scols_table_colors_wanted:
* @tb: table
*