mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
change catalogentry to GPtrArray, documentation fixes, add ifdef wrapper to mdbsql.h
This commit is contained in:
parent
16ecc4fe4d
commit
9b8285d937
1
INSTALL
1
INSTALL
@ -6,6 +6,7 @@ Basic Installation
|
||||
|
||||
This will build some useful utilities:
|
||||
|
||||
mdb-ver -- prints the version (JET 3 or 4) of an mdb file
|
||||
mdb-dump -- simple hex dump utility that I've been using to look at mdb files
|
||||
mdb-schema -- prints DDL for the specified table
|
||||
mdb-export -- export table to CSV format
|
||||
|
6
README
6
README
@ -1,8 +1,6 @@
|
||||
This is mdbtools version 0.3
|
||||
This is mdbtools version 0.4
|
||||
|
||||
This software is beta so don't expect too much unless you know C and
|
||||
probably a little something about databases and reverse engineering file
|
||||
formats, you're welcome to try it out but don't expect miracles.
|
||||
This software is still beta so don't expect too much.
|
||||
|
||||
For the rest of you, read the HACKING file for a description of where the code
|
||||
stands and what has been gleened of the file format.
|
||||
|
10
TODO
10
TODO
@ -2,17 +2,11 @@ Things to Do
|
||||
------------
|
||||
|
||||
. Complete the list of datatypes
|
||||
. Figure out how to properly determine fixed or variable length columns
|
||||
. Figure out what happens for varchar columns starting at > 256
|
||||
. Modify mdb-schema utility support different backend databases
|
||||
. Modify mdb-export to handle different delimiters/options
|
||||
. Get automake working
|
||||
. Check out text file unixODBC driver to see if it can be adapted to use
|
||||
libmdb (it already has a SQL parser).
|
||||
. Straighten out which functions in libmdb are meant to be used and which
|
||||
ones should be static.
|
||||
. Create an API reference for libmdb (maybe some man pages).
|
||||
. Sargs need to support all datatypes
|
||||
. Need a way to express logical relationships between sargs (tree)
|
||||
. Add support for index scanning when using sargs
|
||||
. Convert code to use MSysObjects table for reading catalog.
|
||||
. Use allocation maps to read tables, should be more efficient
|
||||
. Figure out why we get unresolved symbols when ODBC driver load by DM
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include <glib.h>
|
||||
#include <mdbtools.h>
|
||||
|
||||
#ifndef _mdbsql_h_
|
||||
#define _mdbsql_h_
|
||||
|
||||
typedef struct {
|
||||
MdbHandle *mdb;
|
||||
int all_columns;
|
||||
@ -55,3 +58,5 @@ void mdb_sql_exit(MdbSQL *sql);
|
||||
void mdb_sql_reset(MdbSQL *sql);
|
||||
void mdb_sql_listtables(MdbSQL *sql);
|
||||
void mdb_sql_select(MdbSQL *sql);
|
||||
|
||||
#endif
|
||||
|
@ -103,7 +103,7 @@ typedef struct {
|
||||
unsigned char pg_buf[MDB_PGSIZE];
|
||||
unsigned char alt_pg_buf[MDB_PGSIZE];
|
||||
int num_catalog;
|
||||
GArray *catalog;
|
||||
GPtrArray *catalog;
|
||||
int pg_size;
|
||||
guint32 jet_version;
|
||||
guint32 db_key;
|
||||
|
@ -77,10 +77,10 @@ READLINE_LIBS = -lncurses -lreadline
|
||||
SQL =
|
||||
VERSION = 0.3
|
||||
YACC = bison -y
|
||||
#SUBDIRS = libmdb sql util extras
|
||||
SUBDIRS = libmdb util extras
|
||||
#DEFDIR = $(prefix)
|
||||
SUBDIRS = libmdb sql util extras
|
||||
#SUBDIRS = libmdb util extras
|
||||
DEFDIR = $(prefix)
|
||||
#DEFDIR = $(prefix)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
@ -95,7 +95,7 @@ mdb_dump_OBJECTS = mdb-dump.o mdbsupport.o
|
||||
mdb_dump_LDADD = $(LDADD)
|
||||
mdb_dump_DEPENDENCIES = ../libmdb/libmdb.la
|
||||
mdb_dump_LDFLAGS =
|
||||
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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ unittest_OBJECTS = unittest.o
|
||||
unittest_DEPENDENCIES = libmdbodbc.la ../libmdb/libmdb.la \
|
||||
../sql/libmdbsql.la
|
||||
unittest_LDFLAGS =
|
||||
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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Generated automatically from Makefile.in by configure.
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
@ -96,7 +96,7 @@ libmdbsql_la_LIBADD =
|
||||
libmdbsql_la_OBJECTS = mdbsql.lo parser.lo lexer.lo
|
||||
LEX_OUTPUT_ROOT = lex.yy
|
||||
LEXLIB = -lfl
|
||||
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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -286,7 +286,7 @@ int vlen;
|
||||
void mdb_sql_listtables(MdbSQL *sql)
|
||||
{
|
||||
int i;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbHandle *mdb = sql->mdb;
|
||||
|
||||
if (!mdb) {
|
||||
@ -304,11 +304,11 @@ MdbHandle *mdb = sql->mdb;
|
||||
fprintf(stdout,"\n");
|
||||
/* loop over each entry in the catalog */
|
||||
for (i=0; i < mdb->num_catalog; i++) {
|
||||
entry = g_array_index (mdb->catalog, MdbCatalogEntry, i);
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
/* if it's a table */
|
||||
if (entry.object_type == MDB_TABLE) {
|
||||
if (strncmp (entry.object_name, "MSys", 4)) {
|
||||
print_value (entry.object_name,30,1);
|
||||
if (entry->object_type == MDB_TABLE) {
|
||||
if (strncmp (entry->object_name, "MSys", 4)) {
|
||||
print_value (entry->object_name,30,1);
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
}
|
||||
@ -320,7 +320,7 @@ void mdb_sql_describe_table(MdbSQL *sql)
|
||||
{
|
||||
MdbTableDef *table = NULL;
|
||||
MdbSQLTable *sql_tab;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbHandle *mdb = sql->mdb;
|
||||
MdbColumn *col;
|
||||
int i;
|
||||
@ -336,10 +336,10 @@ char colsize[11];
|
||||
mdb_read_catalog(mdb, MDB_TABLE);
|
||||
|
||||
for (i=0;i<mdb->num_catalog;i++) {
|
||||
entry = g_array_index(mdb->catalog,MdbCatalogEntry,i);
|
||||
if (entry.object_type == MDB_TABLE &&
|
||||
!strcasecmp(entry.object_name,sql_tab->name)) {
|
||||
table = mdb_read_table(&entry);
|
||||
entry = g_ptr_array_index(mdb->catalog,i);
|
||||
if (entry->object_type == MDB_TABLE &&
|
||||
!strcasecmp(entry->object_name,sql_tab->name)) {
|
||||
table = mdb_read_table(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -385,7 +385,7 @@ char colsize[11];
|
||||
void mdb_sql_select(MdbSQL *sql)
|
||||
{
|
||||
int i,j;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbHandle *mdb = sql->mdb;
|
||||
MdbTableDef *table = NULL;
|
||||
MdbSQLTable *sql_tab;
|
||||
@ -404,10 +404,10 @@ int found = 0;
|
||||
mdb_read_catalog(mdb, MDB_TABLE);
|
||||
|
||||
for (i=0;i<mdb->num_catalog;i++) {
|
||||
entry = g_array_index(mdb->catalog,MdbCatalogEntry,i);
|
||||
if (entry.object_type == MDB_TABLE &&
|
||||
!strcasecmp(entry.object_name,sql_tab->name)) {
|
||||
table = mdb_read_table(&entry);
|
||||
entry = g_ptr_array_index(mdb->catalog,i);
|
||||
if (entry->object_type == MDB_TABLE &&
|
||||
!strcasecmp(entry->object_name,sql_tab->name)) {
|
||||
table = mdb_read_table(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ bin_PROGRAMS = mdb-export mdb-array mdb-schema mdb-tables mdb-parsecsv mdb-heade
|
||||
LIBS = `glib-config --libs` $(READLINE_LIBS) -lfl
|
||||
INCLUDES = -I$(top_srcdir)/include `glib-config --cflags`
|
||||
LDADD = ../libmdb/libmdb.la
|
||||
#mdb_sql_LDADD = #../libmdb/libmdb.la ../sql/libmdbsql.la
|
||||
mdb_sql_LDADD = ../libmdb/libmdb.la ../sql/libmdbsql.la
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
@ -123,8 +123,8 @@ mdb_header_DEPENDENCIES = ../libmdb/libmdb.la
|
||||
mdb_header_LDFLAGS =
|
||||
mdb_sql_SOURCES = mdb-sql.c
|
||||
mdb_sql_OBJECTS = mdb-sql.o
|
||||
#mdb_sql_DEPENDENCIES = ../libmdb/libmdb.la \
|
||||
#../sql/libmdbsql.la
|
||||
mdb_sql_DEPENDENCIES = ../libmdb/libmdb.la \
|
||||
../sql/libmdbsql.la
|
||||
mdb_sql_LDFLAGS =
|
||||
mdb_ver_SOURCES = mdb-ver.c
|
||||
mdb_ver_OBJECTS = mdb-ver.o
|
||||
@ -156,7 +156,7 @@ prdump_OBJECTS = prdump.o
|
||||
prdump_LDADD = $(LDADD)
|
||||
prdump_DEPENDENCIES = ../libmdb/libmdb.la
|
||||
prdump_LDFLAGS =
|
||||
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)
|
||||
|
@ -28,7 +28,7 @@ main (int argc, char **argv)
|
||||
int rows;
|
||||
int i, j;
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
MdbColumn *col;
|
||||
/* doesn't handle tables > 256 columns. Can that happen? */
|
||||
@ -51,11 +51,11 @@ int started;
|
||||
|
||||
for (i = 0; i < mdb->num_catalog; i++)
|
||||
{
|
||||
entry = g_array_index (mdb->catalog, MdbCatalogEntry, i);
|
||||
if (entry.object_type == MDB_TABLE &&
|
||||
!strcmp (entry.object_name, argv [2]))
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
if (entry->object_type == MDB_TABLE &&
|
||||
!strcmp (entry->object_name, argv [2]))
|
||||
{
|
||||
table = mdb_read_table (&entry);
|
||||
table = mdb_read_table (entry);
|
||||
mdb_read_columns (table);
|
||||
mdb_rewind_table (table);
|
||||
|
||||
|
@ -26,7 +26,7 @@ int rows;
|
||||
int i, j;
|
||||
unsigned char buf[2048];
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
MdbColumn *col;
|
||||
/* doesn't handle tables > 256 columns. Can that happen? */
|
||||
@ -75,10 +75,10 @@ int opt;
|
||||
mdb_read_catalog(mdb, MDB_TABLE);
|
||||
|
||||
for (i=0;i<mdb->num_catalog;i++) {
|
||||
entry = g_array_index(mdb->catalog,MdbCatalogEntry,i);
|
||||
if (entry.object_type == MDB_TABLE &&
|
||||
!strcmp(entry.object_name,argv[argc-1])) {
|
||||
table = mdb_read_table(&entry);
|
||||
entry = g_ptr_array_index(mdb->catalog,i);
|
||||
if (entry->object_type == MDB_TABLE &&
|
||||
!strcmp(entry->object_name,argv[argc-1])) {
|
||||
table = mdb_read_table(entry);
|
||||
mdb_read_columns(table);
|
||||
mdb_rewind_table(table);
|
||||
|
||||
|
@ -33,7 +33,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
int i, j, k;
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
MdbColumn *col;
|
||||
FILE *typesfile;
|
||||
@ -74,30 +74,30 @@ FILE *cfile;
|
||||
|
||||
for (i=0; i < mdb->num_catalog; i++)
|
||||
{
|
||||
entry = g_array_index (mdb->catalog, MdbCatalogEntry, i);
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
|
||||
/* if it's a table */
|
||||
|
||||
if (entry.object_type == MDB_TABLE)
|
||||
if (entry->object_type == MDB_TABLE)
|
||||
{
|
||||
/* skip the MSys tables */
|
||||
if (strncmp (entry.object_name, "MSys", 4))
|
||||
if (strncmp (entry->object_name, "MSys", 4))
|
||||
{
|
||||
|
||||
/* make sure it's a table (may be redundant) */
|
||||
|
||||
if (!strcmp (mdb_get_objtype_string (entry.object_type), "Table"))
|
||||
if (!strcmp (mdb_get_objtype_string (entry->object_type), "Table"))
|
||||
{
|
||||
|
||||
fprintf (typesfile, "typedef struct _%s\n", entry.object_name);
|
||||
fprintf (typesfile, "typedef struct _%s\n", entry->object_name);
|
||||
fprintf (typesfile, "{\n");
|
||||
|
||||
fprintf (headerfile, "void dump_%s (%s x);\n",
|
||||
entry.object_name, entry.object_name);
|
||||
entry->object_name, entry->object_name);
|
||||
fprintf (cfile, "void dump_%s (%s x)\n{\n",
|
||||
entry.object_name, entry.object_name);
|
||||
fprintf (cfile, "\tfprintf (stdout, \"**************** %s ****************\\n\");\n", entry.object_name);
|
||||
table = mdb_read_table (&entry);
|
||||
entry->object_name, entry->object_name);
|
||||
fprintf (cfile, "\tfprintf (stdout, \"**************** %s ****************\\n\");\n", entry->object_name);
|
||||
table = mdb_read_table (entry);
|
||||
|
||||
/* get the columns */
|
||||
mdb_read_columns (table);
|
||||
@ -138,7 +138,7 @@ FILE *cfile;
|
||||
fprintf (cfile, ");\n");
|
||||
}
|
||||
|
||||
fprintf (typesfile, "\n} %s ;\n", entry.object_name);
|
||||
fprintf (typesfile, "\n} %s ;\n", entry->object_name);
|
||||
fprintf (typesfile, "\n");
|
||||
fprintf (cfile, "}\n\n");
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
int i, j, k;
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
MdbColumn *col;
|
||||
char *the_relation;
|
||||
@ -55,28 +55,28 @@ char *the_relation;
|
||||
|
||||
for (i=0; i < mdb->num_catalog; i++)
|
||||
{
|
||||
entry = g_array_index (mdb->catalog, MdbCatalogEntry, i);
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
|
||||
/* if it's a table */
|
||||
|
||||
if (entry.object_type == MDB_TABLE)
|
||||
if (entry->object_type == MDB_TABLE)
|
||||
{
|
||||
/* skip the MSys tables */
|
||||
if (strncmp (entry.object_name, "MSys", 4))
|
||||
if (strncmp (entry->object_name, "MSys", 4))
|
||||
{
|
||||
|
||||
/* make sure it's a table (may be redundant) */
|
||||
|
||||
if (!strcmp (mdb_get_objtype_string (entry.object_type), "Table"))
|
||||
if (!strcmp (mdb_get_objtype_string (entry->object_type), "Table"))
|
||||
{
|
||||
/* drop the table if it exists */
|
||||
fprintf (stdout, "DROP TABLE %s;\n", entry.object_name);
|
||||
fprintf (stdout, "DROP TABLE %s;\n", entry->object_name);
|
||||
|
||||
/* create the table */
|
||||
fprintf (stdout, "CREATE TABLE %s\n", entry.object_name);
|
||||
fprintf (stdout, "CREATE TABLE %s\n", entry->object_name);
|
||||
fprintf (stdout, " (\n");
|
||||
|
||||
table = mdb_read_table (&entry);
|
||||
table = mdb_read_table (entry);
|
||||
|
||||
/* get the columns */
|
||||
mdb_read_columns (table);
|
||||
|
@ -24,7 +24,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
int i, j, k;
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
MdbColumn *col;
|
||||
|
||||
@ -48,22 +48,22 @@ MdbColumn *col;
|
||||
|
||||
for (i=0; i < mdb->num_catalog; i++)
|
||||
{
|
||||
entry = g_array_index (mdb->catalog, MdbCatalogEntry, i);
|
||||
entry = g_ptr_array_index (mdb->catalog, i);
|
||||
|
||||
/* if it's a table */
|
||||
|
||||
if (entry.object_type == MDB_TABLE)
|
||||
if (entry->object_type == MDB_TABLE)
|
||||
{
|
||||
/* skip the MSys tables */
|
||||
if (strncmp (entry.object_name, "MSys", 4))
|
||||
if (strncmp (entry->object_name, "MSys", 4))
|
||||
{
|
||||
|
||||
/* make sure it's a table (may be redundant) */
|
||||
|
||||
if (!strcmp (mdb_get_objtype_string (entry.object_type), "Table"))
|
||||
if (!strcmp (mdb_get_objtype_string (entry->object_type), "Table"))
|
||||
{
|
||||
/* drop the table if it exists */
|
||||
fprintf (stdout, "%s ", entry.object_name);
|
||||
fprintf (stdout, "%s ", entry->object_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ int rows;
|
||||
int i;
|
||||
unsigned char buf[2048];
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
GList *l;
|
||||
|
||||
@ -42,10 +42,10 @@ GList *l;
|
||||
mdb_read_catalog(mdb, MDB_TABLE);
|
||||
|
||||
for (i=0;i<mdb->num_catalog;i++) {
|
||||
entry = g_array_index(mdb->catalog,MdbCatalogEntry,i);
|
||||
if (entry.object_type == MDB_TABLE &&
|
||||
!strcmp(entry.object_name,argv[2])) {
|
||||
table = mdb_read_table(&entry);
|
||||
entry = g_ptr_array_index(mdb->catalog,i);
|
||||
if (entry->object_type == MDB_TABLE &&
|
||||
!strcmp(entry->object_name,argv[2])) {
|
||||
table = mdb_read_table(entry);
|
||||
mdb_read_columns(table);
|
||||
mdb_data_dump(table);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ int rows;
|
||||
int i;
|
||||
unsigned char buf[2048];
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
GList *l;
|
||||
|
||||
|
||||
@ -41,10 +41,10 @@ GList *l;
|
||||
mdb_read_catalog(mdb, MDB_TABLE);
|
||||
|
||||
for (i=0;i<mdb->num_catalog;i++) {
|
||||
entry = g_array_index(mdb->catalog,MdbCatalogEntry,i);
|
||||
if (entry.object_type == MDB_TABLE &&
|
||||
!strcmp(entry.object_name,argv[2])) {
|
||||
mdb_table_dump(&entry);
|
||||
entry = g_ptr_array_index(mdb->catalog,i);
|
||||
if (entry->object_type == MDB_TABLE &&
|
||||
!strcmp(entry->object_name,argv[2])) {
|
||||
mdb_table_dump(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ int rows;
|
||||
int i;
|
||||
unsigned char buf[2048];
|
||||
MdbHandle *mdb;
|
||||
MdbCatalogEntry entry;
|
||||
MdbCatalogEntry *entry;
|
||||
MdbTableDef *table;
|
||||
|
||||
mdb_init();
|
||||
@ -44,10 +44,10 @@ MdbTableDef *table;
|
||||
mdb_read_catalog(mdb, MDB_TABLE);
|
||||
|
||||
for (i=0;i<mdb->num_catalog;i++) {
|
||||
entry = g_array_index(mdb->catalog,MdbCatalogEntry,i);
|
||||
if (entry.object_type == MDB_TABLE &&
|
||||
!strcmp(entry.object_name,TABLE_NAME)) {
|
||||
table = mdb_read_table(&entry);
|
||||
entry = g_ptr_array_index(mdb->catalog,i);
|
||||
if (entry->object_type == MDB_TABLE &&
|
||||
!strcmp(entry->object_name,TABLE_NAME)) {
|
||||
table = mdb_read_table(entry);
|
||||
print_table(table);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user