summaryrefslogtreecommitdiffstats
path: root/libblkid/tt.h
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2013-02-23 02:55:50 +0100
committerbigbiff bigbiff <bigbiff@teamw.in>2013-02-25 15:06:46 +0100
commite60683a0d553b6488c564863f4e48954944fb0f8 (patch)
tree9364f97cb88b7c1359f5f06dfb32150a78168c31 /libblkid/tt.h
parentFix building of updater for 4.2 environment (diff)
downloadandroid_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar
android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.gz
android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.bz2
android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.lz
android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.xz
android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.zst
android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.zip
Diffstat (limited to '')
-rw-r--r--libblkid/tt.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/libblkid/tt.h b/libblkid/tt.h
new file mode 100644
index 000000000..603844f66
--- /dev/null
+++ b/libblkid/tt.h
@@ -0,0 +1,94 @@
+/*
+ * Prints table or tree. See lib/table.c for more details and example.
+ *
+ * Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+#ifndef UTIL_LINUX_TT_H
+#define UTIL_LINUX_TT_H
+
+#include "list.h"
+
+enum {
+ /*
+ * Global flags
+ */
+ TT_FL_RAW = (1 << 1),
+ TT_FL_ASCII = (1 << 2),
+ TT_FL_NOHEADINGS = (1 << 3),
+ TT_FL_EXPORT = (1 << 4),
+
+ /*
+ * Column flags
+ */
+ TT_FL_TRUNC = (1 << 5), /* truncate fields data if necessary */
+ TT_FL_TREE = (1 << 6), /* use tree "ascii art" */
+ TT_FL_RIGHT = (1 << 7), /* align to the right */
+ TT_FL_STRICTWIDTH = (1 << 8), /* don't reduce width if column is empty */
+ TT_FL_NOEXTREMES = (1 << 9) /* ignore extreme fields when count column width*/
+};
+
+struct tt {
+ size_t ncols; /* number of columns */
+ size_t termwidth; /* terminal width */
+ int is_term; /* is a tty? */
+ int flags;
+ int first_run;
+
+ struct list_head tb_columns;
+ struct list_head tb_lines;
+
+ const struct tt_symbols *symbols;
+};
+
+struct tt_column {
+ const char *name; /* header */
+ size_t seqnum;
+
+ size_t width; /* real column width */
+ size_t width_min; /* minimal width (usually header width) */
+ size_t width_max; /* maximal width */
+ size_t width_avg; /* average width, used to detect extreme fields */
+ double width_hint; /* hint (N < 1 is in percent of termwidth) */
+
+ int flags;
+ int is_extreme;
+
+ struct list_head cl_columns;
+};
+
+struct tt_line {
+ struct tt *table;
+ char const **data;
+ void *userdata;
+ size_t data_sz; /* strlen of all data */
+
+ struct list_head ln_lines; /* table lines */
+
+ struct list_head ln_branch; /* begin of branch (head of ln_children) */
+ struct list_head ln_children;
+
+ struct tt_line *parent;
+};
+
+extern struct tt *tt_new_table(int flags);
+extern void tt_free_table(struct tt *tb);
+extern void tt_remove_lines(struct tt *tb);
+extern int tt_print_table(struct tt *tb);
+
+extern struct tt_column *tt_define_column(struct tt *tb, const char *name,
+ double whint, int flags);
+
+extern struct tt_column *tt_get_column(struct tt *tb, size_t colnum);
+
+extern struct tt_line *tt_add_line(struct tt *tb, struct tt_line *parent);
+
+extern int tt_line_set_data(struct tt_line *ln, int colnum, const char *data);
+extern int tt_line_set_userdata(struct tt_line *ln, void *data);
+
+extern void tt_fputs_quoted(const char *data, FILE *out);
+extern void tt_fputs_nonblank(const char *data, FILE *out);
+
+#endif /* UTIL_LINUX_TT_H */