mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
Add function mdb_read_table_by_name
This commit is contained in:
@@ -258,22 +258,7 @@ char *mdb_get_relationships(MdbHandle *mdb)
|
||||
}
|
||||
|
||||
if (is_init == 0) {
|
||||
MdbCatalogEntry *entry;
|
||||
|
||||
mdb_read_catalog (mdb, MDB_TABLE);
|
||||
|
||||
/* loop over each entry in the catalog */
|
||||
for (i=0; i < mdb->num_catalog; i++) {
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
if ((entry->object_type == MDB_TABLE) &&
|
||||
(strncmp (entry->object_name, "MSysRelationships", 17) == 0))
|
||||
break;
|
||||
}
|
||||
if (i == mdb->num_catalog) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
table = mdb_read_table (entry);
|
||||
table = mdb_read_table_by_name(mdb, "MSysRelationships", MDB_TABLE);
|
||||
if ((!table) || (table->num_rows == 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -117,6 +117,21 @@ MdbTableDef *mdb_read_table(MdbCatalogEntry *entry)
|
||||
|
||||
return table;
|
||||
}
|
||||
MdbTableDef *mdb_read_table_by_name(MdbHandle *mdb, gchar *table_name, int obj_type)
|
||||
{
|
||||
unsigned int i;
|
||||
MdbCatalogEntry *entry;
|
||||
|
||||
mdb_read_catalog(mdb, obj_type);
|
||||
|
||||
for (i=0; i<mdb->num_catalog; i++) {
|
||||
entry = g_ptr_array_index(mdb->catalog, i);
|
||||
if (!strcasecmp(entry->object_name, table_name))
|
||||
return mdb_read_table(entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
** read the next page if offset is > pg_size
|
||||
|
||||
Reference in New Issue
Block a user