]> mj.ucw.cz Git - libucw.git/commitdiff
tableprinter: removed unnecessary macros, code cleanup
authorRobert Kessl <kesslr@centrum.cz>
Fri, 18 Jul 2014 11:55:32 +0000 (13:55 +0200)
committerRobert Kessl <kesslr@centrum.cz>
Fri, 18 Jul 2014 11:55:32 +0000 (13:55 +0200)
ucw/table-types.c
ucw/table-types.h

index 3b11c140be20466a908033b5912f7cb49c5b42fe..e3d184cd787599be2fba3014f05ca465fd1de09a 100644 (file)
@@ -63,7 +63,7 @@ int table_set_col_opt_size(struct table *tbl, uint col_inst_idx, const char *col
   }
 
   const struct table_column *col_def = tbl->column_order[col_inst_idx].col_def;
-  if(col_def->type_def != COL_TYPE_SIZE) {
+  if(col_def->type_def != &xt_size) {
     *err = NULL;
     return TABLE_OPT_UNKNOWN;
   }
@@ -106,7 +106,7 @@ const struct xtype xt_size = {
 int table_set_col_opt_timestamp(struct table *tbl, uint col_inst_idx, const char *col_arg, char **err)
 {
   int col_type_idx = tbl->column_order[col_inst_idx].idx;
-  if(tbl->columns[col_type_idx].type_def != COL_TYPE_TIMESTAMP) {
+  if(tbl->columns[col_type_idx].type_def != &xt_timestamp) {
     *err = NULL;
     return TABLE_OPT_UNKNOWN;
   }
index 6cdc8d590f66e98a3c4a06dfc6d9bd8e36e1a71d..e7b4366b22c9aaeffe1aaa79a29e3b641dc37eda 100644 (file)
@@ -18,9 +18,6 @@ enum size_units {
   SIZE_UNIT_AUTO
 };
 
-#define COL_TYPE_SIZE       &xt_size
-#define COL_TYPE_TIMESTAMP  &xt_timestamp
-
 #define TIMESTAMP_EPOCH     XTYPE_FMT_RAW
 #define TIMESTAMP_DATETIME  XTYPE_FMT_PRETTY
 
@@ -29,23 +26,16 @@ enum size_units {
 extern const struct xtype xt_size;
 extern const struct xtype xt_timestamp;
 
-bool table_set_col_opt_size(struct table *tbl, uint col_inst_idx, const char *col_arg, char **err);
-bool table_set_col_opt_timestamp(struct table *tbl, uint col_inst_idx, const char *col_arg, char **err);
-
-#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 }
-#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 }
+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);
 
-#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 }
-#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 }
+#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 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 }
 
-/*
-void table_col_size_name(struct table *tbl, const char *col_name, u64 val);
-void table_col_timestamp_name(struct table *tbl, const char * col_name, u64 val);
 
-void table_col_size(struct table *tbl, int col, u64 val);
-void table_col_timestamp(struct table *tbl, int col, u64 val);
-*/
 TABLE_COL_PROTO(size, u64)
 TABLE_COL_PROTO(timestamp, u64)