]> mj.ucw.cz Git - libucw.git/blob - ucw/table-types.h
xtypes: Added FIXME with possible segfault.
[libucw.git] / ucw / table-types.h
1 /*
2  *      UCW Library -- Table printer
3  *
4  *      (c) 2014 Robert Kessl <robert.kessl@economia.cz>
5  */
6
7 #ifndef _UCW_TABLE_TYPES_H
8 #define _UCW_TABLE_TYPES_H
9
10 #include <ucw/table.h>
11
12 enum size_units {
13   SIZE_UNIT_BYTE,
14   SIZE_UNIT_KILOBYTE,
15   SIZE_UNIT_MEGABYTE,
16   SIZE_UNIT_GIGABYTE,
17   SIZE_UNIT_TERABYTE,
18   SIZE_UNIT_AUTO
19 };
20
21 #define COL_TYPE_SIZE       &xt_size
22 #define COL_TYPE_TIMESTAMP  &xt_timestamp
23
24 #define TIMESTAMP_EPOCH     XTYPE_FMT_RAW
25 #define TIMESTAMP_DATETIME  XTYPE_FMT_PRETTY
26
27 #define SIZE_UNITS_FIXED    0x40000000
28
29 extern const struct xtype xt_size;
30 extern const struct xtype xt_timestamp;
31
32 bool table_set_col_opt_size(struct table *tbl, uint col_inst_idx, const char *col_arg, char **err);
33 bool table_set_col_opt_timestamp(struct table *tbl, uint col_inst_idx, const char *col_arg, char **err);
34
35 #define TBL_COL_SIZE(_name, _width)           { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = COL_TYPE_SIZE, .set_col_instance_option = table_set_col_opt_size }
36 #define TBL_COL_TIMESTAMP(_name, _width)      { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = COL_TYPE_TIMESTAMP, .set_col_instance_option = table_set_col_opt_timestamp }
37
38 #define TBL_COL_SIZE_FMT(_name, _width, _units)         { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = COL_TYPE_SIZE, .set_col_instance_option = table_set_col_opt_size }
39 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt)      { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = COL_TYPE_TIMESTAMP, .set_col_instance_option = table_set_col_opt_timestamp }
40
41
42 /*
43 void table_col_size_name(struct table *tbl, const char *col_name, u64 val);
44 void table_col_timestamp_name(struct table *tbl, const char * col_name, u64 val);
45
46 void table_col_size(struct table *tbl, int col, u64 val);
47 void table_col_timestamp(struct table *tbl, int col, u64 val);
48 */
49 TABLE_COL_PROTO(size, u64)
50 TABLE_COL_PROTO(timestamp, u64)
51
52 #endif