+MDB databases are files produced by the Microsoft 'Jet' database engine. They are used in a variety of products such as MS Money and MS Project, but most importantly, it is used as the format for Microsoft Access databases.
+
+
+
1.2 What does MDB Tools do
+MDB Tools is an open source suite of libraries and utilities to read (and soon write) MDB database files.
+
+
+
1.3 What are the tools in MDB Tools
+MDB Tools includes
+
+
LibMDB, a library for accessing MDB files.
+
MDB Utilities, a set of command line utilities to extract schema and data.
+Post it to the sourceforge project page so it gets tracked and send a note to the list so we can work it out. I may request details about or a copy of your database. Any database sent will be kept confidential.
+
+
+
1.8 How do I help?
+
+Join the mailing list, it's very low traffic at the time of this writing.
+
+
+If you are a programmer, start with the debugger in gmdb2 to get a feel for the database layout. Read the HACKING file included in the distribution.
+
+
+We are currently looking for corrupted Access databases to help with developing recovery tools. If you have them, I will even extract the usable data from them for you for free. ;-)
+
+
+
+
diff --git a/doc/install.sgml b/doc/install.sgml
new file mode 100644
index 0000000..87e18ad
--- /dev/null
+++ b/doc/install.sgml
@@ -0,0 +1,835 @@
+
+
+
+ $Date: 2003/01/12 22:59:42 $
+ $Revision: 1.1 $
+ MDB Tools Installation Guide
+ A Guide to Installing and Configuring MDB Tools
+
+ Brian
+ Bruns
+
+
+ 2003
+ Brian Bruns
+
+
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.1
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, with no
+ Front-Cover Texts, and with no Back-Cover Texts.
+ A copy of the license is included in the section entitled GNU
+ Free Documentation License.
+
+
+
+
+
+ About this Guide
+
+This guide is intended to provide help with installing and configuring the MDB Tools suite of programs. It is a work in progress and the author will happily accept new material, clarifications, or other enhancements in any format. Patches to the original DocBook format can be uploaded to the SourceForge patch area under the MDB Tools project page. Changes in plain text and other formats can be submitted directly to the mailing list or the author.
+
+
+A few technical notes. This guide is written in SGML DocBook format, specifications for which are found in the DocBook book. It was converted to HTML with OpenJade.
+The document you are reading is version
+$Revision: 1.1 $
+, dated
+$Date: 2003/01/12 22:59:42 $ (CVS control number $Id: install.sgml,v 1.1 2003/01/12 22:59:42 brianb Exp $). The most recent version can be found on the MDB Tools
+web site.
+
+
+
+
+ What is MDB Tools?
+
+
+MDB Tools is a suite of libraries and programs to facilitate the use of Microsoft Access databases, also known as Jet databases after the Microsoft's Jet Database Engine or as MDB databases after the .mdb extension used by the file containing the database.
+
+
+MDB Toolsis open source software (also known as free software if you prefer) which means source code is provided under a license which allows you as a user to modify and redistribute the software. In particular, the libraries that come with MDB Tools are licensed under the Gnu LGPL (Lesser General Public License) and the utility programs, graphical interface, and miscellania are licensed under the Gnu GPL (General Public License). More information about these licenses can be found in the COPYING.LIB and COPYING files distributed with MDB Tools or from the Gnu site.
+
+
+
+
+
+ Components of the MDB Tools Suite
+
+MDB Tools is composed of three libraries, a set of command line utilities and a graphical interface.
+
+
+ LibMDB
+
+libmdb is the lowest level library. It handles the details of reading from and writing to the MDB file format. Atop this library sits all the other functionality of MDB Tools.
+
+
+A complete description of libmdb will be available in the forthcoming MDB Tools Programmer's Guide. For now you can look at the utility programs for a general idea of how to use the API, it's fairly straightforward.
+
+
+
+ Command Line Utilities
+
+MDB Tools comes with a set of command line utilties that allow mdb files to be used in shell scripting, extraction to another database, and similar functions. Each program is documented in its man page. A brief synopsis follows.
+
+MDB Utilities
+
+
+
+ Name
+ Description
+
+
+
+
+ mdb-tables
+ list tables in the specified file
+
+
+ mdb-schema
+ generate schema DLL for the specified file
+
+
+ mdb-export
+ generate CSV style output for a table
+
+
+ mdb-ver
+ display the version of the specified file
+
+
+ mdb-header
+ support for using MDB data in C
+
+
+ mdb-parsecsv
+ support for using MDB data in C
+
+
+ mdb-sql
+ command line SQL query tool
+
+
+
+
+
+
+
+ LibMDBSQL (the SQL Engine)
+
+LibMDBSQL is an SQL engine which provides a subset of the SQL query language to access MDB databases. It is used with the ODBC driver, by the mdb-sql utility, and by the query window in gmdb2.
+
+
+For a description of the support SQL, see the mdb-sql man page.
+
+
+
+ LibMDBODBC
+
+LibMDBODBC is an ODBC driver that works with the unixODBC driver manager to allow MDB Tools to work with such programs as PHP and Perl (via DBD::ODBC). At the time of this writing, the breadth of coverage for the driver is rather limited. If you have specific problems with it, please contact the list and they can most likely be resolved.
+
+
+The ODBC driver relies on LibMDB and LibMDBSQL.
+
+
+
+ Gmdb2
+
+Gmdb2 is a graphical interface to the functionality of MDB Tools. Its interface resembles that of access with a tabbed interface to each of the object types in the database (tables, queries, forms, etc...). Additonally, it sports an SQL Query window, and a file debugger useful for developers or anybody interested in examining the dark secrets of the MDB file format.
+
+
+
+
+ Requirements
+
+MDB Tools like any most packages has some requirements for libraries and such on your system. Most of them are optional and will turn off certain features if not present.
+
+
+ Requirements Matrix
+
+The following matrix lists all requirements and which features they affect. An X in the major feature categories (SQL, ODBC, gmdb2) means these features will be turned off if the prequisite is not found.
+
+
+Prerequisites
+
+
+
+ Name
+ SQL
+ ODBC
+ gmdb2
+ Source
+ Notes
+
+
+
+
+ glib 2.0
+ X
+ X
+ X
+ www.gtk.org
+ Absolutely required, will not install without
+
+
+ readline
+
+
+
+ http://cnswww.cns.cwru.edu/~chet/readline/rltop.html
+ Supports history in mdb-sql, will compile without history if not found.
+
+
+ bison
+ X
+ X
+
+ www.gnu.org
+ gmdb2 will not have a SQL window and mdb-sql will be stubbed out.
+
+
+ flex
+ X
+ X
+
+ www.gnu.org
+ gmdb2 will not have a SQL window and mdb-sql will be stubbed out.
+
+
+ unixODBC
+
+ X
+
+ www.unixodbc.com
+
+
+
+ Gnome 2.0
+
+
+ X
+ www.gnome.org
+
+
+
+ libglade
+
+
+ X
+ www.gnome.org
+
+
+
+ wordexp
+
+
+
+
+ Part of the OS, without it ~ expansion in SQL engine will be disabled
+
+
+
+
+
+
+
+ Installation Options
+
+MDB Tools call be installed from binaries or by compiling the source package.
+
+
+ RPMs
+
+RPMs are made available for major releases (not including pre-release or release candidates). The RPM packages are split up along feature boundaries with a core package, a development package, an ODBC package, and a graphical package. To install, simply log in as root and run the following.
+
+$ rpm -i mdbtools-0.5-1.rpm
+$ rpm -i mdbtools-devel-0.5-1.rpm
+$ rpm -i mdbtools-odbc-0.5-1.rpm
+$ rpm -i mdbtools-gui-0.5-1.rpm
+
+
+
+
+ Other Binary Packages
+
+Packages for other systems (debian, bsd ports, etc...) may be available, check with your OS vendor.
+
+
+
+ Source
+
+If none of the binary options are available to you, or if you prefer, you can configure and compile from the source packages. The next chapter will demonstrate that.
+
+
+
+
+ Installing from Source
+
+There are three basic steps to installing from source
+
+
+ configuring
+ building
+ installing
+
+
+ Configuring from the tarball
+
+If you are installing a release or snapshot tarball follow these steps. These steps assume the tarballs name is mdbtools-0.5.tgz.
+
+$ zcat mdbtools-0.5.tgz | tar xvf -
+$ cd mdbtools-0.5
+$ ./configure
+
+If you want to include ODBC support, use the --with-unixodbc argument with the location you installed it to (/usr/local by default).
+
+$ zcat mdbtools-0.5.tgz | tar xvf -
+$ cd mdbtools-0.5
+$ ./configure --with-unixodbc=/usr/local
+
+
+
+
+ Configuring from CVS
+
+If you are looking for the very latest code you can check out it out of CVS and compile. The configure step uses the autogen.sh script so it's a bit different.
+
+$ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mdbtools login
+$ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mdbtools co
+$ cd mdbtools
+$ ./autogen.sh --with-unixodbc=/usr/local
+
+Again, if you don't want ODBC support remove the --with-unixodbc flag.
+
+
+
+ Building
+
+Once you are finished configuring simply type make to build.
+
+$ make
+
+
+
+
+ Installing
+
+To install, sign in as root and type make install
+
+$ su -
+# make install
+
+
+
+
+
+ Post Install Configuration
+
+There are a couple of things that can be configured in the package.
+
+
+ MDBPATH
+
+If you store your MDB files together in directories you can use the MDBPATH environment variable to have MDB Tools search the path similiar to PATH, MANPATH, LD_LIBRARY_PATH (or LIBPATH), etc... Like those, the : (colon) is used as a separator.
+
+
+If you run sh, ksh, or bash
+
+$ MDBPATH=/home/myuser/mdbfiles:/data/mdbfiles ; export MDBPATH
+
+If you run csh or tcsh
+
+$ setenv MDBPATH /home/myuser/mdbfiles:/data/mdbfiles
+
+This will cause MDB Tools to first attempt to open the file using the filename or path provided (current directory or absolute path), then to walk through each entry in the MDBPATH file looking for it. It will stop at the first match.
+
+
+The MDBPATH variable affects all utilities and any program calling mdb_open().
+
+
+
+ ODBC
+
+In order to use ODBC you must place an entry in the odbc.ini file.
+
+
+odbc.ini file
+
+[Northwind]
+Description = Northwind Sample Database
+Driver = /usr/local/lib/libmdbodbc.so
+Database = /data/mdbfiles/Northwind.mdb
+
+
+
+Consult the unixODBC documentation for full details.
+
+
+
+
+GNU Free Documentation License
+
+
+
+
+
+
+ Version 1.1, March 2000
+
+
+ Copyright (C) 2000 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+
+
+ PREAMBLE
+
+ The purpose of this License is to make a manual, textbook,
+ or other written document "free" in the sense of freedom: to
+ assure everyone the effective freedom to copy and redistribute it,
+ with or without modifying it, either commercially or
+ noncommercially. Secondarily, this License preserves for the
+ author and publisher a way to get credit for their work, while not
+ being considered responsible for modifications made by
+ others.
+
+ This License is a kind of "copyleft", which means that
+ derivative works of the document must themselves be free in the
+ same sense. It complements the GNU General Public License, which
+ is a copyleft license designed for free software.
+
+ We have designed this License in order to use it for manuals
+ for free software, because free software needs free documentation:
+ a free program should come with manuals providing the same
+ freedoms that the software does. But this License is not limited
+ to software manuals; it can be used for any textual work,
+ regardless of subject matter or whether it is published as a
+ printed book. We recommend this License principally for works
+ whose purpose is instruction or reference.
+
+
+
+ APPLICABILITY AND DEFINITIONS
+
+ This License applies to any manual or other work that
+ contains a notice placed by the copyright holder saying it can be
+ distributed under the terms of this License. The "Document",
+ below, refers to any such manual or work. Any member of the
+ public is a licensee, and is addressed as "you".
+
+ A "Modified Version" of the Document means any work
+ containing the Document or a portion of it, either copied
+ verbatim, or with modifications and/or translated into another
+ language.
+
+ A "Secondary Section" is a named appendix or a front-matter
+ section of the Document that deals exclusively with the
+ relationship of the publishers or authors of the Document to the
+ Document's overall subject (or to related matters) and contains
+ nothing that could fall directly within that overall subject.
+ (For example, if the Document is in part a textbook of
+ mathematics, a Secondary Section may not explain any mathematics.)
+ The relationship could be a matter of historical connection with
+ the subject or with related matters, or of legal, commercial,
+ philosophical, ethical or political position regarding
+ them.
+
+ The "Invariant Sections" are certain Secondary Sections
+ whose titles are designated, as being those of Invariant Sections,
+ in the notice that says that the Document is released under this
+ License.
+
+ The "Cover Texts" are certain short passages of text that
+ are listed, as Front-Cover Texts or Back-Cover Texts, in the
+ notice that says that the Document is released under this
+ License.
+
+ A "Transparent" copy of the Document means a
+ machine-readable copy, represented in a format whose specification
+ is available to the general public, whose contents can be viewed
+ and edited directly and straightforwardly with generic text
+ editors or (for images composed of pixels) generic paint programs
+ or (for drawings) some widely available drawing editor, and that
+ is suitable for input to text formatters or for automatic
+ translation to a variety of formats suitable for input to text
+ formatters. A copy made in an otherwise Transparent file format
+ whose markup has been designed to thwart or discourage subsequent
+ modification by readers is not Transparent. A copy that is not
+ "Transparent" is called "Opaque".
+
+ Examples of suitable formats for Transparent copies include
+ plain ASCII without markup, Texinfo input format, LaTeX input
+ format, SGML or XML using a publicly available DTD, and
+ standard-conforming simple HTML designed for human modification.
+ Opaque formats include PostScript, PDF, proprietary formats that
+ can be read and edited only by proprietary word processors, SGML
+ or XML for which the DTD and/or processing tools are not generally
+ available, and the machine-generated HTML produced by some word
+ processors for output purposes only.
+
+ The "Title Page" means, for a printed book, the title page
+ itself, plus such following pages as are needed to hold, legibly,
+ the material this License requires to appear in the title page.
+ For works in formats which do not have any title page as such,
+ "Title Page" means the text near the most prominent appearance of
+ the work's title, preceding the beginning of the body of the
+ text.
+
+
+
+ VERBATIM COPYING
+
+ You may copy and distribute the Document in any medium,
+ either commercially or noncommercially, provided that this
+ License, the copyright notices, and the license notice saying this
+ License applies to the Document are reproduced in all copies, and
+ that you add no other conditions whatsoever to those of this
+ License. You may not use technical measures to obstruct or
+ control the reading or further copying of the copies you make or
+ distribute. However, you may accept compensation in exchange for
+ copies. If you distribute a large enough number of copies you
+ must also follow the conditions in section 3.
+
+ You may also lend copies, under the same conditions stated
+ above, and you may publicly display copies.
+
+
+
+ COPYING IN QUANTITY
+
+ If you publish printed copies of the Document numbering more
+ than 100, and the Document's license notice requires Cover Texts,
+ you must enclose the copies in covers that carry, clearly and
+ legibly, all these Cover Texts: Front-Cover Texts on the front
+ cover, and Back-Cover Texts on the back cover. Both covers must
+ also clearly and legibly identify you as the publisher of these
+ copies. The front cover must present the full title with all
+ words of the title equally prominent and visible. You may add
+ other material on the covers in addition. Copying with changes
+ limited to the covers, as long as they preserve the title of the
+ Document and satisfy these conditions, can be treated as verbatim
+ copying in other respects.
+
+ If the required texts for either cover are too voluminous to
+ fit legibly, you should put the first ones listed (as many as fit
+ reasonably) on the actual cover, and continue the rest onto
+ adjacent pages.
+
+ If you publish or distribute Opaque copies of the Document
+ numbering more than 100, you must either include a
+ machine-readable Transparent copy along with each Opaque copy, or
+ state in or with each Opaque copy a publicly-accessible
+ computer-network location containing a complete Transparent copy
+ of the Document, free of added material, which the general
+ network-using public has access to download anonymously at no
+ charge using public-standard network protocols. If you use the
+ latter option, you must take reasonably prudent steps, when you
+ begin distribution of Opaque copies in quantity, to ensure that
+ this Transparent copy will remain thus accessible at the stated
+ location until at least one year after the last time you
+ distribute an Opaque copy (directly or through your agents or
+ retailers) of that edition to the public.
+
+ It is requested, but not required, that you contact the
+ authors of the Document well before redistributing any large
+ number of copies, to give them a chance to provide you with an
+ updated version of the Document.
+
+
+
+ MODIFICATIONS
+
+ You may copy and distribute a Modified Version of the
+ Document under the conditions of sections 2 and 3 above, provided
+ that you release the Modified Version under precisely this
+ License, with the Modified Version filling the role of the
+ Document, thus licensing distribution and modification of the
+ Modified Version to whoever possesses a copy of it. In addition,
+ you must do these things in the Modified Version:
+
+
+ Use in the Title Page
+ (and on the covers, if any) a title distinct from that of the
+ Document, and from those of previous versions (which should, if
+ there were any, be listed in the History section of the
+ Document). You may use the same title as a previous version if
+ the original publisher of that version gives permission.
+
+
+ List on the Title Page,
+ as authors, one or more persons or entities responsible for
+ authorship of the modifications in the Modified Version,
+ together with at least five of the principal authors of the
+ Document (all of its principal authors, if it has less than
+ five).
+
+
+ State on the Title page
+ the name of the publisher of the Modified Version, as the
+ publisher.
+
+
+ Preserve all the
+ copyright notices of the Document.
+
+
+ Add an appropriate
+ copyright notice for your modifications adjacent to the other
+ copyright notices.
+
+
+ Include, immediately
+ after the copyright notices, a license notice giving the public
+ permission to use the Modified Version under the terms of this
+ License, in the form shown in the Addendum below.
+
+
+ Preserve in that license
+ notice the full lists of Invariant Sections and required Cover
+ Texts given in the Document's license notice.
+
+
+ Include an unaltered
+ copy of this License.
+
+
+ Preserve the section
+ entitled "History", and its title, and add to it an item stating
+ at least the title, year, new authors, and publisher of the
+ Modified Version as given on the Title Page. If there is no
+ section entitled "History" in the Document, create one stating
+ the title, year, authors, and publisher of the Document as given
+ on its Title Page, then add an item describing the Modified
+ Version as stated in the previous sentence.
+
+
+ Preserve the network
+ location, if any, given in the Document for public access to a
+ Transparent copy of the Document, and likewise the network
+ locations given in the Document for previous versions it was
+ based on. These may be placed in the "History" section. You
+ may omit a network location for a work that was published at
+ least four years before the Document itself, or if the original
+ publisher of the version it refers to gives permission.
+
+
+ In any section entitled
+ "Acknowledgements" or "Dedications", preserve the section's
+ title, and preserve in the section all the substance and tone of
+ each of the contributor acknowledgements and/or dedications
+ given therein.
+
+
+ Preserve all the
+ Invariant Sections of the Document, unaltered in their text and
+ in their titles. Section numbers or the equivalent are not
+ considered part of the section titles.
+
+
+ Delete any section
+ entitled "Endorsements". Such a section may not be included in
+ the Modified Version.
+
+
+ Do not retitle any
+ existing section as "Endorsements" or to conflict in title with
+ any Invariant Section.
+
+
+
+ If the Modified Version includes new front-matter sections
+ or appendices that qualify as Secondary Sections and contain no
+ material copied from the Document, you may at your option
+ designate some or all of these sections as invariant. To do this,
+ add their titles to the list of Invariant Sections in the Modified
+ Version's license notice. These titles must be distinct from any
+ other section titles.
+
+ You may add a section entitled "Endorsements", provided it
+ contains nothing but endorsements of your Modified Version by
+ various parties--for example, statements of peer review or that
+ the text has been approved by an organization as the authoritative
+ definition of a standard.
+
+ You may add a passage of up to five words as a Front-Cover
+ Text, and a passage of up to 25 words as a Back-Cover Text, to the
+ end of the list of Cover Texts in the Modified Version. Only one
+ passage of Front-Cover Text and one of Back-Cover Text may be
+ added by (or through arrangements made by) any one entity. If the
+ Document already includes a cover text for the same cover,
+ previously added by you or by arrangement made by the same entity
+ you are acting on behalf of, you may not add another; but you may
+ replace the old one, on explicit permission from the previous
+ publisher that added the old one.
+
+ The author(s) and publisher(s) of the Document do not by
+ this License give permission to use their names for publicity for
+ or to assert or imply endorsement of any Modified Version.
+
+
+
+ COMBINING DOCUMENTS
+
+ You may combine the Document with other documents released
+ under this License, under the terms defined in section 4 above for
+ modified versions, provided that you include in the combination
+ all of the Invariant Sections of all of the original documents,
+ unmodified, and list them all as Invariant Sections of your
+ combined work in its license notice.
+
+ The combined work need only contain one copy of this
+ License, and multiple identical Invariant Sections may be replaced
+ with a single copy. If there are multiple Invariant Sections with
+ the same name but different contents, make the title of each such
+ section unique by adding at the end of it, in parentheses, the
+ name of the original author or publisher of that section if known,
+ or else a unique number. Make the same adjustment to the section
+ titles in the list of Invariant Sections in the license notice of
+ the combined work.
+
+ In the combination, you must combine any sections entitled
+ "History" in the various original documents, forming one section
+ entitled "History"; likewise combine any sections entitled
+ "Acknowledgements", and any sections entitled "Dedications". You
+ must delete all sections entitled "Endorsements."
+
+
+
+ COLLECTIONS OF DOCUMENTS
+
+ You may make a collection consisting of the Document and
+ other documents released under this License, and replace the
+ individual copies of this License in the various documents with a
+ single copy that is included in the collection, provided that you
+ follow the rules of this License for verbatim copying of each of
+ the documents in all other respects.
+
+ You may extract a single document from such a collection,
+ and distribute it individually under this License, provided you
+ insert a copy of this License into the extracted document, and
+ follow this License in all other respects regarding verbatim
+ copying of that document.
+
+
+
+ AGGREGATION WITH INDEPENDENT WORKS
+
+ A compilation of the Document or its derivatives with other
+ separate and independent documents or works, in or on a volume of
+ a storage or distribution medium, does not as a whole count as a
+ Modified Version of the Document, provided no compilation
+ copyright is claimed for the compilation. Such a compilation is
+ called an "aggregate", and this License does not apply to the
+ other self-contained works thus compiled with the Document, on
+ account of their being thus compiled, if they are not themselves
+ derivative works of the Document.
+
+ If the Cover Text requirement of section 3 is applicable to
+ these copies of the Document, then if the Document is less than
+ one quarter of the entire aggregate, the Document's Cover Texts
+ may be placed on covers that surround only the Document within the
+ aggregate. Otherwise they must appear on covers around the whole
+ aggregate.
+
+
+
+ TRANSLATION
+
+ Translation is considered a kind of modification, so you may
+ distribute translations of the Document under the terms of section
+ 4. Replacing Invariant Sections with translations requires
+ special permission from their copyright holders, but you may
+ include translations of some or all Invariant Sections in addition
+ to the original versions of these Invariant Sections. You may
+ include a translation of this License provided that you also
+ include the original English version of this License. In case of
+ a disagreement between the translation and the original English
+ version of this License, the original English version will
+ prevail.
+
+
+
+ TERMINATION
+
+ You may not copy, modify, sublicense, or distribute the
+ Document except as expressly provided for under this License. Any
+ other attempt to copy, modify, sublicense or distribute the
+ Document is void, and will automatically terminate your rights
+ under this License. However, parties who have received copies, or
+ rights, from you under this License will not have their licenses
+ terminated so long as such parties remain in full
+ compliance.
+
+
+
+ FUTURE REVISIONS OF THIS LICENSE
+
+ The Free Software Foundation may publish new, revised
+ versions of the GNU Free Documentation License from time to time.
+ Such new versions will be similar in spirit to the present
+ version, but may differ in detail to address new problems or
+ concerns. See http://www.gnu.org/copyleft/.
+
+ Each version of the License is given a distinguishing
+ version number. If the Document specifies that a particular
+ numbered version of this License "or any later version" applies to
+ it, you have the option of following the terms and conditions
+ either of that specified version or of any later version that has
+ been published (not as a draft) by the Free Software Foundation.
+ If the Document does not specify a version number of this License,
+ you may choose any version ever published (not as a draft) by the
+ Free Software Foundation.
+
+
+
+ How to use this License for your documents
+
+ To use this License in a document you have written, include
+ a copy of the License in the document and put the following
+ copyright and license notices just after the title page:
+
+
+ Copyright (c) YEAR YOUR NAME.
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.1
+ or any later version published by the Free Software Foundation;
+ with the Invariant Sections being LIST THEIR TITLES, with the
+ Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
+ A copy of the license is included in the section entitled "GNU
+ Free Documentation License".
+
+
+ If you have no Invariant Sections, write "with no Invariant
+ Sections" instead of saying which ones are invariant. If you have
+ no Front-Cover Texts, write "no Front-Cover Texts" instead of
+ "Front-Cover Texts being LIST"; likewise for Back-Cover
+ Texts.
+
+ If your document contains nontrivial examples of program
+ code, we recommend releasing these examples in parallel under your
+ choice of free software license, such as the GNU General Public
+ License, to permit their use in free software.
+
+
+
+
+
diff --git a/include/mdbtools.h b/include/mdbtools.h
index 5aacc0c..0706752 100644
--- a/include/mdbtools.h
+++ b/include/mdbtools.h
@@ -290,6 +290,9 @@ extern MdbHandle *mdb_alloc_handle();
extern void mdb_free_handle(MdbHandle *mdb);
extern void mdb_free_catalog(MdbHandle *mdb);
extern MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry);
+extern void mdb_alloc_catalog(MdbHandle *mdb);
+extern MdbFile *mdb_alloc_file();
+extern void mdb_free_file(MdbFile *f);
/* file.c */
extern size_t mdb_read_pg(MdbHandle *mdb, unsigned long pg);
@@ -305,6 +308,7 @@ extern MdbHandle *mdb_clone_handle(MdbHandle *mdb);
extern void mdb_swap_pgbuf(MdbHandle *mdb);
/* catalog.c */
+GPtrArray *mdb_read_catalog(MdbHandle *mdb, int obj_type);
extern void mdb_catalog_dump(MdbHandle *mdb, int obj_type);
extern int mdb_catalog_rows(MdbHandle *mdb);
extern MdbCatalogEntry *mdb_get_catalog_entry(MdbHandle *mdb, int rowid, MdbCatalogEntry *entry);
@@ -312,6 +316,8 @@ extern char *mdb_get_objtype_string(int obj_type);
/* table.c */
extern MdbTableDef *mdb_read_table(MdbCatalogEntry *entry);
+extern GPtrArray *mdb_read_columns(MdbTableDef *table);
+
/* data.c */
extern void mdb_data_dump(MdbTableDef *table);
@@ -320,6 +326,7 @@ extern int mdb_rewind_table(MdbTableDef *table);
extern int mdb_fetch_row(MdbTableDef *table);
extern int mdb_is_fixed_col(MdbColumn *col);
extern char *mdb_col_to_string(MdbHandle *mdb, int start, int datatype, int size);
+extern int mdb_find_end_of_row(MdbHandle *mdb, int row);
/* dump.c */
@@ -333,5 +340,9 @@ extern int mdb_set_default_backend(MdbHandle *mdb, char *backend_name);
extern char *mdb_get_relationships(MdbHandle *mdb);
/* sargs.c */
-int mdb_test_sargs(MdbHandle *mdb, MdbColumn *col, int offset, int len);
+extern int mdb_test_sargs(MdbHandle *mdb, MdbColumn *col, int offset, int len);
+
+/* index.c */
+extern GPtrArray *mdb_read_indices(MdbTableDef *table);
+extern void mdb_index_dump(MdbTableDef *table, MdbIndex *idx);
#endif /* _mdbtools_h_ */
diff --git a/mdbtools.spec b/mdbtools.spec
index 85a4472..d8ef32e 100644
--- a/mdbtools.spec
+++ b/mdbtools.spec
@@ -1,43 +1,104 @@
-Summary: Several utilities for using MS-Access .mdb files.
-Name: mdbtools
-Version: 0.5
-Release: 1
-Copyright: GPL
-Group: Development/Tools
-Source: http://download.sourceforge.net/mdbtools/mdbtools-0.3.tgz
-
-%description
+%define name mdbtools
+%define version 0.5
+
+Name: %{name}
+Version: %{version}
+Release: 1
+Vendor: mdbtools.sourceforge.net
+Copyright: LGPL/GPL
+Group: System Environment/Libraries
+Source: http://download.sourceforge.net/mdbtools/%{name}-%{version}.tgz
+BuildRoot: /var/tmp/%{name}-buildroot
+Summary: MDB Tools is a suite of libraries and program for accessing data stored in Microsoft Access databases.
+
+%description
mdb-dump -- simple hex dump utility for looking at mdb files
mdb-schema -- prints DDL for the specified table
mdb-export -- export table to CSV format
mdb-tables -- a simple dump of table names to be used with shell scripts
-mdb-header -- generates a C header to be used in exporting mdb data to a C prog.
+mdb-header -- generates a C header to be used in exporting mdb data to a C prog
mdb-parsecvs -- generates a C program given a CSV file made with mdb-export
mdb-sql -- demo SQL engine program
+mdb-ver -- print version of database
+
+%package devel
+Group: Development/Libraries
+Summary: Include files needed for development with MDB Tools
+Requires: mdbtools = %{version}
+
+%package odbc
+Group: System Environment/Libraries
+Summary: MDB Tools ODBC driver for unixODBC
+Requires: mdbtools = %{version}, unixODBC >= 2.0.0
+
+%package gui
+Group: Applications/Databases
+Summary: gmdb2 graphical interface for MDB Tools
+Requires: mdbtools = %{version}, libgnomeui >= 2.0.0, libglade2 >= 2.0.0
+
+%description devel
+The mdbtools-devel package contains the files necessary for development with with the MDB Tools libraries.
+
+%description odbc
+The mdbtools-odbc package contains ODBC driver build for unixODBC.
+
+%description gui
+The mdbtools-gui package contains the gmdb2 graphical user interface for MDB Tools
%prep
-%setup
+%setup
+
+%build
+%configure --with-unixodbc=/usr/local
+make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
+
+%install
+rm -rf "$RPM_BUILD_ROOT"
+make DESTDIR="$RPM_BUILD_ROOT" install
+gunzip -c doc/install.tgz | tar x
-%build
-./configure
-make
+%post
+/sbin/ldconfig
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README TODO HACKING
+%{_libdir}/libmdb.a
+%{_libdir}/libmdb.la
+%{_libdir}/libmdb.so*
+%{_libdir}/libmdbsql.a
+%{_libdir}/libmdbsql.la
+%{_libdir}/libmdbsql.so*
+%{_bindir}/mdb-schema
+%{_bindir}/mdb-export
+%{_bindir}/mdb-tables
+%{_bindir}/mdb-header
+%{_bindir}/mdb-parsecsv
+%{_bindir}/mdb-dump
+%{_bindir}/mdb-sql
+%{_bindir}/mdb-ver
+
+%files devel
+%defattr (-,root,root)
+%{_includedir}/mdbtools.h
+%{_includedir}/mdbsql.h
-%install
-make install
-
-%files
-%doc AUTHORS COPYING COPYING.LIB HACKERS INSTALL README TODO NEWS
-/usr/local/lib/libmdb.a
-/usr/local/lib/libmdb.so
-/usr/local/lib/libmdb.so.0
-/usr/local/lib/libmdb.so.0.0.0
-/usr/local/bin/mdb-schema
-/usr/local/bin/mdb-export
-/usr/local/bin/mdb-tables
-/usr/local/bin/mdb-header
-/usr/local/bin/mdb-parsecsv
-/usr/local/bin/mdb-dump
-/usr/local/bin/mdb-sql
-/usr/local/include/mdbtools.h
-/usr/local/include/mdbsql.h
+%files odbc
+%defattr(-,root,root)
+%{_libdir}/libmdbodbc.a
+%{_libdir}/libmdbodbc.so*
+%files gui
+%defattr (-,root,root)
+%{_bindir}/gmdb2
+%{_datadir}/gmdb/pixmaps/*
+%{_datadir}/gmdb/glade/*
+%{_datadir}/gnome/help/gmdb/C/*
+%{_datadir}/gnome/help/gmdb/C/figures/*
+
+%changelog
+* Sat Jan 11 2003 Brian Bruns
+- Modifications for 0.5 ver and making .in version
diff --git a/mdbtools.spec.in b/mdbtools.spec.in
new file mode 100644
index 0000000..aeee5cf
--- /dev/null
+++ b/mdbtools.spec.in
@@ -0,0 +1,104 @@
+%define name @PACKAGE@
+%define version @VERSION@
+
+Name: %{name}
+Version: %{version}
+Release: 1
+Vendor: mdbtools.sourceforge.net
+Copyright: LGPL/GPL
+Group: System Environment/Libraries
+Source: http://download.sourceforge.net/mdbtools/%{name}-%{version}.tgz
+BuildRoot: /var/tmp/%{name}-buildroot
+Summary: MDB Tools is a suite of libraries and program for accessing data stored in Microsoft Access databases.
+
+%description
+mdb-dump -- simple hex dump utility for looking at mdb files
+mdb-schema -- prints DDL for the specified table
+mdb-export -- export table to CSV format
+mdb-tables -- a simple dump of table names to be used with shell scripts
+mdb-header -- generates a C header to be used in exporting mdb data to a C prog
+mdb-parsecvs -- generates a C program given a CSV file made with mdb-export
+mdb-sql -- demo SQL engine program
+mdb-ver -- print version of database
+
+%package devel
+Group: Development/Libraries
+Summary: Include files needed for development with MDB Tools
+Requires: mdbtools = %{version}
+
+%package odbc
+Group: System Environment/Libraries
+Summary: MDB Tools ODBC driver for unixODBC
+Requires: mdbtools = %{version}, unixODBC >= 2.0.0
+
+%package gui
+Group: Applications/Databases
+Summary: gmdb2 graphical interface for MDB Tools
+Requires: mdbtools = %{version}, libgnomeui >= 2.0.0, libglade2 >= 2.0.0
+
+%description devel
+The mdbtools-devel package contains the files necessary for development with with the MDB Tools libraries.
+
+%description odbc
+The mdbtools-odbc package contains ODBC driver build for unixODBC.
+
+%description gui
+The mdbtools-gui package contains the gmdb2 graphical user interface for MDB Tools
+
+%prep
+%setup
+
+%build
+%configure --with-unixodbc=/usr/local
+make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
+
+%install
+rm -rf "$RPM_BUILD_ROOT"
+make DESTDIR="$RPM_BUILD_ROOT" install
+gunzip -c doc/install.tgz | tar x
+
+%post
+/sbin/ldconfig
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README TODO HACKING
+%{_libdir}/libmdb.a
+%{_libdir}/libmdb.la
+%{_libdir}/libmdb.so*
+%{_libdir}/libmdbsql.a
+%{_libdir}/libmdbsql.la
+%{_libdir}/libmdbsql.so*
+%{_bindir}/mdb-schema
+%{_bindir}/mdb-export
+%{_bindir}/mdb-tables
+%{_bindir}/mdb-header
+%{_bindir}/mdb-parsecsv
+%{_bindir}/mdb-dump
+%{_bindir}/mdb-sql
+%{_bindir}/mdb-ver
+
+%files devel
+%defattr (-,root,root)
+%{_includedir}/mdbtools.h
+%{_includedir}/mdbsql.h
+
+%files odbc
+%defattr(-,root,root)
+%{_libdir}/libmdbodbc.a
+%{_libdir}/libmdbodbc.so*
+
+%files gui
+%defattr (-,root,root)
+%{_bindir}/gmdb2
+%{_datadir}/gmdb/pixmaps/*
+%{_datadir}/gmdb/glade/*
+%{_datadir}/gnome/help/gmdb/C/*
+%{_datadir}/gnome/help/gmdb/C/figures/*
+
+%changelog
+* Sat Jan 11 2003 Brian Bruns
+- Modifications for 0.5 ver and making .in version
diff --git a/src/gmdb2/Makefile.am b/src/gmdb2/Makefile.am
index ae73a85..9bc2d75 100644
--- a/src/gmdb2/Makefile.am
+++ b/src/gmdb2/Makefile.am
@@ -1,9 +1,14 @@
+SUBDIRS = help gladefiles pixmaps
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 sql.c schema.c
+include_HEADERS = gmdb.h
+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 sql.c schema.c prefs.c
LIBS = -rdynamic $(GNOME_LIBS) @LEXLIB@
-INCLUDES = -I$(top_srcdir)/include $(GNOME_CFLAGS)
+INCLUDES = -I$(top_srcdir)/include \
+ $(GNOME_CFLAGS) \
+ -DDATADIR=\""$(datadir)"\" \
+ -DGMDB_ICONDIR=\""$(datadir)/gmdb/pixmaps/"\" \
+ -DGMDB_GLADEDIR=\""$(datadir)/gmdb/glade/"\"
+
#LDADD = ../libmdb/libmdb.la
LDADD = ../libmdb/libmdb.la ../sql/libmdbsql.la
#if SQL
diff --git a/src/gmdb2/debug.c b/src/gmdb2/debug.c
index 0d9e370..49e303a 100644
--- a/src/gmdb2/debug.c
+++ b/src/gmdb2/debug.c
@@ -887,7 +887,7 @@ gchar text[20];
GladeXML *debugwin_xml;
/* load the interface */
- debugwin_xml = glade_xml_new("gladefiles/gmdb-debug.glade", NULL, NULL);
+ debugwin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-debug.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(debugwin_xml);
@@ -942,8 +942,8 @@ GladeXML *debugwin_xml;
GTK_SIGNAL_FUNC (gmdb_debug_delete_cb), 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,
+ textview = (GtkTextView *) glade_xml_get_widget (debugwin_xml, "debug_textview");
+ gtk_widget_modify_font(GTK_WIDGET(textview),
pango_font_description_from_string("Courier"));
/* set up treeview, libglade only gives us the empty widget */
diff --git a/src/gmdb2/file.c b/src/gmdb2/file.c
index f40526d..17b7258 100644
--- a/src/gmdb2/file.c
+++ b/src/gmdb2/file.c
@@ -21,6 +21,7 @@
GtkWidget *file_selector;
MdbHandle *mdb;
extern int main_show_debug;
+extern GladeXML *mainwin_xml;
void gmdb_file_open_recent_1() { gmdb_file_open_recent("menu_recent1"); }
void gmdb_file_open_recent_2() { gmdb_file_open_recent("menu_recent2"); }
@@ -100,6 +101,11 @@ gmdb_file_add_recent(gchar *file_path)
void
gmdb_file_open(gchar *file_path)
{
+ GtkWidget *win;
+ gchar *file_name;
+ gchar title[100];
+ int i;
+
gmdb_reset_widgets();
mdb = mdb_open(file_path);
if (!mdb) {
@@ -118,13 +124,22 @@ gmdb_file_open(gchar *file_path)
gmdb_macro_populate(mdb);
gmdb_module_populate(mdb);
//if (main_show_debug) gmdb_debug_init(mdb);
+
+ for (i=strlen(file_path);i>0 && file_path[i-1]!='/';i--);
+ file_name=&file_path[i];
+
+ win = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "gmdb");
+ g_snprintf(title, 100, "%s - MDB File Viewer",file_name);
+ gtk_window_set_title(GTK_WINDOW(win), title);
+
+ gmdb_set_sensitive(TRUE);
}
void
gmdb_file_open_cb(GtkWidget *selector, gpointer data)
{
gchar *file_path;
- file_path = gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_selector));
+ file_path = (gchar *) gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_selector));
gmdb_file_open(file_path);
gmdb_load_recent_files();
}
diff --git a/src/gmdb2/form.c b/src/gmdb2/form.c
index 390d699..3383d92 100644
--- a/src/gmdb2/form.c
+++ b/src/gmdb2/form.c
@@ -26,8 +26,8 @@ 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);
+ gil = (GnomeIconList *) glade_xml_get_widget(mainwin_xml, "form_iconlist");
+ gnome_icon_list_append(gil, GMDB_ICONDIR "form_big.xpm", text);
}
void gmdb_form_populate(MdbHandle *mdb)
diff --git a/src/gmdb2/gladefiles/Makefile.am b/src/gmdb2/gladefiles/Makefile.am
new file mode 100644
index 0000000..6c81e4e
--- /dev/null
+++ b/src/gmdb2/gladefiles/Makefile.am
@@ -0,0 +1,13 @@
+gladedir = $(datadir)/gmdb/glade/
+
+glade_DATA = \
+ gmdb.glade \
+ gmdb-sql.glade \
+ gmdb-debug.glade \
+ gmdb-export.glade \
+ gmdb-schema.glade \
+ gmdb-prefs.glade \
+ gmdb-props.glade
+
+EXTRA_DIST = $(glade_DATA)
+
diff --git a/src/gmdb2/gladefiles/gmdb-prefs.glade b/src/gmdb2/gladefiles/gmdb-prefs.glade
new file mode 100644
index 0000000..e997d4c
--- /dev/null
+++ b/src/gmdb2/gladefiles/gmdb-prefs.glade
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+ True
+ Preferences
+ GTK_WINDOW_TOPLEVEL
+ GTK_WIN_POS_NONE
+ False
+ True
+ False
+ True
+
+
+
+ True
+ False
+ 0
+
+
+
+ True
+ GTK_BUTTONBOX_END
+
+
+
+ True
+ True
+ True
+ gtk-cancel
+ True
+ GTK_RELIEF_NORMAL
+ -6
+
+
+
+
+
+ True
+ True
+ True
+ gtk-ok
+ True
+ GTK_RELIEF_NORMAL
+ -5
+
+
+
+
+ 0
+ False
+ True
+ GTK_PACK_END
+
+
+
+
+
+ 10
+ True
+ 1
+ 2
+ False
+ 0
+ 0
+
+
+
+ True
+ <b>Maximum Rows to Display:</b>
+ False
+ True
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0
+ 0.5
+ 0
+ 0
+
+
+ 0
+ 1
+ 0
+ 1
+
+
+
+
+
+
+ True
+ True
+ True
+ True
+ 0
+
+ True
+ *
+ False
+
+
+ 1
+ 2
+ 0
+ 1
+ fill
+
+
+
+
+
+ 0
+ True
+ False
+
+
+
+
+
+
+
diff --git a/src/gmdb2/gladefiles/gmdb-sql.glade b/src/gmdb2/gladefiles/gmdb-sql.glade
index 6947116..6f98229 100644
--- a/src/gmdb2/gladefiles/gmdb-sql.glade
+++ b/src/gmdb2/gladefiles/gmdb-sql.glade
@@ -84,7 +84,7 @@
_ExecuteTrue
-
+
@@ -127,34 +127,23 @@
-
+ TrueGNOMEUIINFO_MENU_CUT_ITEM
-
-
+ TrueGNOMEUIINFO_MENU_COPY_ITEM
-
-
+ TrueGNOMEUIINFO_MENU_PASTE_ITEM
-
-
-
-
-
-
- True
- GNOMEUIINFO_MENU_CLEAR_ITEM
-
diff --git a/src/gmdb2/gladefiles/gmdb.glade b/src/gmdb2/gladefiles/gmdb.glade
index 7a39db6..9e55ded 100644
--- a/src/gmdb2/gladefiles/gmdb.glade
+++ b/src/gmdb2/gladefiles/gmdb.glade
@@ -52,7 +52,7 @@
-
+ TrueGNOMEUIINFO_MENU_PROPERTIES_ITEM
@@ -149,7 +149,7 @@
TrueGNOMEUIINFO_MENU_PREFERENCES_ITEM
-
+
@@ -167,7 +167,7 @@
-
+ TrueS_QL WindowTrue
@@ -177,14 +177,14 @@
-
+ True_Debug WindowTrue
-
+ Truedebug.xpm0.5
@@ -197,14 +197,14 @@
-
+ TrueE_xport SchemaTrue
-
+ Truegtk-convert1
@@ -244,11 +244,23 @@
-
+ TrueContentsTrue
-
+
+
+
+
+ True
+ gtk-help
+ 1
+ 0.5
+ 0.5
+ 0
+ 0
+
+
@@ -291,7 +303,7 @@
-
+ TrueView database file propertiesgtk-properties
@@ -324,7 +336,7 @@
-
+ TrueExport schema definitionExport Schema
@@ -406,6 +418,7 @@
FalseTrue
+
@@ -496,7 +509,7 @@
2
-
+ Truetable.xpm0.5
@@ -617,7 +630,7 @@
2
-
+ Truequery.xpm0.5
@@ -738,7 +751,7 @@
2
-
+ Trueforms.xpm0.5
@@ -859,7 +872,7 @@
2
-
+ Truereports.xpm0.5
@@ -980,7 +993,7 @@
2
-
+ Truemacros.xpm0.5
@@ -1101,7 +1114,7 @@
2
-
+ Truecode.xpm0.5
diff --git a/src/gmdb2/gmdb.h b/src/gmdb2/gmdb.h
index 0babfb2..0dc3da4 100644
--- a/src/gmdb2/gmdb.h
+++ b/src/gmdb2/gmdb.h
@@ -18,15 +18,18 @@ extern "C" {
void gmdb_info_msg(gchar *message);
GtkWidget *gmdb_info_new();
+void gmdb_set_sensitive(gboolean b);
GtkWidget *gmdb_table_data_new(MdbCatalogEntry *entry);
GtkWidget *gmdb_table_def_new(MdbCatalogEntry *entry);
GtkWidget *gmdb_table_export_new(MdbCatalogEntry *entry);
+void gmdb_table_export(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_file_open_recent(gchar *menuname);
void gmdb_sql_new_window_cb(GtkWidget *w, gpointer data);
@@ -39,6 +42,11 @@ void gmdb_module_populate(MdbHandle *mdb);
void gmdb_table_add_tab(GtkWidget *notebook);
void gmdb_debug_tab_new(GtkWidget *notebook);
+void gmdb_debug_new_cb(GtkWidget *w, gpointer *data);
+
+unsigned long gmdb_prefs_get_maxrows();
+
+extern GtkWidget *gmdb_prefs_new();
extern GtkWidget *table_list;
extern GtkWidget *form_list;
diff --git a/src/gmdb2/help/C/Makefile.am b/src/gmdb2/help/C/Makefile.am
new file mode 100644
index 0000000..1ced8da
--- /dev/null
+++ b/src/gmdb2/help/C/Makefile.am
@@ -0,0 +1,8 @@
+figs = \
+ figures/gmdb2_window.png
+docname = gmdb
+lang = C
+omffile = gmdb-C.omf
+entities = legal.xml
+include xmldocs.make
+dist-hook: app-dist-hook
diff --git a/src/gmdb2/help/C/figures/gmdb2_window.png b/src/gmdb2/help/C/figures/gmdb2_window.png
new file mode 100644
index 0000000..26ce184
Binary files /dev/null and b/src/gmdb2/help/C/figures/gmdb2_window.png differ
diff --git a/src/gmdb2/help/C/gmdb-C.omf b/src/gmdb2/help/C/gmdb-C.omf
new file mode 100644
index 0000000..bdad1ab
--- /dev/null
+++ b/src/gmdb2/help/C/gmdb-C.omf
@@ -0,0 +1,32 @@
+
+
+
+
+ camber@ais.org (Brian Bruns)
+
+
+ camber@ais.org (Brian Bruns)
+
+
+ gmdb Manual V1.0
+
+
+ 2003-01-10
+
+
+
+
+ User manual for gmdb2.
+
+
+ user's guide
+
+
+
+
+
+
+
+
diff --git a/src/gmdb2/help/C/gmdb.xml b/src/gmdb2/help/C/gmdb.xml
new file mode 100644
index 0000000..aabab7b
--- /dev/null
+++ b/src/gmdb2/help/C/gmdb.xml
@@ -0,0 +1,310 @@
+
+
+
+
+
+
+]>
+
+
+
+
+
+
+
+ &app; Manual V&manrevision;
+
+ 2003
+ Brian Bruns
+
+
+
+ MDB Tools Project
+
+ &legal;
+
+
+ Brian
+ Bruns
+
+ MDB Tools Project
+ camber@ais.org
+
+
+
+
+
+
+
+
+
+
+
+ gmdb V0.5
+ 2000
+
+ Brian Brunscamber@ais.org
+
+ MDB Tools Project
+
+
+
+ This manual describes version &appversion; of &app;.
+
+
+ Feedback
+ To report a bug or make a suggestion regarding this application or
+ this manual, follow the directions in this
+ document.
+
+
+
+ gmdb2
+
+
+
+
+ Introduction
+ The &app; application is the graphical
+ interface to MDB Tools. You can use &app;
+ to view and export data and schema from MDB databases.
+
+
+
+
+ Getting Started
+
+
+
+ To Start &app; from the Command Line
+ To start &app; from the command line, type the following command, then press Return:
+ gmdb2
+
+
+
+ &app; Window
+
+
+
+
+
+ Screenshot of the gmdb2 main window.
+
+
+
+
+ The &app; window contains the following
+ elements:
+
+ Menubar.
+
+ The menus on the menubar contain all of the commands you need
+ to work with databases in &app;.
+
+
+ Toolbar.
+
+ The toolbar contains a subset of the commands that you can
+ access from the menubar.
+
+
+ Tabbed window.
+
+
+The tabbed window contains a tab for each type of object in the database. Within
+these, a listing of those objects will be displayed along with buttons along the
+left hand side for performing common actions specific to that type of object.
+
+
+
+ Statusbar.
+
+ The statusbar displays information about current
+ &app; activity and contextual information about the
+ menu items.
+
+
+
+
+When you right-click on any icon in the &app;
+icon list, the application displays a popup menu. The popup menu contains the
+full list of available actions that may be performed on that object.
+
+
+
+
+ To Open a File
+ To open a file, choose
+ FileOpen
+
+ to display the Open File dialog. Select the file
+ that you want to open, then click OK. The file is
+ displayed in the &app; window.
+ The application also records the paths and file names of the last
+ four files that you edited and displays them as menu items on the File
+ menu. To open one of the last four files, choose for example
+ File1.
+ /path/filename.
+
+
+
+ To Open Files from a Command Line
+ You can run &app; from a command line
+ and open a file. To open a file from a command
+ line, type the following command, then press Return:
+ gmdb2 file1.mdb
+ When the application starts, the file that you specified is
+ displayed in the &app; window.
+ &app; uses the environment variable MDBPATH when looking for the specified file. If set &app;will search each directory component until the file is found.
+
+
+
+
+ Usage
+
+
+
+ To Display the Properties of a Database
+ To display the properties of a database, perform
+ the following steps:
+
+ Choose
+ FileProperties
+
+
+
+
+ To Export the Schema of a Database
+ To export the schema of the current database,
+ Choose ToolsExport Schema and perform the following steps:
+
+ Select the filename to save the schema in.
+ If you want to only export one table, select it.
+ Choose the SQL dialect of the target database backend.
+ Check desired schema options.
+ Click Export.
+
+ Checking the Include Relationships box will generate foreign key relationships if they are supported by the database.
+ Checking the Include Drop Table commands will generate the commands to drop the tables before creating new tables.
+
+
+
+ To Open a SQL Query Window
+ The SQL Query window allows you enter SQL queries and to execute and view the results.
+ To open the SQL Query window, perform the following steps.
+
+
+Choose ToolsSQL Window
+
+
+
+
+
+ To Open a File Debugger Window
+ The File Debugger window allows you enter SQL queries and to execute and view the results.
+
+
+Choose ToolsDebug Window
+
+
+
+
+
+
+ Table Actions
+ To perform actions on a table choose the Tables tab from the main window.
+
+
+ Table Definition
+ To view the definition of a table, perform the following actions
+
+
+Locate the desired table in the tables icon list.
+
+
+Select the tables icon.
+
+
+Click on the Definition button from the right hand side of the icon list.
+
+
+
+Columns participating in a Primary Key will have an icon of a gold key and the letters PK at the left side of the column.
+
+
+
+
+ Data View
+ The Data view displays a grid of the data in a table.
+ To display the table data, perform the following steps
+
+
+Locate the desired table in the tables icon list.
+
+
+Select the tables icon.
+
+
+Click on the Data button from the right hand side of the icon list.
+
+
+
+
+ Data Export
+ The Export button creates a text file containing the data from a single data.
+ To export the table data, perform the following steps
+
+
+Locate the desired table in the tables icon list.
+
+
+Select the tables icon.
+
+
+Click on the Export button from the right hand side of the icon list to display the Export Table window.
+
+
+ Select the filename to save the data in.
+
+
+ Fill in dialog with desired characteristics of the export file.
+
+
+ Click Export.
+
+
+ Checking the Include Headers box will write a single row at the top of the file with the names of the columns.
+
+
+
diff --git a/src/gmdb2/help/C/legal.xml b/src/gmdb2/help/C/legal.xml
new file mode 100644
index 0000000..d6906f9
--- /dev/null
+++ b/src/gmdb2/help/C/legal.xml
@@ -0,0 +1,76 @@
+
+
+ Permission is granted to copy, distribute and/or modify this
+ document under the terms of the GNU Free Documentation
+ License (GFDL), Version 1.1 or any later version published
+ by the Free Software Foundation with no Invariant Sections,
+ no Front-Cover Texts, and no Back-Cover Texts. You can find
+ a copy of the GFDL at this link or in the file COPYING-DOCS
+ distributed with this manual.
+
+ This manual is part of a collection of GNOME manuals
+ distributed under the GFDL. If you want to distribute this
+ manual separately from the collection, you can do so by
+ adding a copy of the license to the manual, as described in
+ section 6 of the license.
+
+
+
+ Many of the names used by companies to distinguish their
+ products and services are claimed as trademarks. Where those
+ names appear in any GNOME documentation, and the members of
+ the GNOME Documentation Project are made aware of those
+ trademarks, then the names are in capital letters or initial
+ capital letters.
+
+
+
+ DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT ARE PROVIDED
+ UNDER THE TERMS OF THE GNU FREE DOCUMENTATION LICENSE
+ WITH THE FURTHER UNDERSTANDING THAT:
+
+
+
+ DOCUMENT IS PROVIDED ON AN "AS IS" BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
+ IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
+ THAT THE DOCUMENT OR MODIFIED VERSION OF THE
+ DOCUMENT IS FREE OF DEFECTS MERCHANTABLE, FIT FOR
+ A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE
+ RISK AS TO THE QUALITY, ACCURACY, AND PERFORMANCE
+ OF THE DOCUMENT OR MODIFIED VERSION OF THE
+ DOCUMENT IS WITH YOU. SHOULD ANY DOCUMENT OR
+ MODIFIED VERSION PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL WRITER, AUTHOR OR ANY
+ CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
+ SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
+ LICENSE. NO USE OF ANY DOCUMENT OR MODIFIED
+ VERSION OF THE DOCUMENT IS AUTHORIZED HEREUNDER
+ EXCEPT UNDER THIS DISCLAIMER; AND
+
+
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL
+ THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE),
+ CONTRACT, OR OTHERWISE, SHALL THE AUTHOR,
+ INITIAL WRITER, ANY CONTRIBUTOR, OR ANY
+ DISTRIBUTOR OF THE DOCUMENT OR MODIFIED VERSION
+ OF THE DOCUMENT, OR ANY SUPPLIER OF ANY OF SUCH
+ PARTIES, BE LIABLE TO ANY PERSON FOR ANY
+ DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER
+ INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS
+ OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR
+ MALFUNCTION, OR ANY AND ALL OTHER DAMAGES OR
+ LOSSES ARISING OUT OF OR RELATING TO USE OF THE
+ DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT,
+ EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF
+ THE POSSIBILITY OF SUCH DAMAGES.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/gmdb2/help/C/xmldocs.make b/src/gmdb2/help/C/xmldocs.make
new file mode 100644
index 0000000..d857151
--- /dev/null
+++ b/src/gmdb2/help/C/xmldocs.make
@@ -0,0 +1,86 @@
+# To use this template:
+# 1) Define: figs, docname, lang, omffile, entities although figs,
+# omffile, and entities may be empty in your Makefile.am which
+# will "include" this one
+# 2) Figures must go under figures/ and be in PNG format
+# 3) You should only have one document per directory
+#
+# Note that this makefile forces the directory name under
+# $prefix/share/gnome/help/ to be the same as the XML filename
+# of the document. This is required by GNOME. eg:
+# $prefix/share/gnome/help/fish_applet/C/fish_applet.xml
+# ^^^^^^^^^^^ ^^^^^^^^^^^
+# Definitions:
+# figs A list of screenshots which will be included in EXTRA_DIST
+# Note that these should reside in figures/ and should be .png
+# files, or you will have to make modifications below.
+# docname This is the name of the XML file: .xml
+# lang This is the document locale
+# omffile This is the name of the OMF file. Convention is to name
+# it -.omf.
+# entities This is a list of XML entities which must be installed
+# with the main XML file and included in EXTRA_DIST.
+# eg:
+# figs = \
+# figures/fig1.png \
+# figures/fig2.png
+# docname = scrollkeeper-manual
+# lang = C
+# omffile=scrollkeeper-manual-C.omf
+# entities = fdl.xml
+# include $(top_srcdir)/help/xmldocs.make
+# dist-hook: app-dist-hook
+#
+
+docdir = $(datadir)/gnome/help/$(docname)/$(lang)
+
+xml_files = $(entities) $(docname).xml
+
+omf_dir=$(top_srcdir)/omf-install
+
+EXTRA_DIST = xmldocs.make $(xml_files) $(omffile) $(figs)
+
+CLEANFILES = omf_timestamp
+
+all: omf
+
+omf: omf_timestamp
+
+omf_timestamp: $(omffile)
+ -for file in $(omffile); do \
+ scrollkeeper-preinstall $(docdir)/`awk 'BEGIN {RS = ">" } /identifier/ {print $$0}' $${file} | awk 'BEGIN {FS="\""} /url/ {print $$2}'` $${file} $(omf_dir)/$${file}; \
+ done
+ touch omf_timestamp
+
+$(docname).xml: $(entities)
+ ourdir=`pwd`; \
+ cd $(srcdir); \
+ cp $(entities) $$ourdir
+
+app-dist-hook:
+ -$(mkinstalldirs) $(distdir)/figures
+ -if [ -e topic.dat ]; then \
+ cp $(srcdir)/topic.dat $(distdir); \
+ fi
+
+install-data-am: omf
+ -$(mkinstalldirs) $(DESTDIR)$(docdir)/figures
+ -cp $(srcdir)/$(xml_files) $(DESTDIR)$(docdir)
+ -for file in $(srcdir)/figures/*.png; do \
+ basefile=`echo $$file | sed -e 's,^.*/,,'`; \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/figures/$$basefile; \
+ done
+ -if [ -e $(srcdir)/topic.dat ]; then \
+ $(INSTALL_DATA) $(srcdir)/topic.dat $(DESTDIR)$(docdir); \
+ fi
+
+uninstall-local:
+ -for file in $(srcdir)/figures/*.png; do \
+ basefile=`echo $$file | sed -e 's,^.*/,,'`; \
+ rm -f $(docdir)/figures/$$basefile; \
+ done
+ -for file in $(xml_files); do \
+ rm -f $(DESTDIR)$(docdir)/$$file; \
+ done
+ -rmdir $(DESTDIR)$(docdir)/figures
+ -rmdir $(DESTDIR)$(docdir)
diff --git a/src/gmdb2/help/Makefile.am b/src/gmdb2/help/Makefile.am
new file mode 100644
index 0000000..a68e4e5
--- /dev/null
+++ b/src/gmdb2/help/Makefile.am
@@ -0,0 +1,3 @@
+## Process this file with automake to produce Makefile.in.
+
+SUBDIRS = C
diff --git a/src/gmdb2/info.c b/src/gmdb2/info.c
index 937baaf..a67f925 100644
--- a/src/gmdb2/info.c
+++ b/src/gmdb2/info.c
@@ -39,7 +39,7 @@ int i;
struct stat st;
/* load the interface */
- propswin_xml = glade_xml_new("gladefiles/gmdb-props.glade", NULL, NULL);
+ propswin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-props.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(propswin_xml);
diff --git a/src/gmdb2/macro.c b/src/gmdb2/macro.c
index dfadeff..471bd12 100644
--- a/src/gmdb2/macro.c
+++ b/src/gmdb2/macro.c
@@ -27,7 +27,7 @@ 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);
+ gnome_icon_list_append(gil, GMDB_ICONDIR "macro_big.xpm", text);
}
void gmdb_macro_populate(MdbHandle *mdb)
diff --git a/src/gmdb2/main2.c b/src/gmdb2/main2.c
index d1d58a9..2ac72ed 100644
--- a/src/gmdb2/main2.c
+++ b/src/gmdb2/main2.c
@@ -16,9 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include
+#include
#include
#include
#include
+#include "gmdb.h"
GtkWidget *app;
GladeXML *mainwin_xml;
@@ -48,7 +50,7 @@ const gchar *documenters[] = {
};
GdkPixbuf *pixbuf;
-pixbuf = gdk_pixbuf_new_from_file ("logo.xpm", NULL);
+pixbuf = gdk_pixbuf_new_from_file (GMDB_ICONDIR "logo.xpm", NULL);
gtk_widget_show (gnome_about_new ("Gnome MDB Viewer", "0.2",
"Copyright 2002-2003 Brian Bruns",
@@ -56,11 +58,16 @@ gtk_widget_show (gnome_about_new ("Gnome MDB Viewer", "0.2",
"MDB Tools. It lets you view and export data and schema"
"from MDB files produced by MS Access 97/2000/XP."),
(const gchar **) authors,
- (const gchar **) authors,
+ (const gchar **) documenters,
NULL,
pixbuf));
}
void
+gmdb_prefs_cb(GtkWidget *button, gpointer data)
+{
+ gmdb_prefs_new();
+}
+void
gmdb_info_cb(GtkWidget *button, gpointer data)
{
gmdb_info_new();
@@ -75,6 +82,19 @@ a_callback(GtkWidget *button, gpointer data)
/*just print a string so that we know we got there*/
g_print("Inside Callback\n");
}
+void
+gmdb_help_cb(GtkWidget *button, gpointer data)
+{
+ GError *error = NULL;
+
+ g_print("got here\n");
+ gnome_help_display("gmdb.xml", NULL, &error);
+ if (error != NULL) {
+ g_warning (error->message);
+ g_error_free (error);
+ }
+
+}
void gmdb_load_recent_files()
{
@@ -106,11 +126,12 @@ gchar *text, *text2;
void
gmdb_reset_widgets()
{
-GnomeIconList *gil;
-int pos;
+ GnomeIconList *gil;
+ GtkWidget *win;
gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "table_iconlist");
gnome_icon_list_clear(gil);
+ gmdb_table_set_sensitive(FALSE);
gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "query_iconlist");
gnome_icon_list_clear(gil);
gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "form_iconlist");
@@ -121,6 +142,38 @@ int pos;
gnome_icon_list_clear(gil);
gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "module_iconlist");
gnome_icon_list_clear(gil);
+
+ win = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "gmdb");
+ gtk_window_set_title(GTK_WINDOW(win), "MDB File Viewer");
+ gmdb_set_sensitive(FALSE);
+
+}
+
+void
+gmdb_set_sensitive(gboolean b)
+{
+ GtkWidget *mi, *button;
+
+ mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "sql_menu");
+ gtk_widget_set_sensitive(mi,b);
+
+ mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "debug_menu");
+ gtk_widget_set_sensitive(mi,b);
+
+ mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "schema_menu");
+ gtk_widget_set_sensitive(mi,b);
+
+ mi = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "info_menu");
+ gtk_widget_set_sensitive(mi,b);
+
+ button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "sql_button");
+ gtk_widget_set_sensitive(button,b);
+
+ button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "schema_button");
+ gtk_widget_set_sensitive(button,b);
+
+ button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "info_button");
+ gtk_widget_set_sensitive(button,b);
}
void gmdb_init_popups()
@@ -128,9 +181,50 @@ void gmdb_init_popups()
gmdb_table_init_popup();
}
+void
+gmdb_load_icons(GladeXML *xml)
+{
+ GtkWidget *icon;
+ char file[256];
+ GValue value = { 0, };
+ int i = 0;
+
+ char *icons[] = {
+ "table_icon",
+ "query_icon",
+ "form_icon",
+ "report_icon",
+ "macro_icon",
+ "module_icon",
+ "debug_icon",
+ NULL
+ };
+ char *files[] = {
+ "table.xpm",
+ "query.xpm",
+ "forms.xpm",
+ "reports.xpm",
+ "macros.xpm",
+ "code.xpm",
+ "debug.xpm",
+ NULL
+ };
+
+ while (icons[i]) {
+ icon = glade_xml_get_widget (xml, icons[i]);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_snprintf(file,256,"%s%s", GMDB_ICONDIR, files[i]);
+ g_value_set_static_string (&value, file);
+ g_object_set_property (G_OBJECT (icon), "file" , &value);
+ g_value_unset (&value);
+ i++;
+ }
+}
int main(int argc, char *argv[])
{
GtkWidget *gmdb;
+GnomeProgram *program;
#ifdef SQL
/* initialize the SQL engine */
@@ -140,13 +234,21 @@ GtkWidget *gmdb;
mdb_init();
/* Initialize GNOME */
- gnome_init ("gmdb2", "0.2", argc, argv);
- app = gnome_app_new ("gmdb2", "Gnome-MDB File Viewer");
+ /* Initialize gnome program */
+ program = gnome_program_init ("gmdb", "0.2",
+ LIBGNOMEUI_MODULE, argc, argv,
+ GNOME_PARAM_POPT_TABLE, NULL,
+ GNOME_PARAM_HUMAN_READABLE_NAME,
+ _("Gnome-MDB File Viewer"),
+ GNOME_PARAM_APP_DATADIR, DATADIR,
+ NULL);
+ //gnome_init ("gmdb", "0.2", argc, argv);
+ //app = gnome_app_new ("gmdb", "Gnome-MDB File Viewer");
glade_init();
/* load the interface */
- mainwin_xml = glade_xml_new("gladefiles/gmdb.glade", NULL, NULL);
+ mainwin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(mainwin_xml);
@@ -154,8 +256,12 @@ GtkWidget *gmdb;
gtk_signal_connect (GTK_OBJECT (gmdb), "delete_event",
GTK_SIGNAL_FUNC (delete_event), NULL);
+ gmdb_load_icons(mainwin_xml);
+
if (argc>1) {
gmdb_file_open(argv[1]);
+ } else {
+ gmdb_reset_widgets();
}
gmdb_load_recent_files();
diff --git a/src/gmdb2/module.c b/src/gmdb2/module.c
index 73f5fef..1e401e5 100644
--- a/src/gmdb2/module.c
+++ b/src/gmdb2/module.c
@@ -27,7 +27,7 @@ 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);
+ gnome_icon_list_append(gil, GMDB_ICONDIR "module_big.xpm", text);
}
void gmdb_module_populate(MdbHandle *mdb)
diff --git a/src/gmdb2/pixmaps/Makefile.am b/src/gmdb2/pixmaps/Makefile.am
new file mode 100644
index 0000000..f75d0e5
--- /dev/null
+++ b/src/gmdb2/pixmaps/Makefile.am
@@ -0,0 +1,21 @@
+
+appicondir = $(datadir)/gmdb/pixmaps
+
+appicon_DATA = \
+ pk.xpm \
+ logo.xpm \
+ debug.xpm \
+ table.xpm \
+ query.xpm \
+ forms.xpm \
+ reports.xpm \
+ macros.xpm \
+ code.xpm \
+ table_big.xpm \
+ query_big.xpm \
+ form_big.xpm \
+ report_big.xpm \
+ macro_big.xpm \
+ module_big.xpm
+
+EXTRA_DIST = $(appicon_DATA)
diff --git a/src/gmdb2/code.xpm b/src/gmdb2/pixmaps/code.xpm
similarity index 100%
rename from src/gmdb2/code.xpm
rename to src/gmdb2/pixmaps/code.xpm
diff --git a/src/gmdb2/debug.xpm b/src/gmdb2/pixmaps/debug.xpm
similarity index 100%
rename from src/gmdb2/debug.xpm
rename to src/gmdb2/pixmaps/debug.xpm
diff --git a/src/gmdb2/form_big.xpm b/src/gmdb2/pixmaps/form_big.xpm
similarity index 100%
rename from src/gmdb2/form_big.xpm
rename to src/gmdb2/pixmaps/form_big.xpm
diff --git a/src/gmdb2/forms.xpm b/src/gmdb2/pixmaps/forms.xpm
similarity index 100%
rename from src/gmdb2/forms.xpm
rename to src/gmdb2/pixmaps/forms.xpm
diff --git a/src/gmdb2/logo.xpm b/src/gmdb2/pixmaps/logo.xpm
similarity index 100%
rename from src/gmdb2/logo.xpm
rename to src/gmdb2/pixmaps/logo.xpm
diff --git a/src/gmdb2/macro_big.xpm b/src/gmdb2/pixmaps/macro_big.xpm
similarity index 100%
rename from src/gmdb2/macro_big.xpm
rename to src/gmdb2/pixmaps/macro_big.xpm
diff --git a/src/gmdb2/macros.xpm b/src/gmdb2/pixmaps/macros.xpm
similarity index 100%
rename from src/gmdb2/macros.xpm
rename to src/gmdb2/pixmaps/macros.xpm
diff --git a/src/gmdb2/module_big.xpm b/src/gmdb2/pixmaps/module_big.xpm
similarity index 100%
rename from src/gmdb2/module_big.xpm
rename to src/gmdb2/pixmaps/module_big.xpm
diff --git a/src/gmdb2/pk.xpm b/src/gmdb2/pixmaps/pk.xpm
similarity index 100%
rename from src/gmdb2/pk.xpm
rename to src/gmdb2/pixmaps/pk.xpm
diff --git a/src/gmdb2/query.xpm b/src/gmdb2/pixmaps/query.xpm
similarity index 100%
rename from src/gmdb2/query.xpm
rename to src/gmdb2/pixmaps/query.xpm
diff --git a/src/gmdb2/query_big.xpm b/src/gmdb2/pixmaps/query_big.xpm
similarity index 100%
rename from src/gmdb2/query_big.xpm
rename to src/gmdb2/pixmaps/query_big.xpm
diff --git a/src/gmdb2/report_big.xpm b/src/gmdb2/pixmaps/report_big.xpm
similarity index 100%
rename from src/gmdb2/report_big.xpm
rename to src/gmdb2/pixmaps/report_big.xpm
diff --git a/src/gmdb2/reports.xpm b/src/gmdb2/pixmaps/reports.xpm
similarity index 100%
rename from src/gmdb2/reports.xpm
rename to src/gmdb2/pixmaps/reports.xpm
diff --git a/src/gmdb2/table.xpm b/src/gmdb2/pixmaps/table.xpm
similarity index 100%
rename from src/gmdb2/table.xpm
rename to src/gmdb2/pixmaps/table.xpm
diff --git a/src/gmdb2/table_big.xpm b/src/gmdb2/pixmaps/table_big.xpm
similarity index 100%
rename from src/gmdb2/table_big.xpm
rename to src/gmdb2/pixmaps/table_big.xpm
diff --git a/src/gmdb2/prefs.c b/src/gmdb2/prefs.c
new file mode 100644
index 0000000..fef6b9c
--- /dev/null
+++ b/src/gmdb2/prefs.c
@@ -0,0 +1,92 @@
+/* MDB Tools - A library for reading MS Access database file
+ * Copyright (C) 2000 Brian Bruns
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include "gmdb.h"
+
+extern GtkWidget *app;
+extern MdbHandle *mdb;
+
+GladeXML *prefswin_xml;
+
+unsigned long
+gmdb_prefs_get_maxrows()
+{
+ gchar *str;
+
+ str = gnome_config_get_string("/gmdb/prefs/maxrows");
+ if (!str || !strlen(str))
+ return 1000;
+ else
+ return atol(str);
+}
+
+/* callbacks */
+void
+gmdb_prefs_save_cb(GtkWidget *w, GladeXML *xml)
+{
+ GtkWidget *entry;
+ GtkWidget *win;
+ gchar *str;
+
+ entry = glade_xml_get_widget (xml, "maxrows_entry");
+ str = (gchar *) gtk_entry_get_text(GTK_ENTRY(entry));
+ printf("str = %s\n",str);
+ gnome_config_set_string("/gmdb/prefs/maxrows", str);
+ gnome_config_sync();
+ win = glade_xml_get_widget (xml, "prefs_dialog");
+ if (win) gtk_widget_destroy(win);
+}
+
+void
+gmdb_prefs_cancel_cb(GtkWidget *w, GladeXML *xml)
+{
+ GtkWidget *win;
+
+ win = glade_xml_get_widget (xml, "prefs_dialog");
+ if (win) gtk_widget_destroy(win);
+}
+
+GtkWidget *
+gmdb_prefs_new()
+{
+ GtkWidget *prefswin, *button;
+ GtkWidget *entry;
+ gchar *str;
+
+ /* load the interface */
+ prefswin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-prefs.glade", NULL, NULL);
+ /* connect the signals in the interface */
+ glade_xml_signal_autoconnect(prefswin_xml);
+
+ entry = glade_xml_get_widget (prefswin_xml, "maxrows_entry");
+
+ button = glade_xml_get_widget (prefswin_xml, "cancel_button");
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (gmdb_prefs_cancel_cb), prefswin_xml);
+
+ button = glade_xml_get_widget (prefswin_xml, "ok_button");
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (gmdb_prefs_save_cb), prefswin_xml);
+
+ str = gnome_config_get_string("/gmdb/prefs/maxrows");
+ if (!str || !strlen(str)) {
+ str = "1000";
+ gnome_config_set_string("/gmdb/prefs/maxrows", str);
+ gnome_config_sync();
+ }
+ gtk_entry_set_text(GTK_ENTRY(entry), str);
+}
diff --git a/src/gmdb2/query.c b/src/gmdb2/query.c
index 309e453..5751425 100644
--- a/src/gmdb2/query.c
+++ b/src/gmdb2/query.c
@@ -28,7 +28,7 @@ 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);
+ gnome_icon_list_append(gil, GMDB_ICONDIR "query_big.xpm", text);
}
diff --git a/src/gmdb2/report.c b/src/gmdb2/report.c
index eac7513..139b4b5 100644
--- a/src/gmdb2/report.c
+++ b/src/gmdb2/report.c
@@ -26,8 +26,8 @@ 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);
+ gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "report_iconlist");
+ gnome_icon_list_append(gil, GMDB_ICONDIR "report_big.xpm", text);
}
void gmdb_report_populate(MdbHandle *mdb)
diff --git a/src/gmdb2/schema.c b/src/gmdb2/schema.c
index 33ae70f..1383e48 100644
--- a/src/gmdb2/schema.c
+++ b/src/gmdb2/schema.c
@@ -163,7 +163,7 @@ MdbCatalogEntry *entry;
int i;
/* load the interface */
- schemawin_xml = glade_xml_new("gladefiles/gmdb-schema.glade", NULL, NULL);
+ schemawin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-schema.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(schemawin_xml);
diff --git a/src/gmdb2/sql.c b/src/gmdb2/sql.c
index 8b81eaf..97d3416 100644
--- a/src/gmdb2/sql.c
+++ b/src/gmdb2/sql.c
@@ -53,6 +53,42 @@ gmdb_sql_close_all()
/* callbacks */
void
+gmdb_sql_copy_cb(GtkWidget *w, GladeXML *xml)
+{
+ GtkTextBuffer *txtbuffer;
+ GtkClipboard *clipboard;
+ GtkWidget *textview;
+
+ textview = glade_xml_get_widget(xml, "sql_textview");
+ clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+ txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ gtk_text_buffer_copy_clipboard(txtbuffer, clipboard);
+}
+void
+gmdb_sql_cut_cb(GtkWidget *w, GladeXML *xml)
+{
+ GtkTextBuffer *txtbuffer;
+ GtkClipboard *clipboard;
+ GtkWidget *textview;
+
+ textview = glade_xml_get_widget(xml, "sql_textview");
+ clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+ txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ gtk_text_buffer_cut_clipboard(txtbuffer, clipboard, TRUE);
+}
+void
+gmdb_sql_paste_cb(GtkWidget *w, GladeXML *xml)
+{
+ GtkTextBuffer *txtbuffer;
+ GtkClipboard *clipboard;
+ GtkWidget *textview;
+
+ textview = glade_xml_get_widget(xml, "sql_textview");
+ clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+ txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+ gtk_text_buffer_paste_clipboard(txtbuffer, clipboard, NULL, TRUE);
+}
+void
gmdb_sql_close_cb(GtkWidget *w, GladeXML *xml)
{
GtkWidget *win;
@@ -73,7 +109,7 @@ gchar *name;
GtkTreeSelection *select;
GtkTreeStore *store;
GtkTreeView *tree;
-GtkTreeIter *iter, iter2;
+GtkTreeIter iter2;
tree = (GtkTreeView *) glade_xml_get_widget(xml, "sql_treeview");
select = gtk_tree_view_get_selection(GTK_TREE_VIEW (tree));
@@ -99,10 +135,9 @@ void gmdb_sql_dnd_datareceived_cb(
guint info, guint t,
GladeXML *xml)
{
-gchar *buf, *lastbuf;
-GtkTextIter iter, start, end;
+gchar *buf;
+GtkTextIter iter;
GtkTextBuffer *txtbuffer;
-int len;
GtkWidget *textview;
textview = glade_xml_get_widget(xml, "sql_textview");
@@ -144,6 +179,7 @@ GList *history;
GType *gtypes;
GtkTreeIter iter;
GtkTreeViewColumn *column;
+long row, maxrow;
/* stuff this query on the history */
textview = glade_xml_get_widget(xml, "sql_textview");
@@ -177,7 +213,7 @@ GtkTreeViewColumn *column;
for (i=0;inum_columns;i++)
gtypes[i]=G_TYPE_STRING;
- store = gtk_tree_view_get_model(treeview);
+ store = (GtkTreeStore *) gtk_tree_view_get_model(treeview);
if (store) {
i=0;
while (column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), i)) {
@@ -202,7 +238,12 @@ GtkTreeViewColumn *column;
gtk_tree_view_append_column(GTK_TREE_VIEW (treeview), column);
}
- while(mdb_fetch_row(sql->cur_table)) {
+ maxrow = gmdb_prefs_get_maxrows();
+
+ row = 0;
+ while(mdb_fetch_row(sql->cur_table) &&
+ (!maxrow || (row < maxrow))) {
+ row++;
gtk_list_store_append(GTK_LIST_STORE(store), &iter);
for (i=0;inum_columns;i++) {
gtk_list_store_set(GTK_LIST_STORE(store),
@@ -228,12 +269,24 @@ GtkWidget *mi, *but;
GladeXML *sqlwin_xml;
/* load the interface */
- sqlwin_xml = glade_xml_new("gladefiles/gmdb-sql.glade", NULL, NULL);
+ sqlwin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-sql.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(sqlwin_xml);
sql_list = g_list_append(sql_list, sqlwin_xml);
+ mi = glade_xml_get_widget (sqlwin_xml, "paste_menu");
+ g_signal_connect (G_OBJECT (mi), "activate",
+ G_CALLBACK (gmdb_sql_paste_cb), sqlwin_xml);
+
+ mi = glade_xml_get_widget (sqlwin_xml, "cut_menu");
+ g_signal_connect (G_OBJECT (mi), "activate",
+ G_CALLBACK (gmdb_sql_cut_cb), sqlwin_xml);
+
+ mi = glade_xml_get_widget (sqlwin_xml, "copy_menu");
+ g_signal_connect (G_OBJECT (mi), "activate",
+ G_CALLBACK (gmdb_sql_copy_cb), sqlwin_xml);
+
mi = glade_xml_get_widget (sqlwin_xml, "close_menu");
g_signal_connect (G_OBJECT (mi), "activate",
G_CALLBACK (gmdb_sql_close_cb), sqlwin_xml);
@@ -295,7 +348,7 @@ gmdb_sql_tree_populate(MdbHandle *mdb, GladeXML *xml)
{
int i;
MdbCatalogEntry *entry;
-GtkTreeIter *iter1, *iter2;
+GtkTreeIter *iter2;
GtkWidget *tree = glade_xml_get_widget(xml, "sql_treeview");
GtkTreeStore *store = (GtkTreeStore *) gtk_tree_view_get_model(GTK_TREE_VIEW(tree));
diff --git a/src/gmdb2/table.c b/src/gmdb2/table.c
index 4a6d410..d12217d 100644
--- a/src/gmdb2/table.c
+++ b/src/gmdb2/table.c
@@ -27,12 +27,13 @@ extern MdbHandle *mdb;
int selected_table = -1;
extern char *mdb_access_types[];
+void gmdb_table_set_sensitive(gboolean b);
+
/* callbacks */
void
gmdb_table_debug_cb(GtkList *list, GtkWidget *w, gpointer data)
{
MdbCatalogEntry *entry;
-guint32 page;
/* nothing selected yet? */
if (selected_table==-1) {
@@ -85,15 +86,22 @@ MdbCatalogEntry *entry;
gmdb_table_data_new(entry);
}
void
+gmdb_table_unselect_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data)
+{
+ selected_table = -1;
+ gmdb_table_set_sensitive(FALSE);
+}
+void
gmdb_table_select_cb(GnomeIconList *gil, int num, GdkEvent *ev, gpointer data)
{
-int child_num;
-int i,j=0;
+int i;
MdbCatalogEntry *entry;
gchar *text;
text = (gchar *) gnome_icon_list_get_icon_data(gil, num);
+ selected_table = -1;
+
for (i=0;inum_catalog;i++) {
entry = g_ptr_array_index(mdb->catalog,i);
if (entry->object_type==MDB_TABLE &&
@@ -101,6 +109,12 @@ gchar *text;
selected_table = i;
}
}
+ if (selected_table>0) {
+ gmdb_table_set_sensitive(TRUE);
+ } else {
+ gmdb_table_set_sensitive(FALSE);
+ }
+
}
gmdb_table_popup_cb(GtkWidget *menu, GdkEvent *event)
{
@@ -119,12 +133,26 @@ GdkEventButton *event_button;
}
/* functions */
void
+gmdb_table_set_sensitive(gboolean b)
+{
+ GtkWidget *button;
+
+ button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "table_definition");
+ gtk_widget_set_sensitive(button,b);
+
+ button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "table_data");
+ gtk_widget_set_sensitive(button,b);
+
+ button = (GtkWidget *) glade_xml_get_widget (mainwin_xml, "table_export");
+ gtk_widget_set_sensitive(button,b);
+}
+void
gmdb_table_init_popup()
{
GnomeIconList *gil;
GtkWidget *menu, *mi;
- gil = glade_xml_get_widget (mainwin_xml, "table_iconlist");
+ gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "table_iconlist");
menu = gtk_menu_new();
gtk_widget_show(menu);
@@ -151,9 +179,9 @@ GtkWidget *menu, *mi;
g_signal_connect_swapped (G_OBJECT (mi), "activate",
G_CALLBACK (gmdb_table_debug_cb), gil);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
- mi = gtk_menu_item_new_with_label("Usage Map");
- gtk_widget_show(mi);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
+ //mi = gtk_menu_item_new_with_label("Usage Map");
+ //gtk_widget_show(mi);
+ //gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
g_signal_connect_swapped (GTK_OBJECT (gil), "button_press_event",
G_CALLBACK (gmdb_table_popup_cb), GTK_OBJECT(menu));
@@ -164,9 +192,9 @@ gmdb_table_add_icon(gchar *text)
GnomeIconList *gil;
int pos;
- gil = glade_xml_get_widget (mainwin_xml, "table_iconlist");
+ gil = (GnomeIconList *) glade_xml_get_widget (mainwin_xml, "table_iconlist");
- pos = gnome_icon_list_append(gil, "table_big.xpm", text);
+ pos = gnome_icon_list_append(gil, GMDB_ICONDIR "table_big.xpm", text);
gnome_icon_list_set_icon_data(gil, pos, text);
}
diff --git a/src/gmdb2/table_data.c b/src/gmdb2/table_data.c
index 501310c..90e11e8 100644
--- a/src/gmdb2/table_data.c
+++ b/src/gmdb2/table_data.c
@@ -44,6 +44,7 @@ MdbColumn *col;
GtkWidget *clist;
GtkWidget *scroll;
int i, rownum;
+long row, maxrow;
gchar *bound_data[256];
GMdbDataWindow *dataw = NULL;
@@ -97,8 +98,13 @@ GMdbDataWindow *dataw = NULL;
}
gtk_clist_column_titles_show(GTK_CLIST(clist));
+ maxrow = gmdb_prefs_get_maxrows();
+
/* fetch those rows! */
- while(mdb_fetch_row(table)) {
+ row = 0;
+ while(mdb_fetch_row(table) &&
+ (!maxrow || (row < maxrow))) {
+ row++;
rownum = gtk_clist_append(GTK_CLIST(clist), bound_data);
}
diff --git a/src/gmdb2/table_def.c b/src/gmdb2/table_def.c
index 578d163..47e1ee0 100644
--- a/src/gmdb2/table_def.c
+++ b/src/gmdb2/table_def.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "gmdb.h"
-#include "pk.xpm"
+#include "pixmaps/pk.xpm"
extern GtkWidget *app;
extern MdbHandle *mdb;
diff --git a/src/gmdb2/table_export.c b/src/gmdb2/table_export.c
index e8c9db3..3dfe87d 100644
--- a/src/gmdb2/table_export.c
+++ b/src/gmdb2/table_export.c
@@ -160,7 +160,8 @@ GtkWidget *exportwin;
sprintf(msg,"%d Rows exported successfully.\n", rows);
gmdb_info_msg(msg);
}
-void gmdb_table_export(MdbCatalogEntry *entry) {
+void gmdb_table_export(MdbCatalogEntry *entry)
+{
GtkWidget *export_button;
GtkWidget *close_button;
GList *glist = NULL;
@@ -169,7 +170,7 @@ GtkWidget *combo;
cat_entry = entry;
/* load the interface */
- exportwin_xml = glade_xml_new("gladefiles/gmdb-export.glade", NULL, NULL);
+ exportwin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-export.glade", NULL, NULL);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(exportwin_xml);
diff --git a/src/libmdb/catalog.c b/src/libmdb/catalog.c
index fe2a2c2..192714e 100644
--- a/src/libmdb/catalog.c
+++ b/src/libmdb/catalog.c
@@ -19,7 +19,8 @@
#include "mdbtools.h"
-char *mdb_get_objtype_string(int obj_type)
+char *
+mdb_get_objtype_string(int obj_type)
{
static char *type_name[] = {"Form",
"Table",
@@ -43,13 +44,10 @@ static char *type_name[] = {"Form",
}
/* new method */
-#if 1
GPtrArray *mdb_read_catalog (MdbHandle *mdb, int objtype)
{
-int i, j, k;
MdbCatalogEntry entry, msysobj, *data;
MdbTableDef *table;
-MdbColumn *col;
char parentid[256];
char objname[256];
char tobjtype[256];
@@ -98,7 +96,7 @@ int type;
/* old method */
-#else
+#if 0
MdbCatalogEntry *mdb_read_catalog_entry(MdbHandle *mdb, int rowid, MdbCatalogEntry *entry)
{
@@ -146,7 +144,8 @@ int mdb_catalog_rows(MdbHandle *mdb)
{
return mdb_get_int16(mdb, mdb->row_count_offset);
}
-GArray *mdb_read_catalog(MdbHandle *mdb, int obj_type)
+GPtrArray *
+mdb_read_catalog(MdbHandle *mdb, int obj_type)
{
int i;
int rows;
@@ -192,7 +191,7 @@ int next_pg, next_pg_off;
mdb_free_catalog(mdb);
mdb->num_catalog = 0;
- mdb->catalog = g_array_new(FALSE,FALSE,sizeof(MdbCatalogEntry));
+ mdb->catalog = g_ptr_array_new();
next_pg=0;
while (mdb_read_pg(mdb,next_pg)) {
if (mdb->pg_buf[0]==0x01 &&
@@ -205,7 +204,7 @@ int next_pg, next_pg_off;
if (mdb_read_catalog_entry(mdb, i, &entry)) {
//printf("page %d\n",next_pg);
mdb->num_catalog++;
- mdb->catalog = g_array_append_val(mdb->catalog, entry);
+ g_ptr_array_add(mdb->catalog, entry);
}
}
}
@@ -213,10 +212,11 @@ int next_pg, next_pg_off;
}
}
#endif
-void mdb_dump_catalog(MdbHandle *mdb, int obj_type)
+void
+mdb_dump_catalog(MdbHandle *mdb, int obj_type)
{
-int rows, i;
-MdbCatalogEntry *entry;
+ int i;
+ MdbCatalogEntry *entry;
mdb_read_catalog(mdb, obj_type);
for (i=0;inum_catalog;i++) {
@@ -225,8 +225,8 @@ MdbCatalogEntry *entry;
fprintf(stdout,"Type: %-10s Name: %-18s T pg: %04x KKD pg: %04x row: %2d\n",
mdb_get_objtype_string(entry->object_type),
entry->object_name,
- entry->table_pg,
- entry->kkd_pg,
+ (unsigned int) entry->table_pg,
+ (unsigned int) entry->kkd_pg,
entry->kkd_rowid);
}
}
diff --git a/src/libmdb/data.c b/src/libmdb/data.c
index f100f93..2bb9021 100644
--- a/src/libmdb/data.c
+++ b/src/libmdb/data.c
@@ -46,10 +46,11 @@ MdbColumn *col;
col=g_ptr_array_index(table->columns, col_num - 1);
col->len_ptr = len_ptr;
}
-int mdb_find_end_of_row(MdbHandle *mdb, int row)
+int
+mdb_find_end_of_row(MdbHandle *mdb, int row)
{
-MdbFormatConstants *fmt = mdb->fmt;
-int row_end;
+ MdbFormatConstants *fmt = mdb->fmt;
+ int row_end;
/* Search the previous "row start" values for the first non-deleted one.
* If we don't find one, then the end of the page is the correct value.
diff --git a/src/libmdb/file.c b/src/libmdb/file.c
index 69371b4..225a76f 100644
--- a/src/libmdb/file.c
+++ b/src/libmdb/file.c
@@ -64,7 +64,7 @@ int ret;
return 0;
}
g_free(tmpfname);
- } while (dir = strtok(NULL, ":"));
+ } while ((dir = strtok(NULL, ":")));
return -1;
}
MdbHandle *_mdb_open(char *filename, gboolean writable)
@@ -154,10 +154,10 @@ MdbHandle *mdb_clone_handle(MdbHandle *mdb)
newmdb = mdb_alloc_handle();
memcpy(newmdb, mdb, sizeof(MdbHandle));
newmdb->stats = NULL;
- newmdb->catalog = g_array_new(FALSE,FALSE,sizeof(MdbCatalogEntry));
+ newmdb->catalog = g_ptr_array_new();
for (i=0;inum_catalog;i++) {
entry = g_ptr_array_index(mdb->catalog,i);
- newmdb->catalog = g_array_append_val(newmdb->catalog, entry);
+ g_ptr_array_add(newmdb->catalog, entry);
}
mdb->backend_name = NULL;
if (mdb->f) {
@@ -227,13 +227,14 @@ unsigned char c;
mdb->cur_pos++;
return c;
}
-int _mdb_get_int16(unsigned char *buf, int offset)
+int
+_mdb_get_int16(unsigned char *buf, int offset)
{
return buf[offset+1]*256+buf[offset];
}
-int mdb_get_int16(MdbHandle *mdb, int offset)
+int
+mdb_get_int16(MdbHandle *mdb, int offset)
{
-unsigned char *c;
int i;
if (offset < 0 || offset+2 > mdb->fmt->pg_size) return -1;
@@ -244,7 +245,8 @@ int i;
return i;
}
-gint32 mdb_get_int24_msb(MdbHandle *mdb, int offset)
+gint32
+mdb_get_int24_msb(MdbHandle *mdb, int offset)
{
gint32 l;
unsigned char *c;
@@ -295,11 +297,15 @@ long l;
mdb->cur_pos+=4;
return l;
}
-float mdb_get_single(MdbHandle *mdb, int offset)
+float
+mdb_get_single(MdbHandle *mdb, int offset)
{
-float f, f2;
-unsigned char *c;
-int i;
+#ifdef WORDS_BIGENDIAN
+ float f2;
+ int i;
+ unsigned char *c;
+#endif
+ float f;
if (offset <0 || offset+4 > mdb->fmt->pg_size) return -1;
@@ -316,11 +322,15 @@ int i;
return f;
}
-double mdb_get_double(MdbHandle *mdb, int offset)
+double
+mdb_get_double(MdbHandle *mdb, int offset)
{
-double d, d2;
-unsigned char *c;
-int i;
+#ifdef WORDS_BIGENDIAN
+ double d2;
+ int i;
+ unsigned char *c;
+#endif
+ double d;
if (offset <0 || offset+4 > mdb->fmt->pg_size) return -1;
@@ -337,7 +347,8 @@ int i;
return d;
}
-int mdb_set_pos(MdbHandle *mdb, int pos)
+int
+mdb_set_pos(MdbHandle *mdb, int pos)
{
if (pos<0 || pos >= mdb->fmt->pg_size) return 0;
diff --git a/src/libmdb/index.c b/src/libmdb/index.c
index ee9750f..1b1969e 100644
--- a/src/libmdb/index.c
+++ b/src/libmdb/index.c
@@ -53,7 +53,8 @@ char idx_to_text[] = {
0x81, 0x00, 0x00, 0x00, 'x', 0x00, 0x00, 0x00, /* 0xf8-0xff */
};
-GPtrArray *mdb_read_indices(MdbTableDef *table)
+GPtrArray *
+mdb_read_indices(MdbTableDef *table)
{
MdbHandle *mdb = table->entry->mdb;
MdbIndex idx, *pidx;
@@ -170,7 +171,7 @@ void mdb_index_cache_sarg(MdbColumn *col, MdbSarg *sarg, MdbSarg *idx_sarg)
//cache_int = sarg->value.i * -1;
c = &(idx_sarg->value.i);
c[0] |= 0x80;
- printf("int %08x %02x %02x %02x %02x\n", sarg->value.i, c[0], c[1], c[2], c[3]);
+ //printf("int %08x %02x %02x %02x %02x\n", sarg->value.i, c[0], c[1], c[2], c[3]);
break;
case MDB_INT:
@@ -200,7 +201,7 @@ mdb_index_test_sargs(MdbHandle *mdb, MdbIndex *idx, int offset, int len)
c_len = strlen(&mdb->pg_buf[offset + c_offset]);
} else {
c_len = col->col_size;
- fprintf(stderr,"Only text types currently supported. How did we get here?\n");
+ //fprintf(stderr,"Only text types currently supported. How did we get here?\n");
}
/*
* If we have no cached index values for this column,
@@ -211,7 +212,7 @@ mdb_index_test_sargs(MdbHandle *mdb, MdbIndex *idx, int offset, int len)
for (j=0;jnum_sargs;j++) {
sarg = g_ptr_array_index (col->sargs, j);
idx_sarg = g_memdup(sarg,sizeof(MdbSarg));
- printf("calling mdb_index_cache_sarg\n");
+ //printf("calling mdb_index_cache_sarg\n");
mdb_index_cache_sarg(col, sarg, idx_sarg);
g_ptr_array_add(col->idx_sarg_cache, idx_sarg);
}
@@ -227,6 +228,10 @@ mdb_index_test_sargs(MdbHandle *mdb, MdbIndex *idx, int offset, int len)
}
return 1;
}
+/*
+ * find the next entry on a page (either index or leaf). Uses state information
+ * stored in the MdbIndexPage across calls.
+ */
int
mdb_index_find_next_on_page(MdbHandle *mdb, MdbIndexPage *ipg)
{
@@ -249,45 +254,93 @@ mdb_index_find_next_on_page(MdbHandle *mdb, MdbIndexPage *ipg)
}
void mdb_index_page_init(MdbIndexPage *ipg)
{
+ memset(ipg, 0, sizeof(MdbIndexPage));
ipg->offset = 0xf8; /* start byte of the index entries */
ipg->mask_pos = 0x16;
ipg->mask_bit=0;
ipg->len = 0;
}
-int
+/*
+ * find the next leaf page if any given a chain. Assumes any exhausted leaf
+ * pages at the end of the chain have been peeled off before the call.
+ */
+MdbIndexPage *
mdb_find_next_leaf(MdbHandle *mdb, MdbIndexChain *chain)
{
- MdbIndexPage *ipg;
+ MdbIndexPage *ipg, *newipg;
+ guint32 pg;
+ guint passed = 0;
+
+ ipg = &(chain->pages[chain->cur_depth - 1]);
+
/*
* If we are at the first page deep and it's not an index page then
* we are simply done. (there is no page to find
*/
- if (chain->cur_depth==1) {
- ipg = &(chain->pages[0]);
- if (mdb->pg_buf[0]==MDB_PAGE_LEAF ||
- mdb->pg_buf[0]==MDB_PAGE_DATA) {
- return ipg->pg;
+
+ mdb_read_pg(mdb, ipg->pg);
+ if (mdb->pg_buf[0]==MDB_PAGE_LEAF)
+ return ipg;
+
+ /*
+ * apply sargs here, currently we don't
+ */
+ do {
+ ipg->len = 0;
+ //printf("finding next on pg %lu\n", ipg->pg);
+ if (!mdb_index_find_next_on_page(mdb, ipg))
+ return 0;
+ pg = mdb_get_int24_msb(mdb, ipg->offset + ipg->len - 3);
+ //printf("Looking at pg %lu at %lu %d\n", pg, ipg->offset, ipg->len);
+ ipg->offset += ipg->len;
+
+ /*
+ * add to the chain and call this function
+ * recursively.
+ */
+ chain->cur_depth++;
+ if (chain->cur_depth > MDB_MAX_INDEX_DEPTH) {
+ fprintf(stderr,"Error! maximum index depth of %d exceeded. This is probably due to a programming bug, If you are confident that your indexes really are this deep, adjust MDB_MAX_INDEX_DEPTH in mdbtools.h and recompile.\n");
+ exit(1);
}
- }
-
- ipg = &(chain->pages[chain->cur_depth - 1]);
-
+ newipg = &(chain->pages[chain->cur_depth - 1]);
+ mdb_index_page_init(newipg);
+ newipg->pg = pg;
+ newipg = mdb_find_next_leaf(mdb, chain);
+ //printf("returning pg %lu\n",newipg->pg);
+ return newipg;
+ } while (!passed);
/* no more pages */
- return 0;
+ return NULL;
}
+/*
+ * the main index function.
+ * caller provides an index chain which is the current traversal of index
+ * pages from the root page to the leaf. Initially passed as blank,
+ * mdb_index_find_next will store it's state information here. Each invocation
+ * then picks up where the last one left off, allowing us to scroll through
+ * the index one by one.
+ *
+ * Sargs are applied here but also need to be applied on the whole row b/c
+ * text columns may return false positives due to hashing and non-index
+ * columns with sarg values can't be tested here.
+ */
int
mdb_index_find_next(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 *pg, guint16 *row)
{
MdbIndexPage *ipg;
int passed = 0;
+ /*
+ * if it's new use the root index page (idx->first_pg)
+ */
if (!chain->cur_depth) {
ipg = &(chain->pages[0]);
mdb_index_page_init(ipg);
chain->cur_depth = 1;
ipg->pg = idx->first_pg;
- if (!mdb_find_next_leaf(mdb, chain))
+ if (!(ipg = mdb_find_next_leaf(mdb, chain)))
return 0;
} else {
ipg = &(chain->pages[chain->cur_depth - 1]);
@@ -296,10 +349,31 @@ mdb_index_find_next(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32
mdb_read_pg(mdb, ipg->pg);
+ /*
+ * loop while the sargs don't match
+ */
do {
ipg->len = 0;
- if (!mdb_index_find_next_on_page(mdb, ipg))
- return 0;
+ /*
+ * if no more rows on this leaf, try to find a new leaf
+ */
+ if (!mdb_index_find_next_on_page(mdb, ipg)) {
+ //printf("page %lu finished\n",ipg->pg);
+ if (chain->cur_depth==1)
+ return 0;
+ /*
+ * unwind the stack until we find something or reach
+ * the top.
+ */
+ while (chain->cur_depth>1) {
+ chain->cur_depth--;
+ if (!(ipg = mdb_find_next_leaf(mdb, chain)))
+ return 0;
+ mdb_index_find_next_on_page(mdb, ipg);
+ }
+ if (chain->cur_depth==1)
+ return 0;
+ }
*row = mdb->pg_buf[ipg->offset + ipg->len - 1];
*pg = mdb_get_int24_msb(mdb, ipg->offset + ipg->len - 4);
@@ -332,10 +406,11 @@ int i;
printf("column %d coltype %d col_size %d (%d)\n",i,col->col_type, mdb_col_fixed_size(col), col->col_size);
}
}
-void mdb_index_dump(MdbTableDef *table, MdbIndex *idx)
+void
+mdb_index_dump(MdbTableDef *table, MdbIndex *idx)
{
-int i;
-MdbColumn *col;
+ int i;
+ MdbColumn *col;
fprintf(stdout,"index number %d\n", idx->index_num);
fprintf(stdout,"index name %s\n", idx->name);
diff --git a/src/libmdb/kkd.c b/src/libmdb/kkd.c
index 8a80e6a..b0491ee 100644
--- a/src/libmdb/kkd.c
+++ b/src/libmdb/kkd.c
@@ -27,10 +27,9 @@
GArray *mdb_get_column_props(MdbCatalogEntry *entry, int start)
{
-int i, j=0, pos, cnt=0;
+int pos, cnt=0;
int len, tmp, cplen;
MdbColumnProp prop;
-char name[MDB_MAX_OBJ_NAME+1];
MdbHandle *mdb = entry->mdb;
entry->props = g_array_new(FALSE,FALSE,sizeof(MdbColumnProp));
@@ -100,13 +99,8 @@ void mdb_kkd_dump(MdbCatalogEntry *entry)
{
int rows;
int kkd_start, kkd_end;
-int i, j, tmp, pos, row_type, hdrpos=0, datapos=0;
-int len;
-int col_type, col_num, val_len;
-int start;
-unsigned char c;
+int i, tmp, pos, row_type, datapos=0;
MdbColumnProp prop;
-char name[MDB_MAX_OBJ_NAME+1];
MdbHandle *mdb = entry->mdb;
int rowid = entry->kkd_rowid;
diff --git a/src/libmdb/mem.c b/src/libmdb/mem.c
index eb0b298..5728aa3 100644
--- a/src/libmdb/mem.c
+++ b/src/libmdb/mem.c
@@ -35,20 +35,24 @@ MdbStatistics *mdb_alloc_stats(MdbHandle *mdb)
mdb->stats = g_malloc0(sizeof(MdbStatistics));
return mdb->stats;
}
-void mdb_free_stats(MdbHandle *mdb)
+void
+mdb_free_stats(MdbHandle *mdb)
{
g_free(mdb->stats);
mdb->stats = NULL;
}
-MdbFile *mdb_alloc_file()
+MdbFile *
+mdb_alloc_file()
{
-MdbHandle *f;
+ MdbFile *f;
+
f = (MdbFile *) malloc(sizeof(MdbFile));
memset(f, '\0', sizeof(MdbFile));
return f;
}
-void mdb_free_file(MdbFile *f)
+void
+mdb_free_file(MdbFile *f)
{
if (!f) return;
if (f->fd) close(f->fd);
@@ -82,9 +86,6 @@ void mdb_alloc_catalog(MdbHandle *mdb)
}
void mdb_free_catalog(MdbHandle *mdb)
{
-GList *l;
-MdbCatalogEntry entry;
-
//g_ptr_array_free(mdb->catalog, FALSE);
mdb->catalog = NULL;
}
@@ -99,11 +100,13 @@ MdbTableDef *table;
return table;
}
-void mdb_free_tabledef(MdbTableDef *table)
+void
+mdb_free_tabledef(MdbTableDef *table)
{
if (table->usage_map) free(table->usage_map);
if (table) free(table);
}
+void
mdb_append_column(GPtrArray *columns, MdbColumn *in_col)
{
MdbColumn *col;
@@ -111,10 +114,12 @@ MdbColumn *col;
col = g_memdup(in_col,sizeof(MdbColumn));
g_ptr_array_add(columns, col);
}
+void
mdb_free_columns(GPtrArray *columns)
{
g_ptr_array_free(columns, TRUE);
}
+void
mdb_append_index(GPtrArray *indices, MdbIndex *in_idx)
{
MdbIndex *idx;
@@ -122,6 +127,7 @@ MdbIndex *idx;
idx = g_memdup(in_idx,sizeof(MdbIndex));
g_ptr_array_add(indices, idx);
}
+void
mdb_free_indices(GPtrArray *indices)
{
g_ptr_array_free(indices, TRUE);
diff --git a/src/libmdb/table.c b/src/libmdb/table.c
index 3c70820..c978484 100644
--- a/src/libmdb/table.c
+++ b/src/libmdb/table.c
@@ -45,7 +45,7 @@ MdbTableDef *mdb_read_table(MdbCatalogEntry *entry)
MdbTableDef *table;
MdbHandle *mdb = entry->mdb;
MdbFormatConstants *fmt = mdb->fmt;
-int len, i;
+int len;
int rownum, row_start, row_end;
table = mdb_alloc_tabledef(entry);
@@ -104,9 +104,7 @@ MdbColumn col, *pcol;
int len, i,j;
unsigned char low_byte, high_byte;
int cur_col, cur_name;
-int col_type, col_size;
-char name[MDB_MAX_OBJ_NAME+1];
-int name_sz, col_num;
+int name_sz;
GSList *slist = NULL;
table->columns = g_ptr_array_new();
@@ -238,11 +236,11 @@ int i,bitn;
int pgnum;
table = mdb_read_table(entry);
- fprintf(stdout,"definition page = %d\n",entry->table_pg);
+ fprintf(stdout,"definition page = %lu\n",entry->table_pg);
fprintf(stdout,"number of datarows = %d\n",table->num_rows);
fprintf(stdout,"number of columns = %d\n",table->num_cols);
fprintf(stdout,"number of indices = %d\n",table->num_real_idxs);
- fprintf(stdout,"first data page = %d\n",table->first_data_pg);
+ fprintf(stdout,"first data page = %lu\n",table->first_data_pg);
mdb_read_columns(table);
mdb_read_indices(table);
diff --git a/src/util/prindex.c b/src/util/prindex.c
index 6ddcb78..8064614 100644
--- a/src/util/prindex.c
+++ b/src/util/prindex.c
@@ -26,12 +26,10 @@ main(int argc, char **argv)
{
int rows;
int i, j;
-unsigned char buf[2048];
MdbHandle *mdb;
MdbCatalogEntry *entry;
MdbTableDef *table;
MdbIndex *idx;
-GList *l;
int found = 0;
@@ -92,10 +90,10 @@ void check_row(MdbHandle *mdb, MdbIndex *idx, guint32 pg, int row, unsigned char
{
MdbField fields[256];
MdbFormatConstants *fmt;
- int num_fields, i, j, k;
+ int num_fields, i, j;
int row_start, row_end;
MdbColumn *col;
- guchar buf[256], key[256], mykey[256];
+ guchar buf[256], key[256];
int elem, pos;
MdbTableDef *table = idx->table;
@@ -119,25 +117,26 @@ void check_row(MdbHandle *mdb, MdbIndex *idx, guint32 pg, int row, unsigned char
//j = idx->key_col_num[i];
strncpy(buf, fields[elem].value, fields[elem].siz);
buf[fields[elem].siz]=0;
- fprintf(stdout, "elem %d %d column %d %s %s\n",elem, fields[elem].colnum, idx->key_col_num[i], col->name, buf);
+ //fprintf(stdout, "elem %d %d column %d %s %s\n",elem, fields[elem].colnum, idx->key_col_num[i], col->name, buf);
if (col->col_type == MDB_TEXT) {
- fprintf(stdout, "%s = %s \n", buf, key);
+ // fprintf(stdout, "%s = %s \n", buf, key);
}
}
}
void
walk_index(MdbHandle *mdb, MdbIndex *idx)
{
- int i, j, start, len;
+ int start, len;
unsigned char byte;
guint32 pg;
guint16 row;
MdbHandle *mdbidx;
MdbIndexChain chain;
+
+#if 0
MdbTableDef *table = idx->table;
MdbSarg sarg;
-#if 1
sarg.op = MDB_EQUAL;
//strcpy(sarg.value.s, "SP");
sarg.value.i = 2;
@@ -151,33 +150,10 @@ walk_index(MdbHandle *mdb, MdbIndex *idx)
* the data */
mdbidx = mdb_clone_handle(mdb);
mdb_read_pg(mdbidx, idx->first_pg);
- printf("page type %02x %s\n", mdbidx->pg_buf[0], page_name(mdbidx->pg_buf[0]));
+ //printf("page type %02x %s\n", mdbidx->pg_buf[0], page_name(mdbidx->pg_buf[0]));
while (mdb_index_find_next(mdbidx, idx, &chain, &pg, &row)) {
printf("row = %d pg = %lu\n", row, pg);
check_row(mdb, idx, pg, row, &mdbidx->pg_buf[start], len - 4);
}
-#if 0
- if (mdbidx->pg_buf[0]!=MDB_PAGE_LEAF) {
- return;
- }
- start = 0xf8; /* start byte of the index entries */
- len = -1;
- for (i=0x16;i<0xf8;i++) {
- byte = mdbidx->pg_buf[i];
- //printf("%02x ",byte);
- for (j=0;j<8;j++) {
- len++;
- if ((1 << j) & byte) {
- // printf("start = %04x len = %d\n", start, len);
- buffer_dump(mdbidx->pg_buf, start, start+len-1);
- row = mdbidx->pg_buf[start+len-1];
- pg = mdb_get_int24_msb(mdbidx, start+len-4);
- start += len;
- len = 0;
- // printf("\nbit %d set\n", j);
- }
- }
- }
-#endif
mdb_close(mdbidx);
}