X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Ftable-types.h;h=0220288d064686afdfd9b82df5ef94c4c4f1d9fa;hb=14569005ceedc6c2ce34526b8a6ac6778938aa47;hp=e7b4366b22c9aaeffe1aaa79a29e3b641dc37eda;hpb=0fb5afd0064da21f5c11c08ee8ad69319f63242a;p=libucw.git diff --git a/ucw/table-types.h b/ucw/table-types.h index e7b4366b..0220288d 100644 --- a/ucw/table-types.h +++ b/ucw/table-types.h @@ -9,34 +9,44 @@ #include +#ifdef CONFIG_UCW_CLEAN_ABI +#define table_col_size ucw_table_col_size +#define table_col_timestamp ucw_table_col_timestamp +#define xt_size ucw_xt_size +#define xt_timestamp ucw_xt_timestamp +#endif + +/* Size, possibly with a unit. Internally represented as u64. */ + +extern const struct xtype xt_size; + enum size_units { - SIZE_UNIT_BYTE, - SIZE_UNIT_KILOBYTE, - SIZE_UNIT_MEGABYTE, - SIZE_UNIT_GIGABYTE, - SIZE_UNIT_TERABYTE, - SIZE_UNIT_AUTO + XT_SIZE_UNIT_BYTE, + XT_SIZE_UNIT_KILOBYTE, + XT_SIZE_UNIT_MEGABYTE, + XT_SIZE_UNIT_GIGABYTE, + XT_SIZE_UNIT_TERABYTE, + XT_SIZE_UNIT_AUTO }; -#define TIMESTAMP_EPOCH XTYPE_FMT_RAW -#define TIMESTAMP_DATETIME XTYPE_FMT_PRETTY +#define XT_SIZE_FMT_UNIT(_unit) (_unit | XT_SIZE_FMT_FIXED_UNIT) +#define XT_SIZE_FMT_FIXED_UNIT XTYPE_FMT_CUSTOM -#define SIZE_UNITS_FIXED 0x40000000 +#define TBL_COL_SIZE(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size } +#define TBL_COL_SIZE_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_size } -extern const struct xtype xt_size; -extern const struct xtype xt_timestamp; +TABLE_COL_PROTO(size, u64) -int table_set_col_opt_size(struct table *tbl, uint col_inst_idx, const char *col_arg, char **err); -int table_set_col_opt_timestamp(struct table *tbl, uint col_inst_idx, const char *col_arg, char **err); +/* Timestamp. Internally represented as time_t. */ -#define TBL_COL_SIZE(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size, .set_col_instance_option = table_set_col_opt_size } -#define TBL_COL_TIMESTAMP(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp, .set_col_instance_option = table_set_col_opt_timestamp } +#define XT_TIMESTAMP_FMT_EPOCH XTYPE_FMT_RAW +#define XT_TIMESTAMP_FMT_DATETIME XTYPE_FMT_PRETTY -#define TBL_COL_SIZE_FMT(_name, _width, _units) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size, .set_col_instance_option = table_set_col_opt_size } -#define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp, .set_col_instance_option = table_set_col_opt_timestamp } +extern const struct xtype xt_timestamp; +#define TBL_COL_TIMESTAMP(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp } +#define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_timestamp } -TABLE_COL_PROTO(size, u64) TABLE_COL_PROTO(timestamp, u64) #endif