Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
int cli_table_add_row(cli_table* self, ...) {
cli_table_col* col = NULL;
cli_table_row* row = NULL;
+ unsigned int cols = 0;
char buffer[1024];
size_t width = 0;
va_list args;
// Adjust the required width of the column
if (width > col->width)
col->width = width;
+
+ // Count the cols
+ cols++;
}
va_end(args);
+ // Fail if we had an incorrect number of columns
+ if (cols != self->num_cols) {
+ r = -EINVAL;
+ goto ERROR;
+ }
+
// Append the row
STAILQ_INSERT_TAIL(&self->rows, row, nodes);