diff --git a/config.h.in b/config.h.in deleted file mode 100644 index f0de0e0..0000000 --- a/config.h.in +++ /dev/null @@ -1,25 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define if you have the ibs library (-libs). */ -#undef HAVE_LIBIBS - -/* Define if you have the mdb library (-lmdb). */ -#undef HAVE_LIBMDB diff --git a/src/config.h.in b/src/config.h.in deleted file mode 100644 index f0de0e0..0000000 --- a/src/config.h.in +++ /dev/null @@ -1,25 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define if you have the ibs library (-libs). */ -#undef HAVE_LIBIBS - -/* Define if you have the mdb library (-lmdb). */ -#undef HAVE_LIBMDB diff --git a/src/extras/config.h.in b/src/extras/config.h.in deleted file mode 100644 index 61025bc..0000000 --- a/src/extras/config.h.in +++ /dev/null @@ -1 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ diff --git a/src/include/Makefile.in b/src/include/Makefile.in deleted file mode 100644 index dd98223..0000000 --- a/src/include/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ - -SHELL = /bin/sh -VPATH = @srcdir@ - -top_srcdir = @top_srcdir@ -srcdir = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = $(exec_prefix)/bin -infodir = $(exec_prefix)/info -libdir = $(exec_prefix)/lib -includedir = $(exec_prefix)/include -mandir = $(exec_prefix)/man/man1 - -CC = @CC@ -CPPFLAGS = @CPPFLAGS@ -CFLAGS = $(CPPFLAG) @CFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -INSTALL= @INSTALL@ - -HEADERS = mdbtools.h -OBJS = dump.o - -all: $(PROGS) - -clean: - rm -f core *.o $(PROGS) Makefile - -mdb-dump: dump.o - $(CC) -g -o $@ $< - -.c.o: - $(CC) $(CFLAGS) -g -c $< - -install: - mkdir -p $(includedir) - @for header in $(HEADERS); do \ - echo " copying $$header to $(includedir)"; \ - cp $$header $(includedir); \ - done - -uninstall: - @for header in $(HEADERS); do \ - echo " removing $$header from $(includedir)"; \ - rm -f $(includedir)/$$header; \ - done diff --git a/src/include/config.h.in b/src/include/config.h.in deleted file mode 100644 index 61025bc..0000000 --- a/src/include/config.h.in +++ /dev/null @@ -1 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ diff --git a/src/include/mdbtools.h b/src/include/mdbtools.h deleted file mode 100644 index 6c0833e..0000000 --- a/src/include/mdbtools.h +++ /dev/null @@ -1,222 +0,0 @@ -/* MDB Tools - A library for reading MS Access database files - * Copyright (C) 2000 Brian Bruns - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _mdbtools_h_ -#define _mdbtools_h_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MDB_PGSIZE 2048 -#define MDB_MAX_OBJ_NAME 30 -#define MDB_MAX_COLS 256 -#define MDB_CATALOG_PG 18 -#define MDB_MEMO_OVERHEAD 12 -#define MDB_BIND_SIZE 2048 - -enum { - MDB_VER_JET3 = 0, - MDB_VER_JET4 = 1 -}; -enum { - MDB_FORM = 0, - MDB_TABLE, - MDB_MACRO, - MDB_SYSTEM_TABLE, - MDB_REPORT, - MDB_QUERY, - MDB_LINKED_TABLE, - MDB_MODULE, - MDB_RELATIONSHIP, - MDB_UNKNOWN_09, - MDB_UNKNOWN_0A, - MDB_DATABASE_PROPERTY -}; -enum { - MDB_BOOL = 0x01, - MDB_BYTE = 0x02, - MDB_INT = 0x03, - MDB_LONGINT = 0x04, - MDB_MONEY = 0x05, - MDB_FLOAT = 0x06, - MDB_DOUBLE = 0x07, - MDB_SDATETIME = 0x08, - MDB_TEXT = 0x0a, - MDB_OLE = 0x0b, - MDB_MEMO = 0x0c, - MDB_REPID = 0x0f -}; - -/* SARG operators */ -enum { - MDB_EQUAL = 1, - MDB_GT, - MDB_LT, - MDB_GTEQ, - MDB_LTEQ, - MDB_ISNULL, - MDB_NOTNULL -}; - -enum { - MDB_ASC, - MDB_DESC -}; - -/* hash to store registered backends */ -GHashTable *mdb_backends; - -typedef struct { - char **types_table; -} MdbBackend; - -typedef struct { - int fd; - char *filename; - guint16 cur_pg; - guint16 row_num; - unsigned int cur_pos; - unsigned char pg_buf[MDB_PGSIZE]; - unsigned char alt_pg_buf[MDB_PGSIZE]; - int num_catalog; - GArray *catalog; - int pg_size; - guint32 jet_version; - guint32 db_key; - char db_passwd[14]; - MdbBackend *default_backend; - char *backend_name; -} MdbHandle; - -typedef struct { - MdbHandle *mdb; - char object_name[MDB_MAX_OBJ_NAME+1]; - int object_type; - unsigned long table_pg; /* misnomer since object may not be a table */ - unsigned long kkd_pg; - unsigned int kkd_rowid; - int num_props; - GArray *props; - GPtrArray *columns; -} MdbCatalogEntry; - -typedef struct { - MdbCatalogEntry *entry; - char name[MDB_MAX_OBJ_NAME+1]; - int num_cols; - GPtrArray *columns; - int num_rows; - int index_start; - int num_real_idxs; - int num_idxs; - GPtrArray *indices; - int first_data_pg; - int cur_pg_num; - int cur_phys_pg; - int cur_row; -} MdbTableDef; - -typedef struct { - int index_num; - char name[MDB_MAX_OBJ_NAME+1]; - unsigned char primary_key; - int first_pg; - unsigned char sort_order; -} MdbIndex; - -typedef struct { - char name[MDB_MAX_OBJ_NAME+1]; -} MdbColumnProp; - -typedef struct { - char name[MDB_MAX_OBJ_NAME+1]; - int col_type; - int col_size; - void *bind_ptr; - GHashTable *properties; - int num_sargs; - GPtrArray *sargs; - unsigned char is_fixed; - int query_order; - int col_num; -} MdbColumn; - -typedef union { - int i; - double d; - char s[256]; -} MdbAny; - -typedef struct { - int op; - MdbAny value; -} MdbSarg; - -/* mem.c */ -extern void mdb_init(); -extern void mdb_exit(); -extern MdbHandle *mdb_alloc_handle(); -extern void mdb_free_handle(MdbHandle *mdb); -extern void mdb_free_catalog(MdbHandle *mdb); -extern MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry); - -/* file.c */ -extern size_t mdb_read_pg(MdbHandle *mdb, unsigned long pg); -extern size_t mdb_read_alt_pg(MdbHandle *mdb, unsigned long pg); -extern unsigned char mdb_get_byte(MdbHandle *mdb, int offset); -extern int mdb_get_int16(MdbHandle *mdb, int offset); -extern long mdb_get_int32(MdbHandle *mdb, int offset); -extern double mdb_get_double(MdbHandle *mdb, int offset); -extern MdbHandle *mdb_open(char *filename); - -/* catalog.c */ -extern void mdb_catalog_dump(MdbHandle *mdb, int obj_type); -extern int mdb_catalog_rows(MdbHandle *mdb); -extern MdbCatalogEntry *mdb_get_catalog_entry(MdbHandle *mdb, int rowid, MdbCatalogEntry *entry); -extern char *mdb_get_objtype_string(int obj_type); - -/* table.c */ -extern MdbTableDef *mdb_read_table(MdbCatalogEntry *entry); - -/* data.c */ -extern void mdb_data_dump(MdbTableDef *table); -extern void mdb_bind_column(MdbTableDef *table, int col_num, void *bind_ptr); -extern int mdb_rewind_table(MdbTableDef *table); -extern int mdb_fetch_row(MdbTableDef *table); -extern int mdb_is_fixed_col(MdbColumn *col); -extern char *mdb_col_to_string(MdbHandle *mdb, int start, int datatype, int size); - - -/* dump.c */ -extern void buffer_dump(const unsigned char* buf, int start, int end); - -/* backend.c */ -extern char *mdb_get_coltype_string(MdbBackend *backend, int col_type); -extern void mdb_init_backends(); -extern void mdb_register_backend(MdbBackend *backend, char *backend_name); -extern int mdb_set_default_backend(MdbHandle *mdb, char *backend_name); -extern char *mdb_get_relationships(MdbHandle *mdb); - -#endif /* _mdbtools_h_ */ diff --git a/src/libmdb/config.h.in b/src/libmdb/config.h.in deleted file mode 100644 index 61025bc..0000000 --- a/src/libmdb/config.h.in +++ /dev/null @@ -1 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ diff --git a/src/libmdb/write.c b/src/libmdb/write.c index 43b836c..34c91c5 100644 --- a/src/libmdb/write.c +++ b/src/libmdb/write.c @@ -26,7 +26,7 @@ #endif -static int mdb_copy_index_pg(MdbTableDef *table, MdbIndexPage *ipg); +static int mdb_copy_index_pg(MdbTableDef *table, MdbIndex *idx, MdbIndexPage *ipg); void _mdb_put_int16(unsigned char *buf, guint32 offset, guint32 value) @@ -585,7 +585,7 @@ mdb_update_index(MdbTableDef *table, MdbIndex *idx, int num_fields, MdbField *fi mdb_index_find_row(mdb, idx, chain, pgnum, rownum); printf("chain depth = %d\n", chain->cur_depth); printf("pg = %lu\n", chain->pages[chain->cur_depth-1].pg); - mdb_copy_index_pg(table, &chain->pages[chain->cur_depth-1]); + mdb_copy_index_pg(table, idx, &chain->pages[chain->cur_depth-1]); return 1; } @@ -805,24 +805,58 @@ int i, pos; } return 0; } +/*mdb_add_row_to_leaf_pg(MdbTableDef *table, MdbIndex *idx, MdbIndexPage *ipg, MdbRow row, guint32 pgnum, guint16 rownum) */ static int -mdb_copy_index_pg(MdbTableDef *table, MdbIndexPage *ipg) +mdb_copy_index_pg(MdbTableDef *table, MdbIndex *idx, MdbIndexPage *ipg) { MdbCatalogEntry *entry = table->entry; MdbHandle *mdb = entry->mdb; + MdbColumn *col; guint32 pg; + guint16 row; unsigned char *new_pg; + unsigned char key_hash[256]; + unsigned char iflag; + int keycol; new_pg = mdb_new_leaf_pg(entry); mdb_index_page_reset(ipg); mdb_read_pg(mdb, ipg->pg); + + /* do we support this index type yet? */ + if (idx->num_keys > 1) { + fprintf(stderr,"multikey indexes not yet supported, aborting\n"); + return 0; + } + keycol = idx->key_col_num[0]; + col = g_ptr_array_index (table->columns, keycol - 1); + printf("keycol = %d (%s)\n", keycol, col->name); + if (!mdb_is_fixed_col(col)) { + fprintf(stderr,"variable length key columns not yet supported, aborting\n"); + return 0; + } + printf("col size = %d\n", col->col_size); + while (mdb_index_find_next_on_page(mdb, ipg)) { - pg = mdb_pg_get_int24_msb(mdb, ipg->offset + ipg->len - 3); + + if (ipg->len < col->col_size + 1) { + fprintf(stderr,"compressed indexes not yet supported, aborting\n"); + return 0; + } + pg = mdb_pg_get_int24_msb(mdb, ipg->offset + ipg->len - 4); + row = mdb->pg_buf[ipg->offset + ipg->len - 1]; + iflag = mdb->pg_buf[ipg->offset]; + mdb_index_swap_n(&mdb->pg_buf[ipg->offset + 1], col->col_size, key_hash); + key_hash[col->col_size - 1] &= 0x7f; printf("length = %d\n", ipg->len); + printf("iflag = %d pg = %lu row = %d\n", iflag, pg, row); buffer_dump(mdb->pg_buf, ipg->offset, ipg->offset + ipg->len - 1); + buffer_dump(mdb->pg_buf, ipg->offset + 1, ipg->offset + col->col_size); + buffer_dump(key_hash, 0, col->col_size - 1); ipg->offset += ipg->len; ipg->len = 0; + row++; } g_free(new_pg); diff --git a/src/util/config.h.in b/src/util/config.h.in deleted file mode 100644 index 61025bc..0000000 --- a/src/util/config.h.in +++ /dev/null @@ -1 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */