]> mj.ucw.cz Git - libucw.git/blob - ucw/xtypes-extra.h
Mainloop: Be benevolent when file_del() is called on a closed fd
[libucw.git] / ucw / xtypes-extra.h
1 /*
2  *      UCW Library -- Extended types - extra types
3  *
4  *      (c) 2014 Robert Kessl <robert.kessl@economia.cz>
5  */
6
7 #ifndef _UCW_XTYPES_EXTRA_H
8 #define _UCW_XTYPES_EXTRA_H
9
10 #include <ucw/xtypes.h>
11 #include <ucw/table.h>
12
13 #ifdef CONFIG_UCW_CLEAN_ABI
14 #define table_col_size ucw_table_col_size
15 #define table_col_timestamp ucw_table_col_timestamp
16 #define xt_size ucw_xt_size
17 #define xt_timestamp ucw_xt_timestamp
18 #endif
19
20 /* Size, possibly with a unit. Internally represented as u64. */
21
22 extern const struct xtype xt_size;
23
24 enum size_units {
25   XT_SIZE_UNIT_BYTE,
26   XT_SIZE_UNIT_KILOBYTE,
27   XT_SIZE_UNIT_MEGABYTE,
28   XT_SIZE_UNIT_GIGABYTE,
29   XT_SIZE_UNIT_TERABYTE,
30   XT_SIZE_UNIT_AUTO
31 };
32
33 #define XT_SIZE_FMT_UNIT(_unit) (_unit | XT_SIZE_FMT_FIXED_UNIT)
34 #define XT_SIZE_FMT_FIXED_UNIT XTYPE_FMT_CUSTOM
35
36 #define TBL_COL_SIZE(_name, _width)       { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size }
37 #define TBL_COL_SIZE_FMT(_name, _width, _fmt)      { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_size }
38
39 TABLE_COL_PROTO(size, u64)
40
41 /* Timestamp. Internally represented as time_t. */
42
43 #define XT_TIMESTAMP_FMT_EPOCH     XTYPE_FMT_RAW
44 #define XT_TIMESTAMP_FMT_DATETIME  XTYPE_FMT_PRETTY
45
46 extern const struct xtype xt_timestamp;
47
48 #define TBL_COL_TIMESTAMP(_name, _width)  { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp }
49 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_timestamp }
50
51 TABLE_COL_PROTO(timestamp, u64)
52
53 #endif