mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
change catalogentry to GPtrArray, documentation fixes, add ifdef wrapper to mdbsql.h
This commit is contained in:
@@ -94,7 +94,7 @@ libmdb_la_LDFLAGS =
|
||||
libmdb_la_LIBADD =
|
||||
libmdb_la_OBJECTS = catalog.lo mem.lo file.lo kkd.lo table.lo data.lo \
|
||||
dump.lo backend.lo money.lo sargs.lo index.lo like.lo
|
||||
CFLAGS = -g -O2
|
||||
CFLAGS = -g -O2 -DSQL
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
|
||||
@@ -102,7 +102,7 @@ char *mdb_postgres_types[] =
|
||||
char *bound_values[MDB_MAX_COLS];
|
||||
char *relationships[4];
|
||||
MdbColumn *col;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
int did_first;
|
||||
|
||||
@@ -168,11 +168,11 @@ static char text[255];
|
||||
|
||||
/* loop over each entry in the catalog */
|
||||
for (i=0; i < mdb->num_catalog; i++) {
|
||||
entry = g_array_index (mdb->catalog, MdbCatalogEntry, i);
|
||||
if ((entry.object_type == MDB_TABLE) &&
|
||||
(strncmp (entry.object_name, "MSysRelationships", 17) == 0))
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
if ((entry->object_type == MDB_TABLE) &&
|
||||
(strncmp (entry->object_name, "MSysRelationships", 17) == 0))
|
||||
{
|
||||
table = mdb_read_table (&entry);
|
||||
table = mdb_read_table (entry);
|
||||
if ( table->num_rows > 0 ) {
|
||||
mdb_read_columns(table);
|
||||
mdb_rewind_table(table);
|
||||
|
||||
@@ -44,17 +44,16 @@ static char *type_name[] = {"Form",
|
||||
|
||||
/* new method */
|
||||
#if 1
|
||||
GArray *mdb_read_catalog (MdbHandle *mdb, int objtype)
|
||||
GPtrArray *mdb_read_catalog (MdbHandle *mdb, int objtype)
|
||||
{
|
||||
int i, j, k;
|
||||
MdbCatalogEntry entry, msysobj;
|
||||
MdbCatalogEntry entry, msysobj, *data;
|
||||
MdbTableDef *table;
|
||||
MdbColumn *col;
|
||||
char parentid[256];
|
||||
char objname[256];
|
||||
char tobjtype[256];
|
||||
int type;
|
||||
gpointer data;
|
||||
|
||||
mdb_free_catalog(mdb);
|
||||
mdb_alloc_catalog(mdb);
|
||||
@@ -89,8 +88,8 @@ gpointer data;
|
||||
entry.object_type = type;
|
||||
entry.table_pg = atol(parentid) & 0x00FFFFFF;
|
||||
mdb->num_catalog++;
|
||||
//data = g_memdup(&entry,sizeof(MdbCatalogEntry));
|
||||
mdb->catalog = g_array_append_val(mdb->catalog, entry);
|
||||
data = g_memdup(&entry,sizeof(MdbCatalogEntry));
|
||||
g_ptr_array_add(mdb->catalog, data);
|
||||
}
|
||||
}
|
||||
//mdb_dump_catalog(mdb, MDB_TABLE);
|
||||
@@ -217,18 +216,18 @@ int next_pg, next_pg_off;
|
||||
void mdb_dump_catalog(MdbHandle *mdb, int obj_type)
|
||||
{
|
||||
int rows, i;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
|
||||
mdb_read_catalog(mdb, obj_type);
|
||||
for (i=0;i<mdb->num_catalog;i++) {
|
||||
entry = g_array_index(mdb->catalog,MdbCatalogEntry,i);
|
||||
if (obj_type==-1 || entry.object_type==obj_type) {
|
||||
entry = g_ptr_array_index(mdb->catalog,i);
|
||||
if (obj_type==-1 || entry->object_type==obj_type) {
|
||||
fprintf(stdout,"Type: %-10s Name: %-18s T pg: %04x KKD pg: %04x row: %2d\n",
|
||||
mdb_get_objtype_string(entry.object_type),
|
||||
entry.object_name,
|
||||
entry.table_pg,
|
||||
entry.kkd_pg,
|
||||
entry.kkd_rowid);
|
||||
mdb_get_objtype_string(entry->object_type),
|
||||
entry->object_name,
|
||||
entry->table_pg,
|
||||
entry->kkd_pg,
|
||||
entry->kkd_rowid);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -52,13 +52,15 @@ void mdb_free_handle(MdbHandle *mdb)
|
||||
}
|
||||
void mdb_alloc_catalog(MdbHandle *mdb)
|
||||
{
|
||||
mdb->catalog = g_array_new(FALSE,FALSE,sizeof(MdbCatalogEntry));
|
||||
mdb->catalog = g_ptr_array_new();
|
||||
}
|
||||
void mdb_free_catalog(MdbHandle *mdb)
|
||||
{
|
||||
GList *l;
|
||||
MdbCatalogEntry entry;
|
||||
|
||||
//g_ptr_array_free(mdb->catalog, FALSE);
|
||||
mdb->catalog = NULL;
|
||||
}
|
||||
MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user