summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/smartcolsP.h
diff options
context:
space:
mode:
authorKarel Zak2015-06-04 15:47:21 +0200
committerKarel Zak2015-06-04 15:47:21 +0200
commit2a6cfc1361e793c595f53987b83506382caa2d9b (patch)
tree293e018da8163f671572ec2d5cb47b4ba5b63961 /libsmartcols/src/smartcolsP.h
parentlibmount: (docs) fix wording (diff)
downloadkernel-qcow2-util-linux-2a6cfc1361e793c595f53987b83506382caa2d9b.tar.gz
kernel-qcow2-util-linux-2a6cfc1361e793c595f53987b83506382caa2d9b.tar.xz
kernel-qcow2-util-linux-2a6cfc1361e793c595f53987b83506382caa2d9b.zip
libsmartcols: add JSON output format
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/smartcolsP.h')
-rw-r--r--libsmartcols/src/smartcolsP.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/libsmartcols/src/smartcolsP.h b/libsmartcols/src/smartcolsP.h
index 511b182a2..c4fe725d0 100644
--- a/libsmartcols/src/smartcolsP.h
+++ b/libsmartcols/src/smartcolsP.h
@@ -122,7 +122,8 @@ struct libscols_line {
enum {
SCOLS_FMT_HUMAN = 0, /* default, human readable */
SCOLS_FMT_RAW, /* space separated */
- SCOLS_FMT_EXPORT /* COLNAME="data" ... */
+ SCOLS_FMT_EXPORT, /* COLNAME="data" ... */
+ SCOLS_FMT_JSON /* http://en.wikipedia.org/wiki/JSON */
};
/*
@@ -130,6 +131,7 @@ enum {
*/
struct libscols_table {
int refcount;
+ char *name; /* optional table table */
size_t ncols; /* number of columns */
size_t ntreecols; /* number of columns with SCOLS_FL_TREE */
size_t nlines; /* number of lines */
@@ -144,6 +146,8 @@ struct libscols_table {
struct list_head tb_lines;
struct libscols_symbols *symbols;
+ int indent; /* indention counter */
+ int indent_last_sep;/* last printed has been line separator */
int format; /* SCOLS_FMT_* */
/* flags */
@@ -171,4 +175,13 @@ struct libscols_table {
(itr)->p->next : (itr)->p->prev; \
} while(0)
+
+static inline int scols_iter_is_last(struct libscols_iter *itr)
+{
+ if (!itr || !itr->head || !itr->p)
+ return 0;
+
+ return itr->p == itr->head;
+}
+
#endif /* _LIBSMARTCOLS_PRIVATE_H */