port of gmdb to gnome2. lots o other stuff

This commit is contained in:
brianb
2002-12-27 15:09:02 +00:00
parent fcd99f54e0
commit 16735470a7
56 changed files with 6630 additions and 241 deletions

66
HACKING
View File

@@ -47,6 +47,7 @@ pages have the following values:
0x02 Table definition
0x03 Index pages
0x04 Index pages (Leaf nodes?)
0x05 Page Usage Bitmaps (extended page usage)
The second byte is always 0x01 as far as I can tell.
@@ -256,6 +257,65 @@ Beyond this are a series of 20 byte fields for each 'index entry'. There may be
It is currently unknown how indexes are mapped to columns or the format of the index pages.
(end old stuff)
Page Usage Map
--------------
The purpose of the page usage bitmap (called object allocation map (OAM) by
SQL Server, not sure what the official terminology is for Access) is to store
a bitmap of page allocations for a table. This determines quickly which pages
are owned by the table and helps speed up access to the data.
The table definition contains a data pointer to a usage bitmap of pages
allocated to this table. It appears to be of a fixed size for both Jet 3
and 4 (128 and 64 bytes respectively). The first byte of the map is a type
field.
Type 0 page usage map definition follows:
+------+---------+---------------------------------------------------------+
| data | length | name | description |
+------+---------+---------------------------------------------------------+
| 0x00 | 1 byte | map_type | 0x00 indicates map stored within. |
| ???? | 4 byte | page_start | first page for which this map applies |
+------+---------+---------------------------------------------------------+
| Iterate for the length of map |
+--------------------------------------------------------------------------+
| ???? | 1 byte | bitmap | each bit encodes the allocation status of a|
| | | | page. 1 indicates allocated to this table. |
| | | | Pages are stored from msb to lsb. |
+--------------------------------------------------------------------------+
If you're paying attention then you'll realize that the relatively small size of the map (128*8*2048 or 64*8*4096 = 2 Meg) means that this scheme won't work with larger database files although the initial start page helps a bit. To overcome this there is a second page usage map scheme with the map_type of 0x01 as follows:
+------+---------+---------------------------------------------------------+
| data | length | name | description |
+------+---------+---------------------------------------------------------+
| 0x01 | 1 byte | map_type | 0x01 indicates this is a indirection list. |
+------+---------+---------------------------------------------------------+
| Iterate for the length of map |
+--------------------------------------------------------------------------+
| ???? | 4 bytes | map_page | pointer to page type 0x05 containing map |
+--------------------------------------------------------------------------+
Note that the intial start page is gone and is reused for the first page indirection. The 0x05 type page header looks like:
+------+---------+---------------------------------------------------------+
| data | length | name | description |
+------+---------+---------------------------------------------------------+
| 0x05 | 1 byte | page_type | allocation map page |
| 0x01 | 1 byte | unknown | always 1 as with other page types |
| 0x00 | 2 bytes | unknown | |
+------+---------+---------------------------------------------------------+
The rest of the page is the allocation bitmap following the same scheme (lsb
to msb order, 1 bit per page) as a type 0 map. This yields a maximum of
2044*8=16352 (jet3) or 4092*8 = 32736 (jet4) pages mapped per type 0x05 page.
Given 128/4+1 = 33 or 64/4+1 = 17 page pointers per indirection row (remember
the start page field is reused, thus the +1), this yields 33*16352*2048 = 1053
Meg (jet3) or 17*32736*4096 = 2173 Meg (jet4) or enough to cover the maximum
size of each of the database formats comfortably, so there is no reason to
believe any other page map schemes exist.
Data Pages
----------
@@ -322,6 +382,8 @@ Note: it is possible for the offset to the beginning of a variable length
column to require more than one byte (if the sum of the lengths of columns is
greater than 255). I have no idea how this is represented in the data as I
have not looked at tables large enough for this to occur yet.
Update: This is currently implemented using a jump counter for Jet 3 files, see
src/libmdb/data.c for details.
Each memo column (or other long binary data) in a row
looks like this (12 bytes):
@@ -421,13 +483,15 @@ Design View table definitions appear to be stored in 'KKD' records (my name for
them...they always start with 'KKD\0'). Again these reside on pages, packed to
the end of the page.
Update: The KKD records are stored in LvProp column of MSysObjects so they are stored as other OLE/Memo fields are.
They look a little like this: (this needs work...see the kkd.c)
'K' 'K' 'D' 0x00
16 bit length value (this includes the length)
0x00 0x00
0x80 0x00 (0x80 seems to indicate a header)
Then one of more of: 16 bit length field and a value of that size.
Then one or more of: 16 bit length field and a value of that size.
For instance:
0x0d 0x00 and 'AccessVersion' (AccessVersion is 13 bytes, 0x0d 0x00 intel order)

View File

@@ -30,6 +30,7 @@ prcat -- prints the catalog table from an mdb file,
prkkd -- dump of information about design view data given the offset to it.
prtable -- dump of a table definition.
prdata -- dump of the data given a table name.
prole -- dump of ole columns given a table name and sargs.
Once MDB Tools has been compiled, libmdb.[so|a] will be in the src/libmdb
directory and the utility programs will be in the src/util directory.
@@ -42,8 +43,8 @@ Installation Options
configure can be passed any of the following flags to turn on other
capabilities.
--enable-sql will cause the SQL engine to be built, you must have flex and
bison installed for this option.
--enable-sql will cause the SQL engine to be built, you must have flex
and bison installed for this option.
--with-unixodbc specifies the location of the unixODBC driver manager and
causes the ODBC driver to be built.

6
TODO
View File

@@ -17,12 +17,13 @@ libmdb:
. Sargs need to support all datatypes
. Need a way to express logical relationships between sargs (tree)
. Add support for index scanning when using sargs
. Use allocation maps to read tables, should be more efficient
. Use allocation maps to read tables, should be more efficient (done
if -DFAST_READ specified)
. write support
utils:
. need program to unpack VBA script to file
. need program to unpack VBA script to file (see prole)
. Access forms to glade converter ?
SQL Engine:
@@ -32,6 +33,7 @@ SQL Engine:
. OR clauses using sarg trees from above
. insert/updates
. bogus column name in where clause not caught
. const = const type operations not working (e.g. WHERE 0=1)
ODBC:

View File

@@ -17,92 +17,71 @@ AC_CHECK_HEADERS(wordexp.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_C_BIGENDIAN
dnl no optional stuff by default
OPTDIRS=""
dnl ---------------------------------------------------------------------
dnl Compile time options
dnl ---------------------------------------------------------------------
AC_ARG_WITH(iodbc,
[ --with-iodbc=/path/to/iodbc build odbc driver against iODBC])
if test "$with_iodbc"; then
CFLAGS="$CFLAGS -DIODBC";
ODBC_INC=$with_iodbc/include;
odbc=true
fi
AC_ARG_WITH(iodbc,
[ --with-unixodbc=/path/to/unixodbc build odbc driver against unixODBC])
if test "$with_unixodbc"; then
CFLAGS="$CFLAGS -DUNIXODBC"
ODBC_INC=$with_unixodbc/include
odbc=true
fi
AM_CONDITIONAL(HAVE_ODBC, test x$odbc = xtrue)
AC_SUBST(HAVE_ODBC)
AC_SUBST(ODBC_INC)
AC_ARG_ENABLE(sql,
[ --enable-sql Enable SQL engine])
if test "$enable_sql" = "yes" ; then
CFLAGS="$CFLAGS -DSQL"
sql=true
OPTDIRS="$OPTDIRS sql"
fi
AM_CONDITIONAL(SQL, test x$sql = xtrue)
AC_SUBST(SQL)
dnl gnome check modified from gnome-db
AC_MSG_CHECKING(for GTK >= 1.2.0)
if gnome-config --version > /dev/null 2>&1
then
verstxt=`gtk-config --version`
vers=`echo "$verstxt" | \
awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
if test "$vers" -ge 1002000
then
AC_MSG_RESULT(found)
GMDB_LIBS=`gtk-config --libs`
GMDB_CFLAGS=`gtk-config --cflags`
havegtk=true
else
AC_MSG_RESULT(not found)
havegtk=false
dnl check for iODBC
AC_ARG_WITH(iodbc,
[ --with-iodbc=/path/to/iodbc build odbc driver against iODBC])
if test "$with_iodbc"; then
CFLAGS="$CFLAGS -DIODBC";
ODBC_INC=$with_iodbc/include;
odbc=true
OPTDIRS="$OPTDIRS odbc"
if test "$enable_sql" != "yes" ; then
echo
echo ODBC requires the --enable-sql flag
exit 1
fi
else
AC_MSG_RESULT(not found)
havegtk=false
fi
AM_CONDITIONAL(HAVE_GTK, test x$havegtk = xtrue)
dnl check for unixODBC
AC_ARG_WITH(unixodbc,
[ --with-unixodbc=/path/to/unixodbc build odbc driver against unixODBC])
if test "$with_unixodbc"; then
CFLAGS="$CFLAGS -DUNIXODBC"
ODBC_INC=$with_unixodbc/include
odbc=true
OPTDIRS="$OPTDIRS odbc"
if test "$enable_sql" != "yes" ; then
echo
echo ODBC requires the --enable-sql flag
exit 1
fi
fi
AM_CONDITIONAL(HAVE_ODBC, test x$odbc = xtrue)
AC_SUBST(HAVE_ODBC)
AC_SUBST(ODBC_INC)
dnl check for glib/gtk/gnome
AM_PATH_GLIB_2_0(2.0.0)
AM_PATH_GTK_2_0(2.0.0)
AM_CONDITIONAL(HAVE_GTK, test x$no_gtk = xtrue)
AC_SUBST(HAVE_GTK)
dnl gnome check modified from gnome-db
AC_MSG_CHECKING(for Gnome >= 1.2.0)
if gnome-config --version > /dev/null 2>&1
then
verstxt=`gnome-config --version`
vers=`echo "$verstxt" | sed -e "s/^gnome-libs //" | \
awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
if test "$vers" -ge 1002000
then
AC_MSG_RESULT(found)
CFLAGS="$CFLAGS -DHAVE_GNOME"
GMDB_LIBS=`gnome-config gnome gnomeui --libs`
GMDB_CFLAGS=`gnome-config gnome gnomeui --cflags`
havegnome=true
else
AC_MSG_RESULT(not found)
havegnome=false
fi
else
AC_MSG_RESULT(not found)
havegnome=false
if test "$no_gtk" != yes; then
OPTDIRS="$OPTDIRS gmdb2"
fi
AM_CONDITIONAL(HAVE_GNOME, test x$havegnome = xtrue)
AC_SUBST(HAVE_GNOME)
AC_SUBST(GMDB_LIBS)
AC_SUBST(GMDB_CFLAGS)
AC_SUBST([OPTDIRS])
AC_CONFIG_FILES([src/Makefile])
dnl Checks for library functions.
@@ -122,4 +101,4 @@ LDFLAGS=$OLDLDFLAGS
AC_SUBST(READLINE_LIBS)
AC_OUTPUT(src/util/Makefile src/extras/Makefile Makefile include/Makefile src/Makefile src/libmdb/Makefile include/Makefile src/sql/Makefile src/odbc/Makefile src/gmdb/Makefile)
AC_OUTPUT(src/util/Makefile src/extras/Makefile Makefile include/Makefile src/Makefile src/libmdb/Makefile include/Makefile src/sql/Makefile src/odbc/Makefile src/gmdb2/Makefile)

View File

@@ -56,7 +56,8 @@ enum {
MDB_RELATIONSHIP,
MDB_UNKNOWN_09,
MDB_UNKNOWN_0A,
MDB_DATABASE_PROPERTY
MDB_DATABASE_PROPERTY,
MDB_ANY = -1
};
enum {
MDB_BOOL = 0x01,
@@ -114,6 +115,9 @@ typedef struct {
char db_passwd[14];
MdbBackend *default_backend;
char *backend_name;
/* free map */
int map_sz;
unsigned char *free_map;
/* offset to row count on data pages...version dependant */
guint16 row_count_offset;
guint16 tab_num_rows_offset;

View File

@@ -1,7 +1,3 @@
if SQL
SUBDIRS = libmdb sql util extras odbc gmdb
SUBDIRS = libmdb extras $(OPTDIRS) util
DIST_SUBDIRS = libmdb extras sql odbc gmdb2 util
DEFDIR = $(prefix)
else
SUBDIRS = libmdb util extras
DEFDIR = $(prefix)
endif

View File

@@ -26,11 +26,26 @@ int main(int argc, char **argv)
int pg=0;
char addr[10];
int jet4 = 0;
int pg_size = 2048;
if (argc < 1) {
fprintf(stderr, "Usage: mdb-dump <filename>\n\n");
fprintf(stderr, "Usage: mdb-dump <filename> [<page number>]\n\n");
exit(1);
}
if (argc>2) {
if (!strncmp(argv[2],"0x",2)) {
for (i=2;i<strlen(argv[2]);i++) {
pg *= 16;
//if (islower(argv[2][i]))
//argv[2][i] += 0x20;
printf("char %c\n", (int)argv[2][i]);
pg += argv[2][i] > '9' ? argv[2][i] - 'a' + 10 : argv[2][i] - '0';
}
} else {
pg = atol(argv[2]);
}
}
printf("page num %d\n", pg);
if ((in = fopen(argv[1],"r"))==NULL) {
fprintf(stderr, "Couldn't open file %s\n", argv[1]);
exit(1);
@@ -39,10 +54,14 @@ int main(int argc, char **argv)
fread(data,1,1,in);
if (data[0]==0x01) {
jet4 = 1;
pg_size = 4096;
}
fseek(in,0,SEEK_SET);
fseek(in,(pg*pg_size),SEEK_SET);
i = 0;
while (length = fread(data,1,16,in)) {
sprintf(addr, "%06x", i);
//if (!strcmp(&addr[3],"000") || (!jet4 && !strcmp(&addr[3],"800")) &&
//pg) break;
if (!strcmp(&addr[3],"000") || (!jet4 && !strcmp(&addr[3],"800"))) {
fprintf(stdout,"-- Page 0x%04x (%d) --\n", pg, pg);
pg++;

11
src/gmdb2/Makefile.am Normal file
View File

@@ -0,0 +1,11 @@
bin_PROGRAMS = gmdb2
include_HEADERS = gmdb.h debug.xpm forms.xpm macros.xpm pk.xpm \
table.xpm query.xpm code.xpm reports.xpm
gmdb2_SOURCES = main2.c file.c util.c table.c query.c module.c macro.c report.c form.c info.c table_def.c table_data.c table_export.c debug.c
LIBS = -rdynamic $(GNOME_LIBS) $(GLADE_LIBS) @LEXLIB@
INCLUDES = -I$(top_srcdir)/include $(GNOME_CFLAGS) $(GLADE_CFLAGS)
#LDADD = ../libmdb/libmdb.la
LDADD = ../libmdb/libmdb.la ../sql/libmdbsql.la
#if SQL
#gmdb_LDADD = ../libmdb/libmdb.la ../sql/libmdbsql.la
#endif

22
src/gmdb2/code.xpm Normal file
View File

@@ -0,0 +1,22 @@
/* XPM */
static char * code_xpm[] = {
"16 16 3 1",
" c None",
". c #000000",
"+ c #777777",
" ",
" ",
" .. ",
" .++. ",
" . . . ",
" . .. ..",
" . .+ +.",
".... . .+ +. .",
" . . .+. .",
" . .+ +.+ +.",
" . .. +. .+ ..",
" . . . . . ",
" ",
" ",
" ",
" "};

724
src/gmdb2/debug.c Normal file
View File

@@ -0,0 +1,724 @@
#include "gmdb.h"
#include <glade/glade.h>
extern GtkWidget *app;
extern MdbHandle *mdb;
GladeXML *debugwin_xml;
#define LINESZ 77
typedef struct GMdbDebugTab {
GtkWidget *ctree;
GtkWidget *textbox;
GtkWidget *entry;
GtkWidget *pglabel;
int page_num;
int max_page;
int linesz;
GdkFont *font;
GdkColor black;
GdkColor white;
} GMdbDebugTab;
typedef struct GMdbDebugRange {
gint start_byte;
gint end_byte;
} GMdbDebugRange;
GMdbDebugTab *dbug;
/* prototypes */
void gmdb_debug_text_on(GtkWidget *textbox, int start_byte, int end_byte);
void gmdb_debug_text_off(GtkWidget *textbox, int start_byte, int end_byte);
GtkTreeIter *gmdb_debug_add_item(GtkTreeStore *store, GtkTreeIter *iter, gchar *text, int start, int end);
void gmdb_debug_clear(GMdbDebugTab *dbug);
void gmdb_debug_dissect(GtkTreeStore *store, char *fbuf, int offset, int len);
static guint16 get_uint16(unsigned char *c);
static guint32 get_uint24(unsigned char *c);
static guint32 get_uint32(unsigned char *c);
static long gmdb_get_max_page(MdbHandle *mdb);
/* value to string stuff */
typedef struct GMdbValStr {
gint value;
gchar *string;
} GMdbValStr;
GMdbValStr table_types[] = {
{ 0x4e, "System Table" },
{ 0x53, "User Table" },
{ 0, NULL }
};
GMdbValStr column_types[] = {
{ 0x01, "boolean" },
{ 0x02, "byte" },
{ 0x03, "int" },
{ 0x04, "longint" },
{ 0x05, "money" },
{ 0x06, "float" },
{ 0x07, "double" },
{ 0x08, "short datetime" },
{ 0x09, "binary" },
{ 0x0a, "text" },
{ 0x0b, "OLE" },
{ 0x0c, "memo/hyperlink" },
{ 0x0d, "Unknown" },
{ 0x0f, "GUID" },
{ 0, NULL }
};
GMdbValStr object_types[] = {
{ 0x00, "Database Definition Page" },
{ 0x01, "Data Page" },
{ 0x02, "Table Definition Page" },
{ 0x03, "Index Page" },
{ 0x04, "Leaf Index Page" },
{ 0, NULL }
};
/* callbacks */
void
gmdb_debug_select_cb(GtkCTree *tree, GList *node, gint column, GMdbDebugTab *dbug)
{
GMdbDebugRange *range;
int start_row, end_row;
int start_col, end_col;
int i;
range = gtk_ctree_node_get_row_data(tree, GTK_CTREE_NODE(node));
/* container node or otherwise non-represented in the data */
if (range->start_byte == -1 || range->end_byte == -1) return;
start_row = range->start_byte / 16;
end_row = range->end_byte / 16;
start_col = 8 + (range->start_byte % 16) * 3;
end_col = 8 + (range->end_byte % 16) * 3;
/* freeze/thaw needed because of redrawing glitch...only part of text had
** correct colors, rest would come back on resize. */
/*
gtk_text_freeze(GTK_TEXT(dbug->textbox));
*/
if (start_row == end_row) {
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * start_row + start_col,
dbug->linesz * start_row + end_col + 2);
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * start_row + 59 + (range->start_byte % 16),
dbug->linesz * start_row + 59 + (range->end_byte % 16) + 1);
} else {
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * start_row + start_col,
/* 55 = 8 (addr) + 15 (bytes) * 3 (%02x " ") + 2 (last byte) */
dbug->linesz * start_row + 55);
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * start_row + 59 + (range->start_byte % 16),
dbug->linesz * start_row + 75);
for (i=start_row + 1; i < end_row; i++) {
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * i + 8, dbug->linesz * i + 55);
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * i + 59, dbug->linesz * i + 75);
}
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * end_row + 8,
dbug->linesz * end_row + end_col + 2);
gmdb_debug_text_on(dbug->textbox,
dbug->linesz * end_row + 59,
dbug->linesz * end_row + 59 + (range->end_byte % 16) + 1);
}
/* gtk_text_thaw(GTK_TEXT(dbug->textbox)); */
}
void
gmdb_debug_unselect_cb(GtkCTree *tree, GList *node, gint column, GMdbDebugTab *dbug)
{
GMdbDebugRange *range;
int start_row, end_row;
int start_col, end_col;
int i;
range = gtk_ctree_node_get_row_data(tree, GTK_CTREE_NODE(node));
/* container node or otherwise non-represented in the data */
if (range->start_byte == -1 || range->end_byte == -1) return;
start_row = range->start_byte / 16;
end_row = range->end_byte / 16;
start_col = 8 + (range->start_byte % 16) * 3;
end_col = 8 + (range->end_byte % 16) * 3;
if (start_row == end_row) {
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * start_row + start_col,
dbug->linesz * start_row + end_col + 2);
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * start_row + 59 + (range->start_byte % 16),
dbug->linesz * start_row + 59 + (range->end_byte % 16) + 1);
} else {
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * start_row + start_col,
/* 55 = 8 (addr) + 15 (bytes) * 3 (%02x " ") + 2 (last byte) */
dbug->linesz * start_row + 55);
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * start_row + 59 + (range->start_byte % 16),
dbug->linesz * start_row + 75);
for (i=start_row + 1; i < end_row; i++) {
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * i + 8, dbug->linesz * i + 55);
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * i + 59, dbug->linesz * i + 75);
}
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * end_row + 8,
dbug->linesz * end_row + end_col + 2);
gmdb_debug_text_off(dbug->textbox,
dbug->linesz * end_row + 59,
dbug->linesz * end_row + 59 + (range->end_byte % 16) + 1);
}
}
void
gmdb_debug_display_cb(GtkWidget *w, gpointer *dbug)
{
int page;
off_t pos;
unsigned char *fbuf;
unsigned char *tbuf;
int i,j;
int length;
char line[80];
char field[10];
GtkTextBuffer *buffer;
GtkTextIter iter;
GtkWidget *entry;
GtkTextView *textview;
if (!mdb) return;
entry = glade_xml_get_widget (debugwin_xml, "debug_entry");
textview = glade_xml_get_widget (debugwin_xml, "debug_textview");
page = atol(gtk_entry_get_text(GTK_ENTRY(entry)));
if (page>gmdb_get_max_page(mdb) || page<0) {
gmdb_info_msg("Page entered is outside valid page range.");
}
// gmdb_debug_clear(dbug);
pos = lseek(mdb->fd, 0, SEEK_CUR);
lseek(mdb->fd, page * mdb->pg_size, SEEK_SET);
fbuf = (unsigned char *) malloc(mdb->pg_size);
tbuf = (unsigned char *) malloc( (mdb->pg_size / 16) * 80);
memset(tbuf, 0, (mdb->pg_size / 16) * 80);
length = read(mdb->fd, fbuf, mdb->pg_size);
if (length<mdb->pg_size) {
}
i = 0;
while (i<length) {
sprintf(line,"%06x ", i);
for(j=0; j<16; j++) {
sprintf(field, "%02x ", fbuf[i+j]);
strcat(line,field);
}
strcat(line, " |");
for(j=0; j<16; j++) {
sprintf(field, "%c", (isprint(fbuf[i+j])) ? fbuf[i+j] : '.');
strcat(line,field);
}
strcat(line, "|\n");
i += 16;
strcat(tbuf, line);
//if (!dbug->linesz) dbug->linesz = strlen(line);
}
buffer = gtk_text_view_get_buffer(textview);
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
gtk_text_buffer_insert(buffer,&iter,tbuf,strlen(tbuf));
//gtk_editable_select_region(GTK_EDITABLE(dbug->textbox), 9, 15);
GtkWidget *tree = glade_xml_get_widget(debugwin_xml, "debug_treeview");
GtkTreeStore *store = gtk_tree_store_new(1, G_TYPE_STRING);
gmdb_debug_dissect(store, fbuf, 0, length);
gtk_tree_view_set_model(GTK_TREE_VIEW(tree), store);
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Field",
renderer, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW (tree), column);
free(fbuf);
free(tbuf);
}
/* functions */
static long
gmdb_get_max_page(MdbHandle *mdb)
{
struct stat st;
assert( fstat(mdb->fd, &st)!=-1 );
return st.st_size/mdb->pg_size;
}
gchar *
gmdb_val_to_str(GMdbValStr *valstr, gint val)
{
gchar *strptr;
int i = 0;
do {
strptr = valstr[i].string;
if (val == valstr[i].value) {
return strptr;
}
i++;
} while (*strptr);
return "unknown";
}
static guint16
get_uint16(unsigned char *c)
{
guint16 i;
i =c[1]; i<<=8;
i+=c[0];
return i;
}
static guint32
get_uint24(unsigned char *c)
{
guint32 l;
l =c[2]; l<<=8;
l+=c[1]; l<<=8;
l+=c[0];
return l;
}
static guint32
get_uint32(unsigned char *c)
{
guint32 l;
l =c[3]; l<<=8;
l+=c[2]; l<<=8;
l+=c[1]; l<<=8;
l+=c[0];
return l;
}
void
gmdb_debug_dissect_column(GtkTreeStore *store, GtkTreeIter *parent, char *fbuf, int offset)
{
gchar str[100];
GtkCTreeNode *node;
snprintf(str, 100, "Column Type: 0x%02x (%s)", fbuf[offset],
gmdb_val_to_str(column_types, fbuf[offset]));
gmdb_debug_add_item(store, parent, str, offset, offset);
snprintf(str, 100, "Column #: %d", get_uint16(&fbuf[offset+1]));
gmdb_debug_add_item(store, parent, str, offset+1, offset+2);
snprintf(str, 100, "VarCol Offset: %d", get_uint16(&fbuf[offset+3]));
gmdb_debug_add_item(store, parent, str, offset+3, offset+4);
snprintf(str, 100, "Unknown", get_uint32(&fbuf[offset+5]));
gmdb_debug_add_item(store, parent, str, offset+5, offset+8);
snprintf(str, 100, "Unknown", get_uint32(&fbuf[offset+9]));
gmdb_debug_add_item(store, parent, str, offset+9, offset+12);
snprintf(str, 100, "Variable Column: %s",
fbuf[offset+13] & 0x01 ? "No" : "Yes");
gmdb_debug_add_item(store, parent, str, offset+13, offset+13);
snprintf(str, 100, "Fixed Col Offset: %d", get_uint16(&fbuf[offset+14]));
gmdb_debug_add_item(store, parent, str, offset+14, offset+15);
snprintf(str, 100, "Column Length: %d", get_uint16(&fbuf[offset+16]));
gmdb_debug_add_item(store, parent, str, offset+16, offset+17);
}
void
gmdb_debug_dissect_index1(GtkTreeStore *store, GtkTreeIter *parent, char *fbuf, int offset)
{
gchar str[100];
GtkCTreeNode *node;
snprintf(str, 100, "Unknown");
gmdb_debug_add_item(store, parent, str, offset, offset+3);
snprintf(str, 100, "Rows in Index: %lu", get_uint32(&fbuf[offset+4]));
gmdb_debug_add_item(store, parent, str, offset+4, offset+7);
}
void
gmdb_debug_add_page_ptr(GtkTreeStore *store, GtkTreeIter *parent, char *fbuf, const char *label, int offset)
{
gchar str[100];
GtkCTreeNode *node;
snprintf(str, 100, "%s", label);
node = gmdb_debug_add_item(store, parent, str, offset, offset+3);
snprintf(str, 100, "Row Number: %u", fbuf[offset]);
gmdb_debug_add_item(store, node, str, offset, offset);
snprintf(str, 100, "Page Number: %lu", get_uint24(&fbuf[offset+1]));
gmdb_debug_add_item(store, node, str, offset+1, offset+3);
}
void
gmdb_debug_dissect_tabledef_pg(GtkTreeStore *store, char *fbuf, int offset, int len)
{
gchar str[100];
guint32 i, num_idx, num_cols;
int newbase;
GtkTreeIter *node, *container;
snprintf(str, 100, "Next TDEF Page: 0x%06x (%lu)",
get_uint32(&fbuf[offset+4]), get_uint32(&fbuf[offset+4]));
gmdb_debug_add_item(store, NULL, str, offset+4, offset+7);
snprintf(str, 100, "Length of Data: %lu", get_uint32(&fbuf[offset+8]));
gmdb_debug_add_item(store, NULL, str, offset+8, offset+11);
snprintf(str, 100, "# of Records: %lu", get_uint32(&fbuf[offset+12]));
gmdb_debug_add_item(store, NULL, str, offset+12, offset+15);
snprintf(str, 100, "Autonumber Value: %lu", get_uint32(&fbuf[offset+16]));
gmdb_debug_add_item(store, NULL, str, offset+16, offset+19);
snprintf(str, 100, "Table Type: 0x%02x (%s)", fbuf[offset+20],
gmdb_val_to_str(table_types, fbuf[offset+20]));
gmdb_debug_add_item(store, NULL, str, offset+20, offset+20);
num_cols = get_uint16(&fbuf[offset+21]);
snprintf(str, 100, "# of Columns: %u", num_cols);
gmdb_debug_add_item(store, NULL, str, offset+21, offset+22);
snprintf(str, 100, "# of VarCols: %u",
get_uint16(&fbuf[offset+23]));
gmdb_debug_add_item(store, NULL, str, offset+23, offset+24);
snprintf(str, 100, "# of Columns: %u",
get_uint16(&fbuf[offset+25]));
gmdb_debug_add_item(store, NULL, str, offset+25, offset+26);
snprintf(str, 100, "# of Index Entries: %lu",
get_uint32(&fbuf[offset+27]));
gmdb_debug_add_item(store, NULL, str, offset+27, offset+30);
num_idx = get_uint32(&fbuf[offset+31]);
snprintf(str, 100, "# of Real Indices: %lu", num_idx);
gmdb_debug_add_item(store, NULL, str, offset+31, offset+34);
gmdb_debug_add_page_ptr(store, NULL, fbuf, "Used Pages Pointer", offset+35);
container = gmdb_debug_add_item(store, NULL, "Index Entries", -1, -1);
for (i=0;i<num_idx;i++) {
snprintf(str, 100, "Index %d", i+1);
node = gmdb_debug_add_item(store, container, str, offset+43+(8*i), offset+43+(8*i)+7);
gmdb_debug_dissect_index1(store, node, fbuf, offset+43+(8*i));
}
newbase = offset + 43 + (8*i);
container = gmdb_debug_add_item(store, NULL, "Column Data", -1, -1);
for (i=0;i<num_cols;i++) {
snprintf(str, 100, "Column %d", i+1);
node = gmdb_debug_add_item(store, container, str, newbase + (18*i), newbase + (18*i) + 17);
gmdb_debug_dissect_column(store, node, fbuf, newbase + (18*i));
}
newbase += 18*num_cols;
container = gmdb_debug_add_item(store, NULL, "Column Names", -1, -1);
for (i=0;i<num_cols;i++) {
char *tmpstr;
int namelen;
namelen = fbuf[newbase];
tmpstr = malloc(namelen + 1);
strncpy(tmpstr, &fbuf[newbase+1], namelen);
tmpstr[namelen]=0;
snprintf(str, 100, "Column %d: %s", i+1, tmpstr);
free(tmpstr);
node = gmdb_debug_add_item(store, container, str, newbase + 1, newbase + namelen);
newbase += namelen + 1;
}
}
void gmdb_debug_dissect(GtkTreeStore *store, char *fbuf, int offset, int len)
{
gchar str[100];
snprintf(str, 100, "Object Type: 0x%02x (%s)", fbuf[offset],
gmdb_val_to_str(object_types, fbuf[offset]));
gmdb_debug_add_item(store, NULL, str, 0, 0);
switch (fbuf[offset]) {
case 0x00:
//gmdb_debug_dissect_dbpage(store, fbuf, 1, len);
break;
case 0x01:
//gmdb_debug_dissect_dbpage(store, fbuf, 1, len);
break;
case 0x02:
gmdb_debug_dissect_tabledef_pg(store, fbuf, 0, len);
break;
case 0x03:
//gmdb_debug_dissect_dbpage(store, fbuf, 1, len);
break;
case 0x04:
//gmdb_debug_dissect_dbpage(store, fbuf, 1, len);
break;
}
}
gmdb_clear_node_cb(GtkWidget *ctree, GtkCTreeNode *node, gpointer data)
{
gpointer rowdata;
rowdata = gtk_ctree_node_get_row_data(GTK_CTREE(ctree), node);
g_free(rowdata);
gtk_ctree_remove_node(GTK_CTREE(ctree), node);
}
void
gmdb_debug_clear(GMdbDebugTab *dbug)
{
GtkCTreeNode *node;
gpointer data;
GtkTextBuffer *buffer;
/* clear the tree */
gtk_ctree_post_recursive(dbug->ctree, NULL, gmdb_clear_node_cb, NULL);
/*
node = gtk_ctree_node_nth(GTK_CTREE(dbug->ctree), 0);
data = gtk_ctree_node_get_row_data(GTK_CTREE(dbug->ctree), node);
g_free(data);
gtk_ctree_remove_node(GTK_CTREE(dbug->ctree), node);
*/
/* call delete text last because remove_node fires unselect signal */
//gtk_editable_delete_text(GTK_EDITABLE(dbug->textbox),0, -1);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dbug->textbox));
gtk_text_buffer_set_text(buffer, "", 0);
}
GtkTreeIter *
gmdb_debug_add_item(GtkTreeStore *store, GtkTreeIter *iter1, gchar *text, int start, int end)
{
gchar *nodetext[2];
GtkCTreeNode *node;
GMdbDebugRange *range;
GtkTreeIter *iter2;
iter2 = g_malloc(sizeof(GtkTreeIter));
gtk_tree_store_append(store, iter2, iter1);
gtk_tree_store_set(store, iter2, 0, text, -1);
#if 0
nodetext[0] = text;
nodetext[1] = "0";
node = gtk_ctree_insert_node(GTK_CTREE(dbug->ctree), parent, NULL, nodetext, 0, NULL, NULL, NULL, NULL, FALSE, FALSE);
range = g_malloc(sizeof(GMdbDebugRange));
range->start_byte = start;
range->end_byte = end;
gtk_ctree_node_set_row_data(GTK_CTREE(dbug->ctree), node, range);
#endif
return iter2;
}
void
gmdb_debug_text_on(GtkWidget *textbox,
int start_byte, int end_byte)
{
gchar *text;
GtkTextBuffer *buffer;
GtkTextTag *tag;
GtkTextIter start, end;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textbox));
tag = gtk_text_buffer_create_tag (buffer, NULL,
"foreground", "white", NULL);
tag = gtk_text_buffer_create_tag (buffer, NULL,
"background", "blue", NULL);
gtk_text_buffer_get_iter_at_offset (buffer, &start, start_byte);
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_byte);
gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(dbug->textbox),
&start, 0.0, FALSE, 0.0, 0.0);
gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
}
static void
gmdb_debug_text_off(GtkWidget *textbox,
int start_byte, int end_byte)
{
gchar *text;
GtkTextBuffer *buffer;
GtkTextTag *tag;
GtkTextIter start, end;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textbox));
tag = gtk_text_buffer_create_tag (buffer, NULL,
"foreground", "black", NULL);
tag = gtk_text_buffer_create_tag (buffer, NULL,
"background", "white", NULL);
gtk_text_buffer_get_iter_at_offset (buffer, &start, start_byte);
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_byte);
gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
}
#if 0
void
gmdb_debug_tab_new(GtkWidget *notebook)
{
GtkWidget *tabbox;
GtkWidget *label;
GtkWidget *label1;
GtkWidget *button;
GtkWidget *pixmapwid;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *hpane;
GtkWidget *vbox;
GtkWidget *scroll;
GtkWidget *scroll2;
GdkPixmap *pixmap;
GdkBitmap *mask;
GdkColormap *cmap;
dbug = g_malloc0(sizeof(GMdbDebugTab));
dbug->max_page = -1;
dbug->font = gdk_font_load("-*-*-medium-r-normal-*-10-*-*-*-m-*-*-*");
cmap = gdk_colormap_get_system();
gdk_color_white(cmap, &dbug->white);
gdk_color_black(cmap, &dbug->black);
vbox = gtk_vbox_new (FALSE,5);
gtk_widget_show (vbox);
hbox = gtk_hbox_new (FALSE,5);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 10);
label1 = gtk_label_new ("Page Number");
gtk_widget_show (label1);
gtk_box_pack_start (GTK_BOX (hbox), label1, FALSE, FALSE, 10);
dbug->pglabel = gtk_label_new (":");
gtk_widget_show (dbug->pglabel);
gtk_box_pack_start (GTK_BOX (hbox), dbug->pglabel, FALSE, FALSE, 0);
dbug->entry = gtk_entry_new ();
gtk_widget_show (dbug->entry);
gtk_box_pack_start (GTK_BOX (hbox), dbug->entry, TRUE, TRUE, 0);
gtk_signal_connect ( GTK_OBJECT (dbug->entry),
"activate", GTK_SIGNAL_FUNC (gmdb_debug_display_cb), dbug);
button = gtk_button_new_with_label ("Display");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect ( GTK_OBJECT (button),
"clicked", GTK_SIGNAL_FUNC (gmdb_debug_display_cb), dbug);
hpane = gtk_hpaned_new ();
gtk_paned_set_position(GTK_PANED(hpane), 200);
gtk_paned_set_gutter_size(GTK_PANED(hpane), 12);
gtk_widget_show(hpane);
gtk_box_pack_start (GTK_BOX (vbox), hpane, TRUE, TRUE, 10);
scroll = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_widget_show (scroll);
gtk_container_add(GTK_CONTAINER(hpane), scroll);
dbug->ctree = gtk_ctree_new (1, 0);
gtk_widget_show (dbug->ctree);
gtk_container_add (GTK_CONTAINER (scroll), dbug->ctree);
gtk_signal_connect ( GTK_OBJECT (dbug->ctree),
"tree-select-row", GTK_SIGNAL_FUNC (gmdb_debug_select_cb), dbug);
gtk_signal_connect ( GTK_OBJECT (dbug->ctree),
"tree-unselect-row", GTK_SIGNAL_FUNC (gmdb_debug_unselect_cb), dbug);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_container_set_border_width (GTK_CONTAINER (frame), 0);
//gtk_widget_set_usize (frame, 100, 75);
gtk_widget_show (frame);
gtk_container_add (GTK_CONTAINER (hpane), frame);
scroll2 = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll2),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show (scroll2);
gtk_container_add(GTK_CONTAINER(frame), scroll2);
dbug->textbox = gtk_text_view_new ();
gtk_widget_modify_font(dbug->textbox,
pango_font_description_from_string("Courier"));
gtk_widget_show (dbug->textbox);
gtk_container_add(GTK_CONTAINER(scroll2), dbug->textbox);
/* set selection callback for list */
//gtk_signal_connect ( GTK_OBJECT (table_list),
// "select-child", GTK_SIGNAL_FUNC (gmdb_table_select_cb), NULL);
/* create a picture/label box and use for tab */
tabbox = gtk_hbox_new (FALSE,5);
pixmap = gdk_pixmap_colormap_create_from_xpm_d( NULL,
gtk_widget_get_colormap(app), &mask, NULL, debug_xpm);
/* a pixmap widget to contain the pixmap */
pixmapwid = gtk_pixmap_new( pixmap, mask );
gtk_widget_show( pixmapwid );
gtk_box_pack_start (GTK_BOX (tabbox), pixmapwid, FALSE, TRUE, 0);
label = gtk_label_new ("Debug");
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (tabbox), label, FALSE, TRUE, 0);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, tabbox);
if (mdb) gmdb_debug_init(mdb);
}
#endif
void
gmdb_debug_close_cb(GtkWidget *w, gpointer *data)
{
GtkWidget *w;
w = glade_xml_get_widget (debugwin_xml, "debug_window");
gtk_widget_destroy(w);
}
void
gmdb_debug_new_cb(GtkWidget *w, gpointer *data)
{
GtkTextView *textview;
/* load the interface */
debugwin_xml = glade_xml_new("gladefiles/gmdb-debug.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(debugwin_xml);
/* this should be a preference, needs to be fixed width */
textview = glade_xml_get_widget (debugwin_xml, "debug_textview");
gtk_widget_modify_font(textview,
pango_font_description_from_string("Courier"));
if (mdb) gmdb_debug_init(mdb);
/*
GtkTreeIter iter;
GtkWidget *tree = glade_xml_get_widget(debugwin_xml, "debug_treeview");
GtkTreeStore *store = gtk_tree_store_new(1, G_TYPE_STRING);
gtk_tree_store_append(store, &iter, NULL);
gtk_tree_store_set(store, &iter, 0, "Test", -1);
gtk_tree_view_set_model(GTK_TREE_VIEW(tree), store);
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Field",
renderer, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW (tree), column);
*/
}
void gmdb_debug_init(MdbHandle *mdb)
{
struct stat st;
char tmpstr[100];
GtkWidget *pglabel, *entry;
pglabel = glade_xml_get_widget (debugwin_xml, "debug_num_label");
sprintf(tmpstr, "(0-%d):", gmdb_get_max_page(mdb));
gtk_label_set_text(GTK_LABEL(pglabel), tmpstr);
entry = glade_xml_get_widget (debugwin_xml, "debug_entry");
gtk_widget_grab_focus(GTK_WIDGET(entry));
}

23
src/gmdb2/debug.xpm Normal file
View File

@@ -0,0 +1,23 @@
/* XPM */
static char * debug_xpm[] = {
"16 16 4 1",
" c None",
". c #ED2D2D",
"+ c #635757",
"@ c #000000",
" ",
" ..... ",
" ... ... ",
" .. +@+ .. ",
" .... @@@ .. ",
" .@+..+@+ +@. ",
".. @+..@@ +@ .. ",
". @@..@@@ . ",
". @@..@ . ",
". @@@@@@..@@@ . ",
".. @@@@.. .. ",
" . @@@@@@.. . ",
" ..@+ @@@ +... ",
" .. .. ",
" ... ... ",
" ..... "};

142
src/gmdb2/file.c Normal file
View File

@@ -0,0 +1,142 @@
#include "gmdb.h"
#include <mdbtools.h>
GtkWidget *file_selector;
MdbHandle *mdb;
extern int main_show_debug;
void gmdb_file_open_recent_1() { gmdb_file_open_recent("menu_recent1"); }
void gmdb_file_open_recent_2() { gmdb_file_open_recent("menu_recent2"); }
void gmdb_file_open_recent_3() { gmdb_file_open_recent("menu_recent3"); }
void gmdb_file_open_recent_4() { gmdb_file_open_recent("menu_recent4"); }
void gmdb_file_open_recent(gchar *menuname)
{
gchar *text, cfgname[100];
sprintf(cfgname,"/gmdb/RecentFiles/%s.filepath", menuname);
text = gnome_config_get_string(cfgname);
gmdb_file_open(text);
g_free(text);
gmdb_load_recent_files();
}
static void
gmdb_file_shuffle_recent(gchar *file_path)
{
gchar *text, cfgname[100];
int i, index=0;
for (i=1; i<=4; i++) {
sprintf(cfgname,"/gmdb/RecentFiles/menu_recent%d.filepath", i);
text = gnome_config_get_string(cfgname);
if (text && !strcmp(text,file_path)) {
index = i;
break;
}
g_free(text);
}
printf("found file %slocation at menu %d\n",file_path, index);
/* it is the most recently used file, we're done */
if (index==1) return;
/* if this file is not on the recent list bump item 4 */
if (!index) index=4;
for (i=1; i<index; i++) {
sprintf(cfgname, "/gmdb/RecentFiles/menu_recent%d.filepath", i);
text = gnome_config_get_string(cfgname);
if (text) {
sprintf(cfgname,
"/gmdb/RecentFiles/menu_recent%d.filepath",
i+1);
gnome_config_set_string(cfgname, text);
g_free(text);
sprintf(cfgname,
"/gmdb/RecentFiles/menu_recent%d.basename",
i);
text = gnome_config_get_string(cfgname);
sprintf(cfgname,
"/gmdb/RecentFiles/menu_recent%d.basename",
i+1);
gnome_config_set_string(cfgname, text);
g_free(text);
}
}
}
static void
gmdb_file_add_recent(gchar *file_path)
{
gchar basename[33];
int i;
for (i=strlen(file_path);i>=0 && file_path[i]!='/';i--);
if (file_path[i]=='/') {
strncpy(basename,&file_path[i+1],32);
} else {
strncpy(basename,file_path,32);
}
basename[33]='\0';
gnome_config_set_string("/gmdb/RecentFiles/menu_recent1.basename", basename);
gnome_config_set_string("/gmdb/RecentFiles/menu_recent1.filepath", file_path);
gnome_config_sync();
}
void
gmdb_file_open(gchar *file_path)
{
gmdb_reset_widgets();
mdb = mdb_open(file_path);
if (!mdb) {
gmdb_info_msg("Unable to open file.");
return;
}
gmdb_file_shuffle_recent(file_path);
gmdb_file_add_recent(file_path);
sql->mdb = mdb;
mdb_read_catalog(mdb, MDB_ANY);
gmdb_table_populate(mdb);
gmdb_query_populate(mdb);
gmdb_form_populate(mdb);
gmdb_report_populate(mdb);
gmdb_macro_populate(mdb);
gmdb_module_populate(mdb);
//if (main_show_debug) gmdb_debug_init(mdb);
}
void
gmdb_file_open_cb(GtkWidget *selector, gpointer data)
{
gchar *file_path;
file_path = gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_selector));
gmdb_file_open(file_path);
gmdb_load_recent_files();
}
void
gmdb_file_select_cb(GtkWidget *button, gpointer data)
{
/*just print a string so that we know we got there*/
file_selector = gtk_file_selection_new("Please select a database.");
gtk_signal_connect (
GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
"clicked", GTK_SIGNAL_FUNC (gmdb_file_open_cb), NULL);
gtk_signal_connect_object ( GTK_OBJECT (
GTK_FILE_SELECTION(file_selector)->ok_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector);
gtk_signal_connect_object (
GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->cancel_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector);
gtk_widget_show (file_selector);
}
void
gmdb_file_close_cb(GtkWidget *button, gpointer data)
{
gmdb_reset_widgets();
}

31
src/gmdb2/form.c Normal file
View File

@@ -0,0 +1,31 @@
#include "gmdb.h"
#include <glade/glade.h>
extern GladeXML* mainwin_xml;
extern GtkWidget *app;
void
gmdb_form_add_icon(gchar *text)
{
GnomeIconList *gil;
gil = glade_xml_get_widget(mainwin_xml, "form_iconlist");
gnome_icon_list_append(gil, "form_big.xpm", text);
}
void gmdb_form_populate(MdbHandle *mdb)
{
int i;
MdbCatalogEntry *entry;
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
/* if it's a form */
if (entry->object_type == MDB_FORM) {
/* add table to tab */
gmdb_form_add_icon(entry->object_name);
} /* if MDB_FORM */
} /* for */
}

234
src/gmdb2/form_big.xpm Normal file
View File

@@ -0,0 +1,234 @@
/* XPM */
static char * form_big_xpm[] = {
"20 20 211 2",
" c None",
". c #585858",
"+ c #635C56",
"@ c #B97943",
"# c #EAB476",
"$ c #747474",
"% c #808080",
"& c #707070",
"* c #645C55",
"= c #816751",
"- c #CB8E57",
"; c #F0AE62",
"> c #B6B6B6",
", c #E0E0E0",
"' c #E1E1E1",
") c #DFDFDF",
"! c #DEDEDE",
"~ c #DAD4CE",
"{ c #CD894D",
"] c #F5BA7A",
"^ c #FD9D2E",
"/ c #EDEDED",
"( c #FCFCFC",
"_ c #E7E7E7",
": c #DDDDDD",
"< c #CAA88C",
"[ c #D39155",
"} c #F5BA77",
"| c #FD9325",
"1 c #FE8A09",
"2 c #EEEEEE",
"3 c #FFFFFF",
"4 c #E8E8E8",
"5 c #FDFDFD",
"6 c #FDFCFB",
"7 c #EFE5DC",
"8 c #D2AB8C",
"9 c #D8A371",
"0 c #EFAB63",
"a c #FC9930",
"b c #FE8A0B",
"c c #F58104",
"d c #E6E6E6",
"e c #E3E3E3",
"f c #FAF8F5",
"g c #EFE5DB",
"h c #D7AF8E",
"i c #DBA470",
"j c #EDA45A",
"k c #FC9E39",
"l c #FC8709",
"m c #F28004",
"n c #D56C04",
"o c #EBE8E7",
"p c #F1E4DB",
"q c #E0BEA2",
"r c #D4965F",
"s c #EFAA61",
"t c #FC9D38",
"u c #FB8508",
"v c #F27F03",
"w c #D46C04",
"x c #954803",
"y c #E9E9E9",
"z c #E6DDD8",
"A c #E6C6B1",
"B c #DB9B6B",
"C c #F4BC85",
"D c #FC962D",
"E c #FC8505",
"F c #D66D04",
"G c #9D4A04",
"H c #431F02",
"I c #F1F1F1",
"J c #EFE1D7",
"K c #F5D7C2",
"L c #F9D3B8",
"M c #EE9E6E",
"N c #F68725",
"O c #F07D06",
"P c #D36C03",
"Q c #9B4904",
"R c #3A1B02",
"S c #EAD1C2",
"T c #F3D4BC",
"U c #F9D7BD",
"V c #F2BB9B",
"W c #DD8154",
"X c #DB712A",
"Y c #C86312",
"Z c #944806",
"` c #472102",
" . c #EFEFEF",
".. c #E2E1DD",
"+. c #E9CBB6",
"@. c #F6CFB2",
"#. c #F4C7A8",
"$. c #D79371",
"%. c #B2673D",
"&. c #9D5A2F",
"*. c #7C421A",
"=. c #51290E",
"-. c #2A2019",
";. c #FCFAF8",
">. c #EAD7C9",
",. c #EECFB7",
"'. c #F0C3A5",
"). c #DCA282",
"!. c #AB6D4D",
"~. c #754D2D",
"{. c #5D4733",
"]. c #544234",
"^. c #483A31",
"/. c #303030",
"(. c #FBFBFA",
"_. c #F8F1EC",
":. c #E7B598",
"<. c #ECBB9D",
"[. c #D49B7C",
"}. c #A86C4C",
"|. c #785037",
"1. c #463D32",
"2. c #4C4946",
"3. c #877D6F",
"4. c #928673",
"5. c #E1DDD9",
"6. c #D8CCBC",
"7. c #9B8770",
"8. c #A47A5F",
"9. c #825C46",
"0. c #5A473B",
"a. c #66605B",
"b. c #9D9C99",
"c. c #A5A5A3",
"d. c #B1A797",
"e. c #92846F",
"f. c #E8E6E5",
"g. c #DFD9D1",
"h. c #A69A88",
"i. c #474034",
"j. c #5D4E43",
"k. c #796B62",
"l. c #8F8981",
"m. c #A9A5A0",
"n. c #C9C6C4",
"o. c #D5CBBC",
"p. c #CAB99F",
"q. c #92836D",
"r. c #E4DED6",
"s. c #CDC2B1",
"t. c #857A6A",
"u. c #605A50",
"v. c #7B746B",
"w. c #A7A094",
"x. c #CCC2B3",
"y. c #D9CDBD",
"z. c #E1D5C5",
"A. c #E6D4BA",
"B. c #D2BC9C",
"C. c #928269",
"D. c #E0D9CD",
"E. c #CCBFA9",
"F. c #9C9383",
"G. c #B2A99B",
"H. c #C5BAAA",
"I. c #DDCFBA",
"J. c #EDDCC3",
"K. c #EBD8BD",
"L. c #E9D5B7",
"M. c #E7D1B0",
"N. c #D1B995",
"O. c #928066",
"P. c #B4B4B3",
"Q. c #E5E2DB",
"R. c #EFE7DA",
"S. c #EDE3D3",
"T. c #ECE0CC",
"U. c #EADBC6",
"V. c #E9D8BF",
"W. c #E7D4B8",
"X. c #E5D1B2",
"Y. c #E3CDAC",
"Z. c #E2C9A5",
"`. c #CEB48D",
" + c #927F62",
".+ c #A7A49D",
"++ c #C9C5BA",
"@+ c #CAC4B7",
"#+ c #C8C1B0",
"$+ c #C8BDA8",
"%+ c #C7B9A1",
"&+ c #C5B59A",
"*+ c #C4B293",
"=+ c #C3AE8C",
"-+ c #C2AA85",
";+ c #C1A67E",
">+ c #BEA177",
",+ c #927D5F",
"'+ c #5B5A58",
")+ c #5D5B58",
"!+ c #5D5B57",
"~+ c #5C5A55",
"{+ c #5C5953",
"]+ c #5C5851",
"^+ c #5B574E",
"/+ c #5B564C",
"(+ c #5B544A",
"_+ c #5B5348",
":+ c #5A5246",
"<+ c #5A5145",
"[+ c #4D473E",
" . . . . . . . . . . . . . . + @ # ",
" . $ % % % % % % % % % % & * = - ; ",
" . > , ' ' ' ) , ' ' ' ! ~ { ] ^ ",
" . > / ( ( ( _ / ( ( ( : < [ } | 1 ",
" . > 2 3 3 3 4 / 5 6 7 8 9 0 a b c ",
" . > d 2 2 2 e / f g h i j k l m n ",
" . > e 4 4 4 ' o p q r s t u v w x ",
" . > 2 3 3 3 y z A B C D E m F G H ",
" . > 2 3 3 3 I J K L M N O P Q R ",
" . > e 4 4 4 S T U V W X Y Z ` ",
" . > d ./ ..+.@.#.$.%.&.*.=.-. ",
" . > 2 3 ;.>.,.'.).!.~.{.].^./. ",
" . > / (._.:.<.[.}.|.1.2.3.4./. ",
" . > , 5.6.7.8.9.0.a.b.c.d.e./. ",
" . > f.g.h.i.j.k.l.m.n.o.p.q./. ",
" . > r.s.t.u.v.w.x.y.z.A.B.C./. ",
" . > D.E.F.G.H.I.J.K.L.M.N.O./. ",
" . P.Q.R.S.T.U.V.W.X.Y.Z.`. +/. ",
" . .+++@+#+$+%+&+*+=+-+;+>+,+/. ",
" . '+)+!+~+{+]+^+/+(+_+:+<+[+/. "};

126
src/gmdb2/forms.xpm Normal file
View File

@@ -0,0 +1,126 @@
/* XPM */
static char * forms_xpm[] = {
"16 16 107 2",
" c None",
". c #585858",
"+ c #C47D41",
"@ c #FACB8D",
"# c #DEDEDE",
"$ c #C37B40",
"% c #FAC78C",
"& c #FE8F0C",
"* c #FFFFFF",
"= c #CECECE",
"- c #FAC689",
"; c #FE880E",
"> c #FE8801",
", c #FCFCFC",
"' c #FEFEFE",
") c #E5D6C8",
"! c #FAC98F",
"~ c #FD8810",
"{ c #FE8803",
"] c #EC7A03",
"^ c #FDFDFD",
"/ c #E7DACC",
"( c #FD850C",
"_ c #FE8703",
": c #E47604",
"< c #A54E04",
"[ c #ECDAD2",
"} c #D38F5D",
"| c #F8C58D",
"1 c #FE8406",
"2 c #FE8804",
"3 c #A34C04",
"4 c #1C0C01",
"5 c #EDEDED",
"6 c #F4D6C1",
"7 c #FFE2CD",
"8 c #EB9260",
"9 c #FA800A",
"0 c #E47702",
"a c #A04A04",
"b c #210F01",
"c c #DFDFDF",
"d c #EBB698",
"e c #FEE5CA",
"f c #F1B492",
"g c #D37043",
"h c #CF6524",
"i c #A04B0A",
"j c #231001",
"k c #E4E0D8",
"l c #EFD0B5",
"m c #FFD1B1",
"n c #C67E5D",
"o c #87542B",
"p c #5C4733",
"q c #241008",
"r c #303030",
"s c #FDFDFC",
"t c #EFB493",
"u c #F7C9AC",
"v c #C67D5A",
"w c #825234",
"x c #332E23",
"y c #474544",
"z c #BCAB90",
"A c #DCD0BF",
"B c #897862",
"C c #A36F52",
"D c #4C392C",
"E c #5B5957",
"F c #B0B0AF",
"G c #BCA88A",
"H c #FAF6F2",
"I c #A09380",
"J c #1A1812",
"K c #534F4C",
"L c #9F9C96",
"M c #C4BFB9",
"N c #DAD6D3",
"O c #E9D6BA",
"P c #BCA685",
"Q c #DAC8AB",
"R c #736A5A",
"S c #9C9488",
"T c #BDB4A4",
"U c #EEDFC8",
"V c #ECDAC0",
"W c #E9D6B9",
"X c #E7D1B0",
"Y c #BCA37F",
"Z c #F4EDE1",
"` c #F2E8D8",
" . c #F0E4D0",
".. c #EEDEC8",
"+. c #ECDABF",
"@. c #E9D6B8",
"#. c #E5CCA7",
"$. c #BCA178",
"%. c #C6C1B6",
"&. c #C4BDAC",
"*. c #C3B8A3",
"=. c #C2B39A",
"-. c #C0AF91",
";. c #BFAA88",
">. c #BEA57F",
",. c #BDA076",
"'. c #BC9E73",
" . . . . . . . . . . . . + @ ",
" . # # # # # # # # # $ % & ",
" . # * * * # * * * = $ - ; > ",
" . # * * * # , ' ) $ ! ~ { ] ",
" . # # # # # ^ / $ ! ( _ : < ",
" . # * * * # [ } | 1 2 : 3 4 ",
" . # * * * 5 6 7 8 9 0 a b ",
" . c # # # d e f g h i j ",
" . # * * k l m n o p q r ",
" . # * s t u v w x y z r ",
" . # # A B C D E F F G r ",
" . # H I J K L M N O P r ",
" . # Q R S T U V W X Y r ",
" . # Z ` ...+.@.X #.$.r ",
" . %.%.&.*.=.-.;.>.,.'.r ",
" . r r r r r r r r r r r "};

View File

@@ -0,0 +1,375 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<requires lib="gnome"/>
<requires lib="bonobo"/>
<widget class="GnomeApp" id="debug_window">
<property name="visible">True</property>
<property name="title" translatable="yes">MDB File Debugger</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="enable_layout_config">True</property>
<child internal-child="dock">
<widget class="BonoboDock" id="bonobodock1">
<property name="visible">True</property>
<property name="allow_floating">True</property>
<child>
<widget class="BonoboDockItem" id="bonobodockitem1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="file1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_FILE_TREE</property>
<child>
<widget class="GtkMenu" id="file1_menu">
<child>
<widget class="GtkImageMenuItem" id="new1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_NEW_ITEM</property>
<property name="label" translatable="yes">_New</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_new1_activate" last_modification_time="Sat, 21 Dec 2002 14:54:43 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="separator1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="close1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_CLOSE_ITEM</property>
<signal name="activate" handler="gmdb_debug_close_cb" last_modification_time="Sat, 21 Dec 2002 20:42:09 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="edit1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>
<child>
<widget class="GtkMenu" id="edit1_menu">
<child>
<widget class="GtkImageMenuItem" id="cut1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_CUT_ITEM</property>
<signal name="activate" handler="on_cut1_activate" last_modification_time="Sat, 21 Dec 2002 14:54:43 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="copy1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_COPY_ITEM</property>
<signal name="activate" handler="on_copy1_activate" last_modification_time="Sat, 21 Dec 2002 14:54:43 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="paste1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_PASTE_ITEM</property>
<signal name="activate" handler="on_paste1_activate" last_modification_time="Sat, 21 Dec 2002 14:54:43 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="clear1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_CLEAR_ITEM</property>
<signal name="activate" handler="on_clear1_activate" last_modification_time="Sat, 21 Dec 2002 14:54:43 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="help1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>
<child>
<widget class="GtkMenu" id="help1_menu">
<child>
<widget class="GtkImageMenuItem" id="about1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
<signal name="activate" handler="gmdb_about_cb" last_modification_time="Sat, 21 Dec 2002 18:17:10 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="placement">BONOBO_DOCK_TOP</property>
<property name="band">0</property>
<property name="position">0</property>
<property name="offset">0</property>
<property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL|BONOBO_DOCK_ITEM_BEH_LOCKED</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkFrame" id="frame1">
<property name="border_width">8</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">12</property>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">Page Number</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="debug_num_label">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="debug_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
<signal name="activate" handler="gmdb_debug_display_cb" after="yes" last_modification_time="Sat, 21 Dec 2002 19:05:15 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Display</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="gmdb_debug_display_cb" after="yes" last_modification_time="Sat, 21 Dec 2002 18:33:54 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="debug_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="debug_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child internal-child="appbar">
<widget class="GnomeAppBar" id="appbar1">
<property name="visible">True</property>
<property name="has_progress">True</property>
<property name="has_status">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</glade-interface>

View File

@@ -0,0 +1,514 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<requires lib="gnome"/>
<requires lib="bonobo"/>
<widget class="GnomeApp" id="app1">
<property name="visible">True</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="enable_layout_config">True</property>
<child internal-child="dock">
<widget class="BonoboDock" id="bonobodock1">
<property name="visible">True</property>
<property name="allow_floating">True</property>
<child>
<widget class="BonoboDockItem" id="bonobodockitem1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="query1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Query</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="query1_menu">
<child>
<widget class="GtkImageMenuItem" id="new1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_NEW_ITEM</property>
<property name="label" translatable="yes">_New</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_new1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="open1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_OPEN_ITEM</property>
<signal name="activate" handler="on_open1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_SAVE_ITEM</property>
<signal name="activate" handler="on_save1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save_as1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_SAVE_AS_ITEM</property>
<signal name="activate" handler="on_save_as1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="separator4">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="execute1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Execute</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_execute1_activate" last_modification_time="Sat, 21 Dec 2002 15:31:44 GMT"/>
<accelerator key="X" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-execute</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="separator1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="close1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_CLOSE_ITEM</property>
<signal name="activate" handler="on_close1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="edit1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_EDIT_TREE</property>
<child>
<widget class="GtkMenu" id="edit1_menu">
<child>
<widget class="GtkImageMenuItem" id="cut1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_CUT_ITEM</property>
<signal name="activate" handler="on_cut1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="copy1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_COPY_ITEM</property>
<signal name="activate" handler="on_copy1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="paste1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_PASTE_ITEM</property>
<signal name="activate" handler="on_paste1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="clear1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_CLEAR_ITEM</property>
<signal name="activate" handler="on_clear1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="separator2">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="properties1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_PROPERTIES_ITEM</property>
<signal name="activate" handler="on_properties1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="separator3">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="preferences1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_PREFERENCES_ITEM</property>
<signal name="activate" handler="on_preferences1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="view1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_VIEW_TREE</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="help1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>
<child>
<widget class="GtkMenu" id="help1_menu">
<child>
<widget class="GtkImageMenuItem" id="about1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
<signal name="activate" handler="on_about1_activate" last_modification_time="Sat, 21 Dec 2002 15:25:07 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="placement">BONOBO_DOCK_TOP</property>
<property name="band">0</property>
<property name="position">0</property>
<property name="offset">0</property>
<property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL|BONOBO_DOCK_ITEM_BEH_LOCKED</property>
</packing>
</child>
<child>
<widget class="BonoboDockItem" id="bonobodockitem2">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_OUT</property>
<child>
<widget class="GtkToolbar" id="toolbar1">
<property name="border_width">1</property>
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
<property name="tooltips">True</property>
<child>
<widget class="button" id="button1">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">New Query</property>
<property name="label">gtk-new</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="button" id="button2">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Load Query from File</property>
<property name="label">gtk-open</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="button" id="button3">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Save Query</property>
<property name="label">gtk-save</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="button" id="button7">
<property name="visible">True</property>
<property name="label">gtk-execute</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="new_group">True</property>
</packing>
</child>
<child>
<widget class="button" id="button9">
<property name="visible">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="new_group">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="placement">BONOBO_DOCK_TOP</property>
<property name="band">1</property>
<property name="position">0</property>
<property name="offset">0</property>
<property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE</property>
</packing>
</child>
<child>
<widget class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="textview1">
<property name="border_width">1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Recent Querys:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCombo" id="combo1">
<property name="visible">True</property>
<property name="value_in_list">False</property>
<property name="allow_empty">True</property>
<property name="case_sensitive">False</property>
<property name="enable_arrow_keys">True</property>
<property name="enable_arrows_always">False</property>
<child internal-child="entry">
<widget class="GtkEntry" id="combo-entry1">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Recently Executed Querys</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
</child>
<child internal-child="list">
<widget class="GtkList" id="combo-list1">
<property name="visible">True</property>
<property name="selection_mode">GTK_SELECTION_BROWSE</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child internal-child="appbar">
<widget class="GnomeAppBar" id="appbar1">
<property name="visible">True</property>
<property name="has_progress">True</property>
<property name="has_status">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</glade-interface>

File diff suppressed because it is too large Load Diff

56
src/gmdb2/gmdb.h Normal file
View File

@@ -0,0 +1,56 @@
#include <mdbtools.h>
#include <mdbsql.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include <gnome.h>
#ifndef _gmdb_h_
#define _gmdb_h_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void gmdb_info_msg(gchar *message);
GtkWidget *gmdb_info_new();
GtkWidget *gmdb_table_data_new(MdbCatalogEntry *entry);
GtkWidget *gmdb_table_def_new(MdbCatalogEntry *entry);
GtkWidget *gmdb_table_export_new(MdbCatalogEntry *entry);
void gmdb_file_select_cb(GtkWidget *w, gpointer data);
void gmdb_file_open_cb(GtkWidget *w, gpointer data);
void gmdb_file_close_cb(GtkWidget *w, gpointer data);
void gmdb_file_open(gchar *file_path);
void gmdb_sql_new_window_cb(GtkWidget *w, gpointer data);
void gmdb_table_populate(MdbHandle *mdb);
void gmdb_form_populate(MdbHandle *mdb);
void gmdb_query_populate(MdbHandle *mdb);
void gmdb_report_populate(MdbHandle *mdb);
void gmdb_macro_populate(MdbHandle *mdb);
void gmdb_module_populate(MdbHandle *mdb);
void gmdb_debug_init(MdbHandle *mdb);
void gmdb_table_add_tab(GtkWidget *notebook);
void gmdb_debug_tab_new(GtkWidget *notebook);
extern GtkWidget *table_list;
extern GtkWidget *form_list;
extern GtkWidget *query_list;
extern GtkWidget *report_list;
extern GtkWidget *macro_list;
extern GtkWidget *module_list;
extern MdbSQL *sql;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif

88
src/gmdb2/info.c Normal file
View File

@@ -0,0 +1,88 @@
#include "gmdb.h"
extern GtkWidget *app;
extern MdbHandle *mdb;
typedef struct GMdbInfoWindow {
GtkWidget *window;
} GMdbInfoWindow;
GMdbInfoWindow *infow;
/* callbacks */
gint
gmdb_info_dismiss_cb(GtkWidget *w, gpointer data)
{
g_free(infow);
infow = NULL;
return FALSE;
}
void
gmdb_info_add_keyvalue(GtkWidget *table, gint row, gchar *key, gchar *value)
{
GtkWidget *label;
label = gtk_label_new(key);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row+1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 0);
gtk_widget_show(label);
label = gtk_label_new(value);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_table_attach(GTK_TABLE(table), label, 1, 2, row, row+1,
GTK_FILL| GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 0);
gtk_widget_show(label);
}
GtkWidget *
gmdb_info_new()
{
GtkWidget *vbox;
GtkWidget *button;
GtkWidget *table;
char tmpstr[20];
struct stat st;
if (infow) {
return infow->window;
}
infow = g_malloc(sizeof(GMdbInfoWindow));
infow->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(infow->window), "File Info");
gtk_widget_set_uposition(infow->window, 300,300);
gtk_widget_show(infow->window);
gtk_signal_connect ( GTK_OBJECT (infow->window),
"destroy", GTK_SIGNAL_FUNC (gmdb_info_dismiss_cb), infow->window);
vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
gtk_container_add(GTK_CONTAINER(infow->window), vbox);
table = gtk_table_new(3,2,FALSE);
gtk_widget_show(table);
gmdb_info_add_keyvalue(table, 0, "File Name:", mdb->filename);
gmdb_info_add_keyvalue(table, 1, "JET Version:", mdb->jet_version == MDB_VER_JET3 ? "3 (Access 97)" : "4 (Access 2000/XP)");
assert( fstat(mdb->fd, &st)!=-1 );
sprintf(tmpstr, "%ld", st.st_size);
gmdb_info_add_keyvalue(table, 2, "File Size:", tmpstr);
sprintf(tmpstr, "%ld", st.st_size / mdb->pg_size);
gmdb_info_add_keyvalue(table, 3, "Number of Pages:", tmpstr);
sprintf(tmpstr, "%d", mdb->num_catalog);
gmdb_info_add_keyvalue(table, 4, "Number of Tables:", tmpstr);
gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 5);
button = gtk_button_new_with_label("Close");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 5);
gtk_signal_connect_object ( GTK_OBJECT (button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT(infow->window));
return infow->window;
}

92
src/gmdb2/logo.xpm Normal file
View File

@@ -0,0 +1,92 @@
/* XPM */
static char * logo_xpm[] = {
"93 73 16 1",
" c None",
". c #B2B2B2",
"+ c #C2C2C2",
"@ c #848484",
"# c #929292",
"$ c #FFFC10",
"% c #E2E2E2",
"& c #D2D2D2",
"* c #A2A2A2",
"= c #6D6D6D",
"- c #3A3A3A",
"; c #F3F164",
"> c #FFFFFF",
", c #F4F4F4",
"' c #ECEB95",
") c #FAF86B",
" + ",
" .#+#. ",
" +@.$$$.@+ ",
" +**%$$$$$@-#+ ",
" *#&$$$$$+=*.-=. ",
" +#+$$$$$%#@&$$=-@+",
" +#.$$$$$%*=+$$+=#@*+",
" +**%$$$$$.=*$$&#@&#** ",
" **&$$$$$+=*$$$##*==*+* ",
" +=+$$$$$%@=$>).=*#-+,&=+ ",
" +**$$$$$%*=.>>+#@*#-#>.@+ ",
" +#*%$$$$$.=.$$&@#*@*+=>.# ",
" .*&$$$$$&=#;$$*@*#@'$=%&@ ",
" +@+$$$$$%@@;$$.=**@&$$**,#+ ",
" +#.$$$$$$*=.$$+##*@.,&$&=,.. ",
" +#.%$$$$$.=.$$;@#*@.%&@#=-&%@ ",
" .@&$$$$$&=#$$$*=.#@'$@@%%==*=+ ",
" .*.$$$$$&#@&$$.##*@.$$@-*.#+ ++ ",
" ++ +@*$$$$$$#=.$$+=##@*$$$+@,-. ",
" +****#* *#&$$$$$.=*$$;@@*@#'$$+.=,+* ",
" +***#@*%+-. .@+$$$$$&@#$$;*=.*=&$$'@##-*# ",
" +.*#------+.-*+ +=@+ +#.$$$$$%#@+$$.@#.=-@#+*=&,.##+ ",
" .**--*%$$$*-&*=-=.@#.*.#.%$$$$$#=+$$+=**@==+%*---##+ ",
" +@.=-@$$$$$$$@->+.%$..%==%$$$$$+=*$$;#@.@*+-#&#. +## ",
" +**@--&$$$$$$$$&-%$$$$*-@+$$$$$&##&$$*@###&,=%@=+ ",
" **#--.$$$$$$$$$$$-+$$$$%.$$$$$$@=+$$.@*#@+$$**>#+ ",
" .*.=-#$$$$$$$$$$$$$=+$$$$$$$$$$.=.$$'##.@*$$$%=,.. ",
" +#.=-=$$$$$$$$$$$$$$$=+$$$$$$$$+=#$$'#@.@@$$$$$=+,@ ",
" .#@--&$$$$$$$$$$$$$$$$-+$$$$$$&@@&$$*@##@+$$$$&@=#@+ ",
" ##--.$$.-*$$$$$$$$$$$$$-.$$$$$@@$$$.=*#@+$$$$$#@&%-# ",
" *#-@$$&@#+#$$$$$$$$$$$$$=.$$$+=.$$'@#.@*$$$$$$#-.+@+ ",
" *@-*$$#@&$&#$$$$$$$$$$$$$=.$$#@'$&#####%$$$$$$+@,-* ",
" +=-.$*=+$$$+@$$$$$$$$$$$$$=+%=*$'@@.##&$$$$$$$$@%&* ",
" @-@$##$$$$*=@$$$$$$$$$$$$$===+&#=..@.$$$$$$$$$@@,*+ ",
" .=-$*@$$$+=++#$$$$$$$$$$$$+--#@#++@*$$$$$$$$$*@@-=. ",
" +@-&&=$$$+=+ +#$$$$$$$$$$$*-=.+&.@#%$$$$$$$$+=.,+@* ",
" *-=$@;$$&= +#$$$$$$$$$$%=%,*==+%$$$$$$$$$*--*#+ ",
" +@-&$#*;$=+ +#$$$$$$$$$$$==-#+#$$$$$$$$$+=*,-- ",
" +--$$$*#=* +#$$$$$$$$$$$+*-+&#$$$$$$$+@#%+*. ",
" *-#$$$$$*=. +#$$$$$$$$$$$$$-.&#$$$$$%@@&,#*+ ",
" +=-&$$$$$$$*@+ +@$$$$$$$$$$$$$-.&@$$$+*=+%.#+ ",
" *-=$$$$$$$$$%##*#$$$$$$$$$$$$$-*&#$+=--*+#+ ",
" @-.$$$$$$$$$$$+#$$$$$$$$$$$$$$-.&-@#&@'*-+ ",
" .@-$+=.$$$$$$$$$$$$$$$$$$$$$$$$-.$@&$$@$$*+ ",
" *-@$=%#@&$$$$$$$$$$$$$$$$$$$$$$-*$$$$'=+$.+ ",
" +#-'.#$$+-@+$$$$$$$$$$$$$$$$$$$$-*$$$.=*@*#+ ",
" +--$@&$$*++##%$$$$$$$$$$$$$$$$$$-*$$=#%$$.-+ ",
" #-.&@$$%# +=$$$$$$$$$$$$$$$$$$-*$=+$$$+#. ",
" +=-'*.$$.. +@$$$*.$$$$$$$$$$$$$-.#*$$$.# ",
" #-@$@$$$#+ @&$$+=@$$$$$$$$$$$$$-#@$$$.* ",
" +=-&&@$$&@ .*$$$=&#$$$$$$$$$$$$+-=&$$+# ",
" .=-$#+$$*+ @%$$*.%#$$$$$$$$$$$$#-@$$$@+ ",
" .-@$=$$$= .+$$%=$%#$$$$$$$$$$$$--.$$.* ",
" .-.$@$$+* +@$$$#.$%#$$$$$$$$$$$+-=%$$#+ ",
"+*-''@$$*+ @+$$&@$$%@$$$$$$$$$$%-=*$$%# ",
"+@-$$=$$@+ +#$$$@&$$+-$$$$$$$$$$@-=%$$.+ ",
"+#-%$#.$#+ #%$$.#$$$==$$$$$$$$$+-=.$$%# ",
"+*-+$$=%*+.*$$$=$$$.##$$$$$$$$%-=@$$$*+ ",
"+.-=$$+=%==%$$#*$$$@ #%$$$$$$+-==$$$+@ ",
" .+-&$$##-.$$&@$$$*+ #%$$$$$@-==%$$%@ ",
" *+=-$$$@#$$$#+$$&# #$$$$+--@=%$$$#+ ",
" @%-=$$$$$$&=$$$@+ =.$$%=-@@@$$$$#+ ",
" +*&-*$$$$$=%$$+=.@'$$@--*@*$$$&@+ ",
" *+*-%$$$.*$$$-=+$$*--@#*%$$$.#+ ",
" @%=-$$$*@+#=*$$&--#@@%$$$+@. ",
" +#%-=$$$*@*$$'@-=*=.$$$&.#+ ",
" +.&-.$$$$$$@-=#@*$$$$*#+ ",
" *+*-*$$$*--#@#%$$$+@+ ",
" @&*-----##@&$$$&#. ",
" +@+%+*.*@.$$$%.#+ ",
" +*==.*.$$$$.*+ ",
" +@#&$$$.@+ ",
" +####. "};

31
src/gmdb2/macro.c Normal file
View File

@@ -0,0 +1,31 @@
#include "gmdb.h"
#include <glade/glade.h>
extern GladeXML* mainwin_xml;
extern GtkWidget *app;
void
gmdb_macro_add_icon(gchar *text)
{
GnomeIconList *gil;
gil = glade_xml_get_widget (mainwin_xml, "macro_iconlist");
gnome_icon_list_append(gil, "macro_big.xpm", text);
}
void gmdb_macro_populate(MdbHandle *mdb)
{
int i;
MdbCatalogEntry *entry;
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
/* if it's a macro */
if (entry->object_type == MDB_MACRO) {
/* add table to tab */
gmdb_macro_add_icon(entry->object_name);
} /* if MDB_MACRO */
} /* for */
}

263
src/gmdb2/macro_big.xpm Normal file
View File

@@ -0,0 +1,263 @@
/* XPM */
static char * macro_big_xpm[] = {
"20 20 240 2",
" c None",
". c #564F44",
"+ c #554D42",
"@ c #544C42",
"# c #585148",
"$ c #786F60",
"% c #7B7162",
"& c #756A5C",
"* c #756B5E",
"= c #635B4E",
"- c #695F51",
"; c #665C50",
"> c #625B4F",
", c #857A69",
"' c #8A7E6C",
") c #867968",
"! c #807565",
"~ c #817666",
"{ c #70685C",
"] c #7A7062",
"^ c #9B8C77",
"/ c #8E816E",
"( c #877B69",
"_ c #928470",
": c #B09E86",
"< c #A5957E",
"[ c #897B69",
"} c #B2A188",
"| c #BFAC91",
"1 c #B5A38A",
"2 c #8E806D",
"3 c #998A74",
"4 c #A0907A",
"5 c #9A8A75",
"6 c #6E6558",
"7 c #807465",
"8 c #BCA990",
"9 c #A89781",
"0 c #9D8E79",
"a c #B3A189",
"b c #CAB69A",
"c c #BCA98F",
"d c #9C8C78",
"e c #C0AD92",
"f c #CEB99C",
"g c #C6B397",
"h c #9D8E78",
"i c #AC9B83",
"j c #B8A68C",
"k c #B6A38A",
"l c #938674",
"m c #6D6356",
"n c #847767",
"o c #D4BEA1",
"p c #BBA88F",
"q c #AC9B84",
"r c #C2B095",
"s c #D6C1A3",
"t c #C8B499",
"u c #AB9A83",
"v c #C7B398",
"w c #CEBA9D",
"x c #C5B196",
"y c #A4947E",
"z c #AF9E85",
"A c #B8A58C",
"B c #908371",
"C c #807667",
"D c #6E6456",
"E c #857867",
"F c #D6BFA2",
"G c #BFAB92",
"H c #AF9E86",
"I c #BFAD93",
"J c #D7C1A4",
"K c #D0BB9E",
"L c #B9A78D",
"M c #CDB99D",
"N c #C4B096",
"O c #9E8E78",
"P c #9C8D76",
"Q c #92836F",
"R c #8C7E6B",
"S c #897C69",
"T c #8A7C69",
"U c #645A4E",
"V c #7C7061",
"W c #D3BDA0",
"X c #B5A28A",
"Y c #B2A088",
"Z c #D5BFA1",
"` c #D1BC9E",
" . c #B6A48B",
".. c #C8B498",
"+. c #B1A087",
"@. c #998B75",
"#. c #A99980",
"$. c #BFAC90",
"%. c #CBB799",
"&. c #C9B599",
"*. c #BAA88F",
"=. c #827665",
"-. c #5D554A",
";. c #74695B",
">. c #C5B297",
",. c #978873",
"'. c #CCB89B",
"). c #B6A48A",
"!. c #C4B195",
"~. c #B09F86",
"{. c #998A75",
"]. c #9B8C76",
"^. c #B3A288",
"/. c #C2AF93",
"(. c #C1AE93",
"_. c #D6C1A4",
":. c #DEC8AA",
"<. c #D2BDA0",
"[. c #887B69",
"}. c #5C554B",
"|. c #6F6659",
"1. c #B3A289",
"2. c #A89880",
"3. c #988974",
"4. c #BEAB90",
"5. c #C5B296",
"6. c #B5A489",
"7. c #C0AD91",
"8. c #A2927C",
"9. c #7F7362",
"0. c #8D806C",
"a. c #938570",
"b. c #E0C9AA",
"c. c #DAC4A6",
"d. c #948570",
"e. c #6F675B",
"f. c #7E7364",
"g. c #BAA78D",
"h. c #B7A48B",
"i. c #AB9A82",
"j. c #AA9981",
"k. c #AD9C83",
"l. c #B4A187",
"m. c #B6A289",
"n. c #9E8D77",
"o. c #857865",
"p. c #847664",
"q. c #AA9982",
"r. c #A7977F",
"s. c #D0BC9E",
"t. c #E3CCAC",
"u. c #DDC7A8",
"v. c #A6957D",
"w. c #776D5E",
"x. c #887C6A",
"y. c #C4B094",
"z. c #D2BC9F",
"A. c #CBB79A",
"B. c #C3B094",
"C. c #C4B095",
"D. c #CBB69A",
"E. c #C9B498",
"F. c #B2A087",
"G. c #A1917B",
"H. c #C1AD93",
"I. c #C9B598",
"J. c #DCC6A7",
"K. c #E4CEAD",
"L. c #A1917A",
"M. c #766C5C",
"N. c #8B7E6B",
"O. c #D5C0A1",
"P. c #E5CEAE",
"Q. c #E5CDAD",
"R. c #E2CCAC",
"S. c #E2CCAD",
"T. c #E4CDAE",
"U. c #E0C9AB",
"V. c #D3BEA1",
"W. c #E1CBAB",
"X. c #D3BEA0",
"Y. c #90826E",
"Z. c #6C6355",
"`. c #817664",
" + c #DFC9A9",
".+ c #E2CBAC",
"++ c #E4CDAD",
"@+ c #756B5C",
"#+ c #897D6A",
"$+ c #B6A58B",
"%+ c #E4CEAE",
"&+ c #D5BFA2",
"*+ c #B7A58C",
"=+ c #928571",
"-+ c #73695B",
";+ c #9E8F79",
">+ c #C3B095",
",+ c #DEC8A9",
"'+ c #DBC5A7",
")+ c #CDB99C",
"!+ c #B3A188",
"~+ c #988A76",
"{+ c #786E5F",
"]+ c #867A6A",
"^+ c #AE9E86",
"/+ c #D1BD9F",
"(+ c #E1CAAA",
"_+ c #DFC8A8",
":+ c #E4CCAC",
"<+ c #9A8C77",
"[+ c #7B6F60",
"}+ c #8F8370",
"|+ c #A69880",
"1+ c #D8C3A4",
"2+ c #DEC8A8",
"3+ c #E4CCAD",
"4+ c #E5CDAE",
"5+ c #E3CDAC",
"6+ c #A5957F",
"7+ c #6B6456",
"8+ c #897D6B",
"9+ c #CEBA9C",
"0+ c #E2CBAB",
"a+ c #90826F",
"b+ c #585249",
"c+ c #796F61",
"d+ c #C6B297",
"e+ c #E5CEAF",
"f+ c #E3CDAD",
"g+ c #E0CAAB",
"h+ c #B09F88",
"i+ c #908270",
"j+ c #645D53",
"k+ c #817768",
"l+ c #C6B398",
"m+ c #E3CEAE",
"n+ c #E2CDAE",
"o+ c #E1CBAD",
"p+ c #BAA890",
"q+ c #A0927D",
" . + @ # $ % & * * ",
" = - ; > , ' ) ! ~ ",
"{ ] ^ / ( _ : < [ } | 1 2 3 4 5 ",
"6 7 8 9 0 a b c d e f g h i j k l ",
"m n o p q r s t u v w x y z j A B C ",
"D E F G H I J K L M N H O P 3 Q R S T ",
"U V W X 4 Y Z ` ...+.@.#.$.%.&.t x *.=.",
"-.;.>.i ,.4 '.f ).!.~.{.].^./.(._.:.<.[.",
"}.|.1.2.3.Q 4.5.6.7.j 8.9.0.3.a.v b.c.d.",
"e.f.~.g.h.i.j.k.l.m.n.o.p.^ q.r.s.t.u.v.",
"w.x.y.z.<.A.B.C.D.E.F.G.: H.b I.J.K.J.L.",
"M.N.O.t.P.Q.R.S.T.U.V.'.u.t.P.P.P.W.X.Y.",
"Z.`.A. +P.P.P.P.P.T.t..+++P.P.P.++s L @+",
" #+$+V.%+P.P.P.P.P.P.P.P.P.P.++&+*+=+-+",
" ;+>+,+P.++t.t.++P.P.P.R.'+)+!+~+{+ ",
" ]+^+/+++(+_+_+t.:+t.P.u.>.<+[+m ",
" }+|+1+2+b.b.3+4+++5+| 6+ ",
" 7+8+9+J..+.+T.P.++0++.a+ ",
" b+c+d+J.P.P.e+%+f+g+h+i+ ",
" j+k+l+J.P.P.%+m+n+o+p+q+ "};

137
src/gmdb2/macros.xpm Normal file
View File

@@ -0,0 +1,137 @@
/* XPM */
static char * macros_xpm[] = {
"14 14 120 2",
" c None",
". c #564F44",
"+ c #554C41",
"@ c #534D44",
"# c #817867",
"$ c #756A5C",
"% c #756B5E",
"& c #70685C",
"* c #A0907A",
"= c #827766",
"- c #998A75",
"; c #C8B498",
"> c #887A68",
", c #C5B195",
"' c #887B68",
") c #A8977F",
"! c #9A8A75",
"~ c #6D6356",
"{ c #DEC7A9",
"] c #A0907B",
"^ c #C4B196",
"/ c #DDC7A8",
"( c #A1917C",
"_ c #CDB99C",
": c #D9C3A5",
"< c #A2927C",
"[ c #C5B296",
"} c #7A7165",
"| c #6E6456",
"1 c #E1C9AB",
"2 c #A89781",
"3 c #BFAD93",
"4 c #E1CAAB",
"5 c #B6A48B",
"6 c #D3BEA1",
"7 c #B4A38A",
"8 c #9B8C76",
"9 c #9C8D76",
"0 c #92836F",
"a c #897C69",
"b c #8A7C69",
"c c #5F564B",
"d c #AC9A83",
"e c #E5CEAD",
"f c #B3A188",
"g c #CBB79A",
"h c #877A67",
"i c #B3A287",
"j c #E0C9A9",
"k c #E1CBAB",
"l c #E2CBAD",
"m c #D8C2A5",
"n c #6B6255",
"o c #595349",
"p c #BDAB90",
"q c #968772",
"r c #8F806C",
"s c #D6C1A3",
"t c #B4A388",
"u c #C5B295",
"v c #B2A088",
"w c #796D5D",
"x c #978973",
"y c #90826E",
"z c #DCC6A8",
"A c #E4CDAD",
"B c #7D705F",
"C c #756C5F",
"D c #B6A48A",
"E c #C5B196",
"F c #B2A188",
"G c #9E8F78",
"H c #B3A087",
"I c #B39F86",
"J c #7A6E5D",
"K c #867866",
"L c #B09F87",
"M c #AD9C83",
"N c #E3CDAC",
"O c #E5CEAE",
"P c #9D8C76",
"Q c #796E5E",
"R c #E3CCAA",
"S c #E5CDAD",
"T c #E0CAAB",
"U c #E4CDAE",
"V c #DDC7A9",
"W c #C0AD92",
"X c #DEC8A9",
"Y c #847764",
"Z c #6B6254",
"` c #D4BFA1",
" . c #E3CCAD",
".. c #BFAC91",
"+. c #5E574C",
"@. c #A89880",
"#. c #E3CDAD",
"$. c #E3CCAC",
"%. c #786E5F",
"&. c #867A6A",
"*. c #C9B699",
"=. c #DEC7A7",
"-. c #D7C2A4",
";. c #9A8C77",
">. c #797060",
",. c #D3BFA0",
"'. c #E0C9AA",
"). c #E5CDAE",
"!. c #E2CCAB",
"~. c #928470",
"{. c #565148",
"]. c #C6B297",
"^. c #E5CEAF",
"/. c #E4CEAE",
"(. c #8E806E",
"_. c #676056",
":. c #C6B398",
"<. c #E2CDAE",
"[. c #E1CBAD",
"}. c #A49681",
" . + @ # $ % ",
"& * = - ; > , ; ' ) ! ",
"~ { ] ^ / ( _ : < [ ; } ",
"| 1 2 3 4 5 6 7 8 9 0 a b ",
"c { 0 d e f g h i j k l m n ",
"o p q r s t u v w x y z A B ",
"C D E F G H I J K L M N O P ",
"Q R O S T U V W X O O O A Y ",
"Z ` O O O O O O O O O ...+.",
" @.#.O O O O O O O $.W %. ",
" &.*.A j =.A $.O -.;.~ ",
" >.,.4 '.).O !.~. ",
" {.].O O ^./.T (. ",
" _.:.O O /.<.[.}. "};

155
src/gmdb2/main2.c Normal file
View File

@@ -0,0 +1,155 @@
#include <gnome.h>
#include <glade/glade.h>
#include <mdbtools.h>
#include <mdbsql.h>
GtkWidget *app;
GladeXML *mainwin_xml;
MdbSQL *sql;
/* called when the user closes the window */
static gint
delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
/* signal the main loop to quit */
gtk_main_quit();
/* return FALSE to continue closing the window */
return FALSE;
}
void
gmdb_about_cb(GtkWidget *button, gpointer data)
{
const gchar *authors[] = {
"Brian Bruns",
NULL
};
const gchar *documenters[] = {
"Brian Bruns",
NULL
};
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_file ("logo.gif", NULL);
gtk_widget_show (gnome_about_new ("Gnome MDB Viewer", "0.2",
"Copyright 2002-2003 Brian Bruns",
_("The Gnome-MDB Viewer is the grapical interface to "
"MDB Tools. It lets you view, print and export data "
"from MDB files produced by MS Access 97/2000/XP."),
(const gchar **) authors,
(const gchar **) authors,
NULL,
pixbuf));
}
void
gmdb_info_cb(GtkWidget *button, gpointer data)
{
gmdb_info_new();
}
/* a callback for the buttons */
void
a_callback(GtkWidget *button, gpointer data)
{
/*just print a string so that we know we got there*/
g_print("Inside Callback\n");
}
void gmdb_load_recent_files()
{
GtkWidget *menuitem;
GtkWidget *menulabel;
char menuname[100];
char cfgname[100];
int i;
gchar *text, *text2;
for (i=4;i>=1;i--) {
sprintf(menuname, "menu_recent%d",i);
sprintf(cfgname, "/gmdb/RecentFiles/menu_recent%d.basename",i);
menuitem = glade_xml_get_widget (mainwin_xml, menuname);
menulabel = gtk_bin_get_child(GTK_BIN(menuitem));
text = gnome_config_get_string(cfgname);
if (!text) {
gtk_widget_hide(menuitem);
} else {
text2 = g_malloc(strlen(text)+4);
sprintf(text2,"%d. %s",i,text);
gtk_label_set_text(GTK_LABEL(menulabel),text2);
gtk_widget_show(menuitem);
g_free(text2);
}
g_free(text);
}
}
void
gmdb_reset_widgets()
{
GnomeIconList *gil;
int pos;
gil = glade_xml_get_widget (mainwin_xml, "table_iconlist");
gnome_icon_list_clear(gil);
gil = glade_xml_get_widget (mainwin_xml, "query_iconlist");
gnome_icon_list_clear(gil);
gil = glade_xml_get_widget (mainwin_xml, "form_iconlist");
gnome_icon_list_clear(gil);
gil = glade_xml_get_widget (mainwin_xml, "report_iconlist");
gnome_icon_list_clear(gil);
gil = glade_xml_get_widget (mainwin_xml, "macro_iconlist");
gnome_icon_list_clear(gil);
gil = glade_xml_get_widget (mainwin_xml, "module_iconlist");
gnome_icon_list_clear(gil);
}
void gmdb_init_popups()
{
}
int main(int argc, char *argv[])
{
GtkWidget *menuitem;
GtkWidget *menulabel;
#ifdef SQL
/* initialize the SQL engine */
sql = mdb_sql_init();
#endif
/* initialize MDB Tools library */
mdb_init();
/* Initialize GNOME */
gnome_init ("gmdb2", "0.2", argc, argv);
app = gnome_app_new ("gmdb2", "Gnome-MDB File Viewer");
glade_init();
/* load the interface */
mainwin_xml = glade_xml_new("gladefiles/gmdb.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(mainwin_xml);
gtk_signal_connect (GTK_OBJECT (app), "delete_event",
GTK_SIGNAL_FUNC (delete_event), NULL);
if (argc>1) {
gmdb_file_open(argv[1]);
}
gmdb_load_recent_files();
gmdb_init_popups();
/* start the event loop */
gtk_main();
#ifdef SQL
/* free MDB Tools library */
mdb_sql_exit(sql);
#endif
mdb_exit();
return 0;
}

31
src/gmdb2/module.c Normal file
View File

@@ -0,0 +1,31 @@
#include "gmdb.h"
#include <glade/glade.h>
extern GladeXML* mainwin_xml;
extern GtkWidget *app;
void
gmdb_module_add_icon(gchar *text)
{
GnomeIconList *gil;
gil = glade_xml_get_widget (mainwin_xml, "module_iconlist");
gnome_icon_list_append(gil, "module_big.xpm", text);
}
void gmdb_module_populate(MdbHandle *mdb)
{
int i;
MdbCatalogEntry *entry;
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
/* if it's a module */
if (entry->object_type == MDB_MODULE) {
/* add table to tab */
gmdb_module_add_icon(entry->object_name);
} /* if MDB_MODULE */
} /* for */
}

25
src/gmdb2/module_big.xpm Normal file
View File

@@ -0,0 +1,25 @@
/* XPM */
static char * module_big_xpm[] = {
"24 20 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" . .. . . ",
" . .. . . ",
" . . . ",
" . . . ",
" .... .. ... .. ..",
" . .. .. . ..",
" . .. .. . ..",
" . .. .. ..",
" . .. .. ..",
" . .. . .. ..",
" . . . .. . ",
" ... .. ... .... .. ",
" . . ",
" ",
" ",
" ",
" "};

24
src/gmdb2/pk.xpm Normal file
View File

@@ -0,0 +1,24 @@
/* XPM */
static char * pk_xpm[] = {
"16 16 5 1",
" c None",
". c #FFBF00",
"+ c #1C59DD",
"@ c #000000",
"# c #E8AC17",
" ",
" .... +++ ",
" ..@@.. + + ",
" ...... + + ",
" ...... +++ ",
" .... + ",
" .# + ",
" .# ",
" .# + + ",
" .#. + + ",
" .#.. ++ ",
" .# + + ",
" .#. + + ",
" .#.. + + ",
" ",
" "};

32
src/gmdb2/query.c Normal file
View File

@@ -0,0 +1,32 @@
#include "gmdb.h"
#include <glade/glade.h>
extern GladeXML* mainwin_xml;
GtkWidget *query_list;
extern GtkWidget *app;
void
gmdb_query_add_icon(gchar *text)
{
GnomeIconList *gil;
gil = glade_xml_get_widget (mainwin_xml, "query_iconlist");
gnome_icon_list_append(gil, "query_big.xpm", text);
}
void gmdb_query_populate(MdbHandle *mdb)
{
int i;
MdbCatalogEntry *entry;
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
/* if it's a query */
if (entry->object_type == MDB_QUERY) {
gmdb_query_add_icon(entry->object_name);
} /* if MDB_QUERY */
} /* for */
}

46
src/gmdb2/query.xpm Normal file
View File

@@ -0,0 +1,46 @@
/* XPM */
static char * query_xpm[] = {
"10 12 31 1",
" c None",
". c #C9C5C5",
"+ c #C2BEBE",
"@ c #D0CCCC",
"# c #DAD5D5",
"$ c #C1BDBD",
"% c #9B9B9B",
"& c #B6B5B5",
"* c #C0BCBC",
"= c #9D9C9C",
"- c #D4D1D1",
"; c #CCC8C8",
"> c #8C8C8C",
", c #A09F9F",
"' c #959696",
") c #A7A6A6",
"! c #C6C1C1",
"~ c #8D8E8E",
"{ c #A4A5A5",
"] c #BEBBBB",
"^ c #C3C0C0",
"/ c #9D9E9E",
"( c #AFACAC",
"_ c #949595",
": c #B9B7B7",
"< c #AEABAB",
"[ c #B0AEAE",
"} c #A2A2A2",
"| c #A5A5A5",
"1 c #979797",
"2 c #ACABAB",
" .+@ ",
" #$%&*%=- ",
" ;> ,' ",
" )> !~+",
" +{ ]~+",
" ^~/ ",
" (_: ",
" <[ ",
" } ",
" ",
" |+ ",
" +12 "};

29
src/gmdb2/query_big.xpm Normal file
View File

@@ -0,0 +1,29 @@
/* XPM */
static char * query_big_xpm[] = {
"20 24 2 1",
" c None",
". c #000000",
" ",
" ",
" ........ ",
" .. ..... ",
" .... ..... ",
" ..... ..... ",
" ..... ..... ",
" .... ..... ",
" ..... ",
" ..... ",
" .... ",
" .... ",
" .. ",
" .. ",
" . ",
" . ",
" ",
" ... ",
" ..... ",
" ..... ",
" ..... ",
" .... ",
" ",
" "};

31
src/gmdb2/report.c Normal file
View File

@@ -0,0 +1,31 @@
#include "gmdb.h"
#include <glade/glade.h>
extern GladeXML* mainwin_xml;
extern GtkWidget *app;
void
gmdb_report_add_icon(gchar *text)
{
GnomeIconList *gil;
gil = glade_xml_get_widget (mainwin_xml, "report_iconlist");
gnome_icon_list_append(gil, "report_big.xpm", text);
}
void gmdb_report_populate(MdbHandle *mdb)
{
int i;
MdbCatalogEntry *entry;
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
/* if it's a report */
if (entry->object_type == MDB_REPORT) {
/* add table to tab */
gmdb_report_add_icon(entry->object_name);
} /* if MDB_REPORT */
} /* for */
}

217
src/gmdb2/report_big.xpm Normal file
View File

@@ -0,0 +1,217 @@
/* XPM */
static char * report_big_xpm[] = {
"20 20 194 2",
" c None",
". c #45372B",
"+ c #746450",
"@ c #766654",
"# c #736250",
"$ c #625241",
"% c #5E4844",
"& c #D9C3A0",
"* c #EAD7B7",
"= c #E0CAAB",
"- c #9C8A71",
"; c #171512",
"> c #15120E",
", c #5F4946",
"' c #DFCAAB",
") c #EFE2CD",
"! c #F0E6D7",
"~ c #E8DBC9",
"{ c #D1BEA2",
"] c #BBA382",
"^ c #3F362B",
"/ c #020201",
"( c #000000",
"_ c #5D4D43",
": c #DFD1BF",
"< c #F5EDE2",
"[ c #FAF5EE",
"} c #FBF5EE",
"| c #F8EFE4",
"1 c #F0E3D3",
"2 c #BCAE9A",
"3 c #9B8A72",
"4 c #826F5B",
"5 c #564642",
"6 c #594A46",
"7 c #605346",
"8 c #E0D6C9",
"9 c #F8F2EA",
"0 c #FDF9F5",
"a c #FEFBF8",
"b c #FEFAF7",
"c c #FDF6F0",
"d c #F6EADB",
"e c #C3B19E",
"f c #7E6A5B",
"g c #4C3E3C",
"h c #584946",
"i c #2A2221",
"j c #65584A",
"k c #E4DACC",
"l c #F9F3EA",
"m c #FDF8F3",
"n c #FEFAF5",
"o c #FDF8F5",
"p c #FBF4EE",
"q c #FBF3EC",
"r c #AA9E99",
"s c #554643",
"t c #4E413D",
"u c #806F62",
"v c #28231F",
"w c #6E5E4F",
"x c #E8DECF",
"y c #FCF5EA",
"z c #FEF8EF",
"A c #FEF7EF",
"B c #FCF6F0",
"C c #F9F1E7",
"D c #FAF1E6",
"E c #A69A93",
"F c #514240",
"G c #5E4F49",
"H c #CAB695",
"I c #453F33",
"J c #624E3D",
"K c #A88A70",
"L c #F1E6D6",
"M c #FDF4E7",
"N c #FEF5EA",
"O c #FCF4E8",
"P c #F9F0E3",
"Q c #F7EEDE",
"R c #F7EDDD",
"S c #807A72",
"T c #090707",
"U c #0A0908",
"V c #161411",
"W c #4B3B2E",
"X c #766554",
"Y c #DECAB1",
"Z c #F8ECD7",
"` c #FDF2DF",
" . c #FEF3E0",
".. c #FCF1DE",
"+. c #F8EBD7",
"@. c #F5E8D3",
"#. c #F2E2CE",
"$. c #7A7167",
"%. c #030202",
"&. c #493A2E",
"*. c #7C6D5C",
"=. c #F4E4C9",
"-. c #F9EAD0",
";. c #FCEED4",
">. c #F5E5CA",
",. c #EFDFC6",
"'. c #EAD8BE",
"). c #756C5E",
"!. c #5D4D3C",
"~. c #8E7D67",
"{. c #F0DEBE",
"]. c #F1DFBE",
"^. c #F6E5C5",
"/. c #F5E4C5",
"(. c #F2E0C2",
"_. c #F0DDBF",
":. c #E9D7BA",
"<. c #E2CDAF",
"[. c #6F6555",
"}. c #584B40",
"|. c #584A3E",
"1. c #564739",
"2. c #7F6B55",
"3. c #B8A080",
"4. c #DBC5A0",
"5. c #E0C8A1",
"6. c #E9D1AE",
"7. c #EBD5B3",
"8. c #EAD5B4",
"9. c #EAD5B6",
"0. c #E6D1B2",
"a. c #CCB696",
"b. c #665A48",
"c. c #7B7067",
"d. c #ECE8E5",
"e. c #ECE5D8",
"f. c #DAC6AA",
"g. c #AB9177",
"h. c #866C58",
"i. c #907560",
"j. c #BDA381",
"k. c #D3B995",
"l. c #DBC19E",
"m. c #DEC5A1",
"n. c #E2C8A4",
"o. c #DAC09D",
"p. c #514839",
"q. c #15130E",
"r. c #726252",
"s. c #DECAB0",
"t. c #EFDEC5",
"u. c #F5E9D9",
"v. c #E8DCCE",
"w. c #D3C1AD",
"x. c #BFA486",
"y. c #9A7F66",
"z. c #997E66",
"A. c #AE9477",
"B. c #C5AB88",
"C. c #C9AF8C",
"D. c #C7AC89",
"E. c #3C3429",
"F. c #010100",
"G. c #544637",
"H. c #685A48",
"I. c #746A5A",
"J. c #C4B6A5",
"K. c #EDDFCA",
"L. c #F4E6D0",
"M. c #EBDCCA",
"N. c #C5B4A3",
"O. c #B69E86",
"P. c #9D856F",
"Q. c #8A7663",
"R. c #927C67",
"S. c #B29A7A",
"T. c #372F25",
"U. c #6E5F4B",
"V. c #9A8972",
"W. c #BBAE9C",
"X. c #F1E6DA",
"Y. c #F7EDDA",
"Z. c #CCB8A0",
"`. c #867364",
" + c #5F4E48",
".+ c #776651",
"++ c #2E281F",
"@+ c #3C3329",
"#+ c #7E6E64",
"$+ c #4F413E",
"%+ c #463A37",
"&+ c #594946",
"*+ c #181413",
"=+ c #1B1615",
" . . . . ",
" + @ # $ ",
" % & * = - ; > ",
" , ' ) ! ~ { ] ^ / ( ",
" _ : < [ } | 1 2 3 4 5 6 ",
" 7 8 9 0 a b c d e f g h i ",
" j k l m n o p q r s t u v ",
" w x y z A B C D E F G H I ",
" J K L M N O P Q R S T U V ",
" W X Y Z ` ...+.@.#.$.%. ",
" &.*.=.-.;.;.-.>.,.'.)./ ",
" !.~.{.].^./.(._.:.<.[.( ",
" }.|.1.2.3.4.5.6.7.8.9.0.a.b.( ",
". c.d.e.f.g.h.i.j.k.l.m.n.o.p.q. ",
". r.s.t.u.v.w.x.y.z.A.B.C.D.E.F. ",
". G.H.I.J.K.L.M.N.O.P.Q.R.S.T.( ",
" ( ( U.V.W.X.Y.Z.`.s +.+++ ",
" ( ( @+] { #+$+$+G U ",
" > ; %+&+u H V ",
" *+=+v I "};

95
src/gmdb2/reports.xpm Normal file
View File

@@ -0,0 +1,95 @@
/* XPM */
static char * reports_xpm[] = {
"16 16 76 1",
" c None",
". c #45372B",
"+ c #4F3939",
"@ c #E7D1AA",
"# c #EBD7B9",
"$ c #D1B692",
"% c #000000",
"& c #F0DBB9",
"* c #F0E7D9",
"= c #F5EBDF",
"- c #CDB18C",
"; c #050403",
"> c #4C3E31",
", c #EFE4D7",
"' c #FBF7F3",
") c #FFFCF9",
"! c #FDF6EF",
"~ c #554542",
"{ c #5A4A47",
"] c #55473A",
"^ c #F2E9DB",
"/ c #FBF6F0",
"( c #FEFBF8",
"_ c #FEFAF7",
": c #FCF4EF",
"< c #FAF3ED",
"[ c #413533",
"} c #57483A",
"| c #F7EDDE",
"1 c #FEF8F0",
"2 c #FEF8EF",
"3 c #FDF7F3",
"4 c #F9F1E7",
"5 c #FBF2E7",
"6 c #594946",
"7 c #EFD8B0",
"8 c #A78568",
"9 c #FBF2E3",
"0 c #FEF5E8",
"a c #FDF5EA",
"b c #F9EFE2",
"c c #F7EDDC",
"d c #F7ECDC",
"e c #4D3D30",
"f c #F1E2CA",
"g c #FCEFD9",
"h c #FEF2DC",
"i c #F8EAD3",
"j c #F4E5CE",
"k c #EEDBC5",
"l c #F5E5C7",
"m c #F7E7C9",
"n c #FCEED0",
"o c #F6E6C8",
"p c #F4E1C3",
"q c #E9D8BC",
"r c #E2CFB1",
"s c #AE9676",
"t c #E5CFA8",
"u c #E4CCA5",
"v c #EFD8B6",
"w c #EBD7B5",
"x c #E7D3B4",
"y c #D7BD99",
"z c #FFFCFB",
"A c #FFF8E9",
"B c #E2C7A3",
"C c #806553",
"D c #BFA582",
"E c #DBC19D",
"F c #020200",
"G c #E1C6A2",
"H c #836854",
"I c #B89F7D",
"J c #FEF7E8",
"K c #5D4B47",
" ... ",
" +@#$%% ",
" +&*=#-;% ",
" >,'))!#-~{ ",
" ]^/(_:<{[{%",
" }|12345{67%",
" .890abcd%%% ",
" efghhijk; ",
" .lmnopqr% ",
" ...stuvw#xy% ",
".zABCCDyEByF ",
".-#zAGHCIDD% ",
" %%-#zJB{Ks% ",
" %%-#{[{% ",
" %%{{7% ",
" %%% "};

321
src/gmdb2/sql.c Normal file
View File

@@ -0,0 +1,321 @@
#include "gmdb.h"
#if SQL
typedef struct GMdbSQLWindow {
GtkWidget *window;
GtkWidget *textbox;
GtkWidget *combo;
GtkWidget *clist;
GtkWidget *scroll;
GtkWidget *ctree;
GtkCTreeNode *current_node;
GList *history;
} GMdbSQLWindow;
GList *window_list;
extern GtkWidget *app;
extern MdbHandle *mdb;
extern MdbSQL *sql;
GtkCTreeNode *gmdb_sql_ctree_populate(MdbHandle *mdb, GMdbSQLWindow *sqlwin);
/* callbacks */
gint
gmdb_sql_close(GtkList *list, GtkWidget *w, GMdbSQLWindow *sqlwin)
{
window_list = g_list_remove(window_list, sql);
g_free(sql);
return FALSE;
}
void
gmdb_sql_tree_select_cb(GtkCTree *tree, GList *node, gint column, GMdbSQLWindow *sqlwin)
{
sqlwin->current_node = node;
}
void
gmdb_sql_dnd_dataget_cb(
GtkWidget *w, GdkDragContext *dc,
GtkSelectionData *selection_data, guint info, guint t,
GMdbSQLWindow *sqlwin)
{
gchar tablename[256];
gchar *text[2];
gtk_ctree_get_node_info(GTK_CTREE(sqlwin->ctree), sqlwin->current_node, text, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
//strcpy(tablename, "Shippers");
gtk_selection_data_set(
selection_data,
GDK_SELECTION_TYPE_STRING,
8, /* 8 bits per character. */
text[0], strlen(text[0]));
}
void gmdb_sql_dnd_datareceived_cb(
GtkWidget *w,
GdkDragContext *dc,
gint x, gint y,
GtkSelectionData *selection_data,
guint info, guint t,
GMdbSQLWindow *sqlwin)
{
gchar *buf, *lastbuf;
GtkTextIter iter, start, end;
GtkTextBuffer *txtbuffer;
int len;
buf = selection_data->data;
txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sqlwin->textbox));
if (gtk_text_buffer_get_char_count(txtbuffer)==0) {
gtk_text_buffer_get_iter_at_offset (txtbuffer, &iter, 0);
gtk_text_buffer_insert(txtbuffer, &iter, "select * from ", 14);
}
#if 0
len = gtk_text_buffer_get_char_count(txtbuffer);
gtk_text_buffer_get_iter_at_offset (txtbuffer, &end, len);
gtk_text_buffer_get_iter_at_offset (txtbuffer, &start, len - strlen(buf));
lastbuf = gtk_text_buffer_get_text(txtbuffer, &start, &end, FALSE);
printf("last buf %s\n", lastbuf);
if (strcmp(buf,lastbuf)) {
//gtk_text_buffer_insert_at_cursor(txtbuffer,buf,strlen(buf));
}
#endif
gtk_widget_grab_focus(GTK_WIDGET(sqlwin->textbox));
}
void
gmdb_sql_select_hist_cb(GtkList *list, GtkWidget *w, GMdbSQLWindow *sqlwin)
{
guint child_num;
gchar *buf;
GtkTextBuffer *txtbuffer;
child_num = gtk_list_child_position(list, w);
buf = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(sqlwin->combo)->entry));
txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sqlwin->textbox));
gtk_text_buffer_set_text(txtbuffer, buf, strlen(buf));
}
void
gmdb_sql_execute_cb(GtkWidget *w, GMdbSQLWindow *sqlwin)
{
guint len;
gchar *buf;
gchar *bound_data[256];
int i;
MdbSQLColumn *sqlcol;
gchar *titles[256];
GtkTextBuffer *txtbuffer;
GtkTextIter start, end;
/* stuff this query on the history */
txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sqlwin->textbox));
len = gtk_text_buffer_get_char_count(txtbuffer);
gtk_text_buffer_get_iter_at_offset (txtbuffer, &start, 0);
gtk_text_buffer_get_iter_at_offset (txtbuffer, &end, len);
buf = gtk_text_buffer_get_text(txtbuffer, &start, &end, FALSE);
sqlwin->history = g_list_prepend(sqlwin->history, g_strdup(buf));
gtk_combo_set_popdown_strings(GTK_COMBO(sqlwin->combo), sqlwin->history);
/* ok now execute it */
g_input_ptr = buf;
/* begin unsafe */
_mdb_sql(sql);
if (yyparse()) {
/* end unsafe */
gmdb_info_msg("Couldn't parse SQL");
mdb_sql_reset(sql);
return;
}
for (i=0;i<sql->num_columns;i++) {
bound_data[i] = (char *) malloc(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdbsql_bind_column(sql, i+1, bound_data[i]);
sqlcol = g_ptr_array_index(sql->columns,i);
titles[i] = sqlcol->name;
}
if (sqlwin->clist) {
gtk_container_remove(GTK_CONTAINER(sqlwin->scroll), sqlwin->clist);
}
sqlwin->clist = gtk_clist_new_with_titles(sql->num_columns, titles);
gtk_container_add(GTK_CONTAINER(sqlwin->scroll),sqlwin->clist);
gtk_widget_show(sqlwin->clist);
while(mdb_fetch_row(sql->cur_table)) {
gtk_clist_append(GTK_CLIST(sqlwin->clist), bound_data);
}
/* free the memory used to bind */
for (i=0;i<sql->num_columns;i++) {
free(bound_data[i]);
}
mdb_sql_reset(sql);
g_free(buf);
}
void
gmdb_sql_new_window_cb(GtkWidget *w, gpointer data)
{
GtkWidget *hpane;
GtkWidget *vpane;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *scroll;
GtkWidget *button;
GtkWidget *frame1;
GtkTargetEntry src;
GMdbSQLWindow *sqlwin;
GtkWindow *txtbuffer;
GtkCTreeNode *node;
if (!mdb) {
gmdb_info_msg("No database is open.");
return;
}
sqlwin = g_malloc0(sizeof(GMdbSQLWindow));
sqlwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(sqlwin->window), "Query Tool");
gtk_widget_set_usize(sqlwin->window, 400,300);
gtk_widget_show(sqlwin->window);
gtk_signal_connect (GTK_OBJECT (sqlwin->window), "delete_event",
GTK_SIGNAL_FUNC (gmdb_sql_close), sqlwin);
vpane = gtk_vpaned_new();
gtk_widget_show(vpane);
gtk_paned_set_position(GTK_PANED(vpane), 100);
gtk_paned_set_gutter_size(GTK_PANED(vpane), 12);
gtk_container_add(GTK_CONTAINER(sqlwin->window), vpane);
hpane = gtk_hpaned_new();
gtk_widget_show(hpane);
gtk_paned_set_position(GTK_PANED(hpane), 100);
gtk_paned_set_gutter_size(GTK_PANED(hpane), 12);
gtk_container_add(GTK_CONTAINER(vpane), hpane);
scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_widget_show (scroll);
gtk_container_add(GTK_CONTAINER(hpane), scroll);
sqlwin->ctree = gtk_ctree_new (1, 0);
gtk_widget_show (sqlwin->ctree);
gtk_container_add (GTK_CONTAINER (scroll), sqlwin->ctree);
gtk_signal_connect ( GTK_OBJECT (sqlwin->ctree),
"tree-select-row", GTK_SIGNAL_FUNC (gmdb_sql_tree_select_cb), sqlwin);
vbox = gtk_vbox_new(FALSE,0);
gtk_widget_show (vbox);
gtk_container_add(GTK_CONTAINER(hpane), vbox);
frame1 = gtk_frame_new (NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_IN);
gtk_widget_show (frame1);
gtk_box_pack_start (GTK_BOX (vbox), frame1, TRUE, TRUE, 0);
sqlwin->textbox = gtk_text_view_new();
gtk_widget_show (sqlwin->textbox);
gtk_container_add(GTK_CONTAINER(frame1), sqlwin->textbox);
#if 0
gtk_signal_connect ( GTK_OBJECT (sqlwin->textbox),
"activate", GTK_SIGNAL_FUNC (gmdb_sql_execute_cb), sqlwin);
#endif
hbox = gtk_hbox_new(FALSE,0);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
sqlwin->combo = gtk_combo_new();
gtk_widget_show (sqlwin->combo);
gtk_box_pack_start (GTK_BOX (hbox), sqlwin->combo, TRUE, TRUE, 0);
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(sqlwin->combo)->entry), FALSE);
gtk_signal_connect ( GTK_OBJECT (GTK_COMBO(sqlwin->combo)->list),
"select-child", GTK_SIGNAL_FUNC (gmdb_sql_select_hist_cb), sqlwin);
button = gtk_button_new_with_label("Execute");
gtk_widget_show (button);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 5);
gtk_signal_connect ( GTK_OBJECT (button),
"clicked", GTK_SIGNAL_FUNC (gmdb_sql_execute_cb), sqlwin);
sqlwin->scroll = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sqlwin->scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show (sqlwin->scroll);
gtk_container_add(GTK_CONTAINER(vpane), sqlwin->scroll);
sqlwin->clist = gtk_clist_new(1);
gtk_widget_show(sqlwin->clist);
gtk_container_add(GTK_CONTAINER(sqlwin->scroll),sqlwin->clist);
/* populate first level of tree */
node = gmdb_sql_ctree_populate(mdb, sqlwin);
gtk_ctree_select(sqlwin->ctree, node);
src.target = "table";
src.flags = 0;
src.info = 1;
gtk_drag_source_set( sqlwin->ctree, GDK_BUTTON1_MASK, &src, 1, GDK_ACTION_COPY);
gtk_drag_dest_set( sqlwin->textbox,
//GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT ,
// GTK_DEST_DEFAULT_DROP,
&src, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_signal_connect( GTK_OBJECT(sqlwin->ctree), "drag_data_get",
GTK_SIGNAL_FUNC(gmdb_sql_dnd_dataget_cb), sqlwin);
gtk_signal_connect( GTK_OBJECT(sqlwin->textbox), "drag_data_received",
GTK_SIGNAL_FUNC(gmdb_sql_dnd_datareceived_cb), sqlwin);
gtk_widget_grab_focus(GTK_WIDGET(sqlwin->textbox));
/* add this one to the window list */
window_list = g_list_append(window_list, sql);
}
/* functions */
GtkCTreeNode *
gmdb_sql_ctree_populate(MdbHandle *mdb, GMdbSQLWindow *sqlwin)
{
int i;
MdbCatalogEntry *entry;
gchar *text[2];
GtkCTreeNode *node, *first_node = NULL;
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
/* if it's a table */
if (entry->object_type == MDB_TABLE) {
/* skip the MSys tables */
if (strncmp (entry->object_name, "MSys", 4)) {
/* add table to tab */
text[0] = entry->object_name;
text[1] = "";
node = gtk_ctree_insert_node(GTK_CTREE(sqlwin->ctree), NULL, NULL, text, 0, NULL, NULL, NULL, NULL, FALSE, FALSE);
if (! first_node) first_node = node;
}
} /* if MDB_TABLE */
} /* for */
return first_node;
}
#else
void
gmdb_sql_new_window_cb(GtkWidget *w, gpointer data)
{
gmdb_info_msg("SQL support was not built in.\nRun configure with the --enable-sql option.");
}
#endif

107
src/gmdb2/table.c Normal file
View File

@@ -0,0 +1,107 @@
#include "gmdb.h"
#include <glade/glade.h>
GtkWidget *table_list;
GtkWidget *table_data_window;
GtkWidget *table_def_window;
extern GtkWidget *app;
extern GladeXML* mainwin_xml;
extern MdbHandle *mdb;
int selected_table = -1;
extern char *mdb_access_types[];
/* callbacks */
void
gmdb_table_def_cb(GtkList *list, GtkWidget *w, gpointer data)
{
MdbCatalogEntry *entry;
printf("here\n");
/* nothing selected yet? */
if (selected_table==-1) {
return;
}
entry = g_ptr_array_index(mdb->catalog,selected_table);
gmdb_table_def_new(entry);
}
void
gmdb_table_export_cb(GtkList *list, GtkWidget *w, gpointer data)
{
MdbCatalogEntry *entry;
/* nothing selected yet? */
if (selected_table==-1) {
return;
}
entry = g_ptr_array_index(mdb->catalog,selected_table);
gmdb_table_export(entry);
}
void
gmdb_table_data_cb(GtkList *list, GtkWidget *w, gpointer data)
{
MdbCatalogEntry *entry;
/* nothing selected yet? */
if (selected_table==-1) {
return;
}
entry = g_ptr_array_index(mdb->catalog,selected_table);
gmdb_table_data_new(entry);
}
void
gmdb_table_select_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data)
{
int child_num;
int i,j=0;
MdbCatalogEntry *entry;
gchar *text;
text = (gchar *) gnome_icon_list_get_icon_data(gil, num);
printf ("text !%s!\n",text);
for (i=0;i<mdb->num_catalog;i++) {
entry = g_ptr_array_index(mdb->catalog,i);
if (entry->object_type==MDB_TABLE &&
!strcmp(entry->object_name,text)) {
selected_table = i;
}
}
}
/* functions */
void
gmdb_table_add_icon(gchar *text)
{
GnomeIconList *gil;
int pos;
gil = glade_xml_get_widget (mainwin_xml, "table_iconlist");
pos = gnome_icon_list_append(gil, "table_big.xpm", text);
gnome_icon_list_set_icon_data(gil, pos, text);
}
void gmdb_table_populate(MdbHandle *mdb)
{
int i;
MdbCatalogEntry *entry;
/* loop over each entry in the catalog */
for (i=0; i < mdb->num_catalog; i++) {
entry = g_ptr_array_index (mdb->catalog, i);
/* if it's a table */
if (entry->object_type == MDB_TABLE) {
/* skip the MSys tables */
if (strncmp (entry->object_name, "MSys", 4)) {
/* add table to tab */
gmdb_table_add_icon(entry->object_name);
}
} /* if MDB_TABLE */
} /* for */
}

19
src/gmdb2/table.xpm Normal file
View File

@@ -0,0 +1,19 @@
/* XPM */
static char * table_xpm[] = {
"10 12 4 1",
" c None",
". c #1874B1",
"+ c #606060",
"@ c #D7D2D2",
"..........",
"..........",
"+@@+@@@+@+",
"++++++++++",
"+@@+@@@+@+",
"++++++++++",
"+@@+@@@+@+",
"++++++++++",
"+@@+@@@+@+",
"++++++++++",
"+@@+@@@+@+",
"++++++++++"};

36
src/gmdb2/table_big.xpm Normal file
View File

@@ -0,0 +1,36 @@
/* XPM */
static char * table_big_xpm[] = {
"20 24 9 1",
" c None",
". c #1874B1",
"+ c #3C6A88",
"@ c #5A86A5",
"# c #78A3C2",
"$ c #606060",
"% c #9C9999",
"& c #D7D2D2",
"* c #7E7C7C",
"....................",
"....................",
"....................",
"....................",
"++@###@+@#####@+@#@+",
"$$%&&&%$%&&&&&%$%&%$",
"$$*%%%*$*%%%%%*$*%*$",
"$$$$$$$$$$$$$$$$$$$$",
"$$*%%%*$*%%%%%*$*%*$",
"$$%&&&%$%&&&&&%$%&%$",
"$$*%%%*$*%%%%%*$*%*$",
"$$$$$$$$$$$$$$$$$$$$",
"$$*%%%*$*%%%%%*$*%*$",
"$$%&&&%$%&&&&&%$%&%$",
"$$*%%%*$*%%%%%*$*%*$",
"$$$$$$$$$$$$$$$$$$$$",
"$$*%%%*$*%%%%%*$*%*$",
"$$%&&&%$%&&&&&%$%&%$",
"$$*%%%*$*%%%%%*$*%*$",
"$$$$$$$$$$$$$$$$$$$$",
"$$*%%%*$*%%%%%*$*%*$",
"$$%&&&%$%&&&&&%$%&%$",
"$$*%%%*$*%%%%%*$*%*$",
"$$$$$$$$$$$$$$$$$$$$"};

97
src/gmdb2/table_data.c Normal file
View File

@@ -0,0 +1,97 @@
#include "gmdb.h"
extern GtkWidget *app;
extern MdbHandle *mdb;
typedef struct GMdbDataWindow {
gchar table_name[MDB_MAX_OBJ_NAME];
GtkWidget *window;
} GMdbDataWindow;
static GList *window_list;
/* callbacks */
gint
gmdb_table_data_close(GtkWidget *w, GdkEvent *event, GMdbDataWindow *dataw)
{
window_list = g_list_remove(window_list, dataw);
g_free(dataw);
return FALSE;
}
/* functions */
GtkWidget *
gmdb_table_data_new(MdbCatalogEntry *entry)
{
MdbTableDef *table;
MdbColumn *col;
GtkWidget *clist;
GtkWidget *scroll;
int i, rownum;
gchar *bound_data[256];
GMdbDataWindow *dataw = NULL;
/* do we have an active window for this object? if so raise it */
for (i=0;i<g_list_length(window_list);i++) {
dataw = g_list_nth_data(window_list, i);
if (!strcmp(dataw->table_name, entry->object_name)) {
gdk_window_raise (dataw->window->window);
return dataw->window;
}
}
dataw = g_malloc(sizeof(GMdbDataWindow));
strcpy(dataw->table_name, entry->object_name);
dataw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(dataw->window), entry->object_name);
gtk_widget_set_usize(dataw->window, 300,200);
gtk_widget_set_uposition(dataw->window, 50,50);
gtk_widget_show(dataw->window);
gtk_signal_connect (GTK_OBJECT (dataw->window), "delete_event",
GTK_SIGNAL_FUNC (gmdb_table_data_close), dataw);
scroll = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show (scroll);
gtk_container_add(GTK_CONTAINER(dataw->window), scroll);
/* read table */
table = mdb_read_table(entry);
mdb_read_columns(table);
mdb_rewind_table(table);
clist = gtk_clist_new(table->num_cols);
gtk_widget_show(clist);
gtk_container_add(GTK_CONTAINER(scroll),clist);
for (i=0;i<table->num_cols;i++) {
/* bind columns */
bound_data[i] = (char *) malloc(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdb_bind_column(table, i+1, bound_data[i]);
/* display column titles */
col=g_ptr_array_index(table->columns,i);
gtk_clist_set_column_title(GTK_CLIST(clist), i, col->name);
}
gtk_clist_column_titles_show(GTK_CLIST(clist));
/* fetch those rows! */
while(mdb_fetch_row(table)) {
rownum = gtk_clist_append(GTK_CLIST(clist), bound_data);
}
/* free the memory used to bind */
for (i=0;i<table->num_cols;i++) {
free(bound_data[i]);
}
/* add this one to the window list */
window_list = g_list_append(window_list, dataw);
return dataw->window;
}

129
src/gmdb2/table_def.c Normal file
View File

@@ -0,0 +1,129 @@
#include "gmdb.h"
#include "pk.xpm"
extern GtkWidget *app;
extern MdbHandle *mdb;
extern char *mdb_access_types[];
typedef struct GMdbDefWindow {
gchar table_name[MDB_MAX_OBJ_NAME];
GtkWidget *window;
} GMdbDefWindow;
static GList *window_list;
/* callbacks */
gint
gmdb_table_def_close(GtkList *list, GtkWidget *w, GMdbDefWindow *defw)
{
window_list = g_list_remove(window_list, defw);
g_free(defw);
return FALSE;
}
GtkWidget *
gmdb_table_def_new(MdbCatalogEntry *entry)
{
MdbTableDef *table;
MdbIndex *idx;
MdbColumn *col;
GtkWidget *clist;
GtkWidget *scroll;
GdkPixmap *pixmap;
GdkBitmap *mask;
int i,j;
gchar *titles[] = { "", "Column", "Name", "Type", "Size", "Allow Nulls" };
gchar *row[6];
GMdbDefWindow *defw;
/* do we have an active window for this object? if so raise it */
for (i=0;i<g_list_length(window_list);i++) {
defw = g_list_nth_data(window_list, i);
if (!strcmp(defw->table_name, entry->object_name)) {
gdk_window_raise (defw->window->window);
return defw->window;
}
}
defw = g_malloc(sizeof(GMdbDefWindow));
strcpy(defw->table_name, entry->object_name);
defw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(defw->window), entry->object_name);
gtk_widget_set_usize(defw->window, 300,200);
gtk_widget_show(defw->window);
gtk_signal_connect (GTK_OBJECT (defw->window), "delete_event",
GTK_SIGNAL_FUNC (gmdb_table_def_close), defw);
scroll = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show (scroll);
gtk_container_add(GTK_CONTAINER(defw->window), scroll);
/* read table */
table = mdb_read_table(entry);
mdb_read_columns(table);
mdb_rewind_table(table);
clist = gtk_clist_new_with_titles(5, titles);
gtk_clist_set_column_width (GTK_CLIST(clist), 0, 20);
gtk_clist_set_column_width (GTK_CLIST(clist), 1, 35);
gtk_clist_set_column_width (GTK_CLIST(clist), 2, 80);
gtk_clist_set_column_width (GTK_CLIST(clist), 3, 60);
gtk_clist_set_column_width (GTK_CLIST(clist), 4, 30);
gtk_clist_set_column_width (GTK_CLIST(clist), 5, 30);
gtk_widget_show(clist);
gtk_container_add(GTK_CONTAINER(scroll),clist);
for (i=0;i<table->num_cols;i++) {
/* display column titles */
col=g_ptr_array_index(table->columns,i);
row[0] = (char *) malloc(MDB_BIND_SIZE);
memset(row[0],0,MDB_BIND_SIZE);
row[1] = (char *) malloc(MDB_BIND_SIZE);
memset(row[1],0,MDB_BIND_SIZE);
row[2] = (char *) malloc(MDB_BIND_SIZE);
memset(row[2],0,MDB_BIND_SIZE);
row[3] = (char *) malloc(MDB_BIND_SIZE);
memset(row[3],0,MDB_BIND_SIZE);
row[4] = (char *) malloc(MDB_BIND_SIZE);
memset(row[4],0,MDB_BIND_SIZE);
row[5] = (char *) malloc(MDB_BIND_SIZE);
memset(row[5],0,MDB_BIND_SIZE);
strcpy(row[0],"");
sprintf(row[1],"%d", col->col_num+1);
strcpy(row[2],col->name);
strcpy(row[3],mdb_access_types[col->col_type]);
sprintf(row[4],"%d",col->col_size);
if (col->is_fixed) {
strcpy(row[5],"No");
} else {
strcpy(row[5],"Yes");
}
gtk_clist_append(GTK_CLIST(clist), row);
}
pixmap = gdk_pixmap_colormap_create_from_xpm_d( NULL,
gtk_widget_get_colormap(app), &mask, NULL, pk_xpm);
mdb_read_indices(table);
for (i=0;i<table->num_idxs;i++) {
idx = g_ptr_array_index (table->indices, i);
if (idx->index_type==1) {
for (j=0;j<idx->num_keys;j++) {
gtk_clist_set_pixmap(GTK_CLIST(clist), idx->key_col_num[j]-1,0, pixmap, mask);
}
// } else {
//for (j=0;j<idx->num_keys;j++) {
//sprintf(tmpstr,"%s:%d",idx->name,j);
//gtk_clist_set_text(GTK_CLIST(clist), idx->key_col_num[j]-1,0, tmpstr);
//}
}
} /* for */
/* add this one to the window list */
window_list = g_list_append(window_list, defw);
return defw->window;
}

260
src/gmdb2/table_export.c Normal file
View File

@@ -0,0 +1,260 @@
#include "gmdb.h"
extern GtkWidget *app;
extern MdbHandle *mdb;
typedef struct GMdbTableExportDialog {
MdbCatalogEntry *entry;
GtkWidget *dialog;
GtkWidget *lineterm;
GtkWidget *colsep;
GtkWidget *quote;
GtkWidget *quotechar;
GtkWidget *headers;
GtkWidget *filesel;
} GMdbTableExportDialog;
GMdbTableExportDialog *export;
#define COMMA "Comma (,)"
#define TAB "Tab"
#define SPACE "Space"
#define COLON "Colon (:)"
#define SEMICOLON "Semicolon (;)"
#define PIPE "Pipe (|)"
#define LF "Unix (linefeed only)"
#define CR "Mac (carriage return only)"
#define CRLF "Windows (CR + LF)"
#define ALWAYS "Always"
#define NEVER "Never"
#define AUTOMAT "Automatic (where necessary)"
void
print_quote(FILE *outfile, int need_quote, char quotechar, char *colsep, char *str)
{
if (need_quote==1) {
fprintf(outfile, "%c", quotechar);
} else if (need_quote==-1) {
if (strstr(str,colsep)) {
fprintf(outfile, "%c", quotechar);
}
}
}
void
gmdb_export_file_cb(GtkWidget *selector, GMdbTableExportDialog *export)
{
gchar *file_path;
FILE *outfile;
gchar *bound_data[256];
MdbTableDef *table;
MdbColumn *col;
int i;
int need_headers = 0;
int need_quote = 0;
gchar delimiter[11];
gchar quotechar;
gchar lineterm[5];
gchar *str;
int rows=0;
char msg[100];
str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(export->colsep)->entry));
if (!strcmp(str,COMMA)) { strcpy(delimiter, ","); }
else if (!strcmp(str,TAB)) { strcpy(delimiter, "\t"); }
else if (!strcmp(str,SPACE)) { strcpy(delimiter, " "); }
else if (!strcmp(str,COLON)) { strcpy(delimiter, ":"); }
else if (!strcmp(str,SEMICOLON)) { strcpy(delimiter, ";"); }
else if (!strcmp(str,PIPE)) { strcpy(delimiter, "|"); }
else {
strncpy(delimiter,str, 10);
delimiter[10]='\0';
}
str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(export->lineterm)->entry));
if (!strcmp(str,LF)) { strcpy(lineterm, "\n"); }
else if (!strcmp(str,CR)) { strcpy(lineterm, "\r"); }
else if (!strcmp(str,CRLF)) { strcpy(lineterm, "\r\n"); }
str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(export->quote)->entry));
if (!strcmp(str,ALWAYS)) { need_quote = 1; }
else if (!strcmp(str,NEVER)) { need_quote = 0; }
else if (!strcmp(str,AUTOMAT)) { need_quote = -1; }
str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(export->quotechar)->entry));
quotechar = str[0];
/* headers */
str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(export->headers)->entry));
if (str && str[0]=='Y') need_headers = 1;
file_path = gtk_file_selection_get_filename (GTK_FILE_SELECTION(export->filesel));
// printf("file path %s\n",file_path);
if ((outfile=fopen(file_path, "w"))==NULL) {
gmdb_info_msg("Unable to Open File!");
return;
}
/* read table */
table = mdb_read_table(export->entry);
mdb_read_columns(table);
mdb_rewind_table(table);
for (i=0;i<table->num_cols;i++) {
/* bind columns */
bound_data[i] = (char *) malloc(MDB_BIND_SIZE);
bound_data[i][0] = '\0';
mdb_bind_column(table, i+1, bound_data[i]);
/* display column titles */
col=g_ptr_array_index(table->columns,i);
if (need_headers) {
if (i>0) fprintf(outfile,delimiter);
print_quote(outfile, need_quote, quotechar, delimiter, col->name);
fprintf(outfile,"%s", col->name);
print_quote(outfile, need_quote, quotechar, delimiter, col->name);
}
}
if (need_headers) fprintf(outfile,lineterm);
/* fetch those rows! */
while(mdb_fetch_row(table)) {
for (i=0;i<table->num_cols;i++) {
if (i>0) fprintf(outfile,delimiter);
print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]);
fprintf(outfile,"%s", bound_data[i]);
print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]);
}
fprintf(outfile,lineterm);
rows++;
}
/* free the memory used to bind */
for (i=0;i<table->num_cols;i++) {
free(bound_data[i]);
}
fclose(outfile);
gtk_widget_destroy(export->dialog);
sprintf(msg,"%d Rows exported successfully.\n", rows);
gmdb_info_msg(msg);
}
void
gmdb_export_button_cb(GtkWidget *w, GMdbTableExportDialog *export)
{
/* just print a string so that we know we got there */
export->filesel = gtk_file_selection_new("Please choose a filename.");
gtk_signal_connect (
GTK_OBJECT (GTK_FILE_SELECTION(export->filesel)->ok_button),
"clicked", GTK_SIGNAL_FUNC (gmdb_export_file_cb), export);
gtk_signal_connect_object ( GTK_OBJECT (
GTK_FILE_SELECTION(export->filesel)->ok_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) export->filesel);
gtk_signal_connect_object (
GTK_OBJECT (GTK_FILE_SELECTION(export->filesel)->cancel_button),
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) export->filesel);
gtk_widget_show (export->filesel);
}
GtkWidget *
gmdb_export_add_combo(GtkWidget *table, int row, gchar *text, GList *strings)
{
GtkWidget *combo;
GtkWidget *label;
label = gtk_label_new(text);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 0);
gtk_widget_show(label);
combo = gtk_combo_new();
gtk_combo_set_popdown_strings(GTK_COMBO(combo), strings);
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 0);
gtk_widget_show(combo);
return combo;
}
void gmdb_table_export(MdbCatalogEntry *entry) {
GtkWidget *export_button;
GtkWidget *close_button;
GList *glist = NULL;
GtkWidget *table;
export = g_malloc(sizeof(GMdbTableExportDialog));
export->entry = entry;
/* Create the widgets */
export->dialog = gtk_dialog_new();
gtk_widget_set_uposition(export->dialog, 300, 300);
table = gtk_table_new(3,2,FALSE);
gtk_widget_show(table);
glist = g_list_append(glist, LF);
glist = g_list_append(glist, CR);
glist = g_list_append(glist, CRLF);
export->lineterm = gmdb_export_add_combo(table, 0, "Line Terminator:",glist);
g_list_free(glist);
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(export->lineterm)->entry), FALSE);
glist = NULL;
glist = g_list_append(glist, COMMA);
glist = g_list_append(glist, TAB);
glist = g_list_append(glist, SPACE);
glist = g_list_append(glist, COLON);
glist = g_list_append(glist, SEMICOLON);
glist = g_list_append(glist, PIPE);
export->colsep = gmdb_export_add_combo(table, 1, "Column Separator:",glist);
g_list_free(glist);
glist = NULL;
glist = g_list_append(glist, ALWAYS);
glist = g_list_append(glist, NEVER);
glist = g_list_append(glist, AUTOMAT);
export->quote = gmdb_export_add_combo(table, 2, "Quotes:",glist);
g_list_free(glist);
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(export->quote)->entry), FALSE);
glist = NULL;
glist = g_list_append(glist, "\"");
glist = g_list_append(glist, "'");
glist = g_list_append(glist, "`");
export->quotechar = gmdb_export_add_combo(table, 3, "Quote Character:",glist);
g_list_free(glist);
glist = NULL;
glist = g_list_append(glist, "Yes");
glist = g_list_append(glist, "No");
export->headers = gmdb_export_add_combo(table, 4, "Include Headers:",glist);
g_list_free(glist);
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(export->headers)->entry), FALSE);
export_button = gtk_button_new_with_label("Export");
gtk_signal_connect ( GTK_OBJECT (export_button),
"clicked", GTK_SIGNAL_FUNC (gmdb_export_button_cb), export);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(export->dialog)->action_area),
export_button);
close_button = gtk_button_new_with_label("Cancel");
gtk_signal_connect_object (GTK_OBJECT (close_button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT(export->dialog));
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(export->dialog)->action_area),
close_button);
/* Add the table, and show everything we've added to the dialog. */
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(export->dialog)->vbox), table);
gtk_widget_show_all (export->dialog);
}

24
src/gmdb2/util.c Normal file
View File

@@ -0,0 +1,24 @@
#include "gmdb.h"
void gmdb_info_msg(gchar *message) {
GtkWidget *dialog, *label, *okay_button;
/* Create the widgets */
dialog = gtk_dialog_new();
gtk_widget_set_uposition(dialog, 300, 300);
label = gtk_label_new (message);
gtk_widget_set_usize(label, 250, 100);
okay_button = gtk_button_new_with_label("Okay");
/* Ensure that the dialog box is destroyed when the user clicks ok. */
gtk_signal_connect_object (GTK_OBJECT (okay_button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy), dialog);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
okay_button);
/* Add the label, and show everything we've added to the dialog. */
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label);
gtk_widget_show_all (dialog);
}

View File

@@ -1,4 +1,4 @@
lib_LTLIBRARIES = libmdb.la
libmdb_la_SOURCES= catalog.c mem.c file.c kkd.c table.c data.c dump.c backend.c money.c sargs.c index.c like.c
INCLUDES = -I$(top_srcdir)/include `glib-config --cflags`
LIBS = `glib-config --libs`
libmdb_la_SOURCES= catalog.c mem.c file.c kkd.c table.c data.c dump.c backend.c money.c sargs.c index.c like.c write.c
INCLUDES = -I$(top_srcdir)/include $(GLIB_CFLAGS)
LIBS = $(GLIB_LIBS)

View File

@@ -79,13 +79,13 @@ int type;
while (mdb_fetch_row(table)) {
type = atoi(tobjtype);
if (type == objtype) {
if (objtype==MDB_ANY || type == objtype) {
// fprintf(stdout, "parentid: %10ld objtype: %-3d objname: %s\n",
// (atol(parentid) & 0x00FFFFFF), type, objname);
memset(&entry,0,sizeof(entry));
entry.mdb = mdb;
strcpy(entry.object_name, objname);
entry.object_type = type;
entry.object_type = (type & 0x7F);
entry.table_pg = atol(parentid) & 0x00FFFFFF;
mdb->num_catalog++;
data = g_memdup(&entry,sizeof(MdbCatalogEntry));
@@ -124,7 +124,7 @@ fprintf(stdout,"\n");
*/
memset(entry, '\0', sizeof(MdbCatalogEntry));
entry->object_type = mdb->pg_buf[offset+0x09];
entry->object_type = (mdb->pg_buf[offset+0x09] & 0x7F);
j=0;
entry->mdb = mdb;
entry->table_pg = mdb_get_int16(mdb,offset+1);
@@ -221,7 +221,7 @@ 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 (obj_type==-1 || entry->object_type==obj_type) {
if (obj_type==MDB_ANY || 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,

View File

@@ -21,8 +21,6 @@
#include "time.h"
#include "math.h"
//#define FAST_READ 1
char *mdb_money_to_string(MdbHandle *mdb, int start, char *s);
static int _mdb_attempt_bind(MdbHandle *mdb,
MdbColumn *col, unsigned char isnull, int offset, int len);
@@ -77,7 +75,7 @@ int row_end;
return row_end;
#endif
}
static int mdb_is_null(unsigned char *null_mask, int col_num)
int mdb_is_null(unsigned char *null_mask, int col_num)
{
int byte_num = (col_num - 1) / 8;
int bit_num = (col_num - 1) % 8;
@@ -99,6 +97,24 @@ static int mdb_xfer_bound_bool(MdbHandle *mdb, MdbColumn *col, int value)
return 0;
}
static int mdb_xfer_bound_ole(MdbHandle *mdb, int start, MdbColumn *col, int len)
{
int ret;
if (len) {
col->cur_value_start = start;
col->cur_value_len = len;
} else {
col->cur_value_start = 0;
col->cur_value_len = 0;
}
if (col->bind_ptr || col->len_ptr) {
ret = mdb_copy_ole(mdb, col->bind_ptr, start, len);
}
if (col->len_ptr) {
*col->len_ptr = ret;
}
return ret;
}
static int mdb_xfer_bound_data(MdbHandle *mdb, int start, MdbColumn *col, int len)
{
int ret;
@@ -329,6 +345,8 @@ static int _mdb_attempt_bind(MdbHandle *mdb,
{
if (col->col_type == MDB_BOOL) {
mdb_xfer_bound_bool(mdb, col, isnull);
} else if (col->col_type == MDB_OLE) {
mdb_xfer_bound_ole(mdb, offset, col, len);
} else if (isnull) {
mdb_xfer_bound_data(mdb, 0, col, 0);
} else {
@@ -339,12 +357,11 @@ static int _mdb_attempt_bind(MdbHandle *mdb,
}
return 1;
}
int mdb_read_next_dpg(MdbTableDef *table)
int
mdb_read_next_dpg_by_map0(MdbTableDef *table)
{
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
#if FAST_READ
int pgnum, i, bitn;
pgnum = _mdb_get_int32(table->usage_map,1);
@@ -364,14 +381,71 @@ int pgnum, i, bitn;
}
/* didn't find anything */
return 0;
#else
}
int
mdb_read_next_dpg_by_map1(MdbTableDef *table)
{
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
guint32 pgnum, i, j, bitn, map_pg;
unsigned char map_byte;
pgnum = 0;
//printf("map size %ld\n", table->map_sz);
for (i=1;i<table->map_sz-1;i+=4) {
map_pg = _mdb_get_int32(table->usage_map, i);
//printf("loop %d pg %ld %02x%02x%02x%02x\n",i, map_pg,table->usage_map[i],table->usage_map[i+1],table->usage_map[i+2],table->usage_map[i+3]);
if (!map_pg) continue;
if(mdb_read_alt_pg(mdb, map_pg) != mdb->pg_size) {
fprintf(stderr, "Oops! didn't get a full page at %d\n", map_pg);
exit(1);
}
//printf("reading page %ld\n",map_pg);
for (j=4;j<mdb->pg_size;j++) {
for (bitn=0;bitn<8;bitn++) {
if (mdb->alt_pg_buf[j] & 1 << bitn && pgnum > table->cur_phys_pg) {
table->cur_phys_pg = pgnum;
if (!mdb_read_pg(mdb, pgnum)) {
return 0;
} else {
//printf("page found at %04x %d\n",pgnum, pgnum);
return pgnum;
}
}
pgnum++;
}
}
}
/* didn't find anything */
//printf("returning 0\n");
return 0;
}
int
mdb_read_next_dpg(MdbTableDef *table)
{
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
int map_type;
#ifndef SLOW_READ
map_type = table->usage_map[0];
if (map_type==0) {
return mdb_read_next_dpg_by_map0(table);
} else if (map_type==1) {
return mdb_read_next_dpg_by_map1(table);
} else {
fprintf(stderr,"Warning: unrecognized usage map type: %d, defaulting to brute force read\n",table->usage_map[0]);
}
#endif
/* can't do a fast read, go back to the old way */
do {
if (!mdb_read_pg(mdb, table->cur_phys_pg++))
return 0;
} while (mdb->pg_buf[0]!=0x01 || mdb_get_int32(mdb, 4)!=entry->table_pg);
/* fprintf(stderr,"returning new page %ld\n", table->cur_phys_pg); */
return table->cur_phys_pg;
#endif
}
int mdb_rewind_table(MdbTableDef *table)
{
@@ -453,6 +527,99 @@ int i;
return text;
}
int mdb_copy_ole(MdbHandle *mdb, char *dest, int start, int size)
{
guint16 ole_len;
guint16 ole_flags;
guint16 row_start, row_stop;
guint8 ole_row;
guint32 lval_pg;
guint16 len, cur;
if (size<MDB_MEMO_OVERHEAD) {
return 0;
}
ole_len = mdb_get_int16(mdb, start);
ole_flags = mdb_get_int16(mdb, start+2);
if (ole_flags == 0x8000) {
len = size - MDB_MEMO_OVERHEAD;
/* inline ole field */
if (dest) memcpy(dest, &mdb->pg_buf[start + MDB_MEMO_OVERHEAD],
size - MDB_MEMO_OVERHEAD);
return len;
} else if (ole_flags == 0x4000) {
/* The 16 bit integer at offset 0 is the length of the memo field.
* The 24 bit integer at offset 5 is the page it is stored on.
*/
ole_row = mdb->pg_buf[start+4];
lval_pg = mdb_get_int24(mdb, start+5);
#if MDB_DEBUG
printf("Reading LVAL page %06x\n", lval_pg);
#endif
if(mdb_read_alt_pg(mdb, lval_pg) != mdb->pg_size) {
/* Failed to read */
return 0;
}
/* swap the alt and regular page buffers, so we can call get_int16 */
mdb_swap_pgbuf(mdb);
if (ole_row) {
row_stop = mdb_get_int16(mdb, 10 + (ole_row - 1) * 2) & 0x0FFF;
} else {
row_stop = mdb->pg_size - 1;
}
row_start = mdb_get_int16(mdb, 10 + ole_row * 2);
#if MDB_DEBUG
printf("row num %d row start %d row stop %d\n", ole_row, row_start, row_stop);
#endif
len = row_stop - row_start;
if (dest) memcpy(dest, &mdb->pg_buf[row_start], len);
/* make sure to swap page back */
mdb_swap_pgbuf(mdb);
return len;
} else if (ole_flags == 0x0000) {
ole_row = mdb->pg_buf[start+4];
lval_pg = mdb_get_int24(mdb, start+5);
#if MDB_DEBUG
printf("Reading LVAL page %06x\n", lval_pg);
#endif
/* swap the alt and regular page buffers, so we can call get_int16 */
mdb_swap_pgbuf(mdb);
cur=0;
do {
if(mdb_read_pg(mdb, lval_pg) != mdb->pg_size) {
/* Failed to read */
return 0;
}
if (ole_row) {
row_stop = mdb_get_int16(mdb, 10 + (ole_row - 1) * 2) & 0x0FFF;
} else {
row_stop = mdb->pg_size - 1;
}
row_start = mdb_get_int16(mdb, 10 + ole_row * 2);
#if MDB_DEBUG
printf("row num %d row start %d row stop %d\n", ole_row, row_start, row_stop);
#endif
len = row_stop - row_start;
if (dest)
memcpy(&dest[cur], &mdb->pg_buf[row_start+4],
len - 4);
cur += len - 4;
/* find next lval page */
ole_row = mdb->pg_buf[row_start];
lval_pg = mdb_get_int24(mdb, row_start+1);
} while (lval_pg);
/* make sure to swap page back */
mdb_swap_pgbuf(mdb);
return cur;
} else {
fprintf(stderr,"Unhandled ole field flags = %04x\n", ole_flags);
return 0;
}
}
static char *mdb_memo_to_string(MdbHandle *mdb, int start, int size)
{
guint16 memo_len;

View File

@@ -19,6 +19,8 @@
#include "mdbtools.h"
#define MDB_DEBUG_USAGE 0
static gint mdb_col_comparer(MdbColumn *a, MdbColumn *b)
{
if (a->col_num > b->col_num)
@@ -61,13 +63,17 @@ int rownum, row_start, row_end;
mdb_swap_pgbuf(mdb);
row_start = mdb_get_int16(mdb, (mdb->row_count_offset + 2) + (rownum*2));
row_end = mdb_find_end_of_row(mdb, rownum);
table->map_sz = row_end - row_start;
table->map_sz = row_end - row_start + 1;
table->usage_map = malloc(table->map_sz);
memcpy(table->usage_map, &mdb->pg_buf[row_start], table->map_sz);
#if MDB_DEBUG_USAGE
buffer_dump(mdb->pg_buf, row_start, row_end);
#endif
/* swap back */
mdb_swap_pgbuf(mdb);
#if MDB_DEBUG_USAGE
printf ("usage map found on page %ld start %d end %d\n", mdb_get_int24(mdb, mdb->tab_usage_map_offset + 1), row_start, row_end);
#endif
table->first_data_pg = mdb_get_int16(mdb, mdb->tab_first_dpg_offset);

152
src/libmdb/write.c Normal file
View File

@@ -0,0 +1,152 @@
/* MDB Tools - A library for reading MS Access database file
* 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.
*/
#include "mdbtools.h"
#include "time.h"
#include "math.h"
#define MDB_DEBUG_WRITE 1
typedef struct {
void *value;
int siz;
unsigned char is_null;
unsigned char is_fixed;
} MdbField;
static int
mdb_is_col_indexed(MdbTableDef *table, int colnum)
{
int i, j;
MdbIndex *idx;
for (i=0;i<table->num_idxs;i++) {
idx = g_ptr_array_index (table->indices, i);
for (j=0;j<idx->num_keys;j++) {
if (idx->key_col_num[j]==colnum) return 1;
}
}
return 0;
}
static int mdb_is_null(unsigned char *null_mask, int col_num)
{
int byte_num = (col_num - 1) / 8;
int bit_num = (col_num - 1) % 8;
if ((1 << bit_num) & null_mask[byte_num]) {
return 0;
} else {
return 1;
}
}
int
mdb_crack_row(MdbTableDef *table, int row_start, int row_end, MdbField *fields)
{
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
MdbColumn *col;
int var_cols, fixed_cols, num_cols, i;
unsigned char null_mask[33]; /* 256 columns max / 8 bits per byte */
int bitmask_sz;
printf("field 0 %s\n", fields[0].value);
if (mdb->jet_version==MDB_VER_JET4) {
num_cols = mdb_get_int16(mdb, row_start);
} else {
num_cols = mdb->pg_buf[row_start];
}
var_cols = 0; /* mdb->pg_buf[row_end-1]; */
fixed_cols = 0; /* num_cols - var_cols; */
for (i = 0; i < table->num_cols; i++) {
col = g_ptr_array_index (table->columns, i);
if (mdb_is_fixed_col(col))
fixed_cols++;
else
var_cols++;
}
bitmask_sz = (num_cols - 1) / 8 + 1;
for (i=0;i<bitmask_sz;i++) {
null_mask[i]=mdb->pg_buf[row_end - bitmask_sz + i + 1];
}
return num_cols;
}
int
mdb_pack_row(MdbTableDef *table, unsigned char *row_buffer, MdbField *fields)
{
}
int
mdb_pg_get_freespace(MdbHandle *mdb)
{
int rows, free_start, free_end;
rows = mdb_get_int16(mdb, mdb->row_count_offset);
free_start = mdb->row_count_offset + 2 + (rows * 2);
free_end = mdb_get_int16(mdb, (mdb->row_count_offset + rows * 2)) -1;
#if MDB_DEBUG_WRITE
printf("free space left on page = %d\n", free_end - free_start);
#endif
return (free_end - free_start);
}
int
mdb_update_row(MdbTableDef *table)
{
int row_start, row_end;
int i;
MdbColumn *col;
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
MdbField fields[256];
unsigned char row_buffer[4096];
int old_row_size, new_row_size, delta, num_fields;
fields[0].value = "hello";
row_start = mdb_get_int16(mdb, (mdb->row_count_offset + 2) + (table->cur_row*2));
row_end = mdb_find_end_of_row(mdb, table->cur_row);
old_row_size = row_end - row_start;
row_start &= 0x0FFF; /* remove flags */
for (i=0;i<table->num_cols;i++) {
col = g_ptr_array_index(table->columns,i);
if (col->bind_ptr && mdb_is_col_indexed(table,i)) {
fprintf(stderr, "Attempting to update column that is part of an index\n");
return 0;
}
}
num_fields = mdb_crack_row(table, row_start, row_end, &fields);
#if MDB_DEBUG_WRITE
for (i=0;i<num_fields;i++) {
}
#endif
new_row_size = mdb_pack_row(table, row_buffer, &fields);
delta = new_row_size - old_row_size;
if ((mdb_pg_get_freespace(mdb) - delta) < 0) {
fprintf(stderr, "No space left on this page, update will not occur\n");
return 0;
}
}

View File

@@ -1,7 +1,7 @@
lib_LTLIBRARIES = libmdbsql.la
libmdbsql_la_SOURCES= mdbsql.c parser.y lexer.l
INCLUDES = -I$(top_srcdir)/include `glib-config --cflags`
LIBS = `glib-config --libs`
INCLUDES = -I$(top_srcdir)/include $(GLIB_CFLAGS)
LIBS = $(GLIB_LIBS)
LDADD = ../libmdb/libmdb.la
YACC = bison -y -d

View File

@@ -1,7 +1,7 @@
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
* $Header: /Users/brian/cvs/mdbtools/mdbtools/src/sql/Attic/lexer.c,v 1.4 2002/01/24 12:34:13 brianb Exp $
* $Header: /Users/brian/cvs/mdbtools/mdbtools/src/sql/Attic/lexer.c,v 1.5 2002/12/27 15:09:02 brianb Exp $
*/
#define FLEX_SCANNER
@@ -282,19 +282,19 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*yy_cp = '\0'; \
yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 21
#define YY_END_OF_BUFFER 22
static yyconst short int yy_accept[85] =
#define YY_NUM_RULES 22
#define YY_END_OF_BUFFER 23
static yyconst short int yy_accept[89] =
{ 0,
18, 18, 22, 20, 15, 21, 20, 19, 20, 18,
20, 20, 16, 16, 16, 16, 16, 16, 16, 16,
16, 20, 0, 17, 0, 19, 0, 19, 19, 18,
12, 13, 16, 16, 16, 16, 16, 16, 16, 16,
16, 5, 16, 0, 18, 18, 8, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 2,
14, 6, 16, 16, 16, 16, 16, 16, 16, 10,
7, 16, 16, 16, 1, 9, 3, 16, 16, 11,
16, 16, 4, 0
19, 19, 23, 21, 15, 22, 21, 21, 20, 21,
19, 21, 21, 17, 17, 17, 17, 17, 17, 17,
17, 17, 21, 0, 0, 18, 0, 20, 0, 20,
20, 19, 12, 13, 17, 17, 17, 17, 17, 17,
17, 17, 17, 5, 17, 0, 16, 0, 19, 19,
8, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 2, 14, 6, 17, 17, 17, 17,
17, 17, 17, 10, 7, 17, 17, 17, 1, 9,
3, 17, 17, 11, 17, 17, 4, 0
} ;
static yyconst int yy_ec[256] =
@@ -302,17 +302,17 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 4, 5,
5, 1, 6, 1, 7, 8, 9, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 1, 1, 11,
12, 13, 1, 1, 14, 14, 14, 14, 15, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
15, 14, 14, 14, 14, 14, 16, 17, 18, 19,
1, 4, 1, 5, 1, 1, 1, 1, 6, 7,
7, 1, 8, 1, 9, 10, 11, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 1, 1, 13,
14, 15, 1, 1, 16, 16, 16, 16, 17, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
17, 16, 16, 16, 16, 16, 18, 19, 20, 21,
20, 21, 14, 22, 23, 14, 24, 25, 26, 27,
28, 14, 14, 29, 30, 31, 14, 14, 32, 14,
14, 14, 1, 1, 1, 33, 1, 1, 1, 1,
22, 23, 16, 24, 25, 16, 26, 27, 28, 29,
30, 16, 16, 31, 32, 33, 16, 16, 34, 16,
16, 16, 1, 1, 1, 35, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -329,116 +329,122 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst int yy_meta[34] =
static yyconst int yy_meta[36] =
{ 0,
1, 1, 2, 1, 3, 3, 1, 4, 4, 4,
1, 1, 1, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1
1, 1, 2, 3, 3, 1, 4, 4, 1, 5,
5, 6, 1, 1, 1, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 1
} ;
static yyconst short int yy_base[88] =
static yyconst short int yy_base[94] =
{ 0,
0, 0, 119, 279, 279, 279, 111, 29, 31, 45,
83, 75, 33, 37, 39, 48, 50, 52, 54, 57,
61, 68, 78, 73, 74, 78, 81, 86, 92, 0,
279, 279, 95, 97, 100, 102, 105, 109, 112, 114,
116, 120, 132, 62, 42, 91, 122, 135, 137, 139,
141, 145, 150, 152, 155, 160, 162, 165, 167, 169,
175, 177, 179, 182, 184, 190, 192, 197, 201, 203,
205, 208, 210, 213, 217, 220, 222, 226, 228, 233,
235, 241, 243, 279, 272, 274, 39
0, 0, 129, 295, 295, 295, 0, 116, 29, 31,
37, 104, 84, 42, 44, 46, 49, 51, 53, 55,
57, 59, 69, 85, 80, 74, 76, 79, 82, 87,
93, 0, 295, 295, 96, 98, 101, 103, 106, 110,
113, 115, 117, 121, 133, 67, 295, 46, 38, 92,
123, 136, 138, 140, 142, 146, 151, 153, 156, 161,
163, 166, 168, 170, 176, 178, 180, 183, 185, 191,
193, 198, 202, 204, 206, 209, 211, 214, 218, 221,
223, 227, 229, 234, 236, 242, 244, 295, 36, 275,
279, 282, 287
} ;
static yyconst short int yy_def[88] =
static yyconst short int yy_def[94] =
{ 0,
84, 1, 84, 84, 84, 84, 85, 86, 86, 86,
84, 84, 87, 87, 87, 87, 87, 87, 87, 87,
87, 10, 85, 85, 84, 10, 10, 10, 10, 10,
84, 84, 87, 87, 87, 87, 87, 87, 87, 87,
87, 87, 87, 84, 84, 10, 87, 87, 87, 87,
87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
87, 87, 87, 0, 84, 84, 84
88, 1, 88, 88, 88, 88, 89, 90, 91, 91,
91, 88, 88, 92, 92, 92, 92, 92, 92, 92,
92, 92, 11, 93, 90, 90, 88, 11, 11, 11,
11, 11, 88, 88, 92, 92, 92, 92, 92, 92,
92, 92, 92, 92, 92, 93, 88, 88, 88, 11,
92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
92, 92, 92, 92, 92, 92, 92, 0, 88, 88,
88, 88, 88
} ;
static yyconst short int yy_nxt[313] =
static yyconst short int yy_nxt[331] =
{ 0,
4, 5, 6, 7, 4, 4, 4, 8, 9, 10,
11, 4, 12, 13, 13, 14, 13, 15, 16, 13,
17, 13, 13, 13, 18, 13, 13, 13, 13, 19,
20, 21, 22, 25, 25, 84, 84, 27, 28, 84,
26, 27, 33, 28, 26, 27, 26, 27, 28, 84,
84, 45, 29, 27, 30, 26, 27, 26, 27, 26,
27, 26, 27, 34, 26, 27, 35, 36, 26, 27,
37, 45, 41, 40, 39, 26, 24, 26, 38, 44,
44, 24, 43, 45, 42, 26, 32, 26, 26, 84,
26, 44, 44, 26, 31, 46, 25, 25, 26, 26,
4, 5, 6, 5, 7, 8, 4, 4, 4, 9,
10, 11, 12, 4, 13, 14, 14, 15, 14, 16,
17, 14, 18, 14, 14, 14, 19, 14, 14, 14,
14, 20, 21, 22, 23, 27, 27, 88, 88, 29,
30, 88, 24, 88, 88, 30, 31, 29, 32, 49,
30, 28, 29, 28, 29, 28, 29, 49, 28, 29,
28, 29, 28, 29, 28, 29, 28, 29, 28, 29,
38, 47, 36, 39, 43, 37, 42, 41, 28, 26,
28, 40, 45, 48, 48, 26, 44, 49, 28, 47,
28, 28, 88, 28, 48, 48, 28, 34, 50, 27,
46, 28, 26, 27, 26, 27, 28, 26, 27, 26,
27, 28, 26, 27, 24, 47, 26, 27, 84, 26,
27, 26, 27, 26, 27, 84, 48, 26, 27, 26,
27, 49, 55, 84, 50, 52, 51, 84, 54, 26,
27, 53, 26, 27, 26, 27, 26, 27, 26, 27,
84, 56, 26, 27, 58, 84, 59, 26, 27, 26,
27, 57, 26, 27, 61, 84, 60, 26, 27, 26,
27, 63, 26, 27, 26, 27, 26, 27, 84, 64,
62, 66, 26, 27, 26, 27, 26, 27, 65, 26,
27, 26, 27, 67, 68, 84, 69, 26, 27, 26,
27, 28, 28, 50, 30, 28, 29, 28, 29, 30,
28, 29, 28, 29, 30, 28, 29, 33, 51, 28,
29, 26, 28, 29, 28, 29, 28, 29, 88, 52,
28, 29, 28, 29, 53, 59, 88, 54, 56, 55,
88, 58, 28, 29, 57, 28, 29, 28, 29, 28,
29, 28, 29, 88, 60, 28, 29, 62, 88, 63,
28, 29, 28, 29, 61, 28, 29, 65, 88, 64,
28, 29, 28, 29, 67, 28, 29, 28, 29, 28,
29, 88, 68, 66, 70, 28, 29, 28, 29, 28,
29, 69, 28, 29, 28, 29, 71, 72, 88, 73,
27, 70, 84, 71, 26, 27, 84, 72, 26, 27,
26, 27, 26, 27, 73, 26, 27, 26, 27, 84,
26, 27, 84, 74, 26, 27, 78, 26, 27, 26,
27, 75, 76, 26, 27, 26, 27, 84, 77, 79,
26, 27, 26, 27, 84, 80, 84, 81, 26, 27,
26, 27, 82, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 83, 23, 84, 23, 23, 26, 26, 3, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
28, 29, 28, 29, 74, 88, 75, 28, 29, 88,
76, 28, 29, 28, 29, 28, 29, 77, 28, 29,
28, 29, 88, 28, 29, 88, 78, 28, 29, 82,
28, 29, 28, 29, 79, 80, 28, 29, 28, 29,
88, 81, 83, 28, 29, 28, 29, 88, 84, 88,
85, 28, 29, 28, 29, 86, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 87, 25, 88, 25, 25, 25,
25, 25, 28, 28, 28, 28, 35, 35, 35, 46,
88, 88, 46, 46, 3, 88, 88, 88, 88, 88,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88
} ;
static yyconst short int yy_chk[313] =
static yyconst short int yy_chk[331] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 8, 8, 9, 9, 8, 8, 9,
13, 13, 87, 8, 14, 14, 15, 15, 8, 10,
10, 45, 10, 10, 10, 16, 16, 17, 17, 18,
18, 19, 19, 14, 20, 20, 15, 16, 21, 21,
16, 44, 20, 19, 18, 22, 24, 22, 17, 25,
25, 23, 21, 25, 20, 26, 12, 26, 27, 27,
27, 28, 28, 28, 11, 28, 29, 29, 46, 29,
1, 1, 1, 1, 1, 9, 9, 10, 10, 9,
9, 10, 89, 11, 11, 9, 11, 11, 11, 49,
9, 14, 14, 15, 15, 16, 16, 48, 17, 17,
18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
17, 46, 15, 17, 21, 16, 20, 19, 23, 26,
23, 18, 22, 27, 27, 25, 21, 27, 28, 24,
28, 29, 29, 29, 30, 30, 30, 13, 30, 31,
46, 29, 33, 33, 34, 34, 29, 35, 35, 36,
36, 29, 37, 37, 7, 34, 38, 38, 3, 39,
39, 40, 40, 41, 41, 0, 35, 42, 42, 47,
47, 36, 41, 0, 37, 39, 38, 0, 40, 43,
43, 39, 48, 48, 49, 49, 50, 50, 51, 51,
0, 43, 52, 52, 49, 0, 50, 53, 53, 54,
54, 48, 55, 55, 52, 0, 51, 56, 56, 57,
57, 54, 58, 58, 59, 59, 60, 60, 0, 55,
53, 57, 61, 61, 62, 62, 63, 63, 56, 64,
64, 65, 65, 58, 59, 0, 63, 66, 66, 67,
31, 50, 31, 50, 31, 35, 35, 36, 36, 31,
37, 37, 38, 38, 31, 39, 39, 12, 36, 40,
40, 8, 41, 41, 42, 42, 43, 43, 3, 37,
44, 44, 51, 51, 38, 43, 0, 39, 41, 40,
0, 42, 45, 45, 41, 52, 52, 53, 53, 54,
54, 55, 55, 0, 45, 56, 56, 53, 0, 54,
57, 57, 58, 58, 52, 59, 59, 56, 0, 55,
60, 60, 61, 61, 58, 62, 62, 63, 63, 64,
64, 0, 59, 57, 61, 65, 65, 66, 66, 67,
67, 60, 68, 68, 69, 69, 62, 63, 0, 67,
67, 64, 0, 65, 68, 68, 0, 66, 69, 69,
70, 70, 71, 71, 67, 72, 72, 73, 73, 0,
74, 74, 0, 68, 75, 75, 73, 76, 76, 77,
77, 69, 70, 78, 78, 79, 79, 0, 72, 74,
80, 80, 81, 81, 0, 78, 0, 79, 82, 82,
83, 83, 81, 0, 0, 0, 0, 0, 0, 0,
70, 70, 71, 71, 68, 0, 69, 72, 72, 0,
70, 73, 73, 74, 74, 75, 75, 71, 76, 76,
77, 77, 0, 78, 78, 0, 72, 79, 79, 77,
80, 80, 81, 81, 73, 74, 82, 82, 83, 83,
0, 76, 78, 84, 84, 85, 85, 0, 82, 0,
83, 86, 86, 87, 87, 85, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 82, 85, 0, 85, 85, 86, 86, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
0, 0, 0, 0, 86, 90, 0, 90, 90, 90,
90, 90, 91, 91, 91, 91, 92, 92, 92, 93,
0, 0, 93, 93, 88, 88, 88, 88, 88, 88,
84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88
} ;
static yy_state_type yy_last_accepting_state;
@@ -477,7 +483,7 @@ char *yytext;
#include "mdbsql.h"
#include "parser.h"
#line 481 "lex.yy.c"
#line 487 "lexer.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -630,7 +636,7 @@ YY_DECL
#line 26 "lexer.l"
#line 634 "lex.yy.c"
#line 640 "lexer.c"
if ( yy_init )
{
@@ -681,13 +687,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 85 )
if ( yy_current_state >= 89 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 279 );
while ( yy_base[yy_current_state] != 295 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -791,36 +797,45 @@ YY_RULE_SETUP
case 16:
YY_RULE_SETUP
#line 42 "lexer.l"
{ yylval.name = strdup(yytext); return NAME; }
{
yylval.name = strdup(&yytext[1]);
yylval.name[strlen(yylval.name)-1]='\0';
return IDENT;
}
YY_BREAK
case 17:
YY_RULE_SETUP
#line 43 "lexer.l"
{ yylval.name = strdup(yytext); return STRING; }
#line 47 "lexer.l"
{ yylval.name = strdup(yytext); return NAME; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 44 "lexer.l"
#line 49 "lexer.l"
{ yylval.name = strdup(yytext); return STRING; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 50 "lexer.l"
{
yylval.name = strdup(yytext); return NUMBER;
}
YY_BREAK
case 19:
YY_RULE_SETUP
#line 47 "lexer.l"
{ yylval.name = strdup(yytext); return PATH; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 48 "lexer.l"
{ return yytext[0]; }
#line 53 "lexer.l"
{ yylval.name = strdup(yytext); return PATH; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 49 "lexer.l"
#line 54 "lexer.l"
{ return yytext[0]; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 55 "lexer.l"
ECHO;
YY_BREAK
#line 824 "lex.yy.c"
#line 839 "lexer.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -1112,7 +1127,7 @@ static yy_state_type yy_get_previous_state()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 85 )
if ( yy_current_state >= 89 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1147,11 +1162,11 @@ yy_state_type yy_current_state;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 85 )
if ( yy_current_state >= 89 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 84);
yy_is_jam = (yy_current_state == 88);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1701,7 +1716,7 @@ int main()
return 0;
}
#endif
#line 49 "lexer.l"
#line 55 "lexer.l"
int yywrap()

View File

@@ -39,7 +39,13 @@ describe { return DESCRIBE; }
(>=) { return GTEQ; }
like { return LIKE; }
[ \t\r] ;
\"[A-z][A-z0-9 ]*\" {
yylval.name = strdup(&yytext[1]);
yylval.name[strlen(yylval.name)-1]='\0';
return IDENT;
}
[A-z][A-z0-9]* { yylval.name = strdup(yytext); return NAME; }
'.*' { yylval.name = strdup(yytext); return STRING; }
([0-9]+|([0-9]*\.[0-9+)([eE][-+]?[0-9]+)?) {
yylval.name = strdup(yytext); return NUMBER;

View File

@@ -41,7 +41,7 @@ static MdbSQL *g_sql;
%token <name> NAME PATH STRING NUMBER
%token <name> IDENT NAME PATH STRING NUMBER
%token SELECT FROM WHERE CONNECT DISCONNECT TO LIST TABLES WHERE AND
%token DESCRIBE TABLE
%token LTEQ GTEQ LIKE
@@ -112,6 +112,7 @@ database:
table:
NAME { mdb_sql_add_table(_mdb_sql(NULL), $1); free($1); }
| IDENT { mdb_sql_add_table(_mdb_sql(NULL), $1); free($1); }
;
column_list:
@@ -122,6 +123,7 @@ column_list:
column:
NAME { mdb_sql_add_column(_mdb_sql(NULL), $1); free($1); }
| IDENT { mdb_sql_add_column(_mdb_sql(NULL), $1); free($1); }
;
%%

View File

@@ -1,6 +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
LIBS = `glib-config --libs` $(READLINE_LIBS) @LEXLIB@
INCLUDES = -I$(top_srcdir)/include `glib-config --cflags`
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
LIBS = $(GLIB_LIBS) $(READLINE_LIBS) @LEXLIB@
INCLUDES = -I$(top_srcdir)/include $(GLIB_CFLAGS)
LDADD = ../libmdb/libmdb.la
if SQL
mdb_sql_LDADD = ../libmdb/libmdb.la ../sql/libmdbsql.la

View File

@@ -28,19 +28,34 @@ MdbCatalogEntry *entry;
MdbTableDef *table;
MdbColumn *col;
char *the_relation;
char *tabname = NULL;
int opt;
if (argc < 2) {
fprintf (stderr, "Usage: %s <file> [<backend>]\n",argv[0]);
exit (1);
}
if (argc < 2) {
fprintf (stderr, "Usage: %s [-S] [-1 | -d<delimiter>] <file>\n",argv[0]);
exit (1);
}
while ((opt=getopt(argc, argv, "T:"))!=-1) {
switch (opt) {
case 'T':
tabname = (char *) malloc(strlen(optarg)+1);
strcpy(tabname, optarg);
break;
}
}
mdb_init();
/* open the database */
mdb = mdb_open (argv[1]);
if (argc>2) {
if (!mdb_set_default_backend(mdb, argv[2])) {
mdb = mdb_open (argv[optind]);
if (argc - optind >2) {
if (!mdb_set_default_backend(mdb, argv[optind + 1])) {
fprintf(stderr,"Invalid backend type\n");
mdb_exit();
exit(1);
@@ -62,7 +77,8 @@ char *the_relation;
if (entry->object_type == MDB_TABLE)
{
/* skip the MSys tables */
if (strncmp (entry->object_name, "MSys", 4))
if ((tabname && !strcmp(entry->object_name,tabname)) ||
(!tabname && strncmp (entry->object_name, "MSys", 4)))
{
/* make sure it's a table (may be redundant) */

View File

@@ -29,15 +29,18 @@ MdbTableDef *table;
MdbColumn *col;
char *delimiter = NULL;
int line_break=0;
int skip_sys=1;
int opt;
if (argc < 2) {
fprintf (stderr, "Usage: %s [-1 | -d<delimiter>] <file>\n",argv[0]);
fprintf (stderr, "Usage: %s [-S] [-1 | -d<delimiter>] <file>\n",argv[0]);
exit (1);
}
while ((opt=getopt(argc, argv, "1d:"))!=-1) {
while ((opt=getopt(argc, argv, "S1d:"))!=-1) {
switch (opt) {
case 'S':
skip_sys = 0;
case '1':
line_break = 1;
break;
@@ -65,7 +68,7 @@ int opt;
/* if it's a table */
if (entry->object_type == MDB_TABLE) {
/* skip the MSys tables */
if (strncmp (entry->object_name, "MSys", 4)) {
if (!skip_sys || strncmp (entry->object_name, "MSys", 4)) {
if (line_break)
fprintf (stdout, "%s\n", entry->object_name);
else if (delimiter)

111
src/util/prole.c Normal file
View File

@@ -0,0 +1,111 @@
/* MDB Tools - A library for reading MS Access database file
* 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.
*/
#include "mdbtools.h"
void dump_ole(MdbTableDef *table, char *colname, char *sargname);
main(int argc, char **argv)
{
int rows;
int i;
unsigned char buf[2048];
MdbHandle *mdb;
MdbCatalogEntry *entry;
MdbTableDef *table;
GList *l;
char *dot, *colname, *tabname;
char *sargname = NULL;
if (argc<2) {
fprintf(stderr,"Usage: %s <file> <table.column> [sargs]\n",argv[0]);
exit(1);
}
mdb_init();
mdb = mdb_open(argv[1]);
dot = strchr(argv[2],'.');
if (argc>3) sargname = argv[3];
if (!dot) {
fprintf(stderr,"Usage: %s <file> <table.column> [sarg]\n",argv[0]);
exit(1);
}
tabname = argv[2];
*dot='\0';
colname = ++dot;
mdb_read_catalog(mdb, MDB_TABLE);
for (i=0;i<mdb->num_catalog;i++) {
entry = g_ptr_array_index(mdb->catalog,i);
if (entry->object_type == MDB_TABLE &&
!strcmp(entry->object_name,tabname)) {
table = mdb_read_table(entry);
mdb_read_columns(table);
dump_ole(table, colname, sargname);
}
}
mdb_free_handle(mdb);
mdb_exit();
exit(0);
}
void dump_ole(MdbTableDef *table, char *colname, char *sargname)
{
int i, found = 0;
char ole_data[12000];
int len;
MdbColumn *col;
MdbSarg sarg;
char *sargcol, *sargop, *sargval;
for (i=0;i<=table->num_cols;i++) {
col=g_ptr_array_index(table->columns,i);
printf("%d colname %s\n", i, col->name);
if (col && !strcmp(col->name,colname)) {
found = i+1;
}
}
printf("column %d\n",found);
mdb_bind_column(table, found, ole_data);
mdb_bind_len(table, found, &len);
if (sargname) {
sargcol = strtok(sargname," ");
sargop = strtok(NULL," ");
sargval = strtok(NULL," ");
printf("col %s op %s val %s\n",sargcol,sargop,sargval);
sarg.op = MDB_EQUAL; /* only support = for now, sorry */
strcpy(sarg.value.s, sargval);
mdb_add_sarg_by_name(table, sargcol, &sarg);
}
mdb_rewind_table(table);
while (mdb_fetch_row(table)) {
buffer_dump(ole_data, 0, len);
printf("---\n");
}
}

115
src/util/updrow.c Normal file
View File

@@ -0,0 +1,115 @@
/* MDB Tools - A library for reading MS Access database file
* 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.
*/
#include "mdbtools.h"
main(int argc, char **argv)
{
int rows;
int i;
unsigned char buf[2048];
MdbHandle *mdb;
MdbCatalogEntry *entry;
MdbTableDef *table;
GList *l;
char *dot, *colname, *tabname;
char *colop, *colval;
char *sargname = NULL;
char *updstr = NULL;
unsigned char data[255];
int len;
if (argc<4) {
fprintf(stderr,"Usage: %s <file> <table> <sargs> <updstr>\n",argv[0]);
exit(1);
}
mdb_init();
mdb = mdb_open(argv[1]);
tabname = argv[2];
sargname = argv[3];
updstr = strdup(argv[4]);
mdb_read_catalog(mdb, MDB_TABLE);
for (i=0;i<mdb->num_catalog;i++) {
entry = g_ptr_array_index(mdb->catalog,i);
if (entry->object_type == MDB_TABLE &&
!strcmp(entry->object_name,tabname)) {
table = mdb_read_table(entry);
mdb_read_columns(table);
mdb_read_indices(table);
printf("updstr %s\n",updstr);
colname = strtok(updstr,"=");
colval = strtok(NULL,"=");
bind_column(table, colname, data, &len);
read_to_row(table, sargname);
mdb_update_row(table);
printf("current value of %s is %s, changing to %s\n", colname, data, colval);
}
}
mdb_free_handle(mdb);
mdb_exit();
exit(0);
}
int bind_column(MdbTableDef *table, char *colname, unsigned char *data, int *len)
{
int i, found = 0;
MdbColumn *col;
for (i=0;i<table->num_cols;i++) {
col=g_ptr_array_index(table->columns,i);
printf("%d colname %s\n", i, col->name);
if (col && !strcmp(col->name,colname)) {
found = i+1;
}
}
printf("column %d\n",found);
mdb_bind_column(table, found, data);
mdb_bind_len(table, found, len);
}
void read_to_row(MdbTableDef *table, char *sargname)
{
MdbSarg sarg;
char *sargcol, *sargop, *sargval;
if (sargname) {
sargcol = strtok(sargname," ");
sargop = strtok(NULL," ");
sargval = strtok(NULL," ");
printf("col %s op %s val %s\n",sargcol,sargop,sargval);
sarg.op = MDB_EQUAL; /* only support = for now, sorry */
sarg.value.i = atoi(sargval);
mdb_add_sarg_by_name(table, sargcol, &sarg);
}
mdb_rewind_table(table);
while (mdb_fetch_row(table)) {
printf("row found at page %d row %d\n",
table->cur_phys_pg, table->cur_row);
return;
}
}