diff options
Diffstat (limited to 'smtk-import')
-rw-r--r-- | smtk-import/smartrak.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index ed4717287..6d3cf0e6e 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -583,6 +583,31 @@ static void smtk_list_free(struct types_list *head) } } +/* Return the number of rows in a given table */ +static int get_rows_num(MdbHandle *mdb, char *table_name) +{ + MdbTableDef *table; + MdbColumn *col[MDB_MAX_COLS]; + char *bound_values[MDB_MAX_COLS]; + int n = 0, i = 0; + + table = smtk_open_table(mdb, table_name, col, bound_values); + if (!table) + return n; + + /* We can get an sparse array (less rows in the table than + * index). Ensure we allocate as many strings as greater + * index, at least */ + while (mdb_fetch_row(table)) { + i = atoi(col[0]->bind_ptr); + if (i > n) + n = i; + } + smtk_free(bound_values, table->num_cols); + mdb_free_tabledef(table); + return n; +} + /* * Build a list from a given table_name (Type, Gear, etc) * Managed tables formats: Just consider Idx and Text |