~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to include/tt.h

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#include "list.h"
13
13
 
14
14
enum {
15
 
        TT_FL_TRUNC      = (1 << 1),
16
 
        TT_FL_TREE       = (1 << 2),
17
 
        TT_FL_RAW        = (1 << 3),
18
 
        TT_FL_ASCII      = (1 << 4),
19
 
        TT_FL_NOHEADINGS = (1 << 5),
20
 
        TT_FL_RIGHT      = (1 << 6),
 
15
        /*
 
16
         * Global flags
 
17
         */
 
18
        TT_FL_RAW         = (1 << 1),
 
19
        TT_FL_ASCII       = (1 << 2),
 
20
        TT_FL_NOHEADINGS  = (1 << 3),
 
21
        TT_FL_EXPORT      = (1 << 4),
 
22
 
 
23
        /*
 
24
         * Column flags
 
25
         */
 
26
        TT_FL_TRUNC       = (1 << 5),
 
27
        TT_FL_TREE        = (1 << 6),
 
28
        TT_FL_RIGHT       = (1 << 7),
 
29
        TT_FL_STRICTWIDTH = (1 << 8)
21
30
};
22
31
 
23
32
struct tt {
24
 
        int     ncols;          /* number of columns */
25
 
        int     termwidth;      /* terminal width */
 
33
        size_t  ncols;          /* number of columns */
 
34
        size_t  termwidth;      /* terminal width */
26
35
        int     flags;
 
36
        int     first_run;
27
37
 
28
38
        struct list_head        tb_columns;
29
39
        struct list_head        tb_lines;
33
43
 
34
44
struct tt_column {
35
45
        const char *name;       /* header */
36
 
        int     seqnum;
 
46
        size_t  seqnum;
37
47
 
38
 
        int     width;          /* real column width */
39
 
        int     width_min;      /* minimal width (width of header) */
 
48
        size_t  width;          /* real column width */
 
49
        size_t  width_min;      /* minimal width (width of header) */
40
50
        double  width_hint;     /* hint (N < 1 is in percent of termwidth) */
41
51
 
42
52
        int     flags;
48
58
        struct tt       *table;
49
59
        char const      **data;
50
60
        void            *userdata;
51
 
        ssize_t         data_sz;                /* strlen of all data */
 
61
        size_t          data_sz;                /* strlen of all data */
52
62
 
53
63
        struct list_head        ln_lines;       /* table lines */
54
64
 
60
70
 
61
71
extern struct tt *tt_new_table(int flags);
62
72
extern void tt_free_table(struct tt *tb);
 
73
extern void tt_remove_lines(struct tt *tb);
63
74
extern int tt_print_table(struct tt *tb);
64
75
 
65
76
extern struct tt_column *tt_define_column(struct tt *tb, const char *name,
66
77
                                                double whint, int flags);
67
78
 
68
 
extern struct tt_column *tt_get_column(struct tt *tb, int colnum);
 
79
extern struct tt_column *tt_get_column(struct tt *tb, size_t colnum);
69
80
 
70
81
extern struct tt_line *tt_add_line(struct tt *tb, struct tt_line *parent);
71
82
 
72
83
extern int tt_line_set_data(struct tt_line *ln, int colnum, const char *data);
73
84
extern int tt_line_set_userdata(struct tt_line *ln, void *data);
74
85
 
75
 
extern int tt_parse_columns_list(const char *list, int cols[], int *ncols,
 
86
extern int tt_parse_columns_list(const char *list, int ary[], size_t arrsz,
76
87
                                int (name2id)(const char *, size_t));
77
88
 
78
89
#endif /* UTIL_LINUX_TT_H */