[UNIT_TERABYTE] = "TB"
};
- int curr_col = tbl->columns[col].first_column;
- while(curr_col != -1) {
-
+ TBL_COL_ITER_START(tbl, col, curr_col) {
// FIXME: do some rounding?
uint out_type = 0;
if(tbl->column_order[curr_col].output_type == CELL_OUT_UNINITIALIZED) {
}
tbl->column_order[curr_col].cell_content = mp_printf(tbl->pool, "%lu%s", val, unit_suffix[out_type]);
- curr_col = tbl->column_order[curr_col].next_column;
- }
+ } TBL_COL_ITER_END(tbl, curr_col)
}
time_t tmp_time = (time_t)val;
struct tm t = *gmtime(&tmp_time);
- int curr_col = tbl->columns[col].first_column;
- while(curr_col != -1) {
+ TBL_COL_ITER_START(tbl, col, curr_col) {
switch (tbl->column_order[curr_col].output_type) {
case TIMESTAMP_EPOCH:
case CELL_OUT_UNINITIALIZED:
}
tbl->column_order[curr_col].cell_content = mp_printf(tbl->pool, "%s", formatted_time_buf);
- curr_col = tbl->column_order[curr_col].next_column;
- }
+ } TBL_COL_ITER_END(tbl, curr_col)
}
#define TBL_OUTPUT_BLOCKLINE .formatter = &table_fmt_blockline
#define TBL_OUTPUT_MACHINE_READABLE .formatter = &table_fmt_machine_readable
+#define TBL_COL_ITER_START(_tbl, _colidx, _var) int _var = _tbl->columns[_colidx].first_column; while(_var != -1) {
+#define TBL_COL_ITER_END(_tbl, _var) _var = _tbl->column_order[_var].next_column; }
+
/**
* Initialize a table definition. The structure should already contain
* the definitions of columns.