mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-11-26 02:09:49 +08:00
index work
dmalloc headers mem leak fixes start on i18n
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
AC_INIT(src/extras/mdb-dump.c)
|
AC_INIT(src/extras/mdb-dump.c)
|
||||||
AM_INIT_AUTOMAKE(mdbtools,0.5)
|
AM_INIT_AUTOMAKE(mdbtools,0.5)
|
||||||
|
AM_CONFIG_HEADER(include/config.h)
|
||||||
|
|
||||||
AC_PROG_CC(gcc)
|
AC_PROG_CC(gcc)
|
||||||
dnl Checks for programs.
|
dnl Checks for programs.
|
||||||
@@ -123,4 +124,7 @@ LDFLAGS=$OLDLDFLAGS
|
|||||||
|
|
||||||
AC_SUBST(READLINE_LIBS)
|
AC_SUBST(READLINE_LIBS)
|
||||||
|
|
||||||
|
localedir=${datadir}/locale
|
||||||
|
AC_SUBST(localedir)
|
||||||
|
|
||||||
AC_OUTPUT(src/util/Makefile src/extras/Makefile Makefile include/Makefile src/Makefile src/libmdb/Makefile include/Makefile src/sql/Makefile src/odbc/Makefile doc/Makefile src/gmdb2/Makefile src/gmdb2/gladefiles/Makefile src/gmdb2/pixmaps/Makefile src/gmdb2/help/Makefile src/gmdb2/help/C/Makefile mdbtools.spec)
|
AC_OUTPUT(src/util/Makefile src/extras/Makefile Makefile include/Makefile src/Makefile src/libmdb/Makefile include/Makefile src/sql/Makefile src/odbc/Makefile doc/Makefile src/gmdb2/Makefile src/gmdb2/gladefiles/Makefile src/gmdb2/pixmaps/Makefile src/gmdb2/help/Makefile src/gmdb2/help/C/Makefile mdbtools.spec)
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Access data types */
|
/* Access data types */
|
||||||
char *mdb_access_types[] =
|
char *mdb_access_types[] =
|
||||||
{"Unknown 0x00",
|
{"Unknown 0x00",
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
char *
|
char *
|
||||||
mdb_get_objtype_string(int obj_type)
|
mdb_get_objtype_string(int obj_type)
|
||||||
{
|
{
|
||||||
@@ -91,6 +95,9 @@ int type;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//mdb_dump_catalog(mdb, MDB_TABLE);
|
//mdb_dump_catalog(mdb, MDB_TABLE);
|
||||||
|
|
||||||
|
mdb_free_tabledef(table);
|
||||||
|
|
||||||
return mdb->catalog;
|
return mdb->catalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MDB_DEBUG_OLE 1
|
#define MDB_DEBUG_OLE 1
|
||||||
|
|
||||||
char *mdb_money_to_string(MdbHandle *mdb, int start, char *s);
|
char *mdb_money_to_string(MdbHandle *mdb, int start, char *s);
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void buffer_dump(const unsigned char* buf, int start, int end)
|
void buffer_dump(const unsigned char* buf, int start, int end)
|
||||||
{
|
{
|
||||||
char asc[20];
|
char asc[20];
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
MdbFormatConstants MdbJet4Constants = {
|
MdbFormatConstants MdbJet4Constants = {
|
||||||
4096, 0x0c, 12, 45, 47, 51, 55, 56, 63, 12, 15, 23, 5, 25
|
4096, 0x0c, 12, 45, 47, 51, 55, 56, 63, 12, 15, 23, 5, 25
|
||||||
};
|
};
|
||||||
@@ -143,7 +147,10 @@ mdb_close(MdbHandle *mdb)
|
|||||||
{
|
{
|
||||||
if (mdb->f) {
|
if (mdb->f) {
|
||||||
mdb->f->refs--;
|
mdb->f->refs--;
|
||||||
if (mdb->f->refs<=0) mdb_free_file(mdb->f);
|
if (mdb->f->refs<=0) {
|
||||||
|
mdb_free_file(mdb->f);
|
||||||
|
mdb->f = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MdbHandle *mdb_clone_handle(MdbHandle *mdb)
|
MdbHandle *mdb_clone_handle(MdbHandle *mdb)
|
||||||
|
|||||||
@@ -18,6 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
char idx_to_text[] = {
|
char idx_to_text[] = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0-7 0x00-0x07 */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0-7 0x00-0x07 */
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8-15 0x09-0x0f */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8-15 0x09-0x0f */
|
||||||
@@ -53,43 +58,70 @@ char idx_to_text[] = {
|
|||||||
0x81, 0x00, 0x00, 0x00, 'x', 0x00, 0x00, 0x00, /* 0xf8-0xff */
|
0x81, 0x00, 0x00, 0x00, 'x', 0x00, 0x00, 0x00, /* 0xf8-0xff */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GPtrArray *
|
GPtrArray *
|
||||||
mdb_read_indices(MdbTableDef *table)
|
mdb_read_indices(MdbTableDef *table)
|
||||||
{
|
{
|
||||||
MdbHandle *mdb = table->entry->mdb;
|
MdbCatalogEntry *entry = table->entry;
|
||||||
|
MdbHandle *mdb = entry->mdb;
|
||||||
|
MdbFormatConstants *fmt = mdb->fmt;
|
||||||
MdbIndex idx, *pidx;
|
MdbIndex idx, *pidx;
|
||||||
int i, j;
|
int i, j;
|
||||||
int idx_num, key_num, col_num;
|
int idx_num, key_num, col_num;
|
||||||
int cur_pos;
|
int cur_pos;
|
||||||
int name_sz;
|
int name_sz, idx2_sz;
|
||||||
|
gchar *tmpbuf;
|
||||||
|
|
||||||
/* FIX ME -- doesn't handle multipage table headers */
|
/* FIX ME -- doesn't handle multipage table headers */
|
||||||
|
|
||||||
table->indices = g_ptr_array_new();
|
table->indices = g_ptr_array_new();
|
||||||
|
|
||||||
cur_pos = table->index_start + 39 * table->num_real_idxs;
|
if (IS_JET4(mdb)) {
|
||||||
|
cur_pos = table->index_start + 52 * table->num_real_idxs;
|
||||||
|
idx2_sz = 27;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cur_pos = table->index_start + 39 * table->num_real_idxs;
|
||||||
|
idx2_sz = 19;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0;i<table->num_idxs;i++) {
|
for (i=0;i<table->num_idxs;i++) {
|
||||||
memset(&idx, '\0', sizeof(MdbIndex));
|
memset(&idx, '\0', sizeof(MdbIndex));
|
||||||
idx.table = table;
|
idx.table = table;
|
||||||
idx.index_num = mdb_get_int16(mdb, cur_pos);
|
cur_pos +=4;
|
||||||
cur_pos += 19;
|
idx.index_num = read_pg_if_16(mdb, &cur_pos);
|
||||||
|
read_pg_if(mdb, &cur_pos, idx2_sz - 4);
|
||||||
|
cur_pos += idx2_sz - 4;
|
||||||
idx.index_type = mdb->pg_buf[cur_pos++];
|
idx.index_type = mdb->pg_buf[cur_pos++];
|
||||||
mdb_append_index(table->indices, &idx);
|
mdb_append_index(table->indices, &idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<table->num_idxs;i++) {
|
for (i=0;i<table->num_idxs;i++) {
|
||||||
pidx = g_ptr_array_index (table->indices, i);
|
pidx = g_ptr_array_index (table->indices, i);
|
||||||
name_sz=mdb->pg_buf[cur_pos++];
|
read_pg_if(mdb, &cur_pos, 0);
|
||||||
memcpy(pidx->name, &mdb->pg_buf[cur_pos], name_sz);
|
if (IS_JET4(mdb)) {
|
||||||
pidx->name[name_sz]='\0';
|
name_sz=read_pg_if_16(mdb, &cur_pos);
|
||||||
|
cur_pos += 2;
|
||||||
|
tmpbuf = g_malloc((name_sz + 1)*2);
|
||||||
|
read_pg_if_n(mdb, tmpbuf, &cur_pos, name_sz*2);
|
||||||
|
mdb_unicode2ascii(mdb, tmpbuf, 0, name_sz, pidx->name);
|
||||||
|
g_free(tmpbuf);
|
||||||
|
cur_pos += name_sz;
|
||||||
|
} else {
|
||||||
|
name_sz=mdb->pg_buf[cur_pos++];
|
||||||
|
read_pg_if_n(mdb, pidx->name, &cur_pos, name_sz);
|
||||||
|
pidx->name[name_sz]='\0';
|
||||||
|
cur_pos += name_sz;
|
||||||
|
}
|
||||||
//fprintf(stderr, "index name %s\n", pidx->name);
|
//fprintf(stderr, "index name %s\n", pidx->name);
|
||||||
cur_pos += name_sz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_pos = table->index_start;
|
cur_pos = table->index_start;
|
||||||
|
mdb_read_alt_pg(mdb, entry->table_pg);
|
||||||
|
mdb_read_pg(mdb, entry->table_pg);
|
||||||
idx_num=0;
|
idx_num=0;
|
||||||
for (i=0;i<table->num_real_idxs;i++) {
|
for (i=0;i<table->num_real_idxs;i++) {
|
||||||
|
if (IS_JET4(mdb)) cur_pos += 4;
|
||||||
do {
|
do {
|
||||||
pidx = g_ptr_array_index (table->indices, idx_num++);
|
pidx = g_ptr_array_index (table->indices, idx_num++);
|
||||||
} while (pidx && pidx->index_type==2);
|
} while (pidx && pidx->index_type==2);
|
||||||
@@ -103,11 +135,13 @@ int name_sz;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pidx->num_rows = mdb_get_int32(mdb, 43+(i*8) );
|
pidx->num_rows = _mdb_get_int32(mdb->alt_pg_buf,
|
||||||
|
fmt->tab_cols_start_offset +
|
||||||
|
(i*fmt->tab_ridx_entry_size));
|
||||||
|
|
||||||
key_num=0;
|
key_num=0;
|
||||||
for (j=0;j<MDB_MAX_IDX_COLS;j++) {
|
for (j=0;j<MDB_MAX_IDX_COLS;j++) {
|
||||||
col_num=mdb_get_int16(mdb,cur_pos);
|
col_num=read_pg_if_16(mdb,&cur_pos);
|
||||||
cur_pos += 2;
|
cur_pos += 2;
|
||||||
if (col_num != 0xFFFF) {
|
if (col_num != 0xFFFF) {
|
||||||
/* set column number to a 1 based column number and store */
|
/* set column number to a 1 based column number and store */
|
||||||
@@ -123,9 +157,11 @@ int name_sz;
|
|||||||
}
|
}
|
||||||
pidx->num_keys = key_num;
|
pidx->num_keys = key_num;
|
||||||
cur_pos += 4;
|
cur_pos += 4;
|
||||||
pidx->first_pg = mdb_get_int32(mdb, cur_pos);
|
pidx->first_pg = read_pg_if_32(mdb, &cur_pos);
|
||||||
cur_pos += 4;
|
cur_pos += 4;
|
||||||
|
read_pg_if(mdb, &cur_pos, 1);
|
||||||
pidx->flags = mdb->pg_buf[cur_pos++];
|
pidx->flags = mdb->pg_buf[cur_pos++];
|
||||||
|
if (IS_JET4(mdb)) cur_pos += 9;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -569,7 +605,7 @@ mdb_choose_index(MdbTableDef *table, int *choice)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* and the winner is: *choice */
|
/* and the winner is: *choice */
|
||||||
if (!least) return MDB_TABLE_SCAN;
|
if (least==99) return MDB_TABLE_SCAN;
|
||||||
return MDB_INDEX_SCAN;
|
return MDB_INDEX_SCAN;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
@@ -590,6 +626,7 @@ mdb_index_scan_init(MdbHandle *mdb, MdbTableDef *table)
|
|||||||
mdb_read_pg(table->mdbidx, table->scan_idx->first_pg);
|
mdb_read_pg(table->mdbidx, table->scan_idx->first_pg);
|
||||||
//printf("best index is %s\n",table->scan_idx->name);
|
//printf("best index is %s\n",table->scan_idx->name);
|
||||||
}
|
}
|
||||||
|
//printf("TABLE SCAN? %d\n", table->strategy);
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
mdb_index_scan_free(MdbTableDef *table)
|
mdb_index_scan_free(MdbTableDef *table)
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Note: This code is mostly garbage right now...just a test to parse out the
|
** Note: This code is mostly garbage right now...just a test to parse out the
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
//#define MDB_DEBUG_LIKE 1
|
//#define MDB_DEBUG_LIKE 1
|
||||||
|
|
||||||
int mdb_like_cmp(char *s, char *r)
|
int mdb_like_cmp(char *s, char *r)
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void mdb_init()
|
void mdb_init()
|
||||||
{
|
{
|
||||||
mdb_init_backends();
|
mdb_init_backends();
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAXPRECISION 9
|
#define MAXPRECISION 9
|
||||||
/*
|
/*
|
||||||
** these routines are copied from the freetds project which does something
|
** these routines are copied from the freetds project which does something
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
mdb_sql_walk_tree(MdbSargNode *node, MdbSargTreeFunc func, gpointer data)
|
mdb_sql_walk_tree(MdbSargNode *node, MdbSargTreeFunc func, gpointer data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
mdb_stats_on(MdbHandle *mdb)
|
mdb_stats_on(MdbHandle *mdb)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MDB_DEBUG_USAGE 0
|
#define MDB_DEBUG_USAGE 0
|
||||||
|
|
||||||
static gint mdb_col_comparer(MdbColumn *a, MdbColumn *b)
|
static gint mdb_col_comparer(MdbColumn *a, MdbColumn *b)
|
||||||
@@ -86,7 +90,8 @@ int rownum, row_start, row_end;
|
|||||||
** read the next page if offset is > pg_size
|
** read the next page if offset is > pg_size
|
||||||
** return true if page was read
|
** return true if page was read
|
||||||
*/
|
*/
|
||||||
static int read_pg_if(MdbHandle *mdb, int *cur_pos, int offset)
|
int
|
||||||
|
read_pg_if(MdbHandle *mdb, int *cur_pos, int offset)
|
||||||
{
|
{
|
||||||
if (*cur_pos + offset >= mdb->fmt->pg_size) {
|
if (*cur_pos + offset >= mdb->fmt->pg_size) {
|
||||||
mdb_read_pg(mdb, mdb_get_int32(mdb,4));
|
mdb_read_pg(mdb, mdb_get_int32(mdb,4));
|
||||||
@@ -95,6 +100,47 @@ static int read_pg_if(MdbHandle *mdb, int *cur_pos, int offset)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
guint32
|
||||||
|
read_pg_if_32(MdbHandle *mdb, int *cur_pos)
|
||||||
|
{
|
||||||
|
unsigned char c[4];
|
||||||
|
int i, rc = 0;
|
||||||
|
|
||||||
|
for (i=0;i<4;i++) {
|
||||||
|
rc += read_pg_if(mdb, cur_pos, i);
|
||||||
|
c[i] = mdb->pg_buf[(*cur_pos) + i];
|
||||||
|
}
|
||||||
|
return _mdb_get_int32(c, 0);
|
||||||
|
}
|
||||||
|
guint16
|
||||||
|
read_pg_if_16(MdbHandle *mdb, int *cur_pos)
|
||||||
|
{
|
||||||
|
unsigned char low_byte, high_byte;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
rc += read_pg_if(mdb, cur_pos, 0);
|
||||||
|
low_byte = mdb->pg_buf[*cur_pos];
|
||||||
|
rc += read_pg_if(mdb, cur_pos, 1);
|
||||||
|
high_byte = mdb->pg_buf[(*cur_pos) + 1];
|
||||||
|
|
||||||
|
return (high_byte * 256 + low_byte);
|
||||||
|
}
|
||||||
|
guint16
|
||||||
|
read_pg_if_n(MdbHandle *mdb, unsigned char *buf, int *cur_pos, int len)
|
||||||
|
{
|
||||||
|
int half;
|
||||||
|
|
||||||
|
if (*cur_pos + len < mdb->fmt->pg_size) {
|
||||||
|
memcpy(buf, &mdb->pg_buf[*cur_pos], len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
half = (mdb->fmt->pg_size - *cur_pos - 1);
|
||||||
|
memcpy(buf, &mdb->pg_buf[*cur_pos], half);
|
||||||
|
mdb_read_pg(mdb, mdb_get_int32(mdb,4));
|
||||||
|
memcpy(buf, &mdb->pg_buf[8], len - half);
|
||||||
|
*cur_pos = 8 - (mdb->fmt->pg_size - (*cur_pos));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
GPtrArray *mdb_read_columns(MdbTableDef *table)
|
GPtrArray *mdb_read_columns(MdbTableDef *table)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MDB_DEBUG_WRITE 1
|
#define MDB_DEBUG_WRITE 1
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
#include "mdbsql.h"
|
#include "mdbsql.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void mdb_dump_results(MdbSQL *sql);
|
void mdb_dump_results(MdbSQL *sql);
|
||||||
|
|
||||||
#ifdef HAVE_WORDEXP_H
|
#ifdef HAVE_WORDEXP_H
|
||||||
@@ -74,19 +78,29 @@ MdbSQLSarg *sql_sarg;
|
|||||||
memset(sql_sarg->sarg,0,sizeof(MdbSarg));
|
memset(sql_sarg->sarg,0,sizeof(MdbSarg));
|
||||||
return sql_sarg;
|
return sql_sarg;
|
||||||
}
|
}
|
||||||
|
void mdb_sql_free_column(MdbSQLColumn *c)
|
||||||
|
{
|
||||||
|
if (c->name) g_free(c->name);
|
||||||
|
g_free(c);
|
||||||
|
}
|
||||||
MdbSQLColumn *mdb_sql_alloc_column()
|
MdbSQLColumn *mdb_sql_alloc_column()
|
||||||
{
|
{
|
||||||
MdbSQLColumn *c;
|
MdbSQLColumn *c;
|
||||||
|
|
||||||
c = (MdbSQLColumn *) malloc(sizeof(MdbSQLColumn));
|
c = (MdbSQLColumn *) g_malloc(sizeof(MdbSQLColumn));
|
||||||
memset(c,0,sizeof(MdbSQLColumn));
|
memset(c,0,sizeof(MdbSQLColumn));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
void mdb_sql_free_table(MdbSQLTable *t)
|
||||||
|
{
|
||||||
|
if (t->name) g_free(t->name);
|
||||||
|
g_free(t);
|
||||||
|
}
|
||||||
MdbSQLTable *mdb_sql_alloc_table()
|
MdbSQLTable *mdb_sql_alloc_table()
|
||||||
{
|
{
|
||||||
MdbSQLTable *t;
|
MdbSQLTable *t;
|
||||||
|
|
||||||
t = (MdbSQLTable *) malloc(sizeof(MdbSQLTable));
|
t = (MdbSQLTable *) g_malloc(sizeof(MdbSQLTable));
|
||||||
memset(t,0,sizeof(MdbSQLTable));
|
memset(t,0,sizeof(MdbSQLTable));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@@ -387,6 +401,8 @@ MdbSQLSarg *sql_sarg;
|
|||||||
g_ptr_array_free(sql->columns,TRUE);
|
g_ptr_array_free(sql->columns,TRUE);
|
||||||
g_ptr_array_free(sql->tables,TRUE);
|
g_ptr_array_free(sql->tables,TRUE);
|
||||||
g_ptr_array_free(sql->sargs,TRUE);
|
g_ptr_array_free(sql->sargs,TRUE);
|
||||||
|
mdb_close(sql->mdb);
|
||||||
|
mdb_free_handle(sql->mdb);
|
||||||
}
|
}
|
||||||
void mdb_sql_reset(MdbSQL *sql)
|
void mdb_sql_reset(MdbSQL *sql)
|
||||||
{
|
{
|
||||||
@@ -402,11 +418,11 @@ MdbSQLSarg *sql_sarg;
|
|||||||
}
|
}
|
||||||
for (i=0;i<sql->num_columns;i++) {
|
for (i=0;i<sql->num_columns;i++) {
|
||||||
c = g_ptr_array_index(sql->columns,i);
|
c = g_ptr_array_index(sql->columns,i);
|
||||||
if (c->name) g_free(c->name);
|
mdb_sql_free_column(c);
|
||||||
}
|
}
|
||||||
for (i=0;i<sql->num_tables;i++) {
|
for (i=0;i<sql->num_tables;i++) {
|
||||||
t = g_ptr_array_index(sql->tables,i);
|
t = g_ptr_array_index(sql->tables,i);
|
||||||
if (t->name) g_free(t->name);
|
mdb_sql_free_table(t);
|
||||||
}
|
}
|
||||||
for (i=0;i<sql->num_sargs;i++) {
|
for (i=0;i<sql->num_sargs;i++) {
|
||||||
sql_sarg = g_ptr_array_index(sql->sargs,i);
|
sql_sarg = g_ptr_array_index(sql->sargs,i);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
bin_PROGRAMS = mdb-export mdb-array mdb-schema mdb-tables mdb-parsecsv mdb-header mdb-sql mdb-ver prtable prcat prdata prkkd prdump prole updrow prindex
|
bin_PROGRAMS = mdb-export mdb-array mdb-schema mdb-tables mdb-parsecsv mdb-header mdb-sql mdb-ver prtable prcat prdata prkkd prdump prole updrow prindex
|
||||||
LIBS = $(GLIB_LIBS) $(READLINE_LIBS) @LEXLIB@
|
LIBS = $(GLIB_LIBS) $(READLINE_LIBS) @LEXLIB@
|
||||||
|
DEFS = @DEFS@ -DLOCALEDIR=\"$(localedir)\"
|
||||||
INCLUDES = -I$(top_srcdir)/include $(GLIB_CFLAGS)
|
INCLUDES = -I$(top_srcdir)/include $(GLIB_CFLAGS)
|
||||||
LDADD = ../libmdb/libmdb.la
|
LDADD = ../libmdb/libmdb.la
|
||||||
if SQL
|
if SQL
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
dbcc_page_usage(MdbTableDef *table)
|
dbcc_page_usage(MdbTableDef *table)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,9 +17,12 @@
|
|||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define is_text_type(x) (x==MDB_TEXT || x==MDB_MEMO || x==MDB_SDATETIME)
|
#define is_text_type(x) (x==MDB_TEXT || x==MDB_MEMO || x==MDB_SDATETIME)
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@@ -129,9 +132,11 @@ char *s;
|
|||||||
for (j=0;j<table->num_cols;j++) {
|
for (j=0;j<table->num_cols;j++) {
|
||||||
free(bound_values[j]);
|
free(bound_values[j]);
|
||||||
}
|
}
|
||||||
|
mdb_free_tabledef(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mdb_close(mdb);
|
||||||
mdb_free_handle(mdb);
|
mdb_free_handle(mdb);
|
||||||
mdb_exit();
|
mdb_exit();
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,13 @@
|
|||||||
|
|
||||||
/* this utility dumps the C headers for an existing database */
|
/* this utility dumps the C headers for an existing database */
|
||||||
/* it will create three files - types.h and dump_types.[ch] */
|
/* it will create three files - types.h and dump_types.[ch] */
|
||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void copy_header (FILE *f)
|
void copy_header (FILE *f)
|
||||||
{
|
{
|
||||||
fprintf (f, "/******************************************************************/\n");
|
fprintf (f, "/******************************************************************/\n");
|
||||||
|
|||||||
@@ -19,11 +19,14 @@
|
|||||||
/* this utility converts a CSV from an existing database to a C file */
|
/* this utility converts a CSV from an existing database to a C file */
|
||||||
/* input FOO.txt, output FOO.c */
|
/* input FOO.txt, output FOO.c */
|
||||||
/* generates an array of type FOO */
|
/* generates an array of type FOO */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FILENAMESIZE 128
|
#define FILENAMESIZE 128
|
||||||
#define BUFFERSIZE 4096
|
#define BUFFERSIZE 4096
|
||||||
#define LF 10
|
#define LF 10
|
||||||
|
|||||||
@@ -17,9 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* this utility dumps the schema for an existing database */
|
/* this utility dumps the schema for an existing database */
|
||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef HAVE_READLINE
|
#ifdef HAVE_READLINE
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
@@ -24,6 +23,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "mdbsql.h"
|
#include "mdbsql.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void dump_results(MdbSQL *sql);
|
void dump_results(MdbSQL *sql);
|
||||||
void dump_results_pp(MdbSQL *sql);
|
void dump_results_pp(MdbSQL *sql);
|
||||||
|
|
||||||
@@ -415,6 +418,8 @@ FILE *in = NULL, *out = NULL;
|
|||||||
}
|
}
|
||||||
mdb_sql_exit(sql);
|
mdb_sql_exit(sql);
|
||||||
|
|
||||||
|
free(mybuf);
|
||||||
|
free(s);
|
||||||
myexit(0);
|
myexit(0);
|
||||||
|
|
||||||
return 0; /* make gcc -Wall happy */
|
return 0; /* make gcc -Wall happy */
|
||||||
|
|||||||
@@ -17,9 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* this utility dumps the schema for an existing database */
|
/* this utility dumps the schema for an existing database */
|
||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -84,7 +87,8 @@ int opt;
|
|||||||
if (!line_break)
|
if (!line_break)
|
||||||
fprintf (stdout, "\n");
|
fprintf (stdout, "\n");
|
||||||
|
|
||||||
mdb_free_handle (mdb);
|
mdb_close(mdb);
|
||||||
|
mdb_free_handle(mdb);
|
||||||
mdb_exit();
|
mdb_exit();
|
||||||
if (delimiter) free(delimiter);
|
if (delimiter) free(delimiter);
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,13 @@
|
|||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
#include "mdbprivate.h"
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
|
#ifdef DMALLOC
|
||||||
|
#include "dmalloc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@@ -26,12 +31,15 @@ main(int argc, char **argv)
|
|||||||
MdbHandle *mdb;
|
MdbHandle *mdb;
|
||||||
/* doesn't handle tables > 256 columns. Can that happen? */
|
/* doesn't handle tables > 256 columns. Can that happen? */
|
||||||
|
|
||||||
|
/* setlocale (LC_ALL, ""); */
|
||||||
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
|
textdomain (PACKAGE);
|
||||||
/*
|
/*
|
||||||
** optind is now the position of the first non-option arg,
|
** optind is now the position of the first non-option arg,
|
||||||
** see getopt(3)
|
** see getopt(3)
|
||||||
*/
|
*/
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr,"Usage: %s <file>\n",argv[0]);
|
fprintf(stderr,_("Usage: %s <file>\n"),argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +53,7 @@ MdbHandle *mdb;
|
|||||||
} else if (IS_JET4(mdb)) {
|
} else if (IS_JET4(mdb)) {
|
||||||
printf("JET4\n");
|
printf("JET4\n");
|
||||||
} else {
|
} else {
|
||||||
printf("unknown\n");
|
printf(_("unknown database version\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mdb_free_handle(mdb);
|
mdb_free_handle(mdb);
|
||||||
|
|||||||
Reference in New Issue
Block a user