diff -Nru mdbtools-0.7/.gitignore mdbtools-0.7.1/.gitignore --- mdbtools-0.7/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/.gitignore 2013-10-13 08:51:24.000000000 +0000 @@ -0,0 +1,53 @@ +*.o +*.lo +*.la +*.out +.deps/ +.libs/ +aclocal.m4 +autom4te.cache/ +build-aux/ +m4/ +!m4/ccalias.m4 +!m4/iconv.m4 +!m4/readline.m4 +config.log +config.status +configure +dumptypes.c +dumptypes.h +Makefile.in +Makefile +doc/*.1 +INSTALL +include/mdbver.h +libmdb.pc +libmdbsql.pc +libtool +mdbtools.spec +types.h +src/extras/mdb-hexdump +src/gmdb2/gmdb2 +src/gmdb2/help/C/omf_timestamp +src/odbc/unittest +src/sql/lexer.c +src/sql/parser.c +src/sql/parser.h +src/util/mdb-array +src/util/mdb-export +src/util/mdb-header +src/util/mdb-import +src/util/mdb-parsecsv +src/util/mdb-prop +src/util/mdb-schema +src/util/mdb-sql +src/util/mdb-tables +src/util/mdb-ver +src/util/prcat +src/util/prdata +src/util/prdump +src/util/prindex +src/util/prkkd +src/util/prole +src/util/prtable +src/util/updrow diff -Nru mdbtools-0.7/HACKING mdbtools-0.7.1/HACKING --- mdbtools-0.7/HACKING 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/HACKING 2013-10-13 08:51:24.000000000 +0000 @@ -242,6 +242,11 @@ user interface; 2 gigabytes of character storage when entering data programmatically. That would mean 31 bits for length. +Note: if a memo field is marked for compression, only at value which is at +most 1024 characters when uncompressed can be compressed. fields longer than +that _must_ be stored uncompressed. + + LVAL (Long Value) Pages ----------------------- @@ -306,7 +311,7 @@ | ???? | 2 bytes | max_cols | Max columns a row will have (deletions) | | ???? | 2 bytes | num_var_cols| Number of variable columns in table | | ???? | 2 bytes | num_cols | Number of columns in table (repeat) | -| ???? | 4 bytes | num_idx | Number of indexes in table | +| ???? | 4 bytes | num_idx | Number of logical indexes in table | | ???? | 4 bytes | num_real_idx| Number of index entries | | ???? | 4 bytes | used_pages | Points to a record containing the | | | | | usage bitmask for this table. | @@ -337,14 +342,14 @@ | ???? | 1 byte | col_name_len| len of the name of the column | | ???? | n bytes | col_name | Name of the column | +-------------------------------------------------------------------------+ -| Iterate for indexes with index_type 0 or 1 (30+9 = 39 bytes) | +| Iterate for the number of num_real_idx (30+9 = 39 bytes) | +-------------------------------------------------------------------------+ | Iterate 10 times for 10 possible columns (10*3 = 30 bytes) | +-------------------------------------------------------------------------+ | ???? | 2 bytes | col_num | number of a column (0xFFFF= none) | | ???? | 1 byte | col_order | 0x01 = ascendency order | +-------------------------------------------------------------------------+ -| ???? | 4 bytes | unknown | | +| ???? | 4 bytes | used_pages | Points to usage bitmap for index | | ???? | 4 bytes | first_dp | Data pointer of the index page | | ???? | 1 byte | flags | See flags table for indexes | +-------------------------------------------------------------------------+ @@ -353,11 +358,14 @@ | ???? | 4 bytes | index_num | Number of the index | | | | |(warn: not always in the sequential order)| | ???? | 4 bytes | index_num2 | Index into index cols list | -| 0x00 | 1 byte | ??? | | -| 0xFF | 4 bytes | ??? | | -| 0x00 | 4 bytes | ??? | | -| 0x04 | 2 bytes | ??? | | -| ???? | 1 byte | primary_key | 0x01 if this index is primary | +| 0x00 | 1 byte | rel_tbl_type| type of the other table in this fk | +| | | | (same values as index_type) | +| 0xFF | 4 bytes | rel_idx_num | index number of other index in fk | +| | | | (or -1 if this index is not a fk) | +| 0x00 | 4 bytes | rel_tbl_page| page number of other table in fk | +| 0x01 | 1 byte | cascade_ups | flag indicating if updates are cascaded | +| 0x01 | 1 byte | cascade_dels| flag indicating if deletes are cascaded | +| ???? | 1 byte | index_type | 0x01 if index is primary, 0x02 if foreign| +-------------------------------------------------------------------------+ | Iterate for the number of num_idx | +-------------------------------------------------------------------------+ @@ -367,8 +375,10 @@ | Iterate while col_num != 0xffff | +-------------------------------------------------------------------------+ | ???? | 2 bytes | col_num | Column number with variable length | -| ???? | 4 bytes | arg1 | | -| ???? | 4 bytes | arg2 | | +| ???? | 4 bytes | used_pages | Points to a record containing the | +| | | | usage bitmask for this column. | +| ???? | 4 bytes | free_pages | Points to a similar record as above, | +| | | | listing pages which contain free space. | +-------------------------------------------------------------------------+ +-------------------------------------------------------------------------+ @@ -390,7 +400,7 @@ | ???? | 2 bytes | max_cols | Max columns a row will have (deletions) | | ???? | 2 bytes | num_var_cols| Number of variable columns in table | | ???? | 2 bytes | num_cols | Number of columns in table (repeat) | -| ???? | 4 bytes | num_idx | Number of indexes in table | +| ???? | 4 bytes | num_idx | Number of logical indexes in table | | ???? | 4 bytes | num_real_idx| Number of index entries | | ???? | 4 bytes | used_pages | Points to a record containing the | | | | | usage bitmask for this table. | @@ -425,7 +435,7 @@ | ???? | 2 bytes | col_name_len| len of the name of the column | | ???? | n bytes | col_name | Name of the column (UCS-2 format) | +-------------------------------------------------------------------------+ -| Iterate for indexes with index_type 0 or 1 (30+22 = 52 bytes) | +| Iterate for the number of num_real_idx (30+22 = 52 bytes) | +-------------------------------------------------------------------------+ | ???? | 4 bytes | ??? | | +-------------------------------------------------------------------------+ @@ -434,7 +444,7 @@ | ???? | 2 bytes | col_num | number of a column (0xFFFF= none) | | ???? | 1 byte | col_order | 0x01 = ascendency order | +-------------------------------------------------------------------------+ -| ???? | 4 bytes | unknown | | +| ???? | 4 bytes | used_pages | Points to usage bitmap for index | | ???? | 4 bytes | first_dp | Data pointer of the index page | | ???? | 1 byte | flags | See flags table for indexes | | ???? | 9 bytes | unknown | | @@ -445,12 +455,14 @@ | ???? | 4 bytes | index_num | Number of the index | | | | |(warn: not always in the sequential order)| | ???? | 4 bytes | index_num2 | Index into index cols list | -| 0x00 | 1 byte | ??? | | -| 0xFF | 4 bytes | ??? | | -| 0x00 | 4 bytes | ??? | | -| 0x04 | 2 bytes | ??? | | -| ???? | 1 byte | primary_key | 0x01 if this index is primary | -| ???? | 4 bytes | unknown | | +| 0x00 | 1 byte | rel_tbl_type| type of the other table in this fk | +| | | | (same values as index_type) | +| 0xFF | 4 bytes | rel_idx_num | index number of other index in fk | +| | | | (or -1 if this index is not a fk) | +| 0x00 | 4 bytes | rel_tbl_page| page number of other table in fk | +| 0x01 | 1 byte | cascade_ups | flag indicating if updates are cascaded | +| 0x01 | 1 byte | cascade_dels| flag indicating if deletes are cascaded | +| ???? | 1 byte | index_type | 0x01 if index is primary, 0x02 if foreign| +-------------------------------------------------------------------------+ | Iterate for the number of num_idx | +-------------------------------------------------------------------------+ @@ -460,8 +472,10 @@ | Iterate while col_num != 0xffff | +-------------------------------------------------------------------------+ | ???? | 2 bytes | col_num | Column number with variable length | -| ???? | 4 bytes | arg1 | | -| ???? | 4 bytes | arg2 | | +| ???? | 4 bytes | used_pages | Points to a record containing the | +| | | | usage bitmask for this column. | +| ???? | 4 bytes | free_pages | Points to a similar record as above, | +| | | | listing pages which contain free space. | +-------------------------------------------------------------------------+ Columns flags (not complete): @@ -500,6 +514,29 @@ REPID = 0x0F /* GUID */ NUMERIC = 0x10 /* Scaled decimal (17 bytes) */ +Notes on reading index metadata: + +There are 2 types of index metadata, "physical" index info (denoted by +num_real_idx) and "logical" index info (denoted by num_idx). Normally, there +is a 1 to 1 relationship between these 2 types of information. However there +can be more logical index infos than physical index infos (currently only seen +for foreign key indexes). In this situation, one or more of the logical +indexes actually share the same underlying physical index (the index_num2 +indicates which physical index backs which logical index). + +As noted in the previous paragraph, physical index sharing is generally only +seen when a foreign key index has been created. When access creates a +relationship between 2 tables with "enforce referential integrity" enabled, +each of the tables gets an extra logical index with type 2 (foreign key). +These logical indexes contain extra information, primarily pointers to the +related table (rel_tbl_page) and logical index (rel_idx_num). Also, the +rel_tbl_type value indicates which table in the relationship is the "primary" +table (the one one from which cascaded updates/deletes flow). If the indexed +columns for the foreign key are already indexed by another logical index in +the table (e.g. an index which the user has explicitly created), then the +logical foreign key index will simply share the underlying physical index +data. + Notes on deleted and added columns: (sort of Jet4 specific) If a fixed length column is deleted the offset_F field will contain the offsets diff -Nru mdbtools-0.7/INSTALL mdbtools-0.7.1/INSTALL --- mdbtools-0.7/INSTALL 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/INSTALL 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -Basic Installation - from a packaged tarball (.tgz) -=================================================== - -See below if you are installing from git. - - $ ./configure - $ make - -or for a complete install (requires bison, flex, and unixODBC): - - $ ./configure --enable-sql --with-unixodbc=/usr/local - $ make - -This will build some useful utilities: - -mdb-ver -- prints the version (JET 3 or 4) of an mdb file -mdb-dump -- simple hex dump utility that I've been using to look at mdb files -mdb-schema -- prints DDL for the specified table -mdb-export -- export table to CSV format -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 -- if --enable-sql is specified, a simple SQL engine (also used by - ODBC and gmdb). -gmdb2 -- a graphical utility to browse MDB files. - -And some utilities useful for debugging: - -prcat -- prints the catalog table from an mdb file. -prkkd -- dump of information about design view data given the offset to it. -prtable -- dump of a table definition. -prdata -- dump of the data given a table name. -prole -- dump of ole columns given a table name and sargs. - -Once MDB Tools has been compiled, libmdb.[so|a] will be in the src/libmdb -directory and the utility programs will be in the src/util directory. -You can then run 'make install' as root to install (to /usr/local by default). - - -Installation Options -==================== - -configure can be passed any of the following flags to turn on other -capabilities. Note that the options --with-unixodbc and --with-iodbc are -mutually exclusive. - ---enable-sql will cause the SQL engine to be built, you must have flex - and bison (or yacc) installed for this option. ---with-unixodbc specifies the location of the unixODBC driver manager and - causes the unixODBC driver to be built. ---with-iodbc specifies the location of the iODBC driver manager and - causes the iODBC driver to be built. - - -Installation from sources -========================= - -First, you must have reasonably current installations of: - libtool - automake - autoconf -If you don't you should install them first. Sources are available at -ftp.gnu.org. - -Second, download the sources from github: - - $ git clone git://github.com/brianb/mdbtools.git - -Third, run autogen.sh to configure everything: - - $ ./autogen.sh - -- This will run libtoolize, automake, and autoconf. - -Note: FreeBSD systems, as of the time of this writing, have an old version of -libtool (1.3.4) in the ports collection. It works, but requires the presence -of acinclude.m4 in the distribution, which is why it is included. If your -system has a more up-to-date version (1.4.2, at this date), this file is not -needed and, in fact, causes an error when autoconf is run: - ./ltconfig: ./ltconfig: No such file or directory - configure: error: libtool configure failed -If you get this error message, delete the file "acinclude.m4" and run -autogen.sh again. - -At this point, you should resume the instructions at the beginning of this -file. diff -Nru mdbtools-0.7/Makefile.am mdbtools-0.7.1/Makefile.am --- mdbtools-0.7/Makefile.am 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/Makefile.am 2013-10-13 08:51:24.000000000 +0000 @@ -1,3 +1,4 @@ +ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src include doc DEFDIR = $(prefix) diff -Nru mdbtools-0.7/NEWS mdbtools-0.7.1/NEWS --- mdbtools-0.7/NEWS 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/NEWS 2013-10-13 08:51:24.000000000 +0000 @@ -1,3 +1,19 @@ +Version 0.7.1 +============= +autogen.sh is no more. Use "autoreconf -if" to bootstrap the configuration. + +autoconf/automake has been updated to more recent standards. +- config.guess config.sub depcomp install-sh ltmain.sh missing ylwrap + files are now in build-aux/ directory +You'll now need autoconf >= 2.58 + +An experimental (buggy) version of ODBC driver that supports UCS-2 interface +is now available: libmdbodbcW.so +Note that libmdbodbc supports UTF-8 really well, so that this is usually not +needed. + +Version 0.3 +=========== The organization of the project files has changed a bit from that last release. The autoconf stuff has been moved to the root directory. The include directory has also been moved from src/include to include diff -Nru mdbtools-0.7/README mdbtools-0.7.1/README --- mdbtools-0.7/README 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/README 2013-10-13 08:51:24.000000000 +0000 @@ -1,13 +1,31 @@ -This is mdbtools version 0.7 +This is mdbtools version 0.7.1 Welcome to the exciting world of MDB Tools! In short, MDB Tools is a set of programs to help you use Microsoft Access file in various settings. The major pieces are: . libmdb - the core library that allows access to MDB files programatically. -. libmdbsql - builds on libmdb to provide a SQL engine (ala Jet) -. utils - provides command line utilities to list tables, export schema, - and data, show the version of the files, and other useful stuff. +. libmdbsql - builds on libmdb to provide a SQL engine (aka Jet) +. utils - provides command line utilities: + mdb-ver -- prints the version (JET 3 or 4) of an mdb file. + mdb-dump -- simple hex dump utility that I've been using to look + at mdb files. + mdb-schema -- prints DDL for the specified table. + mdb-export -- export table to CSV format. + 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 -- if --enable-sql is specified, a simple SQL engine + (also used by ODBC and gmdb). + - And some utilities useful for debugging: + prcat -- prints the catalog table from an mdb file. + prkkd -- dump of information about design view data given the offset to it. + prtable -- dump of a table definition. + prdata -- dump of the data given a table name. + prole -- dump of ole columns given a table name and sargs. . mdb-sql - a command line SQL tool that allows one to type sql queries and get results. . odbc - An ODBC driver for use with unixODBC or iODBC driver manager. @@ -20,16 +38,83 @@ The initial goal of these tools is to be able to extract data structures and data from mdb files. This goal will of course expand over time as the file -format becomes more well understood. +format becomes more well understood. -Files in libmdb, libmdbsql, and libmdbodbc are licensed under LGPL and the -utilities and gui program are under the GPL, see COPYING.LIB and COPYING files +Files in libmdb, libmdbsql, and libmdbodbc are licensed under LGPL and the +utilities and gui program are under the GPL, see COPYING.LIB and COPYING files respectively. -To install see the INSTALL file -Check out https://github.com/brianb/mdbtools for latest version of sources. -Check out http://mdbtools.sourceforge.net for mailing list and similar. +Requirements: +============= + +First, you must have reasonably current installations of: + libtool + automake + autoconf (version >= 2.58) +If you don't you should install them first. Sources are available at +ftp.gnu.org. + +If you want to build the SQL engine, you'll need bison or byacc, and flex. + +If you want to build the ODBC driver, you'll need unixodbc (version 2.2.10 or +above) or iodbc. + +If you want to build man pages, you'll need txt2man. Source is available at +http://mvertes.free.fr/download/. + +If you want to generate the html version of the docbook, you'll need openjade +and basic dsl catalogs. + + +Installation from source: +========================= + +Last version is available at https://github.com/brianb/mdbtools + + $ autoreconf -i -f + +If you want to build the html version of the docbook documentation, you need to +set the environment variable DOCBOOK_DSL to the modular dsl translation file. +For exemple, before configure, you need something like: + + $ export DOCBOOK_DSL=/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl + + $ ./configure + +OR for a complete install (requires bison, flex, and unixODBC): + + $ ./configure --with-unixodbc=/usr/local + +configure can be passed any of the following flags to turn on other +capabilities. Note that the options --with-unixodbc and --with-iodbc are +mutually exclusive. +--with-unixodbc specifies the location of the unixODBC driver manager and + causes the unixODBC driver to be built. +--with-iodbc specifies the location of the iODBC driver manager and + causes the iODBC driver to be built. +A list of general options is available in the INSTALL file, and +"configure --help" will give you the list of mdbtools specific options. + + $ make + +Once MDB Tools has been compiled, libmdb.[so|a] will be in the src/libmdb +directory and the utility programs will be in the src/util directory. + +You can then run 'make install' as root to install (to /usr/local by default). +Some systems will also need the ld cache to be updated after installation; +You can do that running 'ldconfig' as root. + + +Contacts +======== + +The mailing list from the old site a available at +http://mdbtools.sourceforge.net + +Please send bug repports to the new github platform. +https://github.com/brianb/mdbtools/issues + Brian Bruns brian@bruns.com diff -Nru mdbtools-0.7/TODO mdbtools-0.7.1/TODO --- mdbtools-0.7/TODO 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/TODO 2013-10-13 08:51:24.000000000 +0000 @@ -3,7 +3,7 @@ general: -. compile with -Wall and fix warnings +. compile with -Wall and fix warnings (done) file format: diff -Nru mdbtools-0.7/acinclude.m4 mdbtools-0.7.1/acinclude.m4 --- mdbtools-0.7/acinclude.m4 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/acinclude.m4 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -AC_DEFUN([VL_LIB_READLINE], [ - AC_CACHE_CHECK([for a readline compatible library], - vl_cv_lib_readline, [ - ORIG_LIBS="$LIBS" - for readline_lib in readline edit editline; do - for termcap_lib in "" termcap curses ncurses; do - TRY_LIB="-l$readline_lib" - if test -n "$termcap_lib"; then - TRY_LIB="$TRY_LIB -l$termcap_lib" - fi - LIBS="$ORIG_LIBS $TRY_LIB" - AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline=yes) - if test "$vl_cv_lib_readline" = yes; then - break - fi - done - if test "$vl_cv_lib_readline" = yes; then - break - fi - done - ]) - - if test "$vl_cv_lib_readline" = yes; then - AC_DEFINE(HAVE_LIBREADLINE, 1, - [Define if you have a readline compatible library]) - AC_CHECK_HEADERS(readline.h readline/readline.h) - AC_CACHE_CHECK([whether readline supports history], - vl_cv_lib_readline_history, [ - AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history=yes) - ]) - if test "$vl_cv_lib_readline_history" = yes; then - AC_DEFINE(HAVE_READLINE_HISTORY, 1, - [Define if your readline library has \`add_history']) - AC_CHECK_HEADERS(history.h readline/history.h) - fi - fi - LIBS="$ORIG_LIBS" - - LIBREADLINE= - if test "$vl_cv_lib_readline" = yes; then - LIBREADLINE="$TRY_LIB" - fi - AC_SUBST(LIBREADLINE) -])dnl - -dnl From Bruno Haible. - -AC_DEFUN([AM_ICONV], -[ - dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and - dnl those with the standalone portable GNU libiconv installed). - - AC_ARG_WITH([libiconv-prefix], -AC_HELP_STRING([--with-libiconv-prefix=DIR], [search for libiconv in DIR/include and DIR/lib]), [ - for dir in `echo "$withval" | tr : ' '`; do - if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi - if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi - done - ]) - - AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - am_cv_func_iconv=yes) - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS -liconv" - AC_TRY_LINK([#include -#include ], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], - am_cv_lib_iconv=yes - am_cv_func_iconv=yes) - LIBS="$am_save_LIBS" - fi - ]) - if test "$am_cv_func_iconv" = yes; then - AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) - AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL(am_cv_proto_iconv, [ - AC_TRY_COMPILE([ -#include -#include -extern -#ifdef __cplusplus -"C" -#endif -#if defined(__STDC__) || defined(__cplusplus) -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif -], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) - am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([$]{ac_t:- - }[$]am_cv_proto_iconv) - AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, - [Define as const if the declaration of iconv() needs const.]) - fi - LIBICONV= - if test "$am_cv_lib_iconv" = yes; then - LIBICONV="-liconv" - fi - AC_SUBST(LIBICONV) -]) diff -Nru mdbtools-0.7/autogen.sh mdbtools-0.7.1/autogen.sh --- mdbtools-0.7/autogen.sh 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/autogen.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -#!/bin/sh -# Run this to generate all the initial makefiles, etc. - -# (Copied from output generated by Glade 0.6.2 and modified by James -# Cameron for the FreeTDS project. Changes were to PKG_NAME only.) -# Copied from FreeTDS to MDB Tools by Brian Bruns. - -srcdir=`dirname $0` -PKG_NAME="MDBTools." - -DIE=0 - -(autoconf --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "**Error**: You must have \`autoconf' installed." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - DIE=1 -} - -grep "^A[CM]_PROG_LIBTOOL" configure.in >/dev/null && { - if which libtoolize && (libtooloze --version) < /dev/null > /dev/null 2>&1; then - LIBTOOLIZE=libtoolize - else - if which glibtoolize && (glibtoolize --version) < /dev/null > /dev/null 2>&1; then - LIBTOOLIZE=glibtoolize - else - echo - echo "**Error**: You must have \`libtool' installed." - echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz" - echo "(or a newer version if it is available)" - DIE=1 - fi - fi -} - -grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && { - grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ - (gettext --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "**Error**: You must have \`gettext' installed." - echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" - echo "(or a newer version if it is available)" - DIE=1 - } -} - -grep "^AM_GNOME_GETTEXT" $srcdir/configure.in >/dev/null && { - grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ - (gettext --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "**Error**: You must have \`gettext' installed." - echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" - echo "(or a newer version if it is available)" - DIE=1 - } -} - -(automake --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "**Error**: You must have \`automake' installed." - echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" - echo "(or a newer version if it is available)" - DIE=1 - NO_AUTOMAKE=yes -} - - -# if no automake, don't bother testing for aclocal -test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "**Error**: Missing \`aclocal'. The version of \`automake'" - echo "installed doesn't appear recent enough." - echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" - echo "(or a newer version if it is available)" - DIE=1 -} - -if test "$DIE" -eq 1; then - exit 1 -fi - -if test x$NOCONFIGURE = x; then -if test -z "$*"; then - echo "**Warning**: I am going to run \`configure' with no arguments." - echo "If you wish to pass any to it, please specify them on the" - echo \`$0\'" command line." - echo -fi -fi - -case $CC in -xlc ) - am_opt=--include-deps;; -esac - -for coin in `find $srcdir -name configure.in -print` -do - dr=`dirname $coin` - if test -f $dr/NO-AUTO-GEN; then - echo skipping $dr -- flagged as no auto-gen - else - echo processing $dr - macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin` - ( cd $dr - aclocalinclude="$ACLOCAL_FLAGS" - for k in $macrodirs; do - if test -d $k; then - aclocalinclude="$aclocalinclude -I $k" - ##else - ## echo "**Warning**: No such directory \`$k'. Ignored." - fi - done - if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then - if grep "sed.*POTFILES" configure.in >/dev/null; then - : do nothing -- we still have an old unmodified configure.in - else - echo "Creating $dr/aclocal.m4 ..." - test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 - echo "Running gettextize... Ignore non-fatal messages." - echo "no" | gettextize --force --copy - echo "Making $dr/aclocal.m4 writable ..." - test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 - fi - fi - if grep "^AM_GNOME_GETTEXT" configure.in >/dev/null; then - echo "Creating $dr/aclocal.m4 ..." - test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 - echo "Running gettextize... Ignore non-fatal messages." - echo "no" | gettextize --force --copy - echo "Making $dr/aclocal.m4 writable ..." - test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 - fi - echo "Running aclocal $aclocalinclude ..." - aclocal $aclocalinclude - if grep "^A[CM]_PROG_LIBTOOL" configure.in >/dev/null; then - echo "Running libtoolize..." - ${LIBTOOLIZE} --force --copy - fi - if grep "^A[CM]_CONFIG_HEADER" configure.in >/dev/null; then - echo "Running autoheader..." - autoheader - fi - echo "Running automake --gnu $am_opt ..." - automake --add-missing --gnu --copy $am_opt - echo "Running autoconf ..." - autoconf - ) - fi -done - -#conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c - -if test x$NOCONFIGURE = x; then - echo Running $srcdir/configure $conf_flags "$@" ... - $srcdir/configure $conf_flags "$@" \ - && echo Now type \`make\' to compile $PKG_NAME -else - echo Skipping configure process. -fi diff -Nru mdbtools-0.7/configure.ac mdbtools-0.7.1/configure.ac --- mdbtools-0.7/configure.ac 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/configure.ac 2013-10-13 08:51:24.000000000 +0000 @@ -0,0 +1,240 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT([mdbtools],[0.7.1],[mdbtools-dev@lists.sourceforge.net]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_SRCDIR(src/extras/mdb-dump.c) +AM_INIT_AUTOMAKE + +AM_MAINTAINER_MODE([enable]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +AC_PROG_CC(gcc) +dnl Checks for programs. +AC_PROG_MAKE_SET +AM_PROG_AR +LT_INIT +AC_PROG_LEX +AC_PROG_YACC + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h limits.h unistd.h) +AC_CHECK_HEADERS(wordexp.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +AM_ICONV +AM_GCC_ATTRIBUTE_ALIAS + +dnl no optional stuff by default +OPTDIRS="" + +dnl --------------------------------------------------------------------- +dnl Compile time options +dnl --------------------------------------------------------------------- + +sql=true +AC_MSG_CHECKING( Are we using flex ) +if test "x$LEX" = "xflex"; then +LFLAGS="$LFLAGS -i -8" +AC_MSG_RESULT( yes ); +else +AC_MSG_RESULT( no - SQL engine disable); +sql=false +fi + +if ! $YACC -V >/dev/null 2>&1; then +sql=false +fi + +if test "x$sql" = "xtrue"; then + CFLAGS="$CFLAGS -DSQL" + OPTDIRS="$OPTDIRS sql" +else + AC_MSG_WARN([Yacc is not available: SQL disabled.]) +fi + +AM_CONDITIONAL(SQL, test x$sql = xtrue) +AC_SUBST(SQL) +AC_SUBST(LFLAGS) + +CFLAGS="$CFLAGS -Wall" +dnl Enable -Wl,--as-needed by default to prevent overlinking + +AC_ARG_ENABLE([as-needed], + AS_HELP_STRING([--disable-as-needed],[Disable overlinking protection]), + [enable_as_needed=$enableval], [enable_as_needed=yes]) + +if test "x$enable_as_needed" != "xno"; then + AC_MSG_CHECKING([whether $LD accepts --as-needed]) + case `$LD --as-needed -v 2>&1 = 2.14 libglade-2.0 libgnomeui-2.0, HAVE_GNOME=true, HAVE_GNOME=false) + +AC_ARG_ENABLE(gmdb2, + AS_HELP_STRING([--disable-gmdb2],[do not build gmdb2]), + [build_gmdb2=$enableval], [build_gmdb2=yes]) + +if test "$build_gmdb2" = "yes" ; then + if test "x$HAVE_GNOME" = "xtrue"; then + AC_SUBST(GNOME_CFLAGS) + AC_SUBST(GNOME_LIBS) + OPTDIRS="$OPTDIRS gmdb2" + fi +else + AC_MSG_NOTICE(gmdb2 disabled) +fi + +AC_SUBST([OPTDIRS]) +AC_CONFIG_FILES([src/Makefile]) + + +################################################## +# Check for gtk-doc. +################################################## + +AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ]) + +if test "x$with_html_dir" = "x" ; then + HTML_DIR='${datadir}/gtk-doc/html' +else + HTML_DIR=$with_html_dir +fi + +AC_SUBST(HTML_DIR) + +gtk_doc_min_version=1.0 +AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version]) +if pkg-config --atleast-version=$gtk_doc_min_version gtk-doc; then + AC_MSG_RESULT(yes) + GTKDOC=true +else + AC_MSG_RESULT(no) + GTKDOC=false +fi + +dnl Let people disable the gtk-doc stuff. +AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc Use gtk-doc to build documentation [default=auto]], enable_gtk_doc="$enableval", enable_gtk_doc=auto) + +if test x$enable_gtk_doc = xauto ; then + if test x$GTKDOC = xtrue ; then + enable_gtk_doc=yes + else + enable_gtk_doc=no + fi +fi + +AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes) + +################################################## +# Check for txt2man +################################################## + +AC_ARG_ENABLE(man, [ --disable-man Disable man generation], enable_man="$enableval", [enable_man=yes]) +if test "$enable_man" = yes; then + if ! which txt2man > /dev/null; then + AC_MSG_ERROR([Could not find txt2man script. Install it or configure with --disable-man if you are not interrested in manuals.]) + fi +fi +AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" = yes) + +################################################## +# Check for docbook +################################################## +AM_CONDITIONAL(ENABLE_DOCBOOK, test -n "$DOCBOOK_DSL") + +dnl Checks for library functions. +VL_LIB_READLINE + +localedir=${datadir}/locale +AC_SUBST(localedir) + +AC_CONFIG_FILES([ +libmdb.pc +libmdbsql.pc +src/util/Makefile +src/extras/Makefile +Makefile include/Makefile +src/libmdb/Makefile +src/sql/Makefile +src/odbc/Makefile +doc/Makefile +src/gmdb2/Makefile +src/gmdb2/gladefiles/Makefile +src/gmdb2/pixmaps/Makefile +src/gmdb2/help/Makefile +src/gmdb2/help/C/Makefile +mdbtools.spec +include/mdbver.h]) +AC_OUTPUT +dnl doc/reference/libmdb/Makefile]) diff -Nru mdbtools-0.7/configure.in mdbtools-0.7.1/configure.in --- mdbtools-0.7/configure.in 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/configure.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(mdbtools, 0.7, [mdbtools-dev@lists.sourceforge.net]) -AC_CONFIG_SRCDIR(src/extras/mdb-dump.c) -AM_INIT_AUTOMAKE - -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -AC_CONFIG_HEADERS(include/config.h) - -AC_PROG_CC(gcc) -dnl Checks for programs. -AC_PROG_MAKE_SET -AC_PROG_LIBTOOL -AM_PROG_LEX -AC_PROG_YACC - -dnl Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h limits.h unistd.h) -AC_CHECK_HEADERS(wordexp.h) - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -AM_ICONV - -# add -DHAVE_INCONV to CFLAGS. We should not use #include in -# public headers -if test "$am_cv_func_iconv" = "yes"; then - CFLAGS="$CFLAGS -DHAVE_ICONV" -fi - -dnl no optional stuff by default -OPTDIRS="" - -dnl --------------------------------------------------------------------- -dnl Compile time options -dnl --------------------------------------------------------------------- - -sql=true -AC_MSG_CHECKING( Are we using flex ) -if test "x$LEX" = "xflex"; then -LFLAGS="$LFLAGS -i -8" -AC_MSG_RESULT( yes ); -else -AC_MSG_RESULT( no - SQL engine disable); -sql=false -fi - -if test "x$YACC" = "x"; then -sql=false -fi - -if test "x$sql" = "xtrue"; then - CFLAGS="$CFLAGS -DSQL" - OPTDIRS="$OPTDIRS sql" -fi - -AM_CONDITIONAL(SQL, test x$sql = xtrue) -AC_SUBST(SQL) -AC_SUBST(LFLAGS) - -LDFLAGS="$LDFLAGS -Wl,--as-needed" - -dnl check for iODBC - -AC_ARG_WITH(iodbc, -[ --with-iodbc=/path/to/iodbc build odbc driver against iODBC]) -if test "$with_iodbc"; then - HAVE_ODBC=true - ODBC_CFLAGS="-I$with_iodbc/include" - ODBC_LIBS="-L$with_iodbc/lib" - CFLAGS="$CFLAGS -DIODBC" - - OLDLDFLAGS=$LDFLAGS - LDFLAGS="$LDFLAGS $ODBC_LIBS" - AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString, - [ODBC_LIBS="$ODBC_LIBS -liodbcinst" - AC_DEFINE_UNQUOTED(HAVE_SQLGETPRIVATEPROFILESTRING, 1, - [Define to 1 if you have the SQLGetPrivateProfileString function.])]) - LDFLAGS=$OLDLDFLAGS -fi - -dnl check for unixODBC -AC_ARG_WITH(unixodbc, -[ --with-unixodbc=/path/to/unixodbc build odbc driver against unixODBC]) -if test "$with_unixodbc"; then - HAVE_ODBC=true - ODBC_CFLAGS="-I$with_unixodbc/include" - ODBC_LIBS="-L$with_unixodbc/lib" - CFLAGS="$CFLAGS -DUNIXODBC" - - OLDLDFLAGS=$LDFLAGS - LDFLAGS="$LDFLAGS $ODBC_LIBS" - AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString, - [ODBC_LIBS="$ODBC_LIBS -lodbcinst" - AC_DEFINE_UNQUOTED(HAVE_SQLGETPRIVATEPROFILESTRING, 1, - [Define to 1 if you have the SQLGetPrivateProfileString function.])]) - LDFLAGS=$OLDLDFLAGS -fi - -if test "x$HAVE_ODBC" = "xtrue"; then - if test "x$sql" != "xtrue" ; then - echo - echo ODBC requires flex and bison for the SQL engine - exit 1 - fi - - AC_SUBST(ODBC_CFLAGS) - AC_SUBST(ODBC_LIBS) - OPTDIRS="$OPTDIRS odbc" -fi - - -dnl check for glib/gtk/gnome -PKG_CHECK_MODULES(GLIB, glib-2.0, , - AC_MSG_ERROR([ -glib 2.0 is required by MDB Tools (runtime and devel). -It can be downloaded at www.gtk.org. -])) - -PKG_CHECK_MODULES(GNOME,gtk+-2.0 >= 2.14 libglade-2.0 libgnomeui-2.0, HAVE_GNOME=true, HAVE_GNOME=false) - -AC_ARG_ENABLE(gmdb2, - AC_HELP_STRING([--disable-gmdb2], [do not build gmdb2]), - [build_gmdb2=$enableval], [build_gmdb2=yes]) - -if test "$build_gmdb2" = "yes" ; then - if test "x$HAVE_GNOME" = "xtrue"; then - AC_SUBST(GNOME_CFLAGS) - AC_SUBST(GNOME_LIBS) - OPTDIRS="$OPTDIRS gmdb2" - fi -else - AC_MSG_NOTICE(gmdb2 disabled) -fi - -AC_SUBST([OPTDIRS]) -AC_CONFIG_FILES([src/Makefile]) - - -################################################## -# Check for gtk-doc. -################################################## - -AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ]) - -if test "x$with_html_dir" = "x" ; then - HTML_DIR='${datadir}/gtk-doc/html' -else - HTML_DIR=$with_html_dir -fi - -AC_SUBST(HTML_DIR) - -gtk_doc_min_version=1.0 -AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version]) -if pkg-config --atleast-version=$gtk_doc_min_version gtk-doc; then - AC_MSG_RESULT(yes) - GTKDOC=true -else - AC_MSG_RESULT(no) - GTKDOC=false -fi - -dnl Let people disable the gtk-doc stuff. -AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc Use gtk-doc to build documentation [default=auto]], enable_gtk_doc="$enableval", enable_gtk_doc=auto) - -if test x$enable_gtk_doc = xauto ; then - if test x$GTKDOC = xtrue ; then - enable_gtk_doc=yes - else - enable_gtk_doc=no - fi -fi - -AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes) - -AM_CONDITIONAL(ENABLE_DOCBOOK, test -n "$DOCBOOK_DSL") - -dnl Checks for library functions. -VL_LIB_READLINE - -localedir=${datadir}/locale -AC_SUBST(localedir) - -AC_OUTPUT([ -libmdb.pc -libmdbsql.pc -src/util/Makefile -src/extras/Makefile -Makefile include/Makefile -src/libmdb/Makefile -src/sql/Makefile -src/odbc/Makefile -doc/Makefile -src/gmdb2/Makefile -src/gmdb2/gladefiles/Makefile -src/gmdb2/pixmaps/Makefile -src/gmdb2/help/Makefile -src/gmdb2/help/C/Makefile -mdbtools.spec -include/mdbver.h]) -dnl doc/reference/libmdb/Makefile]) diff -Nru mdbtools-0.7/debian/changelog mdbtools-0.7.1/debian/changelog --- mdbtools-0.7/debian/changelog 2013-07-12 00:30:01.000000000 +0000 +++ mdbtools-0.7.1/debian/changelog 2013-11-27 17:21:38.000000000 +0000 @@ -1,3 +1,41 @@ +mdbtools (0.7.1-1ubuntu1) trusty; urgency=low + + * Add docbook-xml and rarian-compat to build deps since + ubuntu buildd's are a bit more picky about the network. + + -- Rohan Garg Wed, 27 Nov 2013 18:20:01 +0100 + +mdbtools (0.7.1-1) unstable; urgency=low + + * Added keywords to gmdb.desktop, thanks lintian. + * New upstream version + - Support for ucs2 odbc (Closes: #675543) + - Fix mdb-array crash when file is not found (Closes: #716325) + - drop override_dh_autoreconf in rules since upstream INSTALL is gone. + - Refresh patch use_lib_odbc_dir. All other patches are gone, there were + applied upstream. + - Acknowledge new symbols in libmdb2. + - Drop -Wall since it is now upstream. + - Refresh copyright file. + * ODBC driver is no longer shipped as a versioned library: + - Rename libmdbodbc1 into odbc-mdbtools. + - Added back transitionnal package libmdbodbc1. + - Drop odbc-mdbtools.symbols and added -q in dpkg-gensymbols. + - Drop version in odbc-mdbtools.postinst and odbc-mdbtools.install. + * New patch use_common_license so that gmdb prints license from + /usr/share/common-licenses/. This quiets lintian. + * Stop using scrollkeeper: + - Drop build-dependency on rarian-compat. (Closes: #718465) + - New patch gnome-doc from upstream commit. + - New build-dependency on gnome-doc-utils. + - Add --disable-scrollkeeper in debian/rules. + - Add debian/clean to remove gnome-doc tmp file. + - Disable portability warnings in autoreconf (rules): gnome-doc generates + pages of ugly warnings otherwise. + * Bumped policy to 3.9.5: No change required. + + -- Jean-Michel Vourgère Tue, 29 Oct 2013 09:29:15 +0100 + mdbtools (0.7-3) unstable; urgency=low * Authorise byacc as an alternative for bison in Build-Deps. diff -Nru mdbtools-0.7/debian/clean mdbtools-0.7.1/debian/clean --- mdbtools-0.7/debian/clean 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/debian/clean 2013-10-29 08:31:18.000000000 +0000 @@ -0,0 +1,2 @@ +# Delete new intermediate file generated by gnome-doc patch +src/gmdb2/help/gmdb-C.omf diff -Nru mdbtools-0.7/debian/control mdbtools-0.7.1/debian/control --- mdbtools-0.7/debian/control 2013-07-12 00:18:22.000000000 +0000 +++ mdbtools-0.7.1/debian/control 2013-11-27 17:16:57.000000000 +0000 @@ -11,6 +11,7 @@ docbook, docbook-dsssl, flex, + gnome-doc-utils, libglade2-dev, libglib2.0-dev, libgnomeui-dev, @@ -18,12 +19,12 @@ libreadline-dev, libtool, openjade, - rarian-compat, texinfo, txt2man, - unixodbc-dev + unixodbc-dev, + docbook-xml, rarian-compat Build-Conflicts: autoconf2.13 -Standards-Version: 3.9.4 +Standards-Version: 3.9.5 Homepage: http://mdbtools.sourceforge.net/ Vcs-Git: git://anonscm.debian.org/collab-maint/mdbtools.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/mdbtools.git @@ -59,8 +60,8 @@ Section: devel Depends: libglib2.0-dev, libmdb2 (= ${binary:Version}), - libmdbodbc1 (= ${binary:Version}), libmdbsql2 (= ${binary:Version}), + odbc-mdbtools (= ${binary:Version}), ${misc:Depends} Suggests: mdbtools-doc Description: mdbtools development files @@ -95,7 +96,7 @@ . See mdb-sql util in mdbtools package. -Package: libmdbodbc1 +Package: odbc-mdbtools Architecture: any Multi-Arch: same Section: libs @@ -103,8 +104,12 @@ Depends: ${misc:Depends}, ${shlibs:Depends} Recommends: libodbc1 Suggests: mdbtools-doc -Breaks: libiodbc2 (<< 3.52.7-2+deb7u1), odbcinst1debian2 (<< 2.2.14p2-3), unixodbc (<< 2.2.14p2-3) -Description: MDB tools ODBC module +Breaks: libiodbc2 (<< 3.52.7-2+deb7u1), + libmdbodbc1 (<< 0.7.1-1~), + odbcinst1debian2 (<< 2.2.14p2-3), + unixodbc (<< 2.2.14p2-3) +Replaces: libmdbodbc1 (<< 0.7.1-1~) +Description: MDB tools ODBC driver This is the software driver to access JET / MS Access database (MDB) files through ODBC. This also contains the installation interface for unixodbc. @@ -115,16 +120,16 @@ Priority: extra Section: debug Depends: libmdb2 (= ${binary:Version}), - libmdbodbc1 (= ${binary:Version}), libmdbsql2 (= ${binary:Version}), mdbtools (= ${binary:Version}), mdbtools-gmdb (= ${binary:Version}), + odbc-mdbtools (= ${binary:Version}), ${misc:Depends} Description: Debug symbols for MDB Tools MDB tools are used to manipulate JET / MS Access database (MDB) files. . Contains debug symbols for packages mdbtools, libmdb2, libmdbsql2, - libmdbodbc1 and mdbtools-gmdb. + odbc-mdbtools and mdbtools-gmdb. Package: mdbtools-doc Architecture: all @@ -135,3 +140,12 @@ . This package contains a description of the .mdb format, some FAQ and a guide describing common problems such as charset configuration and ODBC usage. + +Package: libmdbodbc1 +Architecture: all +Section: oldlibs +Priority: extra +Depends: odbc-mdbtools, ${misc:Depends} +Description: Transitional package for odbc-mdbtools + This is a transitional package to ease upgrades to the odbc-mdbtools package. + It can safely be removed. diff -Nru mdbtools-0.7/debian/copyright mdbtools-0.7.1/debian/copyright --- mdbtools-0.7/debian/copyright 2013-06-22 14:11:30.000000000 +0000 +++ mdbtools-0.7.1/debian/copyright 2013-10-29 08:17:25.000000000 +0000 @@ -17,16 +17,11 @@ Rene Engelhard Vincent Fourmond Tim Retout - 2011 Nirgal Vourgère + 2011-2013 Jean-Michel Vourgère License: GPL-2+ -Files: include/mdbprivate.h - include/mdbtools.h - include/mdbsql.h - include/mdbodbc.h - include/mdbver.h.in - libmdb.pc.in - libmdbsql.pc.in +Files: include/* + lib*.pc.in src/libmdb/* src/sql/* src/odbc/* @@ -43,12 +38,7 @@ Rene Engelhard Vincent Fourmond Tim Retout - 2011 Nirgal Vourgère -License: LGPL-2+ - -Files: src/gmdb/gtklist.* -Copyright: 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - 1997-1999 The GTK+ Team. + 2011-2013 Jean-Michel Vourgère License: LGPL-2+ Files: debian/* @@ -62,14 +52,12 @@ 2007 Matej Vela 2008-2010 Tim Retout 2011 Luk Claes - 2011-2012 Nirgal Vourgère - 2012 Nelson A. de Oliveira + 2011-2013 Jean-Michel Vourgère + 2012 Nelson A. de Oliveira License: GPL-2+ Files: debian/patches/01_use_lib_odbc_dir - debian/patches/export_repid_uuid_as_string_use_char_38_in_mysql -Copyright: 2011-2012 Nirgal Vourgère - 2012 Will Daniels +Copyright: 2011-2013 Jean-Michel Vourgère License: LGPL-2+ Files: doc/* diff -Nru mdbtools-0.7/debian/libmdb2.symbols mdbtools-0.7.1/debian/libmdb2.symbols --- mdbtools-0.7/debian/libmdb2.symbols 2013-06-22 14:11:30.000000000 +0000 +++ mdbtools-0.7.1/debian/libmdb2.symbols 2013-10-29 08:17:25.000000000 +0000 @@ -4,7 +4,6 @@ mdb_add_row_to_pg@Base 0.5.99.0.6pre1.0.20051109 mdb_add_sarg@Base 0.5.99.0.6pre1.0.20051109 mdb_add_sarg_by_name@Base 0.5.99.0.6pre1.0.20051109 - mdb_buffer_dump@Base 0.7~rc1 mdb_alloc_page@Base 0.5.99.0.6pre1.0.20051109 mdb_alloc_props@Base 0.5.99.0.6pre1.0.20051109 mdb_alloc_tabledef@Base 0.5.99.0.6pre1.0.20051109 @@ -13,6 +12,7 @@ mdb_backends@Base 0.5.99.0.6pre1.0.20051109 mdb_bind_column@Base 0.5.99.0.6pre1.0.20051109 mdb_bind_column_by_name@Base 0.5.99.0.6pre1.0.20051109 + mdb_buffer_dump@Base 0.7~rc1 mdb_chain_add_page@Base 0.5.99.0.6pre1.0.20051109 mdb_choose_index@Base 0.5.99.0.6pre1.0.20051109 mdb_clone_handle@Base 0.5.99.0.6pre1.0.20051109 @@ -48,6 +48,7 @@ mdb_free_props@Base 0.5.99.0.6pre1.0.20051109 mdb_free_tabledef@Base 0.5.99.0.6pre1.0.20051109 mdb_get_byte@Base 0.5.99.0.6pre1.0.20051109 + mdb_get_catalogentry_by_name@Base 0.7.1 mdb_get_colbacktype@Base 0.7~rc1 mdb_get_colbacktype_string@Base 0.7~rc1 mdb_get_coltype_string@Base 0.5.99.0.6pre1.0.20051109 @@ -107,6 +108,9 @@ mdb_pg_get_int32@Base 0.5.99.0.6pre1.0.20051109 mdb_pg_get_single@Base 0.5.99.0.6pre1.0.20051109 mdb_print_schema@Base 0.7~rc1 + mdb_put_int16@Base 0.7.1 + mdb_put_int32@Base 0.7.1 + mdb_put_int32_msb@Base 0.7.1 mdb_read_alt_pg@Base 0.5.99.0.6pre1.0.20051109 mdb_read_catalog@Base 0.5.99.0.6pre1.0.20051109 mdb_read_columns@Base 0.5.99.0.6pre1.0.20051109 diff -Nru mdbtools-0.7/debian/libmdbodbc1.install mdbtools-0.7.1/debian/libmdbodbc1.install --- mdbtools-0.7/debian/libmdbodbc1.install 2013-06-22 14:11:30.000000000 +0000 +++ mdbtools-0.7.1/debian/libmdbodbc1.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -debian/tmp/usr/lib/*/odbc/libmdbodbc*.so.* diff -Nru mdbtools-0.7/debian/libmdbodbc1.postinst mdbtools-0.7.1/debian/libmdbodbc1.postinst --- mdbtools-0.7/debian/libmdbodbc1.postinst 2013-06-22 14:11:30.000000000 +0000 +++ mdbtools-0.7.1/debian/libmdbodbc1.postinst 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -#!/bin/sh -# postinst script for libmdbodbc -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - -odbcinsttemplate() { - cat - <<-EOS - [MDBTools] - Description = MDBTools Driver - Driver = libmdbodbc.so.1 - Setup = libmdbodbc.so.1 - FileUsage = 1 - EOS -} - -case "$1" in - configure) - odbcinsttemplate | odbcinst -i -d -r -v - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff -Nru mdbtools-0.7/debian/libmdbodbc1.prerm mdbtools-0.7.1/debian/libmdbodbc1.prerm --- mdbtools-0.7/debian/libmdbodbc1.prerm 2013-06-22 14:11:30.000000000 +0000 +++ mdbtools-0.7.1/debian/libmdbodbc1.prerm 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -#!/bin/sh -# prerm script for libmdbodbc -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `remove' -# * `upgrade' -# * `failed-upgrade' -# * `remove' `in-favour' -# * `deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - -case "$1" in - remove|upgrade|deconfigure) - # yes, even for upgrade - odbcinst -u -d -n "MDBTools" -v - ;; - - failed-upgrade) - ;; - - *) - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff -Nru mdbtools-0.7/debian/libmdbodbc1.symbols mdbtools-0.7.1/debian/libmdbodbc1.symbols --- mdbtools-0.7/debian/libmdbodbc1.symbols 2013-06-22 14:11:30.000000000 +0000 +++ mdbtools-0.7.1/debian/libmdbodbc1.symbols 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -libmdbodbc.so.1 libmdbodbc1 #MINVER# - ODBCINSTGetProperties@Base 0.5.99.0.6pre1.0.20051109 - SQLAllocConnect@Base 0.5.99.0.6pre1.0.20051109 - SQLAllocEnv@Base 0.5.99.0.6pre1.0.20051109 - SQLAllocHandle@Base 0.5.99.0.6pre1.0.20051109 - SQLAllocStmt@Base 0.5.99.0.6pre1.0.20051109 - SQLBindCol@Base 0.5.99.0.6pre1.0.20051109 - SQLBindParameter@Base 0.5.99.0.6pre1.0.20051109 - SQLBrowseConnect@Base 0.5.99.0.6pre1.0.20051109 - SQLCancel@Base 0.5.99.0.6pre1.0.20051109 - SQLColAttributes@Base 0.5.99.0.6pre1.0.20051109 - SQLColumnPrivileges@Base 0.5.99.0.6pre1.0.20051109 - SQLColumns@Base 0.5.99.0.6pre1.0.20051109 - SQLConnect@Base 0.5.99.0.6pre1.0.20051109 - SQLDataSources@Base 0.5.99.0.6pre1.0.20051109 - SQLDescribeCol@Base 0.5.99.0.6pre1.0.20051109 - SQLDescribeParam@Base 0.5.99.0.6pre1.0.20051109 - SQLDisconnect@Base 0.5.99.0.6pre1.0.20051109 - SQLDriverConnect@Base 0.5.99.0.6pre1.0.20051109 - SQLDrivers@Base 0.5.99.0.6pre1.0.20051109 - SQLError@Base 0.5.99.0.6pre1.0.20051109 - SQLExecDirect@Base 0.5.99.0.6pre1.0.20051109 - SQLExecute@Base 0.5.99.0.6pre1.0.20051109 - SQLExtendedFetch@Base 0.5.99.0.6pre1.0.20051109 - SQLFetch@Base 0.5.99.0.6pre1.0.20051109 - SQLForeignKeys@Base 0.5.99.0.6pre1.0.20051109 - SQLFreeConnect@Base 0.5.99.0.6pre1.0.20051109 - SQLFreeEnv@Base 0.5.99.0.6pre1.0.20051109 - SQLFreeHandle@Base 0.5.99.0.6pre1.0.20051109 - SQLFreeStmt@Base 0.5.99.0.6pre1.0.20051109 - SQLGetConnectOption@Base 0.5.99.0.6pre1.0.20051109 - SQLGetCursorName@Base 0.5.99.0.6pre1.0.20051109 - SQLGetData@Base 0.5.99.0.6pre1.0.20051109 - SQLGetFunctions@Base 0.5.99.0.6pre1.0.20051109 - SQLGetInfo@Base 0.5.99.0.6pre1.0.20051109 - SQLGetStmtAttr@Base 0.5.99.0.6pre1.0.20051109 - SQLGetStmtOption@Base 0.5.99.0.6pre1.0.20051109 - SQLGetTypeInfo@Base 0.5.99.0.6pre1.0.20051109 - SQLMoreResults@Base 0.5.99.0.6pre1.0.20051109 - SQLNativeSql@Base 0.5.99.0.6pre1.0.20051109 - SQLNumParams@Base 0.5.99.0.6pre1.0.20051109 - SQLNumResultCols@Base 0.5.99.0.6pre1.0.20051109 - SQLParamData@Base 0.5.99.0.6pre1.0.20051109 - SQLParamOptions@Base 0.5.99.0.6pre1.0.20051109 - SQLPrepare@Base 0.5.99.0.6pre1.0.20051109 - SQLPrimaryKeys@Base 0.5.99.0.6pre1.0.20051109 - SQLProcedureColumns@Base 0.5.99.0.6pre1.0.20051109 - SQLProcedures@Base 0.5.99.0.6pre1.0.20051109 - SQLPutData@Base 0.5.99.0.6pre1.0.20051109 - SQLRowCount@Base 0.5.99.0.6pre1.0.20051109 - SQLSetConnectOption@Base 0.5.99.0.6pre1.0.20051109 - SQLSetCursorName@Base 0.5.99.0.6pre1.0.20051109 - SQLSetEnvAttr@Base 0.5.99.0.6pre1.0.20051109 - SQLSetParam@Base 0.5.99.0.6pre1.0.20051109 - SQLSetPos@Base 0.5.99.0.6pre1.0.20051109 - SQLSetStmtOption@Base 0.5.99.0.6pre1.0.20051109 - SQLSpecialColumns@Base 0.5.99.0.6pre1.0.20051109 - SQLStatistics@Base 0.5.99.0.6pre1.0.20051109 - SQLTablePrivileges@Base 0.5.99.0.6pre1.0.20051109 - SQLTables@Base 0.5.99.0.6pre1.0.20051109 - SQLTransact@Base 0.5.99.0.6pre1.0.20051109 diff -Nru mdbtools-0.7/debian/mdbtools-gmdb.desktop mdbtools-0.7.1/debian/mdbtools-gmdb.desktop --- mdbtools-0.7/debian/mdbtools-gmdb.desktop 2013-07-12 00:18:22.000000000 +0000 +++ mdbtools-0.7.1/debian/mdbtools-gmdb.desktop 2013-10-29 08:17:25.000000000 +0000 @@ -3,6 +3,7 @@ Version=1.0 Name=MDB Viewer Comment=View and export Microsoft Access databases +Keywords=Microsoft;Access;database;SQL;Jet;schema;query;mdb;accdb; Icon=gmdb2 TryExec=gmdb2 Exec=gmdb2 %f diff -Nru mdbtools-0.7/debian/odbc-mdbtools.install mdbtools-0.7.1/debian/odbc-mdbtools.install --- mdbtools-0.7/debian/odbc-mdbtools.install 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/debian/odbc-mdbtools.install 2013-10-29 08:17:25.000000000 +0000 @@ -0,0 +1 @@ +debian/tmp/usr/lib/*/odbc/libmdbodbc*.so diff -Nru mdbtools-0.7/debian/odbc-mdbtools.postinst mdbtools-0.7.1/debian/odbc-mdbtools.postinst --- mdbtools-0.7/debian/odbc-mdbtools.postinst 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/debian/odbc-mdbtools.postinst 2013-10-29 08:17:25.000000000 +0000 @@ -0,0 +1,49 @@ +#!/bin/sh +# postinst script for odbc-mdbtools +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +odbcinsttemplate() { + cat - <<-EOS + [MDBTools] + Description = MDBTools Driver + Driver = libmdbodbc.so + Setup = libmdbodbc.so + FileUsage = 1 + EOS +} + +case "$1" in + configure) + odbcinsttemplate | odbcinst -i -d -r -v + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru mdbtools-0.7/debian/odbc-mdbtools.prerm mdbtools-0.7.1/debian/odbc-mdbtools.prerm --- mdbtools-0.7/debian/odbc-mdbtools.prerm 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/debian/odbc-mdbtools.prerm 2013-10-29 08:17:25.000000000 +0000 @@ -0,0 +1,39 @@ +#!/bin/sh +# prerm script for odbc-mdbtools +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +case "$1" in + remove|upgrade|deconfigure) + # yes, even for upgrade + odbcinst -u -d -n "MDBTools" -v + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff -Nru mdbtools-0.7/debian/patches/01_use_lib_odbc_dir mdbtools-0.7.1/debian/patches/01_use_lib_odbc_dir --- mdbtools-0.7/debian/patches/01_use_lib_odbc_dir 2013-07-12 00:18:22.000000000 +0000 +++ mdbtools-0.7.1/debian/patches/01_use_lib_odbc_dir 2013-10-29 08:17:25.000000000 +0000 @@ -10,11 +10,10 @@ =================================================================== --- mdbtools.orig/src/odbc/Makefile.am +++ mdbtools/src/odbc/Makefile.am -@@ -9,6 +9,7 @@ - - noinst_PROGRAMS = unittest +@@ -1,5 +1,6 @@ + noinst_PROGRAMS = unittest lib_LTLIBRARIES = libmdbodbc.la +libdir=@libdir@/odbc - AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(ODBC_CFLAGS) - libmdbodbc_la_SOURCES= odbc.c connectparams.c - libmdbodbc_la_LIBADD= ../libmdb/libmdb.la ../sql/libmdbsql.la + AM_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(ODBC_CFLAGS) + libmdbodbc_la_SOURCES = odbc.c connectparams.c mdbodbc.h connectparams.h + libmdbodbc_la_LIBADD = ../libmdb/libmdb.la ../sql/libmdbsql.la diff -Nru mdbtools-0.7/debian/patches/06_maintainermode mdbtools-0.7.1/debian/patches/06_maintainermode --- mdbtools-0.7/debian/patches/06_maintainermode 2013-06-22 14:11:30.000000000 +0000 +++ mdbtools-0.7.1/debian/patches/06_maintainermode 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -Description: Insert AM_MAINTAINER_MODE to avoid buid warning - debian/rules try to enable maintainer mode by default. - mdbtools doesn't support that, so that a warning is issue. -Author: Jean-Michel Vourgère -Forwarded: no -Last-Update: 2012-01-11 - -Index: mdbtools/configure.in -=================================================================== ---- mdbtools.orig/configure.in -+++ mdbtools/configure.in -@@ -2,7 +2,7 @@ - AC_INIT(mdbtools, 0.7, [mdbtools-dev@lists.sourceforge.net]) - AC_CONFIG_SRCDIR(src/extras/mdb-dump.c) - AM_INIT_AUTOMAKE -- -+AM_MAINTAINER_MODE([enable]) - m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - - AC_CONFIG_HEADERS(include/config.h) diff -Nru mdbtools-0.7/debian/patches/binaries_to_string mdbtools-0.7.1/debian/patches/binaries_to_string --- mdbtools-0.7/debian/patches/binaries_to_string 2013-07-12 00:18:22.000000000 +0000 +++ mdbtools-0.7.1/debian/patches/binaries_to_string 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -Description: Fix SEGV in blob data handling - col_to_string was missing break in a switch/case resulting in an invalid call - to mdb_unicode2ascii with an odd number of bytes. -Author: William Rogers -Origin: https://github.com/rogerswb/mdbtools/commit/0d3d2959c6d5d25d41f5e3f5d23bb38adacc4550 -Bug: https://github.com/brianb/mdbtools/issues/30 -Bug-Debian: http://bugs.debian.org/713826 -Forwarded: https://github.com/brianb/mdbtools/issues/30 -Reviewed-By: Jean-Michel Vourgère -Last-Update: 2013-06-23 -Applied-Upstream: commit:9cd05ffdcc44a9a151e3c3caded00fda2ad8d203 - ---- mdbtools-0.7.orig/src/libmdb/data.c -+++ mdbtools-0.7/src/libmdb/data.c -@@ -929,6 +929,7 @@ char *mdb_col_to_string(MdbHandle *mdb, - text = g_malloc(size); - memcpy((char*)buf+start, text, size); - } -+ break; - case MDB_TEXT: - if (size<0) { - text = g_strdup(""); diff -Nru mdbtools-0.7/debian/patches/export_repid_uuid_as_string_use_char_38_in_mysql mdbtools-0.7.1/debian/patches/export_repid_uuid_as_string_use_char_38_in_mysql --- mdbtools-0.7/debian/patches/export_repid_uuid_as_string_use_char_38_in_mysql 2013-07-12 00:18:22.000000000 +0000 +++ mdbtools-0.7.1/debian/patches/export_repid_uuid_as_string_use_char_38_in_mysql 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -Description: Export REPID (UUID) fields as string & use char(38) in mysql -Author: Will Daniels -Applied-Upstream: commit:04b6cf5232169fd5f965cb8645b4b2f6c2bf7216 -Last-Update: 2012-01-04 - ---- - src/libmdb/backend.c | 2 +- - src/libmdb/data.c | 24 ++++++++++++++++++++++++ - src/util/mdb-export.c | 4 ++-- - 3 files changed, 27 insertions(+), 3 deletions(-) - -diff --git a/src/libmdb/backend.c b/src/libmdb/backend.c -index 762655d..a26c2ee 100644 ---- a/src/libmdb/backend.c -+++ b/src/libmdb/backend.c -@@ -145,7 +145,7 @@ static MdbBackendType mdb_mysql_types[] = { - MdbBackendType_STRUCT_ELEMENT("text",1,0,1), - MdbBackendType_STRUCT_ELEMENT("blob",0,0,0), - MdbBackendType_STRUCT_ELEMENT("text",1,0,1), -- MdbBackendType_STRUCT_ELEMENT("numeric",1,1,0), -+ MdbBackendType_STRUCT_ELEMENT("char(38)",0,0,0), - MdbBackendType_STRUCT_ELEMENT("numeric",1,1,0), - }; - static MdbBackendType mdb_mysql_shortdate_type = -diff --git a/src/libmdb/data.c b/src/libmdb/data.c -index bd3b7b6..591f788 100644 ---- a/src/libmdb/data.c -+++ b/src/libmdb/data.c -@@ -840,6 +840,27 @@ mdb_date_to_string(MdbHandle *mdb, int start) - return text; - } - -+static char * -+mdb_uuid_to_string(MdbHandle *mdb, int start) -+{ -+ char *text = NULL; -+ unsigned short uuid1, uuid2, uuid3, uuid4, uuid5, uuid6, uuid7, uuid8; -+ -+ uuid1 = mdb_get_int16(mdb->pg_buf, start); -+ uuid2 = mdb_get_int16(mdb->pg_buf, start + 2); -+ uuid3 = mdb_get_int16(mdb->pg_buf, start + 4); -+ uuid4 = mdb_get_int16(mdb->pg_buf, start + 6); -+ uuid5 = mdb_get_int16(mdb->pg_buf, start + 8); -+ uuid6 = mdb_get_int16(mdb->pg_buf, start + 10); -+ uuid7 = mdb_get_int16(mdb->pg_buf, start + 12); -+ uuid8 = mdb_get_int16(mdb->pg_buf, start + 14); -+ -+ text = g_strdup_printf("{%04x%04x-%04x-%04x-%04x-%04x%04x%04x}", -+ uuid1, uuid2, uuid3, uuid4, uuid5, uuid6, uuid7, uuid8); -+ -+ return text; -+} -+ - #if 0 - int floor_log10(double f, int is_single) - { -@@ -927,6 +948,9 @@ char *mdb_col_to_string(MdbHandle *mdb, void *buf, int start, int datatype, int - text = mdb_money_to_string(mdb, start); - case MDB_NUMERIC: - break; -+ case MDB_REPID: -+ text = mdb_uuid_to_string(mdb, start); -+ break; - default: - text = g_strdup(""); - break; -diff --git a/src/util/mdb-export.c b/src/util/mdb-export.c -index afbf8b1..dcb2409 100644 ---- a/src/util/mdb-export.c -+++ b/src/util/mdb-export.c -@@ -25,8 +25,8 @@ - #undef MDB_BIND_SIZE - #define MDB_BIND_SIZE 200000 - --#define is_quote_type(x) (x==MDB_TEXT || x==MDB_OLE || x==MDB_MEMO || x==MDB_DATETIME || x==MDB_BINARY) --#define is_binary_type(x) (x==MDB_OLE || x==MDB_BINARY) -+#define is_quote_type(x) (x==MDB_TEXT || x==MDB_OLE || x==MDB_MEMO || x==MDB_DATETIME || x==MDB_BINARY || x==MDB_REPID) -+#define is_binary_type(x) (x==MDB_OLE || x==MDB_BINARY || x==MDB_REPID) - - static char *escapes(char *s); - --- -1.7.7.3 - diff -Nru mdbtools-0.7/debian/patches/gmdb2-filename-overflow mdbtools-0.7.1/debian/patches/gmdb2-filename-overflow --- mdbtools-0.7/debian/patches/gmdb2-filename-overflow 2013-07-12 00:28:06.000000000 +0000 +++ mdbtools-0.7.1/debian/patches/gmdb2-filename-overflow 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -Description: Write \0 at the end of buffer, not the byte after - This fixes a build warning. - Previous versions gets their next variable on the stack reset (that would - be variable i). Probably not a big deal, but you never know what CC - optimizers might do. -Author: Jean-Michel Vourgère -Origin: https://github.com/brianb/mdbtools/commit/2ffd30a8580954579ad1957dc80c157b14306215 -Forwarded: https://github.com/brianb/mdbtools/commit/2ffd30a8580954579ad1957dc80c157b14306215 -Reviewed-By: Jean-Michel Vourgère -Last-Update: 2012-06-30 - ---- mdbtools-0.7.orig/src/gmdb2/file.c -+++ mdbtools-0.7/src/gmdb2/file.c -@@ -107,7 +107,7 @@ gmdb_file_add_recent(gchar *file_path) - } else { - strncpy(basename,file_path,32); - } -- basename[33]='\0'; -+ basename[32]='\0'; - gnome_config_set_string("/gmdb/RecentFiles/menu_recent1.basename", basename); - gnome_config_set_string("/gmdb/RecentFiles/menu_recent1.filepath", file_path); - gnome_config_sync(); diff -Nru mdbtools-0.7/debian/patches/gmdb2_double_free mdbtools-0.7.1/debian/patches/gmdb2_double_free --- mdbtools-0.7/debian/patches/gmdb2_double_free 2013-07-12 00:18:22.000000000 +0000 +++ mdbtools-0.7.1/debian/patches/gmdb2_double_free 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -Description: Fixed double free SEGV in gmdb2 dissector -Author: Jean-Michel Vourgère -Origin: upstream, https://github.com/brianb/mdbtools/commit/1ff5d62e3070d1f0d325c510f95105497591f5fb -Last-Update: 2012-07-14 - ---- mdbtools-0.7.orig/src/gmdb2/debug.c -+++ mdbtools-0.7/src/gmdb2/debug.c -@@ -530,7 +530,7 @@ gmdb_debug_dissect_row(GtkTreeStore *sto - ((unsigned char*)fbuf)[eod_ptr], ((unsigned char*)fbuf)[eod_ptr]); - gmdb_debug_add_item(store, parent, str, eod_ptr, 1); - for (i=0;i cannot contains dirrectly. Added a wrapper. +Author: Jean-Michel Vourgère +Last-Update: 2013-10-24 +Forwarded: https://github.com/brianb/mdbtools/commit/b5fb8243a164445139c878128ec90935cdb183de +Bug-Debian: #718465 +Applied-Upstream: commit:b5fb8243a164445139c878128ec90935cdb183de + +Index: mdbtools/.gitignore +=================================================================== +--- mdbtools.orig/.gitignore ++++ mdbtools/.gitignore +@@ -11,6 +11,7 @@ + !m4/ccalias.m4 + !m4/iconv.m4 + !m4/readline.m4 ++!m4/gnome-doc-utils.m4 + config.log + config.status + configure +@@ -28,7 +29,7 @@ + types.h + src/extras/mdb-hexdump + src/gmdb2/gmdb2 +-src/gmdb2/help/C/omf_timestamp ++src/gmdb2/help/gmdb-C.omf + src/odbc/unittest + src/sql/lexer.c + src/sql/parser.c +Index: mdbtools/configure.ac +=================================================================== +--- mdbtools.orig/configure.ac ++++ mdbtools/configure.ac +@@ -150,6 +150,7 @@ + AC_SUBST(GNOME_CFLAGS) + AC_SUBST(GNOME_LIBS) + OPTDIRS="$OPTDIRS gmdb2" ++ GNOME_DOC_INIT + fi + else + AC_MSG_NOTICE(gmdb2 disabled) +@@ -233,7 +234,6 @@ + src/gmdb2/gladefiles/Makefile + src/gmdb2/pixmaps/Makefile + src/gmdb2/help/Makefile +-src/gmdb2/help/C/Makefile + mdbtools.spec + include/mdbver.h]) + AC_OUTPUT +Index: mdbtools/gnome-doc-utils.make +=================================================================== +--- /dev/null ++++ mdbtools/gnome-doc-utils.make +@@ -0,0 +1,706 @@ ++# gnome-doc-utils.make - make magic for building documentation ++# Copyright (C) 2004-2005 Shaun McCance ++# ++# 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. ++# ++# As a special exception to the GNU General Public License, if you ++# distribute this file as part of a program that contains a ++# configuration script generated by Autoconf, you may include it under ++# the same distribution terms that you use for the rest of that program. ++ ++################################################################################ ++## @@ Generating Header Files ++ ++## @ DOC_H_FILE ++## The name of the header file to generate ++DOC_H_FILE ?= ++ ++## @ DOC_H_DOCS ++## The input DocBook files for generating the header file ++DOC_H_DOCS ?= ++ ++$(DOC_H_FILE): $(DOC_H_DOCS); ++ @rm -f $@.tmp; touch $@.tmp; ++ echo 'const gchar* documentation_credits[] = {' >> $@.tmp ++ list='$(DOC_H_DOCS)'; for doc in $$list; do \ ++ xmlpath="`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`:$(srcdir)/`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`"; \ ++ if ! test -f "$$doc"; then doc="$(srcdir)/$$doc"; fi; \ ++ xsltproc --path "$$xmlpath" $(_credits) $$doc; \ ++ done | sort | uniq \ ++ | awk 'BEGIN{s=""}{n=split($$0,w,"<");if(s!=""&&s!=substr(w[1],1,length(w[1])-1)){print s};if(n>1){print $$0;s=""}else{s=$$0}};END{if(s!=""){print s}}' \ ++ | sed -e 's/\\/\\\\/' -e 's/"/\\"/' -e 's/\(.*\)/\t"\1",/' >> $@.tmp ++ echo ' NULL' >> $@.tmp ++ echo '};' >> $@.tmp ++ echo >> $@.tmp ++ list='$(DOC_H_DOCS)'; for doc in $$list; do \ ++ xmlpath="`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`:$(srcdir)/`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`"; \ ++ if ! test -f "$$doc"; then doc="$(srcdir)/$$doc"; fi; \ ++ docid=`echo "$$doc" | sed -e 's/.*\/\([^/]*\)\.xml/\1/' \ ++ | sed -e 's/[^a-zA-Z_]/_/g' | tr 'a-z' 'A-Z'`; \ ++ echo $$xmlpath; \ ++ ids=`xsltproc --xinclude --path "$$xmlpath" $(_ids) $$doc`; \ ++ for id in $$ids; do \ ++ echo '#define HELP_'`echo $$docid`'_'`echo $$id \ ++ | sed -e 's/[^a-zA-Z_]/_/g' | tr 'a-z' 'A-Z'`' "'$$id'"' >> $@.tmp; \ ++ done; \ ++ echo >> $@.tmp; \ ++ done; ++ cp $@.tmp $@ && rm -f $@.tmp ++ ++dist-check-gdu: ++if !HAVE_GNOME_DOC_UTILS ++ @echo "*** GNOME Doc Utils must be installed in order to make dist" ++ @false ++endif ++ ++.PHONY: dist-doc-header ++dist-doc-header: $(DOC_H_FILE) ++ @if test -f "$(DOC_H_FILE)"; then d=; else d="$(srcdir)/"; fi; \ ++ echo "$(INSTALL_DATA) $${d}$(DOC_H_FILE) $(distdir)/$(DOC_H_FILE)"; \ ++ $(INSTALL_DATA) "$${d}$(DOC_H_FILE)" "$(distdir)/$(DOC_H_FILE)"; ++ ++doc-dist-hook: dist-check-gdu $(if $(DOC_H_FILE),dist-doc-header) ++ ++.PHONY: clean-doc-header ++_clean_doc_header = $(if $(DOC_H_FILE),clean-doc-header) ++clean-local: $(_clean_doc_header) ++distclean-local: $(_clean_doc_header) ++mostlyclean-local: $(_clean_doc_header) ++maintainer-clean-local: $(_clean_doc_header) ++clean-doc-header: ++ rm -f $(DOC_H_FILE) ++ ++all: $(DOC_H_FILE) ++ ++ ++################################################################################ ++## @@ Generating Documentation Files ++ ++## @ DOC_MODULE ++## The name of the document being built ++DOC_MODULE ?= ++ ++## @ DOC_ID ++## The unique identifier for a Mallard document ++DOC_ID ?= ++ ++## @ DOC_PAGES ++## Page files in a Mallard document ++DOC_PAGES ?= ++ ++## @ DOC_ENTITIES ++## Files included with a SYSTEM entity ++DOC_ENTITIES ?= ++ ++## @ DOC_INCLUDES ++## Files included with XInclude ++DOC_INCLUDES ?= ++ ++## @ DOC_FIGURES ++## Figures and other external data ++DOC_FIGURES ?= ++ ++## @ DOC_FORMATS ++## The default formats to be built and installed ++DOC_FORMATS ?= docbook ++_DOC_REAL_FORMATS = $(if $(DOC_USER_FORMATS),$(DOC_USER_FORMATS),$(DOC_FORMATS)) ++ ++## @ DOC_LINGUAS ++## The languages this document is translated into ++DOC_LINGUAS ?= ++_DOC_REAL_LINGUAS = $(if $(filter environment,$(origin LINGUAS)), \ ++ $(filter $(LINGUAS),$(DOC_LINGUAS)), \ ++ $(DOC_LINGUAS)) ++ ++_DOC_ABS_SRCDIR = @abs_srcdir@ ++ ++ ++################################################################################ ++## Variables for Bootstrapping ++ ++_xml2po ?= `which xml2po` ++_xml2po_mode = $(if $(DOC_ID),mallard,docbook) ++ ++_db2html ?= `$(PKG_CONFIG) --variable db2html gnome-doc-utils` ++_db2omf ?= `$(PKG_CONFIG) --variable db2omf gnome-doc-utils` ++_chunks ?= `$(PKG_CONFIG) --variable xmldir gnome-doc-utils`/gnome/xslt/docbook/utils/chunks.xsl ++_credits ?= `$(PKG_CONFIG) --variable xmldir gnome-doc-utils`/gnome/xslt/docbook/utils/credits.xsl ++_ids ?= $(shell $(PKG_CONFIG) --variable xmldir gnome-doc-utils)/gnome/xslt/docbook/utils/ids.xsl ++ ++if ENABLE_SK ++_ENABLE_SK = true ++_skpkgdatadir ?= `scrollkeeper-config --pkgdatadir` ++_sklocalstatedir ?= `scrollkeeper-config --pkglocalstatedir` ++_skcontentslist ?= $(_skpkgdatadir)/Templates/C/scrollkeeper_cl.xml ++endif ++ ++ ++################################################################################ ++## Support for automake silent-rules ++GDU_V_XML2PO=$(GDU__v_XML2PO_$(V)) ++GDU__v_XML2PO_=$(GDU__v_XML2PO_$(AM_DEFAULT_VERBOSITY)) ++GDU__v_XML2PO_0=@echo " XML2PO" $@; ++ ++GDU_V_MSGFMT=$(GDU__v_MSGFMT_$(V)) ++GDU__v_MSGFMT_=$(GDU__v_MSGFMT_$(AM_DEFAULT_VERBOSITY)) ++GDU__v_MSGFMT_0=@echo " MSGFMT" $@; ++ ++GDU_V_DB2OMF=$(GDU__v_DB2OMF_$(V)) ++GDU__v_DB2OMF_=$(GDU__v_DB2OMF_$(AM_DEFAULT_VERBOSITY)) ++GDU__v_DB2OMF_0=@echo " DB2OMF" $@; ++ ++GDU_V_DB2HTM=$(GDU__v_DB2HTM_$(V)) ++GDU__v_DB2HTM_=$(GDU__v_DB2HTM_$(AM_DEFAULT_VERBOSITY)) ++GDU__v_DB2HTM_0=@echo " DB2HTM" $@; ++ ++################################################################################ ++## @@ Rules for OMF Files ++ ++db2omf_args = \ ++ --stringparam db2omf.basename $(DOC_MODULE) \ ++ --stringparam db2omf.format $(3) \ ++ --stringparam db2omf.dtd \ ++ $(shell xmllint --format $(2) | grep -h PUBLIC | head -n 1 \ ++ | sed -e 's/.*PUBLIC \(\"[^\"]*\"\).*/\1/') \ ++ --stringparam db2omf.lang $(notdir $(patsubst %/$(notdir $(2)),%,$(2))) \ ++ --stringparam db2omf.omf_dir "$(OMF_DIR)" \ ++ --stringparam db2omf.help_dir "$(HELP_DIR)" \ ++ --stringparam db2omf.omf_in "$(_DOC_OMF_IN)" \ ++ $(if $(_ENABLE_SK), \ ++ --stringparam db2omf.scrollkeeper_cl "$(_skcontentslist)") \ ++ $(_db2omf) $(2) ++ ++## @ _DOC_OMF_IN ++## The OMF input file ++_DOC_OMF_IN = $(if $(DOC_MODULE),$(wildcard $(_DOC_ABS_SRCDIR)/$(DOC_MODULE).omf.in)) ++ ++## @ _DOC_OMF_DB ++## The OMF files for DocBook output ++_DOC_OMF_DB = $(if $(_DOC_OMF_IN), \ ++ $(foreach lc,C $(_DOC_REAL_LINGUAS),$(DOC_MODULE)-$(lc).omf)) ++ ++$(_DOC_OMF_DB) : $(_DOC_OMF_IN) ++$(_DOC_OMF_DB) : $(DOC_MODULE)-%.omf : %/$(DOC_MODULE).xml ++ @test "x$(_ENABLE_SK)" != "xtrue" -o -f "$(_skcontentslist)" || { \ ++ echo "The file '$(_skcontentslist)' does not exist." >&2; \ ++ echo "Please check your ScrollKeeper installation." >&2; \ ++ exit 1; } ++ $(GDU_V_DB2OMF)xsltproc -o $@ $(call db2omf_args,$@,$<,'docbook') || { rm -f "$@"; exit 1; } ++ ++## @ _DOC_OMF_HTML ++## The OMF files for HTML output ++_DOC_OMF_HTML = $(if $(_DOC_OMF_IN), \ ++ $(foreach lc,C $(_DOC_REAL_LINGUAS),$(DOC_MODULE)-html-$(lc).omf)) ++ ++$(_DOC_OMF_HTML) : $(_DOC_OMF_IN) ++$(_DOC_OMF_HTML) : $(DOC_MODULE)-html-%.omf : %/$(DOC_MODULE).xml ++if ENABLE_SK ++ @test "x$(_ENABLE_SK)" != "xtrue" -o -f "$(_skcontentslist)" || { \ ++ echo "The file '$(_skcontentslist)' does not exist" >&2; \ ++ echo "Please check your ScrollKeeper installation." >&2; \ ++ exit 1; } ++endif ++ $(GDU_V_DB2OMF)xsltproc -o $@ $(call db2omf_args,$@,$<,'xhtml') || { rm -f "$@"; exit 1; } ++ ++## @ _DOC_OMF_ALL ++## All OMF output files to be built ++# FIXME ++_DOC_OMF_ALL = \ ++ $(if $(filter docbook,$(_DOC_REAL_FORMATS)),$(_DOC_OMF_DB)) \ ++ $(if $(filter html HTML,$(_DOC_REAL_FORMATS)),$(_DOC_OMF_HTML)) ++ ++.PHONY: omf ++omf: $(_DOC_OMF_ALL) ++ ++ ++################################################################################ ++## @@ C Locale Documents ++ ++## @ _DOC_C_MODULE ++## The top-level documentation file in the C locale ++_DOC_C_MODULE = $(if $(DOC_MODULE),C/$(DOC_MODULE).xml) ++ ++## @ _DOC_C_PAGES ++## Page files in a Mallard document in the C locale ++_DOC_C_PAGES = $(foreach page,$(DOC_PAGES),C/$(page)) ++ ++## @ _DOC_C_ENTITIES ++## Files included with a SYSTEM entity in the C locale ++_DOC_C_ENTITIES = $(foreach ent,$(DOC_ENTITIES),C/$(ent)) ++ ++## @ _DOC_C_XINCLUDES ++## Files included with XInclude in the C locale ++_DOC_C_INCLUDES = $(foreach inc,$(DOC_INCLUDES),C/$(inc)) ++ ++## @ _DOC_C_DOCS ++## All documentation files in the C locale ++_DOC_C_DOCS = \ ++ $(_DOC_C_ENTITIES) $(_DOC_C_INCLUDES) \ ++ $(_DOC_C_PAGES) $(_DOC_C_MODULE) ++ ++## @ _DOC_C_DOCS_NOENT ++## All documentation files in the C locale, ++## except files included with a SYSTEM entity ++_DOC_C_DOCS_NOENT = \ ++ $(_DOC_C_MODULE) $(_DOC_C_INCLUDES) \ ++ $(_DOC_C_PAGES) ++ ++## @ _DOC_C_FIGURES ++## All figures and other external data in the C locale ++_DOC_C_FIGURES = $(if $(DOC_FIGURES), \ ++ $(foreach fig,$(DOC_FIGURES),C/$(fig)), \ ++ $(patsubst $(srcdir)/%,%,$(wildcard $(srcdir)/C/figures/*.png))) ++ ++## @ _DOC_C_HTML ++## All HTML documentation in the C locale ++# FIXME: probably have to shell escape to determine the file names ++_DOC_C_HTML = $(foreach f, \ ++ $(shell xsltproc --xinclude \ ++ --stringparam db.chunk.basename "$(DOC_MODULE)" \ ++ $(_chunks) "C/$(DOC_MODULE).xml"), \ ++ C/$(f).xhtml) ++ ++############################################################################### ++## @@ Other Locale Documentation ++ ++## @ _DOC_POFILES ++## The .po files used for translating the document ++_DOC_POFILES = $(if $(DOC_MODULE)$(DOC_ID), \ ++ $(foreach lc,$(_DOC_REAL_LINGUAS),$(lc)/$(lc).po)) ++ ++.PHONY: po ++po: $(_DOC_POFILES) ++ ++## @ _DOC_MOFILES ++## The .mo files used for translating the document ++_DOC_MOFILES = $(patsubst %.po,%.mo,$(_DOC_POFILES)) ++ ++.PHONY: mo ++mo: $(_DOC_MOFILES) ++ ++## @ _DOC_LC_MODULES ++## The top-level documentation files in all other locales ++_DOC_LC_MODULES = $(if $(DOC_MODULE), \ ++ $(foreach lc,$(_DOC_REAL_LINGUAS),$(lc)/$(DOC_MODULE).xml)) ++ ++## @ _DOC_LC_PAGES ++## Page files in a Mallard document in all other locales ++_DOC_LC_PAGES = \ ++ $(foreach lc,$(_DOC_REAL_LINGUAS),$(foreach page,$(_DOC_C_PAGES), \ ++ $(lc)/$(notdir $(page)) )) ++ ++## @ _DOC_LC_XINCLUDES ++## Files included with XInclude in all other locales ++_DOC_LC_INCLUDES = \ ++ $(foreach lc,$(_DOC_REAL_LINGUAS),$(foreach inc,$(_DOC_C_INCLUDES), \ ++ $(lc)/$(notdir $(inc)) )) ++ ++## @ _DOC_LC_HTML ++## All HTML documentation in all other locales ++# FIXME: probably have to shell escape to determine the file names ++_DOC_LC_HTML = \ ++ $(foreach lc,$(_DOC_REAL_LINGUAS),$(foreach doc,$(_DOC_C_HTML), \ ++ $(lc)/$(notdir $(doc)) )) ++ ++## @ _DOC_LC_DOCS ++## All documentation files in all other locales ++_DOC_LC_DOCS = \ ++ $(_DOC_LC_MODULES) $(_DOC_LC_INCLUDES) $(_DOC_LC_PAGES) \ ++ $(if $(filter html HTML,$(_DOC_REAL_FORMATS)),$(_DOC_LC_HTML)) ++ ++## @ _DOC_LC_FIGURES ++## All figures and other external data in all other locales ++_DOC_LC_FIGURES = $(foreach lc,$(_DOC_REAL_LINGUAS), \ ++ $(patsubst C/%,$(lc)/%,$(_DOC_C_FIGURES)) ) ++ ++_DOC_SRC_FIGURES = \ ++ $(foreach fig,$(_DOC_C_FIGURES), $(foreach lc,C $(_DOC_REAL_LINGUAS), \ ++ $(wildcard $(srcdir)/$(lc)/$(patsubst C/%,%,$(fig))) )) ++ ++$(_DOC_POFILES): ++ @if ! test -d $(dir $@); then \ ++ echo "mkdir $(dir $@)"; \ ++ mkdir "$(dir $@)"; \ ++ fi ++ @if test ! -f $@ -a -f $(srcdir)/$@; then \ ++ echo "cp $(srcdir)/$@ $@"; \ ++ cp "$(srcdir)/$@" "$@"; \ ++ fi; ++ @docs=; \ ++ list='$(_DOC_C_DOCS_NOENT)'; for doc in $$list; do \ ++ docs="$$docs $(_DOC_ABS_SRCDIR)/$$doc"; \ ++ done; \ ++ if ! test -f $@; then \ ++ echo "(cd $(dir $@) && \ ++ $(_xml2po) -m $(_xml2po_mode) -e $$docs > $(notdir $@).tmp && \ ++ cp $(notdir $@).tmp $(notdir $@) && rm -f $(notdir $@).tmp)"; \ ++ (cd $(dir $@) && \ ++ $(_xml2po) -m $(_xml2po_mode) -e $$docs > $(notdir $@).tmp && \ ++ cp $(notdir $@).tmp $(notdir $@) && rm -f $(notdir $@).tmp); \ ++ else \ ++ echo "(cd $(dir $@) && \ ++ $(_xml2po) -m $(_xml2po_mode) -e -u $(notdir $@) $$docs)"; \ ++ (cd $(dir $@) && \ ++ $(_xml2po) -m $(_xml2po_mode) -e -u $(notdir $@) $$docs); \ ++ fi ++ ++$(_DOC_MOFILES): %.mo: %.po ++ $(AM_V_at)if ! test -d $(dir $@); then mkdir "$(dir $@)"; fi ++ $(GDU_V_MSGFMT)msgfmt -o $@ $< ++ ++# FIXME: fix the dependancy ++# FIXME: hook xml2po up ++$(_DOC_LC_DOCS) : $(_DOC_MOFILES) ++$(_DOC_LC_DOCS) : $(_DOC_C_DOCS) ++ $(AM_V_at)if ! test -d $(dir $@); then mkdir $(dir $@); fi ++ $(GDU_V_XML2PO)if [ -f "C/$(notdir $@)" ]; then d="../"; else d="$(_DOC_ABS_SRCDIR)/"; fi; \ ++ mo="$(dir $@)$(patsubst %/$(notdir $@),%,$@).mo"; \ ++ if [ -f "$${mo}" ]; then mo="../$${mo}"; else mo="$(_DOC_ABS_SRCDIR)/$${mo}"; fi; \ ++ (cd $(dir $@) && \ ++ $(_xml2po) -m $(_xml2po_mode) -e -t "$${mo}" \ ++ "$${d}C/$(notdir $@)" > $(notdir $@).tmp && \ ++ cp $(notdir $@).tmp $(notdir $@) && rm -f $(notdir $@).tmp) ++ ++## @ _DOC_POT ++## A pot file ++_DOC_POT = $(if $(DOC_MODULE),$(DOC_MODULE).pot,$(if $(DOC_ID),$(DOC_ID).pot)) ++.PHONY: pot ++pot: $(_DOC_POT) ++$(_DOC_POT): $(_DOC_C_DOCS_NOENT) ++ $(GDU_V_XML2PO)$(_xml2po) -m $(_xml2po_mode) -e -o $@ $^ ++ ++ ++################################################################################ ++## @@ All Documentation ++ ++## @ _DOC_HTML_ALL ++## All HTML documentation, only if it's built ++_DOC_HTML_ALL = $(if $(filter html HTML,$(_DOC_REAL_FORMATS)), \ ++ $(_DOC_C_HTML) $(_DOC_LC_HTML)) ++ ++_DOC_HTML_TOPS = $(foreach lc,C $(_DOC_REAL_LINGUAS),$(lc)/$(DOC_MODULE).xhtml) ++ ++$(_DOC_HTML_TOPS): $(_DOC_C_DOCS) $(_DOC_LC_DOCS) ++ $(GDU_V_DB2HTM)xsltproc -o $@ --xinclude --param db.chunk.chunk_top "false()" --stringparam db.chunk.basename "$(DOC_MODULE)" --stringparam db.chunk.extension ".xhtml" $(_db2html) $(patsubst %.xhtml,%.xml,$@) ++ ++ ++################################################################################ ++## All ++ ++all: \ ++ $(_DOC_C_DOCS) $(_DOC_LC_DOCS) \ ++ $(_DOC_OMF_ALL) $(_DOC_DSK_ALL) \ ++ $(_DOC_HTML_ALL) $(_DOC_POFILES) ++ ++ ++################################################################################ ++## Clean ++ ++.PHONY: clean-doc-omf clean-doc-dsk clean-doc-lc clean-doc-dir ++ ++clean-doc-omf: ; rm -f $(_DOC_OMF_DB) $(_DOC_OMF_HTML) ++clean-doc-dsk: ; rm -f $(_DOC_DSK_DB) $(_DOC_DSK_HTML) ++clean-doc-lc: ++ rm -f $(_DOC_LC_DOCS) ++ rm -f $(_DOC_MOFILES) ++ @list='$(_DOC_POFILES)'; for po in $$list; do \ ++ if ! test "$$po" -ef "$(srcdir)/$$po"; then \ ++ echo "rm -f $$po"; \ ++ rm -f "$$po"; \ ++ fi; \ ++ done ++# .xml2.po.mo cleaning is obsolete as of 0.18.1 and could be removed in 0.20.x ++ @for lc in C $(_DOC_REAL_LINGUAS); do \ ++ if test -f "$$lc/.xml2po.mo"; then \ ++ echo "rm -f $$lc/.xml2po.mo"; \ ++ rm -f "$$lc/.xml2po.mo"; \ ++ fi; \ ++ done ++clean-doc-dir: clean-doc-lc ++ @for lc in C $(_DOC_REAL_LINGUAS); do \ ++ for dir in `find $$lc -depth -type d`; do \ ++ if ! test $$dir -ef $(srcdir)/$$dir; then \ ++ echo "rmdir $$dir"; \ ++ rmdir "$$dir"; \ ++ fi; \ ++ done; \ ++ done ++ ++_clean_omf = $(if $(_DOC_OMF_IN),clean-doc-omf) ++_clean_dsk = $(if $(_DOC_DSK_IN),clean-doc-dsk) ++_clean_lc = $(if $(_DOC_REAL_LINGUAS),clean-doc-lc) ++_clean_dir = $(if $(DOC_MODULE)$(DOC_ID),clean-doc-dir) ++ ++clean-local: \ ++ $(_clean_omf) $(_clean_dsk) \ ++ $(_clean_lc) $(_clean_dir) ++distclean-local: \ ++ $(_clean_omf) $(_clean_dsk) \ ++ $(_clean_lc) $(_clean_dir) ++mostlyclean-local: \ ++ $(_clean_omf) $(_clean_dsk) \ ++ $(_clean_lc) $(_clean_dir) ++maintainer-clean-local: \ ++ $(_clean_omf) $(_clean_dsk) \ ++ $(_clean_lc) $(_clean_dir) ++ ++ ++ ++################################################################################ ++## Dist ++ ++.PHONY: dist-doc-docs dist-doc-pages dist-doc-figs dist-doc-omf dist-doc-dsk ++doc-dist-hook: \ ++ $(if $(DOC_MODULE)$(DOC_ID),dist-doc-docs) \ ++ $(if $(_DOC_C_FIGURES),dist-doc-figs) \ ++ $(if $(_DOC_OMF_IN),dist-doc-omf) ++# $(if $(_DOC_DSK_IN),dist-doc-dsk) ++ ++dist-doc-docs: $(_DOC_C_DOCS) $(_DOC_LC_DOCS) $(_DOC_POFILES) ++ @for lc in C $(_DOC_REAL_LINGUAS); do \ ++ echo " $(mkinstalldirs) $(distdir)/$$lc"; \ ++ $(mkinstalldirs) "$(distdir)/$$lc"; \ ++ done ++ @list='$(_DOC_C_DOCS)'; \ ++ for doc in $$list; do \ ++ if test -f "$$doc"; then d=; else d="$(srcdir)/"; fi; \ ++ docdir=`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \ ++ if ! test -d "$(distdir)/$$docdir"; then \ ++ echo "$(mkinstalldirs) $(distdir)/$$docdir"; \ ++ $(mkinstalldirs) "$(distdir)/$$docdir"; \ ++ fi; \ ++ echo "$(INSTALL_DATA) $$d$$doc $(distdir)/$$doc"; \ ++ $(INSTALL_DATA) "$$d$$doc" "$(distdir)/$$doc"; \ ++ done ++ @list='$(_DOC_LC_DOCS)'; \ ++ for doc in $$list; do \ ++ if test -f "$$doc"; then d=; else d="$(srcdir)/"; fi; \ ++ docdir=`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \ ++ if ! test -d "$(distdir)/$$docdir"; then \ ++ echo "$(mkinstalldirs) $(distdir)/$$docdir"; \ ++ $(mkinstalldirs) "$(distdir)/$$docdir"; \ ++ fi; \ ++ echo "$(INSTALL_DATA) $$d$$doc $(distdir)/$$doc"; \ ++ $(INSTALL_DATA) "$$d$$doc" "$(distdir)/$$doc"; \ ++ done ++ @list='$(_DOC_POFILES)'; \ ++ for doc in $$list; do \ ++ if test -f "$$doc"; then d=; else d="$(srcdir)/"; fi; \ ++ docdir=`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \ ++ if ! test -d "$(distdir)/$$docdir"; then \ ++ echo "$(mkinstalldirs) $(distdir)/$$docdir"; \ ++ $(mkinstalldirs) "$(distdir)/$$docdir"; \ ++ fi; \ ++ echo "$(INSTALL_DATA) $$d$$doc $(distdir)/$$doc"; \ ++ $(INSTALL_DATA) "$$d$$doc" "$(distdir)/$$doc"; \ ++ done ++ ++dist-doc-figs: $(_DOC_SRC_FIGURES) ++ @list='$(_DOC_C_FIGURES) $(_DOC_LC_FIGURES)'; \ ++ for fig in $$list; do \ ++ if test -f "$$fig"; then d=; else d="$(srcdir)/"; fi; \ ++ if test -f "$$d$$fig"; then \ ++ figdir=`echo $$fig | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \ ++ if ! test -d "$(distdir)/$$figdir"; then \ ++ echo "$(mkinstalldirs) $(distdir)/$$figdir"; \ ++ $(mkinstalldirs) "$(distdir)/$$figdir"; \ ++ fi; \ ++ echo "$(INSTALL_DATA) $$d$$fig $(distdir)/$$fig"; \ ++ $(INSTALL_DATA) "$$d$$fig" "$(distdir)/$$fig"; \ ++ fi; \ ++ done; ++ ++dist-doc-omf: ++ @if test -f "$(_DOC_OMF_IN)"; then d=; else d="$(srcdir)/"; fi; \ ++ echo "$(INSTALL_DATA) $$d$(_DOC_OMF_IN) $(distdir)/$(notdir $(_DOC_OMF_IN))"; \ ++ $(INSTALL_DATA) "$$d$(_DOC_OMF_IN)" "$(distdir)/$(notdir $(_DOC_OMF_IN))" ++ ++dist-doc-dsk: ++ @if test -f "$(_DOC_DSK_IN)"; then d=; else d="$(srcdir)/"; fi; \ ++ echo "$(INSTALL_DATA) $$d$(_DOC_DSK_IN) $(distdir)/$(notdir $(_DOC_DSK_IN))"; \ ++ $(INSTALL_DATA) "$$d$(_DOC_DSK_IN)" "$(distdir)/$(notdir $(_DOC_DSK_IN))" ++ ++ ++ ++################################################################################ ++## Check ++ ++.PHONY: check-doc-docs check-doc-omf ++check: \ ++ $(if $(DOC_MODULE),check-doc-docs) \ ++ $(if $(DOC_ID),check-doc-pages) \ ++ $(if $(_DOC_OMF_IN),check-doc-omf) ++ ++check-doc-docs: $(_DOC_C_DOCS) $(_DOC_LC_DOCS) ++ @for lc in C $(_DOC_REAL_LINGUAS); do \ ++ if test -f "$$lc"; \ ++ then d=; \ ++ xmlpath="$$lc"; \ ++ else \ ++ d="$(srcdir)/"; \ ++ xmlpath="$$lc:$(srcdir)/$$lc"; \ ++ fi; \ ++ echo "xmllint --noout --noent --path $$xmlpath --xinclude --postvalid $$d$$lc/$(DOC_MODULE).xml"; \ ++ xmllint --noout --noent --path "$$xmlpath" --xinclude --postvalid "$$d$$lc/$(DOC_MODULE).xml"; \ ++ done ++ ++check-doc-pages: $(_DOC_C_PAGES) $(_DOC_LC_PAGES) ++ for lc in C $(_DOC_REAL_LINGUAS); do \ ++ if test -f "$$lc"; \ ++ then d=; \ ++ xmlpath="$$lc"; \ ++ else \ ++ d="$(srcdir)/"; \ ++ xmlpath="$$lc:$(srcdir)/$$lc"; \ ++ fi; \ ++ for page in $(DOC_PAGES); do \ ++ echo "xmllint --noout --noent --path $$xmlpath --xinclude $$d$$lc/$$page"; \ ++ xmllint --noout --noent --path "$$xmlpath" --xinclude "$$d$$lc/$$page"; \ ++ done; \ ++ done ++ ++check-doc-omf: $(_DOC_OMF_ALL) ++ @list='$(_DOC_OMF_ALL)'; for omf in $$list; do \ ++ echo "xmllint --noout --xinclude --dtdvalid 'http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd' $$omf"; \ ++ xmllint --noout --xinclude --dtdvalid 'http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd' $$omf; \ ++ done ++ ++ ++ ++################################################################################ ++## Install ++ ++.PHONY: install-doc-docs install-doc-html install-doc-figs install-doc-omf install-doc-dsk ++ ++_doc_install_dir = $(if $(DOC_ID),$(DOC_ID),$(DOC_MODULE)) ++ ++install-data-local: \ ++ $(if $(DOC_MODULE)$(DOC_ID),install-doc-docs) \ ++ $(if $(_DOC_HTML_ALL),install-doc-html) \ ++ $(if $(_DOC_C_FIGURES),install-doc-figs) \ ++ $(if $(_DOC_OMF_IN),install-doc-omf) ++# $(if $(_DOC_DSK_IN),install-doc-dsk) ++ ++install-doc-docs: ++ @for lc in C $(_DOC_REAL_LINGUAS); do \ ++ echo "$(mkinstalldirs) $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$lc"; \ ++ $(mkinstalldirs) $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$lc; \ ++ done ++ @list='$(_DOC_C_DOCS)'; for doc in $$list; do \ ++ if test -f "$$doc"; then d=; else d="$(srcdir)/"; fi; \ ++ docdir="$$lc/"`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \ ++ docdir="$(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$docdir"; \ ++ if ! test -d "$$docdir"; then \ ++ echo "$(mkinstalldirs) $$docdir"; \ ++ $(mkinstalldirs) "$$docdir"; \ ++ fi; \ ++ echo "$(INSTALL_DATA) $$d$$doc $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc"; \ ++ $(INSTALL_DATA) $$d$$doc $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc; \ ++ done ++ @list='$(_DOC_LC_DOCS)'; for doc in $$list; do \ ++ if test -f "$$doc"; then d=; else d="$(srcdir)/"; fi; \ ++ docdir="$$lc/"`echo $$doc | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \ ++ docdir="$(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$docdir"; \ ++ if ! test -d "$$docdir"; then \ ++ echo "$(mkinstalldirs) $$docdir"; \ ++ $(mkinstalldirs) "$$docdir"; \ ++ fi; \ ++ echo "$(INSTALL_DATA) $$d$$doc $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc"; \ ++ $(INSTALL_DATA) $$d$$doc $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc; \ ++ done ++ ++install-doc-figs: ++ @list='$(patsubst C/%,%,$(_DOC_C_FIGURES))'; for fig in $$list; do \ ++ for lc in C $(_DOC_REAL_LINGUAS); do \ ++ figsymlink=false; \ ++ if test -f "$$lc/$$fig"; then \ ++ figfile="$$lc/$$fig"; \ ++ elif test -f "$(srcdir)/$$lc/$$fig"; then \ ++ figfile="$(srcdir)/$$lc/$$fig"; \ ++ else \ ++ figsymlink=true; \ ++ fi; \ ++ figdir="$$lc/"`echo $$fig | sed -e 's/^\(.*\/\).*/\1/' -e '/\//!s/.*//'`; \ ++ figdir="$(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$figdir"; \ ++ if ! test -d "$$figdir"; then \ ++ echo "$(mkinstalldirs) $$figdir"; \ ++ $(mkinstalldirs) "$$figdir"; \ ++ fi; \ ++ figbase=`echo $$fig | sed -e 's/^.*\///'`; \ ++ if $$figsymlink; then \ ++ echo "cd $$figdir && $(LN_S) -f ../../C/$$fig $$figbase"; \ ++ ( cd "$$figdir" && $(LN_S) -f "../../C/$$fig" "$$figbase" ); \ ++ else \ ++ echo "$(INSTALL_DATA) $$figfile $$figdir$$figbase"; \ ++ $(INSTALL_DATA) "$$figfile" "$$figdir$$figbase"; \ ++ fi; \ ++ done; \ ++ done ++ ++install-doc-html: ++ echo install-html ++ ++install-doc-omf: ++ $(mkinstalldirs) $(DESTDIR)$(OMF_DIR)/$(_doc_install_dir) ++ @list='$(_DOC_OMF_ALL)'; for omf in $$list; do \ ++ echo "$(INSTALL_DATA) $$omf $(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)/$$omf"; \ ++ $(INSTALL_DATA) $$omf $(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)/$$omf; \ ++ done ++ @if test "x$(_ENABLE_SK)" = "xtrue"; then \ ++ echo "scrollkeeper-update -p $(DESTDIR)$(_sklocalstatedir) -o $(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)"; \ ++ scrollkeeper-update -p "$(DESTDIR)$(_sklocalstatedir)" -o "$(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)"; \ ++ fi; ++ ++install-doc-dsk: ++ echo install-dsk ++ ++ ++ ++################################################################################ ++## Uninstall ++ ++.PHONY: uninstall-doc-docs uninstall-doc-html uninstall-doc-figs uninstall-doc-omf uninstall-doc-dsk ++uninstall-local: \ ++ $(if $(DOC_MODULE)$(DOC_ID),uninstall-doc-docs) \ ++ $(if $(_DOC_HTML_ALL),uninstall-doc-html) \ ++ $(if $(_DOC_C_FIGURES),uninstall-doc-figs) \ ++ $(if $(_DOC_OMF_IN),uninstall-doc-omf) ++# $(if $(_DOC_DSK_IN),uninstall-doc-dsk) ++ ++uninstall-doc-docs: ++ @list='$(_DOC_C_DOCS)'; for doc in $$list; do \ ++ echo " rm -f $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc"; \ ++ rm -f "$(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc"; \ ++ done ++ @list='$(_DOC_LC_DOCS)'; for doc in $$list; do \ ++ echo " rm -f $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc"; \ ++ rm -f "$(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$doc"; \ ++ done ++ ++uninstall-doc-figs: ++ @list='$(_DOC_C_FIGURES) $(_DOC_LC_FIGURES)'; for fig in $$list; do \ ++ echo "rm -f $(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$fig"; \ ++ rm -f "$(DESTDIR)$(HELP_DIR)/$(_doc_install_dir)/$$fig"; \ ++ done; ++ ++uninstall-doc-omf: ++ @list='$(_DOC_OMF_ALL)'; for omf in $$list; do \ ++ if test "x$(_ENABLE_SK)" = "xtrue"; then \ ++ echo "scrollkeeper-uninstall -p $(_sklocalstatedir) $(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)/$$omf"; \ ++ scrollkeeper-uninstall -p "$(_sklocalstatedir)" "$(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)/$$omf"; \ ++ fi; \ ++ echo "rm -f $(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)/$$omf"; \ ++ rm -f "$(DESTDIR)$(OMF_DIR)/$(_doc_install_dir)/$$omf"; \ ++ done +Index: mdbtools/m4/gnome-doc-utils.m4 +=================================================================== +--- /dev/null ++++ mdbtools/m4/gnome-doc-utils.m4 +@@ -0,0 +1,61 @@ ++dnl Do not call GNOME_DOC_DEFINES directly. It is split out from ++dnl GNOME_DOC_INIT to allow gnome-doc-utils to bootstrap off itself. ++AC_DEFUN([GNOME_DOC_DEFINES], ++[ ++AC_ARG_WITH([help-dir], ++ AC_HELP_STRING([--with-help-dir=DIR], [path to help docs]),, ++ [with_help_dir='${datadir}/gnome/help']) ++HELP_DIR="$with_help_dir" ++AC_SUBST(HELP_DIR) ++ ++AC_ARG_WITH([omf-dir], ++ AC_HELP_STRING([--with-omf-dir=DIR], [path to OMF files]),, ++ [with_omf_dir='${datadir}/omf']) ++OMF_DIR="$with_omf_dir" ++AC_SUBST(OMF_DIR) ++ ++AC_ARG_WITH([help-formats], ++ AC_HELP_STRING([--with-help-formats=FORMATS], [list of formats]),, ++ [with_help_formats='']) ++DOC_USER_FORMATS="$with_help_formats" ++AC_SUBST(DOC_USER_FORMATS) ++ ++AC_ARG_ENABLE([scrollkeeper], ++ [AC_HELP_STRING([--disable-scrollkeeper], ++ [do not make updates to the scrollkeeper database])],, ++ enable_scrollkeeper=yes) ++AM_CONDITIONAL([ENABLE_SK],[test "$gdu_cv_have_gdu" = "yes" -a "$enable_scrollkeeper" = "yes"]) ++ ++dnl disable scrollkeeper automatically for distcheck ++DISTCHECK_CONFIGURE_FLAGS="--disable-scrollkeeper $DISTCHECK_CONFIGURE_FLAGS" ++AC_SUBST(DISTCHECK_CONFIGURE_FLAGS) ++ ++AM_CONDITIONAL([HAVE_GNOME_DOC_UTILS],[test "$gdu_cv_have_gdu" = "yes"]) ++]) ++ ++# GNOME_DOC_INIT ([MINIMUM-VERSION],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) ++# ++AC_DEFUN([GNOME_DOC_INIT], ++[AC_REQUIRE([AC_PROG_LN_S])dnl ++ ++if test -z "$AM_DEFAULT_VERBOSITY"; then ++ AM_DEFAULT_VERBOSITY=1 ++fi ++AC_SUBST([AM_DEFAULT_VERBOSITY]) ++ ++ifelse([$1],,[gdu_cv_version_required=0.3.2],[gdu_cv_version_required=$1]) ++ ++AC_MSG_CHECKING([gnome-doc-utils >= $gdu_cv_version_required]) ++PKG_CHECK_EXISTS([gnome-doc-utils >= $gdu_cv_version_required], ++ [gdu_cv_have_gdu=yes],[gdu_cv_have_gdu=no]) ++ ++if test "$gdu_cv_have_gdu" = "yes"; then ++ AC_MSG_RESULT([yes]) ++ ifelse([$2],,[:],[$2]) ++else ++ AC_MSG_RESULT([no]) ++ ifelse([$3],,[AC_MSG_ERROR([gnome-doc-utils >= $gdu_cv_version_required not found])],[$3]) ++fi ++ ++GNOME_DOC_DEFINES ++]) +Index: mdbtools/omf.make +=================================================================== +--- mdbtools.orig/omf.make ++++ /dev/null +@@ -1,65 +0,0 @@ +-# +-# No modifications of this Makefile should be necessary. +-# +-# This file contains the build instructions for installing OMF files. It is +-# generally called from the makefiles for particular formats of documentation. +-# +-# Note that you must configure your package with --localstatedir=/var +-# so that the scrollkeeper-update command below will update the database +-# in the standard scrollkeeper directory. +-# +-# If it is impossible to configure with --localstatedir=/var, then +-# modify the definition of scrollkeeper_localstate_dir so that +-# it points to the correct location. Note that you must still use +-# $(localstatedir) in this or when people build RPMs it will update +-# the real database on their system instead of the one under RPM_BUILD_ROOT. +-# +-# Note: This make file is not incorporated into xmldocs.make because, in +-# general, there will be other documents install besides XML documents +-# and the makefiles for these formats should also include this file. +-# +-# About this file: +-# This file was derived from scrollkeeper_example2, a package +-# illustrating how to install documentation and OMF files for use with +-# ScrollKeeper 0.3.x and 0.4.x. For more information, see: +-# http://scrollkeeper.sourceforge.net/ +-# Version: 0.1.3 (last updated: March 20, 2002) +-# +- +-omf_dest_dir=$(datadir)/omf/@PACKAGE@ +-scrollkeeper_localstate_dir = $(localstatedir)/scrollkeeper +- +-# At some point, it may be wise to change to something like this: +-# scrollkeeper_localstate_dir = @SCROLLKEEPER_STATEDIR@ +- +-omf: omf_timestamp +- +-omf_timestamp: $(omffile) +- -for file in $(omffile); do \ +- absfile=$(srcdir)/$$file; \ +- test -r $$file && absfile=$$file; \ +- scrollkeeper-preinstall $(docdir)/$(docname).xml $$absfile $$file.out; \ +- done; \ +- touch omf_timestamp +- +-install-data-hook-omf: +- $(mkinstalldirs) $(DESTDIR)$(omf_dest_dir) +- for file in $(omffile); do \ +- absfile=$(srcdir)/$$file.out; \ +- test -r $$file.out && absfile=$$file.out; \ +- $(INSTALL_DATA) $$absfile $(DESTDIR)$(omf_dest_dir)/$$file; \ +- done +- -scrollkeeper-update -p $(DESTDIR)$(scrollkeeper_localstate_dir) -o $(DESTDIR)$(omf_dest_dir) +- +-uninstall-local-omf: +- -for file in $(omffile); do \ +- basefile=`basename $$file`; \ +- rm -f $(DESTDIR)$(omf_dest_dir)/$$basefile; \ +- done +- -rmdir $(DESTDIR)$(omf_dest_dir) +- -scrollkeeper-update -p $(DESTDIR)$(scrollkeeper_localstate_dir) +- +-clean-local-omf: +- -for file in $(omffile); do \ +- rm -f $$file.out; \ +- done +Index: mdbtools/src/gmdb2/help/C/Makefile.am +=================================================================== +--- mdbtools.orig/src/gmdb2/help/C/Makefile.am ++++ /dev/null +@@ -1,8 +0,0 @@ +-include $(top_srcdir)/xmldocs.make +-dist-hook: app-dist-hook +- +-figdir = figures +-docname = gmdb +-lang = C +-omffile = gmdb-C.omf +-entities = legal.xml +Index: mdbtools/src/gmdb2/help/C/gmdb-C.omf +=================================================================== +--- mdbtools.orig/src/gmdb2/help/C/gmdb-C.omf ++++ /dev/null +@@ -1,32 +0,0 @@ +- +- +- +- +- camber@ais.org (Brian Bruns) +- +- +- camber@ais.org (Brian Bruns) +- +- +- gmdb Manual V1.0 +- +- +- 2003-01-10 +- +- +- +- +- User manual for gmdb2. +- +- +- user's guide +- +- +- +- +- +- +- +- +Index: mdbtools/src/gmdb2/help/C/gmdb.xml +=================================================================== +--- mdbtools.orig/src/gmdb2/help/C/gmdb.xml ++++ mdbtools/src/gmdb2/help/C/gmdb.xml +@@ -25,6 +25,12 @@ + + + &app; Manual V&manrevision; ++ ++ The &app; application is the graphical ++ interface to MDB Tools. You can use &app; ++ to view and export data and schema from MDB databases. ++ ++ + + 2003 + Brian Bruns +@@ -50,6 +56,14 @@ +
camber@ais.org
+ + ++ ++ Jean-Michel ++ Vourgère ++ ++ MDB Tools Project ++
contact_mdbtools@nirgal.com
++
++
+ + True diff -Nru mdbtools-0.7/src/gmdb2/gladefiles/gmdb-export.glade mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-export.glade --- mdbtools-0.7/src/gmdb2/gladefiles/gmdb-export.glade 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-export.glade 2013-10-13 08:51:24.000000000 +0000 @@ -1,488 +1,324 @@ - - - + - - - True - Export Table Data - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - False - 0 - - - - GTK_BUTTONBOX_END - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - -11 - - - - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - -6 - - - - - - - True - True - True - GTK_RELIEF_NORMAL - -5 - - - - - True - 0.5 - 0.5 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-convert - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Export - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - - True - True - gtk-save - True - GTK_RELIEF_NORMAL - 0 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 30 - True - 6 - 2 - False - 8 - 30 - - - - True - <b>File Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - <b>Line Terminator:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - <b>Column Separator:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - <b>Quotes:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - <b>Quote Character:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - fill - - - - - - - True - <b>Options:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 5 - 6 - fill - - - - - - - True - False - True - False - True - False - - - - True - True - True - True - 0 - - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - - 1 - 2 - 1 - 2 - - - - - - - True - False - True - False - True - False - - - - True - True - True - True - 0 - - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - - 1 - 2 - 2 - 3 - - - - - - - True - False - True - False - True - False - - - - True - True - False - True - 0 - - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - - 1 - 2 - 3 - 4 - - - - - - - True - False - True - False - True - False - - - - True - True - True - True - 0 - - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - - 1 - 2 - 4 - 5 - - - - - - - True - True - Include Headers - True - GTK_RELIEF_NORMAL - True - False - True - - - 1 - 2 - 5 - 6 - fill - - - - - - True - - - 1 - 2 - - - - - 0 - True - True - - - - - - + + + + True + Export Table Data + normal + + + True + + + True + 30 + 7 + 2 + 30 + 8 + + + True + 0 + <b>File Name:</b> + True + + + GTK_FILL + + + + + + True + 0 + <b>Line Terminator:</b> + True + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + <b>Column Separator:</b> + True + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + <b>Options:</b> + True + + + 6 + 7 + GTK_FILL + + + + + + Include Headers + True + True + False + True + True + True + + + 1 + 2 + 6 + 7 + GTK_FILL + + + + + + True + + + + 1 + 2 + 1 + 2 + + + + + True + + + + 1 + 2 + 2 + 3 + + + + + True + 0 + <b>Binaries:</b> + True + + + 5 + 6 + GTK_FILL + + + + + + True + + + + 1 + 2 + 5 + 6 + + + + + True + 0 + <b>Quote Character:</b> + True + + + 3 + 4 + GTK_FILL + + + + + + True + + + + 1 + 2 + 3 + 4 + + + + + True + 0 + <b>Escape Character:</b> + True + + + 4 + 5 + GTK_FILL + + + + + + True + + + + 1 + 2 + 4 + 5 + + + + + True + True + + table.csv + + + 1 + 2 + + + + + 2 + + + + + end + + + gtk-help + -11 + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-cancel + -6 + True + True + True + False + True + + + + False + False + 1 + + + + + -5 + True + True + True + False + + + + True + 0 + 0 + + + True + 2 + + + True + gtk-convert + + + False + False + 0 + + + + + True + _Export + True + + + False + False + 1 + + + + + + + + + False + False + 2 + + + + + gtk-save + True + True + False + True + + + False + False + 3 + + + + + False + end + 0 + + + + + diff -Nru mdbtools-0.7/src/gmdb2/gladefiles/gmdb-prefs.glade mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-prefs.glade --- mdbtools-0.7/src/gmdb2/gladefiles/gmdb-prefs.glade 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-prefs.glade 2013-10-13 08:51:24.000000000 +0000 @@ -1,136 +1,108 @@ - - - + - - - True - Preferences - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - -11 - - - - - - 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 - - - - - - + + + + True + Preferences + normal + + + True + + + True + 10 + 2 + + + True + 0 + <b>Maximum Rows to Display:</b> + True + + + + + + + + True + True + + + 1 + 2 + GTK_FILL + + + + + + False + 2 + + + + + True + end + + + gtk-help + -11 + True + True + True + False + True + + + False + False + 0 + + + + + gtk-cancel + -6 + True + True + True + False + True + + + False + False + 1 + + + + + gtk-ok + -5 + True + True + True + False + True + + + False + False + 2 + + + + + False + end + 0 + + + + + diff -Nru mdbtools-0.7/src/gmdb2/gladefiles/gmdb-props.glade mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-props.glade --- mdbtools-0.7/src/gmdb2/gladefiles/gmdb-props.glade 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-props.glade 2013-10-13 08:51:24.000000000 +0000 @@ -1,448 +1,307 @@ - - - + - - - True - dialog1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - -5 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - 10 - True - 8 - 2 - False - 8 - 30 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 3 - 4 - fill - - - - - - - True - <b>Number of Objects:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 4 - 5 - - - - - - - True - <b>Number of Pages:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - - - - - - - True - <b>File Size:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - - - - - - - True - <b>JET Version:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - - - - - - - True - <b>File Name:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - okbutton1 - - - 0 - 1 - 0 - 1 - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 4 - 5 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - <b>Title:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 5 - 6 - fill - - - - - - - True - <b>Author:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 6 - 7 - fill - - - - - - - True - <b>Company:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 7 - 8 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 5 - 6 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 6 - 7 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 7 - 8 - fill - - - - - - 0 - False - False - - - - - - + + + + True + dialog1 + normal + + + True + + + True + 10 + 9 + 2 + 30 + 8 + + + True + 0 + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + + True + 0 + <b>Number of Objects:</b> + True + right + + + 5 + 6 + + + + + + True + 0 + <b>Number of Pages:</b> + True + right + + + 4 + 5 + + + + + + True + 0 + <b>File Size:</b> + True + right + + + 3 + 4 + + + + + + True + 0 + <b>JET Version:</b> + True + right + + + 1 + 2 + + + + + + True + 0 + <b>File Name:</b> + True + right + okbutton1 + + + + + + + + True + 0 + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + + True + 0 + + + 1 + 2 + 5 + 6 + GTK_FILL + + + + + + True + 0 + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + 0 + <b>Title:</b> + True + + + 6 + 7 + GTK_FILL + + + + + + True + 0 + <b>Author:</b> + True + + + 7 + 8 + GTK_FILL + + + + + + True + 0 + + + 1 + 2 + 6 + 7 + GTK_FILL + + + + + + True + 0 + + + 1 + 2 + 7 + 8 + GTK_FILL + + + + + + True + 0 + + + 1 + 2 + 8 + 9 + GTK_FILL + + + + + + True + 0 + <b>Company:</b> + True + + + 8 + 9 + GTK_FILL + + + + + + True + 0 + <b>Encrypted:</b> + True + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + + False + False + 2 + + + + + True + end + + + gtk-ok + -5 + True + True + True + False + True + + + + False + False + 0 + + + + + False + end + 0 + + + + + diff -Nru mdbtools-0.7/src/gmdb2/gladefiles/gmdb-schema.glade mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-schema.glade --- mdbtools-0.7/src/gmdb2/gladefiles/gmdb-schema.glade 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-schema.glade 2013-10-13 08:51:24.000000000 +0000 @@ -1,525 +1,376 @@ - - - True - Export Schema - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - -11 - - - - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - -6 - - - - - - - True - True - True - GTK_RELIEF_NORMAL - -5 - - - - - True - 0.5 - 0.5 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-convert - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Export - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - 0 - False - True - GTK_PACK_END - - - - - - 33 - True - 5 - 2 - False - 8 - 30 - - - - True - <b>Table:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - <b>Schema Dialect:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - False - True - False - True - False - - - - True - True - True - True - 0 - Access - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - - 1 - 2 - 1 - 2 - - - - - - - True - True - False - False - True - False - - - - True - True - False - True - 0 - Access - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - True - True - Access - - - - - - True - True - Oracle - - - - - - True - True - Sybase - - - - - - True - True - MS SQL Server - - - - - - True - True - PostgreSQL - - - - - - True - True - MySQL - - - - - - - 1 - 2 - 2 - 3 - - - - - - - True - True - Include Relationships - True - GTK_RELIEF_NORMAL - True - False - True - - - 1 - 2 - 9 - 10 - fill - - - - - - - True - <b>Options:</b> - False - True - GTK_JUSTIFY_RIGHT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - True - True - Include Drop Table commands - True - GTK_RELIEF_NORMAL - True - False - True - - - 1 - 2 - 3 - 4 - fill - - - - - - - Include Not Null constraints - True - True - True - True - True - GTK_RELIEF_NORMAL - False - - - 1 - 2 - 4 - 5 - fill - - - - - - - Include indexes - True - True - True - True - True - GTK_RELIEF_NORMAL - False - - - 1 - 2 - 8 - 9 - fill - - - - - - - Include description on tables and columns - True - True - True - True - True - GTK_RELIEF_NORMAL - False - - - 1 - 2 - 7 - 8 - fill - - - - - - - Include Not Empty constraints - True - True - True - True - True - GTK_RELIEF_NORMAL - False - - - 1 - 2 - 6 - 7 - fill - - - - - - - Include Default values - True - True - True - True - True - GTK_RELIEF_NORMAL - False - - - 1 - 2 - 5 - 6 - fill - - - - - - - True - <b>File Name:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - + + + + True + Export Schema + normal + + + True - + True + 33 + 5 + 2 + 30 + 8 + + + True + 0 + <b>Table:</b> + True + right + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + <b>Schema Dialect:</b> + True + right + + + 2 + 3 + GTK_FILL + + + + + + Include Relationships + True + True + False + True + True + True + + + 1 + 2 + 9 + 10 + GTK_FILL + + + + + + True + 0 + <b>Options:</b> + True + right + + + 3 + 4 + GTK_FILL + + + + + + Include Drop Table commands + True + True + False + True + True + True + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + + Include Not Null constraints + True + True + False + True + True + True + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + + Include indexes + True + True + False + True + True + True + + + 1 + 2 + 8 + 9 + GTK_FILL + + + + + + Include description on tables and columns + True + True + False + True + True + True + + + 1 + 2 + 7 + 8 + GTK_FILL + + + + + + Include Not Empty constraints + True + True + False + True + True + True + + + 1 + 2 + 6 + 7 + GTK_FILL + + + + + + Include Default values + True + True + False + True + True + True + + + 1 + 2 + 5 + 6 + GTK_FILL + + + + + + True + 0 + <b>File Name:</b> + True + + + GTK_FILL + + + + + + True + + + + 1 + 2 + 1 + 2 + + + + + True + 0 + Access +Oracle +Sybase +MS SQL Server +PostgreSQL +MySQL +SQLite + + + 1 + 2 + 2 + 3 + + + + + True + True + + export.sql + + + 1 + 2 + + + + + + + + + + + + + + + + + + + + - 1 - 2 + False + 2 - - - 0 - True - False - - - - - - + + + True + end + + + gtk-help + -11 + True + True + True + False + True + + + + False + False + 0 + + + + + gtk-cancel + -6 + True + True + True + False + True + + + + False + False + 1 + + + + + -5 + True + True + True + False + + + + True + 0 + 0 + + + True + 2 + + + True + gtk-convert + + + False + False + 0 + + + + + True + _Export + True + + + False + False + 1 + + + + + + + + + False + False + 2 + + + + + False + end + 0 + + + + + diff -Nru mdbtools-0.7/src/gmdb2/gladefiles/gmdb-sql.glade mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-sql.glade --- mdbtools-0.7/src/gmdb2/gladefiles/gmdb-sql.glade 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-sql.glade 2013-10-13 08:51:24.000000000 +0000 @@ -1,6 +1,6 @@ - + True @@ -321,26 +321,9 @@ - + True - False - - - 24 - True - True - Recently Executed Queries - - - 0 - - - - - True - browse - - + 1 diff -Nru mdbtools-0.7/src/gmdb2/gladefiles/gmdb-tabledef.glade mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-tabledef.glade --- mdbtools-0.7/src/gmdb2/gladefiles/gmdb-tabledef.glade 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb-tabledef.glade 2013-10-13 08:51:24.000000000 +0000 @@ -0,0 +1,276 @@ + + + + + + + + True + vertical + + + True + True + automatic + automatic + + + True + True + both + + + + + 0 + + + + + True + 10 + 2 + + + True + Size + + + + + True + True + False + + + + 1 + 2 + + + + + True + True + False + + + + 1 + 2 + 8 + 9 + + + + + True + Required + + + 8 + 9 + + + + + True + Format + + + 1 + 2 + + + + + True + True + False + + + + 1 + 2 + 1 + 2 + + + + + True + Input mask + + + 3 + 4 + + + + + True + True + False + + + + 1 + 2 + 3 + 4 + + + + + True + Caption + + + 4 + 5 + + + + + True + Default value + + + 5 + 6 + + + + + True + Validation rule + + + 6 + 7 + + + + + True + Validation error message + + + 7 + 8 + + + + + True + Allow zero length + + + 9 + 10 + + + + + True + True + False + + + + 1 + 2 + 4 + 5 + + + + + True + True + False + + + + 1 + 2 + 5 + 6 + + + + + True + True + False + + + + 1 + 2 + 6 + 7 + + + + + True + True + False + + + + 1 + 2 + 7 + 8 + + + + + True + True + False + + + + 1 + 2 + 9 + 10 + + + + + True + Decimal places + + + 2 + 3 + + + + + True + True + False + + + + 1 + 2 + 2 + 3 + + + + + False + 1 + + + + + + diff -Nru mdbtools-0.7/src/gmdb2/gladefiles/gmdb.glade mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb.glade --- mdbtools-0.7/src/gmdb2/gladefiles/gmdb.glade 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gladefiles/gmdb.glade 2013-10-13 08:51:24.000000000 +0000 @@ -1,1121 +1,821 @@ - - - + - - - - - True - MDB File Viewer - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - - - - True - True - - - - True - GTK_SHADOW_NONE - - - - True - - - - True - GNOMEUIINFO_MENU_FILE_TREE - - - - - - - True - GNOMEUIINFO_MENU_OPEN_ITEM - - - - - - - True - - - - - - True - False - GNOMEUIINFO_MENU_PROPERTIES_ITEM - - - - - - - True - - - - - - True - GNOMEUIINFO_MENU_CLOSE_ITEM - - - - - - - True - - - - - - True - item - True - - - - - - - - True - item3 - True - - - - - - - - True - item4 - True - - - - - - - - True - item5 - True - - - - - - - - True - - - - - - True - GNOMEUIINFO_MENU_EXIT_ITEM - - - - - - - - - - - True - GNOMEUIINFO_MENU_EDIT_TREE - - - - - - - True - GNOMEUIINFO_MENU_PREFERENCES_ITEM - - - - - - - - - - - True - _Tools - True - - - - - - - True - False - S_QL Window - True - - - - - True - gtk-execute - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - False - _Debug Window - True - - - - - True - debug.xpm - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - False - E_xport Schema - True - - - - - True - gtk-convert - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - - - - - True - GNOMEUIINFO_MENU_HELP_TREE - - - - - - - True - GNOMEUIINFO_MENU_ABOUT_ITEM - - - - - - - True - - - - - - True - Contents - True - - - - - True - gtk-help - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - - - - - - BONOBO_DOCK_TOP - 0 - 0 - 0 - BONOBO_DOCK_ITEM_BEH_EXCLUSIVE|BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL|BONOBO_DOCK_ITEM_BEH_LOCKED - - - - - - True - GTK_SHADOW_OUT - - - - 1 - True - GTK_ORIENTATION_HORIZONTAL - GTK_TOOLBAR_ICONS - True - - - - True - Open database file - gtk-open - - - - - - - True - False - View database file properties - gtk-properties - - - - - - - True - Close database file - gtk-close - - - - - - - True - False - Perform SQL query - gtk-execute - - - - True - - - - - - True - False - Export schema definition - gtk-convert - - - - - - - - - BONOBO_DOCK_TOP - 1 - 0 - 0 - BONOBO_DOCK_ITEM_BEH_EXCLUSIVE - - - - - - True - False - 0 - - - - True - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - - - True - 0.5 - 0.5 - 1 - 1 - - - - True - False - 0 - - - - 10 - True - 0 - 0.5 - GTK_SHADOW_IN - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - - - 0 - True - True - - - - - - 18 - 120 - True - False - 10 - - - - True - True - Definition - True - GTK_RELIEF_NORMAL - - - - 0 - False - False - - - - - - True - True - Data - True - GTK_RELIEF_NORMAL - - - - 0 - False - False - - - - - - True - True - Export - True - GTK_RELIEF_NORMAL - - - - 0 - False - False - - - - - 0 - False - False - - - - - - - False - True - - - - - - True - False - 2 - - - - True - table.xpm - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - True - Tables - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - tab - - - - - - True - False - 0 - - - - 10 - True - 0 - 0.5 - GTK_SHADOW_IN - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - - - 0 - True - True - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - False - True - - - - - - True - False - 2 - - - - True - query.xpm - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - True - Queries - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - tab - - - - - - True - False - 0 - - - - 10 - True - 0 - 0.5 - GTK_SHADOW_IN - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - - - 0 - True - True - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - False - True - - - - - - True - False - 2 - - - - True - forms.xpm - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - True - Forms - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - tab - - - - - - True - False - 0 - - - - 10 - True - 0 - 0.5 - GTK_SHADOW_IN - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - - - 0 - True - True - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - False - True - - - - - - True - False - 2 - - - - True - reports.xpm - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - True - Reports - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - tab - - - - - - True - False - 0 - - - - 10 - True - 0 - 0.5 - GTK_SHADOW_IN - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - - - 0 - True - True - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - False - True - - - - - - True - False - 2 - - - - True - macros.xpm - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - True - Macros - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - tab - - - - - - True - False - 0 - - - - 10 - True - 0 - 0.5 - GTK_SHADOW_IN - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - - - 0 - True - True - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - False - True - - - - - - True - False - 2 - - - - True - code.xpm - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - True - Modules - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - tab - - - - - 0 - True - True - - - - - - - 0 - True - True - - - - - - True - True - True - - - 0 - True - True - - - - + + + + + + + + True + MDB File Viewer + True + + + True + True + + + True + + + True + 1 + icons + + + True + Open database file + gtk-open + + + + False + True + + + + + True + False + View database file properties + gtk-properties + + + + False + True + + + + + True + False + Close database file + gtk-close + + + + False + True + + + + + True + False + Perform SQL query + gtk-execute + + + + False + True + + + + + True + False + Export schema definition + gtk-convert + + + + False + True + + + + + + + 1 + BONOBO_DOCK_ITEM_BEH_EXCLUSIVE + + + + + True + + + True + + + True + _File + True + + + + + gtk-open + True + True + True + + + + + + True + + + + + gtk-properties + True + False + True + True + + + + + + True + + + + + gtk-close + True + False + True + True + + + + + + True + + + + + True + item + True + + + + + + + True + item3 + True + + + + + + + True + item4 + True + + + + + + + True + item5 + True + + + + + + + True + + + + + gtk-quit + True + True + True + + + + + + + + + + True + _Edit + True + + + + + gtk-preferences + True + True + True + + + + + + + + + + True + _Tools + True + + + + + S_QL Window + True + False + True + False + + + + + True + gtk-execute + + + + + + + _Debug Window + True + False + True + False + + + + True + gtk-find + + + + + + + E_xport Schema + True + False + True + False + + + + True + gtk-convert + + + + + + + + + + + True + _Help + True + + + + + gtk-about + True + True + True + + + + + + True + + + + + gtk-help + True + True + True + + + + + + + + + + + + BONOBO_DOCK_ITEM_BEH_EXCLUSIVE | BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL | BONOBO_DOCK_ITEM_BEH_LOCKED + + + + + True + + + True + True + + + True + + + True + + + True + 10 + 0 + in + + + True + True + automatic + automatic + + + + + 0 + + + + + 120 + True + 18 + vertical + 10 + + + Definition + True + True + False + True + + + + False + False + 0 + + + + + Data + True + True + False + True + + + + False + False + 1 + + + + + Export + True + True + False + True + + + + False + False + 2 + + + + + False + False + 1 + + + + + + + + + True + 2 + + + True + table.xpm + + + 0 + + + + + True + Tables + + + False + False + 1 + + + + + False + tab + + + + + True + + + True + 10 + 0 + in + + + True + True + automatic + automatic + + + + + 0 + + + + + True + + + False + False + 1 + + + + + 1 + + + + + True + 2 + + + True + query.xpm + + + 0 + + + + + True + Queries + + + False + False + 1 + + + + + 1 + False + tab + + + + + True + + + True + 10 + 0 + in + + + True + True + automatic + automatic + + + + + 0 + + + + + True + + + False + False + 1 + + + + + 2 + + + + + True + 2 + + + True + forms.xpm + + + 0 + + + + + True + Forms + + + False + False + 1 + + + + + 2 + False + tab + + + + + True + + + True + 10 + 0 + in + + + True + True + automatic + automatic + + + + + 0 + + + + + True + + + False + False + 1 + + + + + 3 + + + + + True + 2 + + + True + reports.xpm + + + 0 + + + + + True + Reports + + + False + False + 1 + + + + + 3 + False + tab + + + + + True + + + True + 10 + 0 + in + + + True + True + automatic + automatic + + + + + 0 + + + + + True + + + False + False + 1 + + + + + 4 + + + + + True + 2 + + + True + macros.xpm + + + 0 + + + + + True + Macros + + + False + False + 1 + + + + + 4 + False + tab + + + + + True + + + True + 10 + 0 + in + + + True + True + automatic + automatic + + + + + 0 + + + + + True + + + False + False + 1 + + + + + 5 + + + + + True + 2 + + + True + code.xpm + + + 0 + + + + + True + Modules + + + False + False + 1 + + + + + 5 + False + tab + + + + + 0 + + + + + + + True + True + + + + + True + 4 + True + True + + + 1 + True + True + + + diff -Nru mdbtools-0.7/src/gmdb2/gmdb.h mdbtools-0.7.1/src/gmdb2/gmdb.h --- mdbtools-0.7/src/gmdb2/gmdb.h 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/gmdb.h 2013-10-13 08:51:24.000000000 +0000 @@ -1,20 +1,20 @@ -#include -#include +#ifndef _gmdb_h_ +#define _gmdb_h_ + #include #include #include #include #include #include - -#ifndef _gmdb_h_ -#define _gmdb_h_ +#include "mdbtools.h" +#include "mdbsql.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -void gmdb_info_msg(gchar *message); +/* info.c */ GtkWidget *gmdb_info_new(void); /* main2.c */ @@ -25,12 +25,13 @@ void gmdb_load_recent_files(void); 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_table_export_populate_dialog(GladeXML *xml); +/* table_def.c */ +void gmdb_table_def_new(MdbCatalogEntry *entry); + /* file.c */ void gmdb_file_select_cb(GtkWidget *w, gpointer data); void gmdb_file_close_cb(GtkWidget *w, gpointer data); @@ -80,15 +81,16 @@ void gmdb_table_set_sensitive(gboolean b); /* table_export.c */ -void gmdb_export_help_cb(GtkWidget *w, gpointer data); -void gmdb_table_export_button_cb(GtkWidget *w, gpointer data); -void gmdb_print_quote(FILE *outfile, int need_quote, char quotechar, char *colsep, char *str); void gmdb_export_get_delimiter(GladeXML *xml, gchar *delimiter, int max_buf); void gmdb_export_get_lineterm(GladeXML *xml, gchar *lineterm, int max_buf); -int gmdb_export_get_quote(GladeXML *xml); -char gmdb_export_get_quotechar(GladeXML *xml); +void gmdb_export_get_quotechar(GladeXML *xml, gchar *quotechar, int max_buf); +void gmdb_export_get_escapechar(GladeXML *xml, gchar *escapechar, int max_buf); +int gmdb_export_get_binmode(GladeXML *xml); int gmdb_export_get_headers(GladeXML *xml); gchar *gmdb_export_get_filepath(GladeXML *xml); +void gmdb_export_help_cb(GtkWidget *w, gpointer data); +void gmdb_print_col(FILE *outfile, gchar *col_val, int quote_text, int col_type, int bin_len, char *quote_char, char *escape_char, int bin_mode); +void gmdb_table_export_button_cb(GtkWidget *w, gpointer data); extern MdbSQL *sql; diff -Nru mdbtools-0.7/src/gmdb2/help/C/Makefile.am mdbtools-0.7.1/src/gmdb2/help/C/Makefile.am --- mdbtools-0.7/src/gmdb2/help/C/Makefile.am 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/help/C/Makefile.am 2013-10-13 08:51:24.000000000 +0000 @@ -1,9 +1,8 @@ -figs = \ - figures/gmdb2_window.png \ - figures/gmdb2_sql_window.png +include $(top_srcdir)/xmldocs.make +dist-hook: app-dist-hook + +figdir = figures docname = gmdb lang = C omffile = gmdb-C.omf entities = legal.xml -include xmldocs.make -dist-hook: app-dist-hook diff -Nru mdbtools-0.7/src/gmdb2/help/C/xmldocs.make mdbtools-0.7.1/src/gmdb2/help/C/xmldocs.make --- mdbtools-0.7/src/gmdb2/help/C/xmldocs.make 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/help/C/xmldocs.make 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -# 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 -Nru mdbtools-0.7/src/gmdb2/info.c mdbtools-0.7.1/src/gmdb2/info.c --- mdbtools-0.7/src/gmdb2/info.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/info.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,6 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include "gmdb.h" extern GtkWidget *app; @@ -37,6 +38,8 @@ gchar *filename, *filepath; int i; struct stat st; +char* version; +MdbCatalogEntry *entry = mdb_get_catalogentry_by_name(mdb, "SummaryInfo"); /* load the interface */ propswin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-props.glade", NULL, NULL); @@ -55,14 +58,33 @@ gtk_label_set_text(GTK_LABEL(label), filename); label = glade_xml_get_widget (propswin_xml, "props_jetver"); - gtk_label_set_text(GTK_LABEL(label), mdb->f->jet_version == MDB_VER_JET3 ? "3 (Access 97)" : "4 (Access 2000/XP)"); - + switch(mdb->f->jet_version) { + case MDB_VER_JET3: + version = "3 (Access 97)"; + break; + case MDB_VER_JET4: + version = "4 (Access 2000/XP/2003)"; + break; + case MDB_VER_ACCDB_2007: + version = "ACE 12 (Access 2007)"; + break; + case MDB_VER_ACCDB_2010: + version = "ACE 14 (Access 2010)"; + break; + default: + version = "Unknown"; + } + gtk_label_set_text(GTK_LABEL(label), version); + + label = glade_xml_get_widget (propswin_xml, "props_encrypted"); + gtk_label_set_text(GTK_LABEL(label), mdb->f->db_key ? "Yes" : "No"); + assert( fstat(mdb->f->fd, &st)!=-1 ); - sprintf(tmpstr, "%ld K", st.st_size/1024); + sprintf(tmpstr, "%zd K", (size_t)(st.st_size/1024)); label = glade_xml_get_widget (propswin_xml, "props_filesize"); gtk_label_set_text(GTK_LABEL(label), tmpstr); - sprintf(tmpstr, "%ld", st.st_size / mdb->fmt->pg_size); + sprintf(tmpstr, "%zd", (size_t)(st.st_size / mdb->fmt->pg_size)); label = glade_xml_get_widget (propswin_xml, "props_numpages"); gtk_label_set_text(GTK_LABEL(label), tmpstr); @@ -70,6 +92,29 @@ label = glade_xml_get_widget (propswin_xml, "props_numobjs"); gtk_label_set_text(GTK_LABEL(label), tmpstr); + if (entry && entry->props && entry->props->len) + { + // There is only one MdbProps for that kind of entry + MdbProperties *props = g_array_index(entry->props, MdbProperties*, 0); + const char *propval; + + propval = g_hash_table_lookup(props->hash, "Title"); + if (propval) { + label = glade_xml_get_widget (propswin_xml, "props_title"); + gtk_label_set_text(GTK_LABEL(label), propval); + } + propval = g_hash_table_lookup(props->hash, "Company"); + if (propval) { + label = glade_xml_get_widget (propswin_xml, "props_company"); + gtk_label_set_text(GTK_LABEL(label), propval); + } + propval = g_hash_table_lookup(props->hash, "Author"); + if (propval) { + label = glade_xml_get_widget (propswin_xml, "props_author"); + gtk_label_set_text(GTK_LABEL(label), propval); + } + } + g_free(filepath); return propswin; diff -Nru mdbtools-0.7/src/gmdb2/main2.c mdbtools-0.7.1/src/gmdb2/main2.c --- mdbtools-0.7/src/gmdb2/main2.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/main2.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,12 +15,13 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include #include #include -#include -#include -#include +#include "mdbtools.h" +#include "mdbver.h" +#include "mdbsql.h" #include "gmdb.h" GtkWidget *app; @@ -46,6 +47,7 @@ "Jeff Smith", "Filip Van Raemdonck", "Bernhard Reiter", + "Nirgal Vourgère", NULL }; const gchar *documenters[] = { @@ -54,6 +56,9 @@ }; GtkWidget *parent; GdkPixbuf *pixbuf=NULL; +FILE *flicense; +guint32 licenselen; +char *license; parent = gtk_widget_get_toplevel (button); if (!GTK_WIDGET_TOPLEVEL (parent)) @@ -62,18 +67,35 @@ if (!pixbuf) pixbuf = gdk_pixbuf_new_from_file (GMDB_ICONDIR "logo.xpm", NULL); + flicense = fopen(GMDB_ICONDIR "COPYING", "r"); + if (flicense) + { + fseek(flicense, 0, SEEK_END); + licenselen = ftell(flicense); + fseek(flicense, 0, SEEK_SET); + license = g_malloc(licenselen+1); + fread(license, 1, licenselen, flicense); + license[licenselen] = 0; + fclose(flicense); + } else { + fprintf(stderr, "Can't open " GMDB_ICONDIR "COPYING\n"); + license = NULL; + } + gtk_show_about_dialog ((GtkWindow*)parent, "authors", authors, "comments", _("GNOME MDB Viewer is a grapical interface to " "MDB Tools. It lets you view and export data and schema " - "from MDB files produced by MS Access 97/2000/XP/2003."), - "copyright", _("Copyright 2002-2006 Brian Bruns and others"), + "from MDB files produced by MS Access 97/2000/XP/2003/2007/2010."), + "copyright", _("Copyright 2002-2012 Brian Bruns and others"), "documenters", documenters, "logo", pixbuf, - "name", _("GNOME MDB Viewer"), + "program-name", _("GNOME MDB Viewer"), "version", MDB_VERSION_NO, "website", "http://mdbtools.sourceforge.net/", + "license", license, NULL); + g_free(license); } void @@ -137,8 +159,6 @@ /* initialize the SQL engine */ sql = mdb_sql_init(); #endif - /* initialize MDB Tools library */ - mdb_init(); /* Initialize GNOME */ /* Initialize gnome program */ @@ -175,7 +195,6 @@ /* free MDB Tools library */ mdb_sql_exit(sql); #endif - mdb_exit(); return 0; } diff -Nru mdbtools-0.7/src/gmdb2/prefs.c mdbtools-0.7.1/src/gmdb2/prefs.c --- mdbtools-0.7/src/gmdb2/prefs.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/prefs.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,10 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "gmdb.h" #include #include +#include "gmdb.h" extern GtkWidget *app; extern MdbHandle *mdb; diff -Nru mdbtools-0.7/src/gmdb2/schema.c mdbtools-0.7.1/src/gmdb2/schema.c --- mdbtools-0.7/src/gmdb2/schema.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/schema.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,11 +15,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "gmdb.h" #include #include #include +#include "gmdb.h" extern GtkWidget *app; extern MdbHandle *mdb; @@ -52,7 +52,7 @@ GtkWidget *dlg; - printf("file path %s\n",file_path); + //printf("file path %s\n",file_path); if ((outfile=fopen(file_path, "w"))==NULL) { GtkWidget* dlg = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, @@ -75,27 +75,40 @@ void gmdb_schema_export_cb(GtkWidget *w, gpointer data) { -GtkWidget *schemawin, *combo, *checkbox, *chooser; -gchar *file_path; +GtkWidget *schemawin, *checkbox, *chooser; +GtkComboBox *combobox; +const gchar *file_path; +gchar *tmp; int i; schemawin = glade_xml_get_widget (schemawin_xml, "schema_dialog"); - chooser = glade_xml_get_widget (schemawin_xml, "filechooserbutton1"); - file_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); + chooser = glade_xml_get_widget (schemawin_xml, "filename_entry"); + file_path = gtk_entry_get_text(GTK_ENTRY(chooser)); - combo = glade_xml_get_widget (schemawin_xml, "table_combo"); - strncpy(tabname,gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)),MDB_MAX_OBJ_NAME); + combobox = GTK_COMBO_BOX(glade_xml_get_widget(schemawin_xml, "table_combo")); + tmp = gtk_combo_box_get_active_text(combobox); + strncpy(tabname,tmp,MDB_MAX_OBJ_NAME); tabname[MDB_MAX_OBJ_NAME]=0; - if (!strcmp(tabname,ALL_TABLES)) tabname[0]='\0'; + if (!strcmp(tabname,ALL_TABLES)) + tabname[0]='\0'; - combo = glade_xml_get_widget (schemawin_xml, "backend_combo"); - if (!strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)),"Oracle")) strcpy(backend,"oracle"); - else if (!strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)),"Sybase")) strcpy(backend,"sybase"); - else if (!strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)),"MS SQL Server")) strcpy(backend,"sybase"); - else if (!strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)),"PostgreSQL")) strcpy(backend,"postgres"); - else if (!strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)),"MySQL")) strcpy(backend,"mysql"); - else strcpy(backend,"access"); + combobox = GTK_COMBO_BOX(glade_xml_get_widget (schemawin_xml, "backend_combo")); + tmp = gtk_combo_box_get_active_text(combobox); + if (!strcmp(tmp, "Oracle")) + strcpy(backend, "oracle"); + else if (!strcmp(tmp, "Sybase")) + strcpy(backend,"sybase"); + else if (!strcmp(tmp,"MS SQL Server")) + strcpy(backend,"sybase"); + else if (!strcmp(tmp, "PostgreSQL")) + strcpy(backend,"postgres"); + else if (!strcmp(tmp,"MySQL")) + strcpy(backend,"mysql"); + else if (!strcmp(tmp,"SQLite")) + strcpy(backend,"sqlite"); + else + strcpy(backend,"access"); /* make sure unknown default options are enabled */ export_options = MDB_SHEXP_DEFAULT; @@ -110,8 +123,8 @@ } //printf("%s %s %02X\n",tabname,backend,export_options); - gtk_widget_destroy(schemawin); gmdb_schema_export(file_path); + gtk_widget_destroy(schemawin); } static void check_default_options() { @@ -124,21 +137,23 @@ } static void refresh_available_options() { - GtkWidget *combo, *checkbox; + GtkComboBox *combobox; + GtkWidget *checkbox; guint32 capabilities; extern GHashTable *mdb_backends; /* FIXME */ MdbBackend *backend_obj; int i; - combo = glade_xml_get_widget (schemawin_xml, "backend_combo"); - if (!combo) return; /* window is beeing destroyed */ + combobox = GTK_COMBO_BOX(glade_xml_get_widget (schemawin_xml, "backend_combo")); + if (!combobox) return; /* window is beeing destroyed */ - const gchar *backend_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); + const gchar *backend_name = gtk_combo_box_get_active_text(combobox); if (!strcmp(backend_name,"Oracle")) strcpy(backend,"oracle"); else if (!strcmp(backend_name,"Sybase")) strcpy(backend,"sybase"); else if (!strcmp(backend_name,"MS SQL Server")) strcpy(backend,"sybase"); else if (!strcmp(backend_name,"PostgreSQL")) strcpy(backend,"postgres"); else if (!strcmp(backend_name,"MySQL")) strcpy(backend,"mysql"); + else if (!strcmp(backend_name,"SQLite")) strcpy(backend,"sqlite"); else strcpy(backend,"access"); backend_obj = (MdbBackend *) g_hash_table_lookup(mdb_backends, backend); @@ -153,7 +168,8 @@ } void -gmdb_schema_capabilities_cb(GtkList *list) { +gmdb_schema_backend_cb(GtkComboBox *widget, gpointer data) +{ refresh_available_options(); } @@ -172,8 +188,7 @@ void gmdb_schema_new_cb(GtkWidget *w, gpointer data) { - GList *glist = NULL; - GtkWidget *combo; + GtkComboBox *combobox; MdbCatalogEntry *entry; int i; @@ -182,23 +197,22 @@ /* connect the signals in the interface */ glade_xml_signal_autoconnect(schemawin_xml); /* set up capabilities call back. TODO: autoconnect should do that */ - combo = glade_xml_get_widget(schemawin_xml, "combo-list2"); - g_signal_connect( G_OBJECT (combo), "selection_changed", - G_CALLBACK(gmdb_schema_capabilities_cb), schemawin_xml); + combobox = GTK_COMBO_BOX(glade_xml_get_widget(schemawin_xml, "backend_combo")); + gtk_combo_box_set_active(combobox, 0); + g_signal_connect( G_OBJECT (combobox), "changed", + G_CALLBACK(gmdb_schema_backend_cb), NULL); /* set signals with user data, anyone know how to do this in glade? */ - combo = glade_xml_get_widget (schemawin_xml, "table_combo"); - - glist = g_list_append(glist, ALL_TABLES); + combobox = GTK_COMBO_BOX(glade_xml_get_widget(schemawin_xml, "table_combo")); + gtk_combo_box_append_text(combobox, ALL_TABLES); /* add all user tables in catalog to list */ for (i=0; i < mdb->num_catalog; i++) { entry = g_ptr_array_index (mdb->catalog, i); if (mdb_is_user_table(entry)) { - glist = g_list_append(glist, entry->object_name); + gtk_combo_box_append_text(combobox, entry->object_name); } } /* for */ - gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); - g_list_free(glist); + gtk_combo_box_set_active(combobox, 0); check_default_options(); refresh_available_options(); diff -Nru mdbtools-0.7/src/gmdb2/sql.c mdbtools-0.7.1/src/gmdb2/sql.c --- mdbtools-0.7/src/gmdb2/sql.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/sql.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,27 +15,15 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "gmdb.h" #include #include +#include "gmdb.h" #if SQL -typedef struct GMdbSQLWindow { - GtkWidget *window; - GtkWidget *textbox; - GtkWidget *combo; - GtkWidget *clist; - GtkWidget *scroll; - GtkWidget *ctree; - GtkCTreeNode *current_node; - GList *history; -} GMdbSQLWindow; - GList *sql_list; -extern GtkWidget *app; extern MdbHandle *mdb; extern MdbSQL *sql; @@ -63,33 +51,40 @@ static void gmdb_sql_write_rslt_cb(GtkWidget *w, GladeXML *xml) { + /* We need to re-run the whole query because some information is not stored + * in the TreeStore, such as column types. + */ gchar *file_path; GladeXML *sql_xml; GtkWidget *filesel, *dlg; FILE *outfile; int i; int need_headers = 0; - int need_quote = 0; gchar delimiter[11]; - gchar quotechar; + gchar quotechar[5]; + gchar escape_char[5]; + int bin_mode; gchar lineterm[5]; - gchar *str; - int rows=0, n_columns; - GtkWidget *treeview; - GtkTreeViewColumn *col; - GList *glist; - GtkTreeModel *store; - GtkTreeIter iter; - GValue value = { 0, }; - - filesel = glade_xml_get_widget (xml, "export_dialog"); - sql_xml = g_object_get_data(G_OBJECT(filesel), "sql_xml"); - //printf("sql_xml %p\n",sql_xml); - gmdb_export_get_delimiter(xml, delimiter, 10); - gmdb_export_get_lineterm(xml, lineterm, 5); - need_quote = gmdb_export_get_quote(xml); - quotechar = gmdb_export_get_quotechar(xml); + guint len; + gchar *buf; + GtkTextIter start, end; + GtkTextBuffer *txtbuffer; + GtkWidget *textview; + char **bound_values; + int *bound_lens; + MdbSQLColumn *sqlcol; + long row; + char *value; + size_t length; + MdbTableDef *table; + MdbColumn *col = NULL; + + gmdb_export_get_delimiter(xml, delimiter, sizeof(delimiter)); + gmdb_export_get_lineterm(xml, lineterm, sizeof(lineterm)); + gmdb_export_get_quotechar(xml, quotechar, sizeof(quotechar)); + gmdb_export_get_escapechar(xml, escape_char, sizeof(escape_char)); + bin_mode = gmdb_export_get_binmode(xml); need_headers = gmdb_export_get_headers(xml); file_path = gmdb_export_get_filepath(xml); @@ -102,53 +97,104 @@ return; } - treeview = glade_xml_get_widget (sql_xml, "sql_results"); - glist = gtk_tree_view_get_columns(GTK_TREE_VIEW(treeview)); - i = 0; - if (need_headers) { - while ((col = g_list_nth_data(glist, i))) { - gchar *title; - if (i>0) fputs(delimiter, outfile); - title = g_strdup(gtk_tree_view_column_get_title(col)); - gmdb_print_quote(outfile, need_quote, quotechar, - delimiter, title); - fputs(title, outfile); - gmdb_print_quote(outfile, need_quote, quotechar, - delimiter, title); - g_free(title); - i++; + /* Get SQL */ + filesel = glade_xml_get_widget (xml, "export_dialog"); + sql_xml = g_object_get_data(G_OBJECT(filesel), "sql_xml"); + //printf("sql_xml %p\n",sql_xml); + textview = glade_xml_get_widget(sql_xml, "sql_textview"); + txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); + len = gtk_text_buffer_get_char_count(txtbuffer); + gtk_text_buffer_get_iter_at_offset (txtbuffer, &start, 0); + gtk_text_buffer_get_iter_at_offset (txtbuffer, &end, len); + buf = gtk_text_buffer_get_text(txtbuffer, &start, &end, FALSE); + + + /* ok now execute it */ + mdb_sql_run_query(sql, buf); + if (mdb_sql_has_error(sql)) { + GtkWidget* dlg = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (w)), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, + "%s", mdb_sql_last_error(sql)); + gtk_dialog_run (GTK_DIALOG (dlg)); + gtk_widget_destroy (dlg); + mdb_sql_reset(sql); + + fclose(outfile); + gtk_widget_destroy(filesel); + return; + } + + bound_values = (char **) g_malloc(sql->num_columns * sizeof(char *)); + bound_lens = (int *) g_malloc(sql->num_columns * sizeof(int)); + + for (i=0; inum_columns; i++) { + /* bind columns */ + bound_values[i] = (char *) g_malloc0(MDB_BIND_SIZE); + mdb_sql_bind_column(sql, i+1, bound_values[i], &bound_lens[i]); + + /* display column titles */ + if (need_headers) { + if (i>0) + fputs(delimiter, outfile); + sqlcol = g_ptr_array_index(sql->columns,i); + gmdb_print_col(outfile, sqlcol->name, quotechar[0]!='\0', MDB_TEXT, 0, quotechar, escape_char, bin_mode); } - fputs(lineterm, outfile); - g_list_free(glist); } - store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)); - gtk_tree_model_get_iter_first(store, &iter); - rows=0; - g_value_init (&value, G_TYPE_STRING); - do { - rows++; - n_columns = gtk_tree_model_get_n_columns(store); - for (i=0; i < n_columns; i++) { - if (i>0) fputs(delimiter, outfile); - gtk_tree_model_get_value(store, &iter, i, &value); - str = (gchar *) g_value_get_string(&value); - gmdb_print_quote(outfile, need_quote, quotechar, delimiter, str); - fputs(str, outfile); - gmdb_print_quote(outfile, need_quote, quotechar, delimiter, str); - g_value_unset(&value); + row = 0; + while (mdb_fetch_row(sql->cur_table)) { + row++; + for (i=0; inum_columns; i++) { + if (i>0) + fputs(delimiter, outfile); + + sqlcol = g_ptr_array_index(sql->columns, i); + + /* Find col matching sqlcol */ + table = sql->cur_table; + for (i=0; inum_cols; i++) { + col = g_ptr_array_index(table->columns, i); + if (!strcasecmp(sqlcol->name, col->name)) + break; + } + /* assert(i!=table->num_cols). Can't happen, already checked. */ + + /* Don't quote NULLs */ + if (bound_lens[i] && sqlcol->bind_type != MDB_OLE) { + if (col->col_type == MDB_OLE) { + value = mdb_ole_read_full(mdb, col, &length); + } else { + value = bound_values[i]; + length = bound_lens[i]; + } + gmdb_print_col(outfile, value, quotechar[0]!='\0', col->col_type, length, quotechar, escape_char, bin_mode); + if (col->col_type == MDB_OLE) + free(value); + } } fputs(lineterm, outfile); - } while (gtk_tree_model_iter_next(store, &iter)); + } + + /* free the memory used to bind */ + for (i=0; inum_columns; i++) { + g_free(bound_values[i]); + } + + mdb_sql_reset(sql); + g_free(buf); fclose(outfile); - gtk_widget_destroy(filesel); + dlg = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (w)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, - _("%d rows successfully exported."), rows); + _("%ld rows successfully exported."), row); gtk_dialog_run (GTK_DIALOG (dlg)); gtk_widget_destroy (dlg); + + gtk_widget_destroy(filesel); } + + static void gmdb_sql_results_cb(GtkWidget *w, GladeXML *xml) { @@ -331,15 +377,13 @@ } static void -gmdb_sql_select_hist_cb(GtkList *list, GladeXML *xml) +gmdb_sql_select_hist_cb(GtkComboBox *combobox, GladeXML *xml) { gchar *buf; GtkTextBuffer *txtbuffer; - GtkWidget *combo, *textview; + GtkWidget *textview; - combo = glade_xml_get_widget(xml, "sql_combo"); - if (!combo) return; - buf = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); + buf = gtk_combo_box_get_active_text(combobox); if (!buf) return; textview = glade_xml_get_widget(xml, "sql_textview"); txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); @@ -349,6 +393,7 @@ static void gmdb_sql_execute_cb(GtkWidget *w, GladeXML *xml) { + guint len; gchar *buf; gchar *bound_data[256]; @@ -356,10 +401,9 @@ MdbSQLColumn *sqlcol; GtkTextBuffer *txtbuffer; GtkTextIter start, end; - GtkWidget *textview, *combo, *treeview; + GtkWidget *textview, *combobox, *treeview; GtkTreeModel *store; /*GtkWidget *window;*/ - GList *history; GType *gtypes; GtkTreeIter iter; GtkTreeViewColumn *column; @@ -375,18 +419,16 @@ /* stuff this query on the history */ textview = glade_xml_get_widget(xml, "sql_textview"); - combo = glade_xml_get_widget(xml, "sql_combo"); + combobox = glade_xml_get_widget(xml, "sql_combo"); txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); - len = gtk_text_buffer_get_char_count(txtbuffer); + len = gtk_text_buffer_get_char_count(txtbuffer); gtk_text_buffer_get_iter_at_offset (txtbuffer, &start, 0); gtk_text_buffer_get_iter_at_offset (txtbuffer, &end, len); buf = gtk_text_buffer_get_text(txtbuffer, &start, &end, FALSE); /* add to the history */ - history = g_object_get_data(G_OBJECT(combo),"hist_list"); - history = g_list_prepend(history, g_strdup(buf)); - g_object_set_data(G_OBJECT(combo), "hist_list", history); - gtk_combo_set_popdown_strings(GTK_COMBO(combo), history); + gtk_combo_box_prepend_text(GTK_COMBO_BOX(combobox), buf); + gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0); /* ok now execute it */ mdb_sql_run_query(sql, buf); @@ -462,7 +504,7 @@ void gmdb_sql_new_cb (GtkWidget *w, gpointer data) { GtkTargetEntry src; - GtkWidget *mi, *but, *combo; + GtkWidget *mi, *but, *combobox; GladeXML *sqlwin_xml; /* load the interface */ @@ -528,8 +570,8 @@ g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (gmdb_sql_execute_cb), sqlwin_xml); - combo = glade_xml_get_widget(sqlwin_xml, "sql_combo"); - g_signal_connect (G_OBJECT(GTK_COMBO(combo)->list), "selection-changed", + combobox = glade_xml_get_widget(sqlwin_xml, "sql_combo"); + g_signal_connect (G_OBJECT(GTK_COMBO_BOX(combobox)), "changed", G_CALLBACK (gmdb_sql_select_hist_cb), sqlwin_xml); but = glade_xml_get_widget (sqlwin_xml, "execute_button"); @@ -699,9 +741,9 @@ void gmdb_sql_new_cb (GtkWidget *w, gpointer data) { - GtkWidget* dlg = gtk_message_dialog_new (gtk_widget_get_toplevel (w), + GtkWidget* dlg = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (w)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, - _("SQL support was not built.\nRun configure with the --enable-sql option.")); + _("SQL support was not built.\nMake sure flex and yacc are installed at build time.")); gtk_dialog_run (GTK_DIALOG (dlg)); gtk_widget_destroy (dlg); } diff -Nru mdbtools-0.7/src/gmdb2/table.c mdbtools-0.7.1/src/gmdb2/table.c --- mdbtools-0.7/src/gmdb2/table.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/table.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,19 +15,14 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "gmdb.h" #include #include +#include "gmdb.h" -GtkWidget *table_list; -GtkWidget *table_data_window; -GtkWidget *table_def_window; -extern GtkWidget *app; extern GladeXML* mainwin_xml; extern MdbHandle *mdb; int selected_table = -1; -extern char *mdb_access_types[]; /* callbacks */ void diff -Nru mdbtools-0.7/src/gmdb2/table_data.c mdbtools-0.7.1/src/gmdb2/table_data.c --- mdbtools-0.7/src/gmdb2/table_data.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/table_data.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,6 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include "gmdb.h" extern GtkWidget *app; diff -Nru mdbtools-0.7/src/gmdb2/table_def.c mdbtools-0.7.1/src/gmdb2/table_def.c --- mdbtools-0.7/src/gmdb2/table_def.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/table_def.c 2013-10-13 08:51:24.000000000 +0000 @@ -1,5 +1,5 @@ /* MDB Tools - A library for reading MS Access database file - * Copyright (C) 2000 Brian Bruns + * Copyright (C) 2000-2012 Brian Bruns and others * * 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 @@ -15,10 +15,26 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include "gmdb.h" -extern GtkWidget *app; -extern MdbHandle *mdb; +#define COL_PK 0 +#define COL_NAME 1 +#define COL_TYPE 2 +#define COL_TYPETEXT 3 +#define COL_DESCRIPTION 4 +#define COL_LEN 5 +#define COL_FORMAT 6 +#define COL_DECIMALPLACES 7 +#define COL_INPUTMASK 8 +#define COL_CAPTION 9 +#define COL_DEFAULTVALUE 10 +#define COL_VALIDATIONRULE 11 +#define COL_VALIDATIONTEXT 12 +#define COL_REQUIRED 13 +#define COL_ALLOWZEROLENGTH 14 + +static void update_bottom_properties(GtkTreeView *treeview, GladeXML *xml); typedef struct GMdbDefWindow { gchar table_name[MDB_MAX_OBJ_NAME]; @@ -36,110 +52,484 @@ return FALSE; } -GtkWidget * +static gint +gmdb_table_def_cursorchanged(GtkTreeView *treeview, GladeXML *xml) +{ + update_bottom_properties(treeview, xml); + return FALSE; +} + +void gmdb_table_def_new(MdbCatalogEntry *entry) { +/* FIXME: many reference should be freed */ +GladeXML *xml; +GtkWindow *win; +GtkTreeView *treeview; +GtkListStore *store; +GtkTreeModel *model; +GtkTreeIter iter; +GtkTreeSelection *selection; +int i, j; +GMdbDefWindow *defw; MdbTableDef *table; -MdbIndex *idx; MdbColumn *col; -GtkWidget *clist; -GtkWidget *scroll; -GdkPixmap *pixmap; -GdkBitmap *mask; -int i,j; -gchar *titles[] = { "", "Column", "Name", "Type", "Size", "Allow Nulls", "Description" }; -gchar *row[sizeof(titles)/sizeof(titles[0])]; -GMdbDefWindow *defw; -GtkStyle *style; +const char *propval; +MdbIndex *idx; +GdkPixbuf *pixbuf; /* do we have an active window for this object? if so raise it */ for (i=0;itable_name, entry->object_name) && entry->object_type == MDB_TABLE) { gdk_window_raise (defw->window->window); - return defw->window; + return; } } - defw = g_malloc(sizeof(GMdbDefWindow)); - strcpy(defw->table_name, entry->object_name); - - defw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(defw->window), entry->object_name); - gtk_widget_set_usize(defw->window, 300,200); - gtk_widget_show(defw->window); - - gtk_signal_connect (GTK_OBJECT (defw->window), "delete_event", - GTK_SIGNAL_FUNC (gmdb_table_def_close), defw); - - scroll = gtk_scrolled_window_new(NULL,NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_widget_show (scroll); - gtk_container_add(GTK_CONTAINER(defw->window), scroll); + /* load the interface */ + xml = glade_xml_new(GMDB_GLADEDIR "gmdb-tabledef.glade", NULL, NULL); + glade_xml_signal_autoconnect(xml); + win = GTK_WINDOW(glade_xml_get_widget(xml, "window1")); + + gtk_window_set_title(win, entry->object_name); + gtk_window_set_default_size(win, 600, 400); + + /* icon to be used as primary key member indicator */ + pixbuf = gdk_pixbuf_new_from_file(GMDB_ICONDIR "pk.xpm", NULL); + + store = gtk_list_store_new(15, + GDK_TYPE_PIXBUF, /* part of primary key */ + G_TYPE_STRING, /* column name */ + G_TYPE_INT, /* type */ + G_TYPE_STRING, /* type as text */ + G_TYPE_STRING, /* description */ + G_TYPE_INT, /* length */ + G_TYPE_STRING, /* format */ + G_TYPE_INT, /* decimal places */ + G_TYPE_STRING, /* inputmask */ + G_TYPE_STRING, /* caption */ + G_TYPE_STRING, /* default value */ + G_TYPE_STRING, /* validation rule */ + G_TYPE_STRING, /* validation text */ + G_TYPE_BOOLEAN, /* required */ + G_TYPE_BOOLEAN /* allow zero length */ + ); /* read table */ table = mdb_read_table(entry); mdb_read_columns(table); mdb_rewind_table(table); - clist = gtk_clist_new_with_titles(sizeof(titles)/sizeof(titles[0]), titles); - gtk_clist_set_column_width (GTK_CLIST(clist), 0, 20); - gtk_clist_set_column_width (GTK_CLIST(clist), 1, 35); - gtk_clist_set_column_width (GTK_CLIST(clist), 2, 80); - gtk_clist_set_column_width (GTK_CLIST(clist), 3, 60); - gtk_clist_set_column_width (GTK_CLIST(clist), 4, 30); - gtk_clist_set_column_width (GTK_CLIST(clist), 5, 30); - gtk_clist_set_column_width (GTK_CLIST(clist), 6, 60); - gtk_widget_show(clist); - gtk_container_add(GTK_CONTAINER(scroll),clist); - for (i=0;inum_cols;i++) { - /* display column titles */ - const char *propval; + int required = 0; + gtk_list_store_append (store, &iter); col=g_ptr_array_index(table->columns,i); - row[0] = (char *) g_malloc0(MDB_BIND_SIZE); - row[1] = (char *) g_malloc0(MDB_BIND_SIZE); - row[2] = (char *) g_malloc0(MDB_BIND_SIZE); - row[3] = (char *) g_malloc0(MDB_BIND_SIZE); - row[4] = (char *) g_malloc0(MDB_BIND_SIZE); - row[5] = (char *) g_malloc0(MDB_BIND_SIZE); - row[6] = (char *) g_malloc0(MDB_BIND_SIZE); - strcpy(row[0],""); - sprintf(row[1],"%d", col->col_num+1); - strcpy(row[2],col->name); - strcpy(row[3], mdb_get_colbacktype_string(col)); - sprintf(row[4],"%d",col->col_size); - strcpy(row[5], col->is_fixed ? "No" : "Yes"); + gtk_list_store_set (store, &iter, + COL_NAME, col->name, + COL_TYPE, col->col_type, + COL_TYPETEXT, mdb_get_colbacktype_string(col), + COL_LEN, col->col_size, + COL_REQUIRED, 0, + -1); + propval = mdb_col_get_prop(col, "Description"); - strcpy(row[6], propval ? propval : ""); - gtk_clist_append(GTK_CLIST(clist), row); + if (propval) + gtk_list_store_set (store, &iter, + COL_DESCRIPTION, propval, + -1); + + propval = mdb_col_get_prop(col, "Format"); + if (propval) + gtk_list_store_set (store, &iter, + COL_FORMAT, propval, + -1); + + propval = mdb_col_get_prop(col, "DecimalPlaces"); + if (propval) + gtk_list_store_set (store, &iter, + COL_DECIMALPLACES, atoi(propval), + -1); + + propval = mdb_col_get_prop(col, "InputMask"); + if (propval) + gtk_list_store_set (store, &iter, + COL_INPUTMASK, propval, + -1); + + propval = mdb_col_get_prop(col, "Caption"); + if (propval) + gtk_list_store_set (store, &iter, + COL_CAPTION, propval, + -1); + + propval = mdb_col_get_prop(col, "DefaultValue"); + if (propval) + gtk_list_store_set (store, &iter, + COL_DEFAULTVALUE, propval, + -1); + + propval = mdb_col_get_prop(col, "ValidationRule"); + if (propval) + gtk_list_store_set (store, &iter, + COL_VALIDATIONRULE, propval, + -1); + + propval = mdb_col_get_prop(col, "ValidationText"); + if (propval) + gtk_list_store_set (store, &iter, + COL_VALIDATIONTEXT, propval, + -1); + + propval = mdb_col_get_prop(col, "AllowZeroLength"); + if (propval) + gtk_list_store_set (store, &iter, + COL_ALLOWZEROLENGTH, propval, + -1); + + if (col->col_type == MDB_BOOL) + required = 1; + else { + propval = mdb_col_get_prop(col, "Required"); + if (propval && propval[0]=='y') + required = 1; + } + gtk_list_store_set (store, &iter, + COL_REQUIRED, required, + -1); } - style = gtk_widget_get_style(clist); - pixmap = gdk_pixmap_create_from_xpm(clist->window, - &mask, - &style->bg[GTK_STATE_NORMAL], - GMDB_ICONDIR "pk.xpm"); + model = GTK_TREE_MODEL(store); mdb_read_indices(table); for (i=0;inum_idxs;i++) { idx = g_ptr_array_index (table->indices, i); - if (idx->index_type==1) { + if (idx->index_type==1) for (j=0;jnum_keys;j++) { - if (pixmap) gtk_clist_set_pixmap(GTK_CLIST(clist), idx->key_col_num[j]-1,0, pixmap, mask); - } - // } else { - //for (j=0;jnum_keys;j++) { - //sprintf(tmpstr,"%s:%d",idx->name,j); - //gtk_clist_set_text(GTK_CLIST(clist), idx->key_col_num[j]-1,0, tmpstr); - //} - } - } /* for */ + gtk_tree_model_iter_nth_child(model, &iter, NULL, idx->key_col_num[j]-1); + gtk_list_store_set (store, &iter, + COL_PK, pixbuf, + -1); + } + } - gtk_clist_columns_autosize(GTK_CLIST(clist)); - /* add this one to the window list */ + treeview = GTK_TREE_VIEW(glade_xml_get_widget(xml, "columns_treeview")); + gtk_tree_view_insert_column_with_attributes (treeview, + -1, + "PK", gtk_cell_renderer_pixbuf_new(), + "pixbuf", COL_PK, + NULL); + gtk_tree_view_insert_column_with_attributes (treeview, + -1, + "Name", gtk_cell_renderer_text_new(), + "text", COL_NAME, + NULL); + gtk_tree_view_insert_column_with_attributes (treeview, + -1, + "Type", gtk_cell_renderer_text_new(), + "text", COL_TYPETEXT, + NULL); + gtk_tree_view_insert_column_with_attributes (treeview, + -1, + "Description", gtk_cell_renderer_text_new(), + "text", COL_DESCRIPTION, + NULL); + + gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), model); + + /* The tree view has acquired its own reference to the + * model, so we can drop ours. That way the model will + * be freed automatically when the tree view is destroyed */ + g_object_unref (model); + + /* select first item */ + gtk_tree_model_iter_nth_child(model, &iter, NULL, 0); + selection = gtk_tree_view_get_selection(treeview); + gtk_tree_selection_select_iter(selection, &iter); + update_bottom_properties(treeview, xml); + + gtk_widget_show(GTK_WIDGET(win)); + + defw = g_malloc(sizeof(GMdbDefWindow)); + strcpy(defw->table_name, entry->object_name); + defw->window = GTK_WIDGET(win); window_list = g_list_append(window_list, defw); - return defw->window; + gtk_signal_connect (GTK_OBJECT (treeview), "cursor-changed", + GTK_SIGNAL_FUNC (gmdb_table_def_cursorchanged), xml); + gtk_signal_connect (GTK_OBJECT (defw->window), "delete_event", + GTK_SIGNAL_FUNC (gmdb_table_def_close), defw); +} + +/* That function is called when selection is changed + * It updates the window bottom information + */ +static void +update_bottom_properties_selected(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + GladeXML *xml) +{ +char tmp[20]; +gint col_type; +gint size; +char *format; +gint decimalplaces; +char *inputmask; +char *caption; +char *defaultvalue; +char *validationrule; +char *validationtext; +gboolean required; +gboolean allowzerolength; +GtkLabel *label; +GtkEntry *entry; + + gtk_tree_model_get(model, iter, + COL_TYPE, &col_type, + COL_LEN, &size, + COL_FORMAT, &format, + COL_DECIMALPLACES, &decimalplaces, + COL_INPUTMASK, &inputmask, + COL_CAPTION, &caption, + COL_DEFAULTVALUE, &defaultvalue, + COL_VALIDATIONRULE, &validationrule, + COL_VALIDATIONTEXT, &validationtext, + COL_REQUIRED, &required, + COL_ALLOWZEROLENGTH, &allowzerolength, + -1); + + //fprintf(stderr, "type=%d\n", col_type); + label = GTK_LABEL(glade_xml_get_widget(xml, "size_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "size_entry")); + switch (col_type) { + //case MDB_BOOL: + case MDB_BYTE: + case MDB_INT: + case MDB_LONGINT: + case MDB_MONEY: + case MDB_FLOAT: + case MDB_DOUBLE: + case MDB_DATETIME: + //case MDB_BINARY: + //case MDB_TEXT: + //case MDB_OLE: + //case MDB_MEMO: + //case MDB_REPID: + //case MDB_NUMERIC: + //case MDB_COMPLEX: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + sprintf(tmp, "%d", size); + gtk_entry_set_text(entry, tmp); + break; + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } + + label = GTK_LABEL(glade_xml_get_widget(xml, "format_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "format_entry")); + switch (col_type) { + case MDB_BOOL: + case MDB_BYTE: + case MDB_INT: + case MDB_LONGINT: + case MDB_MONEY: + case MDB_FLOAT: + case MDB_DOUBLE: + case MDB_DATETIME: + //case MDB_BINARY: + case MDB_TEXT: + //case MDB_OLE: + case MDB_MEMO: + //case MDB_REPID: + //case MDB_NUMERIC: + //case MDB_COMPLEX: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + sprintf(tmp, "%d", size); + gtk_entry_set_text(entry, format ? format : ""); + break; + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } + g_free(format); + + label = GTK_LABEL(glade_xml_get_widget(xml, "decimalplaces_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "decimalplaces_entry")); + switch (col_type) { + case MDB_BYTE: + case MDB_INT: + case MDB_LONGINT: + case MDB_FLOAT: + case MDB_DOUBLE: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + if (decimalplaces) { + sprintf(tmp, "%d", decimalplaces); + gtk_entry_set_text(entry, tmp); + } else + gtk_entry_set_text(entry, ""); + break; + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } + + label = GTK_LABEL(glade_xml_get_widget(xml, "inputmask_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "inputmask_entry")); + switch (col_type) { + //case MDB_BOOL: + case MDB_BYTE: + case MDB_INT: + case MDB_LONGINT: + case MDB_MONEY: + case MDB_FLOAT: + case MDB_DOUBLE: + case MDB_DATETIME: + //case MDB_BINARY: + case MDB_TEXT: + //case MDB_OLE: + case MDB_MEMO: + //case MDB_REPID: + //case MDB_NUMERIC: + //case MDB_COMPLEX: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + gtk_entry_set_text(entry, inputmask ? inputmask : ""); + break; + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } + g_free(inputmask); + + entry = GTK_ENTRY(glade_xml_get_widget(xml, "caption_entry")); + gtk_entry_set_text(entry, caption ? caption : ""); + g_free(caption); + + label = GTK_LABEL(glade_xml_get_widget(xml, "defaultvalue_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "defaultvalue_entry")); + switch (col_type) { + case MDB_BOOL: + case MDB_BYTE: + case MDB_INT: + case MDB_LONGINT: + case MDB_MONEY: + case MDB_FLOAT: + case MDB_DOUBLE: + case MDB_DATETIME: + //case MDB_BINARY: + case MDB_TEXT: + //case MDB_OLE: + //case MDB_MEMO: + //case MDB_REPID: + //case MDB_NUMERIC: + //case MDB_COMPLEX: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + gtk_entry_set_text(entry, defaultvalue ? defaultvalue : ""); + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } + g_free(defaultvalue); + + label = GTK_LABEL(glade_xml_get_widget(xml, "validationrule_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "validationrule_entry")); + switch (col_type) { + case MDB_BOOL: + case MDB_BYTE: + case MDB_INT: + case MDB_LONGINT: + case MDB_MONEY: + case MDB_FLOAT: + case MDB_DOUBLE: + case MDB_DATETIME: + //case MDB_BINARY: + case MDB_TEXT: + //case MDB_OLE: + case MDB_MEMO: + //case MDB_REPID: + //case MDB_NUMERIC: + //case MDB_COMPLEX: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + gtk_entry_set_text(entry, validationrule ? validationrule : ""); + break; + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } + g_free(validationrule); + + label = GTK_LABEL(glade_xml_get_widget(xml, "validationtext_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "validationtext_entry")); + switch (col_type) { + case MDB_BOOL: + case MDB_BYTE: + case MDB_INT: + case MDB_LONGINT: + case MDB_MONEY: + case MDB_FLOAT: + case MDB_DOUBLE: + case MDB_DATETIME: + //case MDB_BINARY: + case MDB_TEXT: + //case MDB_OLE: + case MDB_MEMO: + //case MDB_REPID: + //case MDB_NUMERIC: + //case MDB_COMPLEX: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + gtk_entry_set_text(entry, validationtext ? validationtext : ""); + break; + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } + g_free(validationtext); + + entry = GTK_ENTRY(glade_xml_get_widget(xml, "required_entry")); + gtk_entry_set_text(entry, required ? "Yes" : "No"); + + label = GTK_LABEL(glade_xml_get_widget(xml, "allowzerolength_label")); + entry = GTK_ENTRY(glade_xml_get_widget(xml, "allowzerolength_entry")); + switch (col_type) { + //case MDB_BOOL: + //case MDB_BYTE: + //case MDB_INT: + //case MDB_LONGINT: + //case MDB_MONEY: + //case MDB_FLOAT: + //case MDB_DOUBLE: + //case MDB_DATETIME: + //case MDB_BINARY: + case MDB_TEXT: + //case MDB_OLE: + case MDB_MEMO: + //case MDB_REPID: + //case MDB_NUMERIC: + //case MDB_COMPLEX: + gtk_widget_show(GTK_WIDGET(label)); + gtk_widget_show(GTK_WIDGET(entry)); + gtk_entry_set_text(entry, allowzerolength ? "Yes" : "No"); + break; + default: + gtk_widget_hide(GTK_WIDGET(label)); + gtk_widget_hide(GTK_WIDGET(entry)); + } +} + +static void +update_bottom_properties(GtkTreeView *treeview, GladeXML *xml) { +GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection(treeview); + gtk_tree_selection_selected_foreach(selection, + (GtkTreeSelectionForeachFunc)update_bottom_properties_selected, + xml); } diff -Nru mdbtools-0.7/src/gmdb2/table_export.c mdbtools-0.7.1/src/gmdb2/table_export.c --- mdbtools-0.7/src/gmdb2/table_export.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/table_export.c 2013-10-13 08:51:24.000000000 +0000 @@ -15,11 +15,12 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "gmdb.h" +#include #include #include #include +#include "gmdb.h" extern GtkWidget *app; extern MdbHandle *mdb; @@ -41,80 +42,103 @@ #define NEVER "Never" #define AUTOMAT "Automatic (where necessary)" -void -gmdb_print_quote(FILE *outfile, int need_quote, char quotechar, char *colsep, char *str) -{ - if (need_quote==1) { - fprintf(outfile, "%c", quotechar); - } else if (need_quote==-1) { - if (strstr(str,colsep)) { - fprintf(outfile, "%c", quotechar); - } - } -} +#define NOQUOTE "Don't quote" + +#define BIN_STRIP "Strip" +#define BIN_RAW "Raw" +#define BIN_OCTAL "Octal" void gmdb_export_get_delimiter(GladeXML *xml, gchar *delimiter, int max_buf) { - GtkWidget *combo; + GtkComboBox *combobox; gchar *str; - combo = glade_xml_get_widget(xml, "sep_combo"); - str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); - if (!strcmp(str,COMMA)) { strcpy(delimiter, ","); } - else if (!strcmp(str,TAB)) { strcpy(delimiter, "\t"); } - else if (!strcmp(str,SPACE)) { strcpy(delimiter, " "); } - else if (!strcmp(str,COLON)) { strcpy(delimiter, ":"); } - else if (!strcmp(str,SEMICOLON)) { strcpy(delimiter, ";"); } - else if (!strcmp(str,PIPE)) { strcpy(delimiter, "|"); } - else { - strncpy(delimiter,str, 10); - delimiter[10]='\0'; - } + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "sep_combo")); + str = gtk_combo_box_get_active_text(combobox); + if (!strcmp(str,COMMA)) + strncpy(delimiter, ",", max_buf); + else if (!strcmp(str,TAB)) + strncpy(delimiter, "\t", max_buf); + else if (!strcmp(str,SPACE)) + strncpy(delimiter, " ", max_buf); + else if (!strcmp(str,COLON)) + strncpy(delimiter, ":", max_buf); + else if (!strcmp(str,SEMICOLON)) + strncpy(delimiter, ";", max_buf); + else if (!strcmp(str,PIPE)) + strncpy(delimiter, "|", max_buf); + else + strncpy(delimiter, str, max_buf); + if (max_buf) + delimiter[max_buf-1] = '\0'; } void gmdb_export_get_lineterm(GladeXML *xml, gchar *lineterm, int max_buf) { - GtkWidget *combo; + GtkComboBox *combobox; gchar *str; - combo = glade_xml_get_widget(xml, "term_combo"); - str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); - if (!strcmp(str,LF)) { strcpy(lineterm, "\n"); } - else if (!strcmp(str,CR)) { strcpy(lineterm, "\r"); } - else if (!strcmp(str,CRLF)) { strcpy(lineterm, "\r\n"); } + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "term_combo")); + str = gtk_combo_box_get_active_text (combobox); + if (!strcmp(str,LF)) + strncpy(lineterm, "\n", max_buf); + else if (!strcmp(str,CR)) + strncpy(lineterm, "\r", max_buf); + else if (!strcmp(str,CRLF)) + strncpy(lineterm, "\r\n", max_buf); + if (max_buf) + lineterm[max_buf-1] = '\0'; } -int -gmdb_export_get_quote(GladeXML *xml) +void +gmdb_export_get_quotechar(GladeXML *xml, gchar *quotechar, int max_buf) { - GtkWidget *combo; - int need_quote = 0; + GtkComboBox *combobox; gchar *str; - combo = glade_xml_get_widget(xml, "quote_combo"); - str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); - if (!strcmp(str,ALWAYS)) { need_quote = 1; } - else if (!strcmp(str,NEVER)) { need_quote = 0; } - else if (!strcmp(str,AUTOMAT)) { need_quote = -1; } + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "qchar_combo")); + str = gtk_combo_box_get_active_text (combobox); + if (!strcmp(str, NOQUOTE)) + quotechar[0] = '\0'; /* Quoting disabled */ + else + strncpy(quotechar, str, max_buf); + if (max_buf) + quotechar[max_buf-1] = '\0'; +} + +void +gmdb_export_get_escapechar(GladeXML *xml, gchar *escapechar, int max_buf) +{ + GtkComboBox *combobox; + gchar *str; - return need_quote; + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "escchar_combo")); + str = gtk_combo_box_get_active_text (combobox); + strncpy(escapechar, str, max_buf); + if (max_buf) + escapechar[max_buf-1] = '\0'; } -char -gmdb_export_get_quotechar(GladeXML *xml) +int +gmdb_export_get_binmode(GladeXML *xml) { - GtkWidget *combo; + GtkComboBox *combobox; gchar *str; - char quotechar; - combo = glade_xml_get_widget(xml, "qchar_combo"); - str = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); - quotechar = str[0]; + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "bin_combo")); + str = gtk_combo_box_get_active_text (combobox); - return quotechar; + if (!strcmp(str,BIN_STRIP)) + return MDB_BINEXPORT_STRIP; + else if (!strcmp(str,BIN_OCTAL)) + return MDB_BINEXPORT_OCTAL; + else + return MDB_BINEXPORT_RAW; } + + int gmdb_export_get_headers(GladeXML *xml) { @@ -131,8 +155,8 @@ { GtkWidget *fchoose; - fchoose = glade_xml_get_widget(xml, "filechooserbutton1"); - return (gchar *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fchoose)); + fchoose = glade_xml_get_widget(xml, "filename_entry"); + return (gchar *) gtk_entry_get_text (GTK_ENTRY (fchoose)); } void @@ -146,29 +170,83 @@ g_error_free (error); } } + +/* That function is a duplicate of the one in util/mdb-export.c + * They should be merged and moved in libmdb (backend.c) + */ +#define is_quote_type(x) (x==MDB_TEXT || x==MDB_OLE || x==MDB_MEMO || x==MDB_DATETIME || x==MDB_BINARY || x==MDB_REPID) +#define is_binary_type(x) (x==MDB_OLE || x==MDB_BINARY || x==MDB_REPID) +//#define DONT_ESCAPE_ESCAPE +void +gmdb_print_col(FILE *outfile, gchar *col_val, int quote_text, int col_type, int bin_len, char *quote_char, char *escape_char, int bin_mode) +{ + size_t quote_len = strlen(quote_char); /* multibyte */ + + size_t orig_escape_len = escape_char ? strlen(escape_char) : 0; + + /* double the quote char if no escape char passed */ + if (!escape_char) + escape_char = quote_char; + + if (quote_text && is_quote_type(col_type)) { + fputs(quote_char, outfile); + while (1) { + if (is_binary_type(col_type)) { + if (bin_mode == MDB_BINEXPORT_STRIP) + break; + if (!bin_len--) + break; + } else /* use \0 sentry */ + if (!*col_val) + break; + + if (quote_len && !strncmp(col_val, quote_char, quote_len)) { + fprintf(outfile, "%s%s", escape_char, quote_char); + col_val += quote_len; +#ifndef DONT_ESCAPE_ESCAPE + } else if (orig_escape_len && !strncmp(col_val, escape_char, orig_escape_len)) { + fprintf(outfile, "%s%s", escape_char, escape_char); + col_val += orig_escape_len; +#endif + } else if (is_binary_type(col_type) && *col_val <= 0 && bin_mode == MDB_BINEXPORT_OCTAL) + fprintf(outfile, "\\%03o", *(unsigned char*)col_val++); + else + putc(*col_val++, outfile); + } + fputs(quote_char, outfile); + } else + fputs(col_val, outfile); +} + + void gmdb_table_export_button_cb(GtkWidget *w, gpointer data) { gchar *file_path; FILE *outfile; -gchar *bound_data[256]; +char **bound_values; +int *bound_lens; MdbTableDef *table; MdbColumn *col; int i; int need_headers = 0; -int need_quote = 0; gchar delimiter[11]; -gchar quotechar; +gchar quotechar[5]; +gchar escape_char[5]; gchar lineterm[5]; +int bin_mode = MDB_BINEXPORT_RAW; int rows=0; +char *value; +size_t length; GtkWidget *exportwin, *dlg; - gmdb_export_get_delimiter(exportwin_xml, delimiter, 10); - gmdb_export_get_lineterm(exportwin_xml, lineterm, 5); - need_quote = gmdb_export_get_quote(exportwin_xml); - quotechar = gmdb_export_get_quotechar(exportwin_xml); + gmdb_export_get_delimiter(exportwin_xml, delimiter, sizeof(delimiter)); + gmdb_export_get_lineterm(exportwin_xml, lineterm, sizeof(lineterm)); + gmdb_export_get_quotechar(exportwin_xml, quotechar, sizeof(quotechar)); + gmdb_export_get_escapechar(exportwin_xml, escape_char, sizeof(escape_char)); need_headers = gmdb_export_get_headers(exportwin_xml); + bin_mode = gmdb_export_get_binmode(exportwin_xml); file_path = gmdb_export_get_filepath(exportwin_xml); // printf("file path %s\n",file_path); @@ -186,18 +264,19 @@ mdb_read_columns(table); mdb_rewind_table(table); + bound_values = (char **) g_malloc(table->num_cols * sizeof(char *)); + bound_lens = (int *) g_malloc(table->num_cols * sizeof(int)); for (i=0;inum_cols;i++) { /* bind columns */ - bound_data[i] = (char *) g_malloc0(MDB_BIND_SIZE); - mdb_bind_column(table, i+1, bound_data[i], NULL); + bound_values[i] = (char *) g_malloc0(MDB_BIND_SIZE); + mdb_bind_column(table, i+1, bound_values[i], &bound_lens[i]); /* display column titles */ - col=g_ptr_array_index(table->columns,i); - if (need_headers) { - if (i>0) fputs(delimiter, outfile); - gmdb_print_quote(outfile, need_quote, quotechar, delimiter, col->name); - fputs(col->name, outfile); - gmdb_print_quote(outfile, need_quote, quotechar, delimiter, col->name); + if (need_headers) { + if (i>0) + fputs(delimiter, outfile); + col=g_ptr_array_index(table->columns,i); + gmdb_print_col(outfile, col->name, quotechar[0]!='\0', MDB_TEXT, 0, quotechar, escape_char, bin_mode); } } if (need_headers) fputs(lineterm, outfile); @@ -205,10 +284,21 @@ /* fetch those rows! */ while(mdb_fetch_row(table)) { for (i=0;inum_cols;i++) { - if (i>0) fputs(delimiter, outfile); - gmdb_print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]); - fputs(bound_data[i], outfile); - gmdb_print_quote(outfile, need_quote, quotechar, delimiter, bound_data[i]); + if (i>0) + fputs(delimiter, outfile); + col=g_ptr_array_index(table->columns,i); + /* Don't quote NULLs */ + if (bound_lens[i]) { + if (col->col_type == MDB_OLE) { + value = mdb_ole_read_full(mdb, col, &length); + } else { + value = bound_values[i]; + length = bound_lens[i]; + } + gmdb_print_col(outfile, value, quotechar[0]!='\0', col->col_type, length, quotechar, escape_char, bin_mode); + if (col->col_type == MDB_OLE) + free(value); + } } fputs(lineterm, outfile); rows++; @@ -216,8 +306,10 @@ /* free the memory used to bind */ for (i=0;inum_cols;i++) { - g_free(bound_data[i]); + g_free(bound_values[i]); } + g_free(bound_values); + g_free(bound_lens); fclose(outfile); exportwin = glade_xml_get_widget (exportwin_xml, "export_dialog"); @@ -241,41 +333,38 @@ void gmdb_table_export_populate_dialog(GladeXML *xml) { - GList *glist = NULL; - GtkWidget *combo; + GtkComboBox *combobox; - /* Create the widgets */ - combo = glade_xml_get_widget (xml, "term_combo"); - glist = g_list_append(glist, LF); - glist = g_list_append(glist, CR); - glist = g_list_append(glist, CRLF); - gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); - g_list_free(glist); - - combo = glade_xml_get_widget (xml, "sep_combo"); - glist = NULL; - glist = g_list_append(glist, COMMA); - glist = g_list_append(glist, TAB); - glist = g_list_append(glist, SPACE); - glist = g_list_append(glist, COLON); - glist = g_list_append(glist, SEMICOLON); - glist = g_list_append(glist, PIPE); - gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); - g_list_free(glist); - - combo = glade_xml_get_widget (xml, "quote_combo"); - glist = NULL; - glist = g_list_append(glist, ALWAYS); - glist = g_list_append(glist, NEVER); - glist = g_list_append(glist, AUTOMAT); - gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); - g_list_free(glist); - - combo = glade_xml_get_widget (xml, "qchar_combo"); - glist = NULL; - glist = g_list_append(glist, "\""); - glist = g_list_append(glist, "'"); - glist = g_list_append(glist, "`"); - gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); - g_list_free(glist); + /* Populate the widgets */ + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "term_combo")); + gtk_combo_box_append_text(combobox, LF); + gtk_combo_box_append_text(combobox, CR); + gtk_combo_box_append_text(combobox, CRLF); + gtk_combo_box_set_active(combobox, 0); + + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "sep_combo")); + gtk_combo_box_append_text(combobox, COMMA); + gtk_combo_box_append_text(combobox, TAB); + gtk_combo_box_append_text(combobox, SPACE); + gtk_combo_box_append_text(combobox, COLON); + gtk_combo_box_append_text(combobox, SEMICOLON); + gtk_combo_box_append_text(combobox, PIPE); + gtk_combo_box_set_active(combobox, 0); + + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "qchar_combo")); + gtk_combo_box_append_text(combobox, "\""); + gtk_combo_box_append_text(combobox, "'"); + gtk_combo_box_append_text(combobox, "`"); + gtk_combo_box_append_text(combobox, NOQUOTE); + gtk_combo_box_set_active(combobox, 0); + + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "escchar_combo")); + gtk_combo_box_append_text(combobox, "\\"); + gtk_combo_box_set_active(combobox, 0); + + combobox = GTK_COMBO_BOX(glade_xml_get_widget(xml, "bin_combo")); + gtk_combo_box_append_text(combobox, BIN_STRIP); + gtk_combo_box_append_text(combobox, BIN_RAW); + gtk_combo_box_append_text(combobox, BIN_OCTAL); + gtk_combo_box_set_active(combobox, 1); } diff -Nru mdbtools-0.7/src/gmdb2/util.c mdbtools-0.7.1/src/gmdb2/util.c --- mdbtools-0.7/src/gmdb2/util.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/gmdb2/util.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#include "gmdb.h" - -void gmdb_info_msg(gchar *message) { -GtkWidget *dialog, *label, *okay_button; - - /* Create the widgets */ - dialog = gtk_dialog_new(); - gtk_widget_set_uposition(dialog, 300, 300); - label = gtk_label_new (message); - gtk_widget_set_usize(label, 250, 100); - okay_button = gtk_button_new_with_label("Okay"); - - /* Ensure that the dialog box is destroyed when the user clicks ok. */ - - g_signal_connect_swapped (G_OBJECT (okay_button), "clicked", - G_CALLBACK (gtk_widget_destroy), dialog); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), - okay_button); - - /* Add the label, and show everything we've added to the dialog. */ - - gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label); - gtk_widget_show_all (dialog); -} diff -Nru mdbtools-0.7/src/libmdb/Makefile.am mdbtools-0.7.1/src/libmdb/Makefile.am --- mdbtools-0.7/src/libmdb/Makefile.am 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/Makefile.am 2013-10-13 08:51:24.000000000 +0000 @@ -1,5 +1,5 @@ lib_LTLIBRARIES = libmdb.la libmdb_la_SOURCES= catalog.c mem.c file.c table.c data.c dump.c backend.c money.c sargs.c index.c like.c write.c stats.c map.c props.c worktable.c options.c iconv.c -libmdb_la_LDFLAGS = -version-info 2:0:0 -Wl,--version-script=$(srcdir)/libmdb.map -AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) -LIBS = $(GLIB_LIBS) @LIBS@ +libmdb_la_LDFLAGS = -version-info 2:1:0 -export-symbols-regex '^(mdb_|_mdb_put_int16$$|_mdb_put_int32$$)' +AM_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) +LIBS = $(GLIB_LIBS) @LIBS@ @LIBICONV@ diff -Nru mdbtools-0.7/src/libmdb/backend.c mdbtools-0.7.1/src/libmdb/backend.c --- mdbtools-0.7/src/libmdb/backend.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/backend.c 2013-10-13 08:51:24.000000000 +0000 @@ -35,6 +35,7 @@ static int is_init; GHashTable *mdb_backends; +void _mdb_remove_backends(); /* Access data types */ static MdbBackendType mdb_access_types[] = { @@ -145,11 +146,33 @@ MdbBackendType_STRUCT_ELEMENT("text",1,0,1), MdbBackendType_STRUCT_ELEMENT("blob",0,0,0), MdbBackendType_STRUCT_ELEMENT("text",1,0,1), - MdbBackendType_STRUCT_ELEMENT("numeric",1,1,0), + MdbBackendType_STRUCT_ELEMENT("char(38)",0,0,0), MdbBackendType_STRUCT_ELEMENT("numeric",1,1,0), }; static MdbBackendType mdb_mysql_shortdate_type = MdbBackendType_STRUCT_ELEMENT("date",0,0,0); + +/* sqlite data types */ +static MdbBackendType mdb_sqlite_types[] = { + MdbBackendType_STRUCT_ELEMENT("BLOB", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("INTEGER", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("INTEGER", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("INTEGER", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("INTEGER", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("REAL", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("REAL", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("REAL", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("DateTime", 0,0,1), + MdbBackendType_STRUCT_ELEMENT("BLOB", 0,0,1), + MdbBackendType_STRUCT_ELEMENT("varchar", 0,0,1), + MdbBackendType_STRUCT_ELEMENT("BLOB", 0,0,1), + MdbBackendType_STRUCT_ELEMENT("TEXT", 0,0,1), + MdbBackendType_STRUCT_ELEMENT("BLOB", 0,0,1), + MdbBackendType_STRUCT_ELEMENT("BLOB", 0,0,1), + MdbBackendType_STRUCT_ELEMENT("INTEGER", 0,0,0), + MdbBackendType_STRUCT_ELEMENT("INTEGER", 0,0,0), +}; + #ifndef JAVA static gboolean mdb_drop_backend(gpointer key, gpointer value, gpointer data); @@ -237,8 +260,8 @@ return quote_generic(value, '\'', '\''); } -/* deprecated */ char * -mdb_get_coltype_string(MdbBackend *backend, int col_type) +MDB_DEPRECATED(char*, +mdb_get_coltype_string(MdbBackend *backend, int col_type)) { static int warn_deprecated = 0; static char buf[16]; @@ -255,8 +278,8 @@ return backend->types_table[col_type].name; } -/* deprecated */ int -mdb_coltype_takes_length(MdbBackend *backend, int col_type) +MDB_DEPRECATED(int, +mdb_coltype_takes_length(MdbBackend *backend, int col_type)) { static int warn_deprecated = 0; if (!warn_deprecated) { @@ -303,13 +326,19 @@ return type->needs_length; } +MDB_DEPRECATED(void, +mdb_init_backends()) +{ + fprintf(stderr, "mdb_init_backends() is DEPRECATED and does nothing. Stop calling it.\n"); +} + /** - * mdb_init_backends + * _mdb_init_backends * * Initializes the mdb_backends hash and loads the builtin backends. * Use mdb_remove_backends() to destroy this hash when done. */ -void mdb_init_backends() +MDB_CONSTRUCTOR(_mdb_init_backends) { mdb_backends = g_hash_table_new(g_str_hash, g_str_equal); @@ -354,16 +383,29 @@ "COMMENT ON TABLE %s IS %s;\n", quote_schema_name_dquote); mdb_register_backend("mysql", - MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES, + MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_DEFVALUES, mdb_mysql_types, &mdb_mysql_shortdate_type, NULL, "current_date", "now()", "-- That file uses encoding %s\n", "DROP TABLE IF EXISTS %s;\n", "ALTER TABLE %s ADD CHECK (%s <>'');\n", - "COMMENT ON COLUMN %s.%s IS %s;\n", - "COMMENT ON TABLE %s IS %s;\n", + NULL, + NULL, quote_schema_name_rquotes_merge); + mdb_register_backend("sqlite", + MDB_SHEXP_DROPTABLE|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES, + mdb_sqlite_types, NULL, NULL, + "date('now')", "date('now')", + "-- That file uses encoding %s\n", + "DROP TABLE IF EXISTS %s;\n", + NULL, + NULL, + NULL, + quote_schema_name_rquotes_merge); + + atexit(_mdb_remove_backends); } + void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendType *backend_type, MdbBackendType *type_shortdate, MdbBackendType *type_autonum, const char *short_now, const char *long_now, const char *charset_statement, const char *drop_statement, const char *constaint_not_empty_statement, const char *column_comment_statement, const char *table_comment_statement, gchar* (*quote_schema_name)(const gchar*, const gchar*)) { MdbBackend *backend = (MdbBackend *) g_malloc0(sizeof(MdbBackend)); @@ -382,12 +424,19 @@ g_hash_table_insert(mdb_backends, backend_name, backend); } +MDB_DEPRECATED(void, +mdb_remove_backends()) +{ + fprintf(stderr, "mdb_remove_backends() is DEPRECATED and does nothing. Stop calling it.\n"); +} + /** * mdb_remove_backends * * Removes all entries from and destroys the mdb_backends hash. */ -void mdb_remove_backends() +void +_mdb_remove_backends() { g_hash_table_foreach_remove(mdb_backends, mdb_drop_backend, NULL); g_hash_table_destroy(mdb_backends); @@ -415,6 +464,7 @@ backend = (MdbBackend *) g_hash_table_lookup(mdb_backends, backend_name); if (backend) { mdb->default_backend = backend; + g_free(mdb->backend_name); // NULL is ok mdb->backend_name = (char *) g_strdup(backend_name); is_init = 0; return 1; @@ -475,7 +525,7 @@ fprintf (outfile, " UNIQUE"); fprintf(outfile, " INDEX %s ON %s (", quoted_name, quoted_table_name); } - free(quoted_name); + g_free(quoted_name); free(index_name); for (j=0;jnum_keys;j++) { @@ -488,12 +538,14 @@ /* no DESC for primary keys */ fprintf(outfile, " DESC"); - free(quoted_name); + g_free(quoted_name); } fprintf (outfile, ");\n"); } fputc ('\n', outfile); + + g_free(quoted_table_name); } /** @@ -531,6 +583,8 @@ backend = 1; } else if (!strcmp(mdb->backend_name, "postgres")) { backend = 2; + } else if (!strcmp(mdb->backend_name, "sqlite")) { + backend = 3; } else { if (is_init == 0) { /* the first time through */ is_init = 1; @@ -593,7 +647,7 @@ grbit = atoi(bound[4]); constraint_name = g_strconcat(bound[1], "_", bound[0], "_fk", NULL); quoted_constraint_name = mdb->default_backend->quote_schema_name(dbnamespace, constraint_name); - free(constraint_name); + g_free(constraint_name); if (grbit & 0x00000002) { text = g_strconcat( @@ -605,6 +659,7 @@ switch (backend) { case 1: /* oracle */ case 2: /* postgres */ + case 3: /* sqlite */ text = g_strconcat( "ALTER TABLE ", quoted_table_1, " ADD CONSTRAINT ", quoted_constraint_name, @@ -617,11 +672,11 @@ break; } } - free(quoted_table_1); - free(quoted_column_1); - free(quoted_table_2); - free(quoted_column_2); - free(quoted_constraint_name); + g_free(quoted_table_1); + g_free(quoted_column_1); + g_free(quoted_table_2); + g_free(quoted_column_2); + g_free(quoted_constraint_name); return (char *)text; } @@ -660,7 +715,7 @@ quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name); fprintf (outfile, "\t%s\t\t\t%s", quoted_name, mdb_get_colbacktype_string (col)); - free(quoted_name); + g_free(quoted_name); if (mdb_colbacktype_takes_length(col)) { @@ -693,7 +748,7 @@ if (defval[0]=='"' && defval[def_len-1]=='"') { /* this is a string */ gchar *output_default = malloc(def_len-1); - gchar *output_default_escaped = malloc(def_len-1); + gchar *output_default_escaped; memcpy(output_default, defval+1, def_len-2); output_default[def_len-2] = 0; output_default_escaped = quote_with_squotes(output_default); @@ -751,14 +806,14 @@ fprintf(outfile, mdb->default_backend->column_comment_statement, quoted_table_name, quoted_name, comment); - free(comment); + g_free(comment); } } - free(quoted_name); + g_free(quoted_name); } - /* Add the constraints on table */ + /* Add the comments on table */ if (export_options & MDB_SHEXP_COMMENTS) { prop_value = mdb_table_get_prop(table, "Description"); if (prop_value) { @@ -766,7 +821,7 @@ fprintf(outfile, mdb->default_backend->table_comment_statement, quoted_table_name, comment); - free(comment); + g_free(comment); } } fputc('\n', outfile); @@ -776,7 +831,7 @@ // prints all the indexes of that table mdb_print_indexes(outfile, table, dbnamespace); - free(quoted_table_name); + g_free(quoted_table_name); mdb_free_tabledef (table); } @@ -788,6 +843,7 @@ unsigned int i; char *the_relation; MdbCatalogEntry *entry; + const char *charset; /* clear unsupported options */ export_options &= mdb->default_backend->capabilities; @@ -803,7 +859,7 @@ "-- ----------------------------------------------------------\n\n", outfile); - const char *charset = mdb_target_charset(mdb); + charset = mdb_target_charset(mdb); if (charset) { fprintf(outfile, mdb->default_backend->charset_statement, charset); fputc('\n', outfile); diff -Nru mdbtools-0.7/src/libmdb/catalog.c mdbtools-0.7.1/src/libmdb/catalog.c --- mdbtools-0.7/src/libmdb/catalog.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/catalog.c 2013-10-13 08:51:24.000000000 +0000 @@ -35,7 +35,7 @@ "Module", "Relationship", "Unknown 0x09", - "Unknown 0x0a", + "User Info", "Database" }; @@ -48,11 +48,21 @@ void mdb_free_catalog(MdbHandle *mdb) { - unsigned int i; + unsigned int i, j; + MdbCatalogEntry *entry; if ((!mdb) || (!mdb->catalog)) return; - for (i=0; icatalog->len; i++) - g_free (g_ptr_array_index(mdb->catalog, i)); + for (i=0; icatalog->len; i++) { + entry = (MdbCatalogEntry *)g_ptr_array_index(mdb->catalog, i); + if (entry) { + if (entry->props) { + for (j=0; jprops->len; j++) + mdb_free_props(g_array_index(entry->props, MdbProperties*, j)); + g_array_free(entry->props, TRUE); + } + g_free(entry); + } + } g_ptr_array_free(mdb->catalog, TRUE); mdb->catalog = NULL; } @@ -128,6 +138,21 @@ return mdb->catalog; } + +MdbCatalogEntry * +mdb_get_catalogentry_by_name(MdbHandle *mdb, const gchar* name) +{ + unsigned int i; + MdbCatalogEntry *entry; + + for (i=0; inum_catalog; i++) { + entry = g_ptr_array_index(mdb->catalog, i); + if (!strcasecmp(entry->object_name, name)) + return entry; + } + return NULL; +} + void mdb_dump_catalog(MdbHandle *mdb, int obj_type) { @@ -138,10 +163,10 @@ for (i=0;inum_catalog;i++) { entry = g_ptr_array_index(mdb->catalog,i); if (obj_type==MDB_ANY || entry->object_type==obj_type) { - fprintf(stdout,"Type: %-10s Name: %-18s T pg: %04x", + printf("Type: %-12s Name: %-48s Page: %06lx\n", mdb_get_objtype_string(entry->object_type), entry->object_name, - (unsigned int) entry->table_pg); + entry->table_pg); } } return; diff -Nru mdbtools-0.7/src/libmdb/data.c mdbtools-0.7.1/src/libmdb/data.c --- mdbtools-0.7/src/libmdb/data.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/data.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,9 +16,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include #include "mdbtools.h" -#include "time.h" -#include "math.h" #ifdef DMALLOC #include "dmalloc.h" @@ -139,12 +139,12 @@ if (row > 1000) return -1; /* if lookupflag is not set, it's good (deleteflag is ok) */ - for (i = row; i > 0; i--) { - row_start = mdb_get_int16(mdb->pg_buf, (rco + i*2)); - if (!(row_start & 0x8000)) { - break; - } - } + for (i = row; i > 0; i--) { + row_start = mdb_get_int16(mdb->pg_buf, (rco + i*2)); + if (!(row_start & 0x8000)) { + break; + } + } row_end = (i == 0) ? mdb->fmt->pg_size : row_start & OFFSET_MASK; #endif @@ -223,9 +223,9 @@ //fprintf(stdout,"len %d size %d\n",len, col->col_size); char *str; if (col->col_type == MDB_NUMERIC) { - str = mdb_numeric_to_string(mdb, start, col->col_prec, col->col_scale); + str = mdb_numeric_to_string(mdb, start, col->col_prec, col->col_scale); } else { - str = mdb_col_to_string(mdb, mdb->pg_buf, start, col->col_type, len); + str = mdb_col_to_string(mdb, mdb->pg_buf, start, col->col_type, len); } strcpy(col->bind_ptr, str); g_free(str); @@ -477,15 +477,15 @@ int row_start; size_t len; - if (ole_ptr) { - ole_len = mdb_get_int32(ole_ptr, 0); - mdb_debug(MDB_DEBUG_OLE,"ole len = %d ole flags = %02x", - ole_len & 0x00ffffff, ole_len >> 24); - - if ((ole_len & 0x80000000) - || (ole_len & 0x40000000)) - /* inline or single-page fields don't have a next */ - return 0; + if (ole_ptr) { + ole_len = mdb_get_int32(ole_ptr, 0); + mdb_debug(MDB_DEBUG_OLE,"ole len = %d ole flags = %02x", + ole_len & 0x00ffffff, ole_len >> 24); + + if ((ole_len & 0x80000000) + || (ole_len & 0x40000000)) + /* inline or single-page fields don't have a next */ + return 0; } mdb_debug(MDB_DEBUG_OLE, "pg_row %d", col->cur_blob_pg_row); if (!col->cur_blob_pg_row) @@ -840,6 +840,27 @@ return text; } +static char * +mdb_uuid_to_string(MdbHandle *mdb, int start) +{ + char *text = NULL; + unsigned short uuid1, uuid2, uuid3, uuid4, uuid5, uuid6, uuid7, uuid8; + + uuid1 = mdb_get_int16(mdb->pg_buf, start); + uuid2 = mdb_get_int16(mdb->pg_buf, start + 2); + uuid3 = mdb_get_int16(mdb->pg_buf, start + 4); + uuid4 = mdb_get_int16(mdb->pg_buf, start + 6); + uuid5 = mdb_get_int16(mdb->pg_buf, start + 8); + uuid6 = mdb_get_int16(mdb->pg_buf, start + 10); + uuid7 = mdb_get_int16(mdb->pg_buf, start + 12); + uuid8 = mdb_get_int16(mdb->pg_buf, start + 14); + + text = g_strdup_printf("{%04x%04x-%04x-%04x-%04x-%04x%04x%04x}", + uuid1, uuid2, uuid3, uuid4, uuid5, uuid6, uuid7, uuid8); + + return text; +} + #if 0 int floor_log10(double f, int is_single) { @@ -890,6 +911,7 @@ (short)mdb_get_int16(buf, start)); break; case MDB_LONGINT: + case MDB_COMPLEX: text = g_strdup_printf("%ld", mdb_get_int32(buf, start)); break; @@ -908,6 +930,7 @@ text = g_malloc(size); memcpy((char*)buf+start, text, size); } + break; case MDB_TEXT: if (size<0) { text = g_strdup(""); @@ -927,6 +950,9 @@ text = mdb_money_to_string(mdb, start); case MDB_NUMERIC: break; + case MDB_REPID: + text = mdb_uuid_to_string(mdb, start); + break; default: text = g_strdup(""); break; @@ -946,6 +972,7 @@ return 6; break; case MDB_LONGINT: + case MDB_COMPLEX: return 11; break; case MDB_FLOAT: @@ -982,6 +1009,7 @@ return 2; break; case MDB_LONGINT: + case MDB_COMPLEX: return 4; break; case MDB_FLOAT: diff -Nru mdbtools-0.7/src/libmdb/file.c mdbtools-0.7.1/src/libmdb/file.c --- mdbtools-0.7/src/libmdb/file.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/file.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "mdbtools.h" #ifdef DMALLOC @@ -133,7 +134,11 @@ /* try the provided file name first */ if (!stat(file_name, &status)) { - return g_strdup(file_name); + char *result; + result = g_strdup(file_name); + if (!result) + fprintf(stderr, "Can't alloc filename\n"); + return result; } /* Now pull apart $MDBPATH and try those */ @@ -185,7 +190,7 @@ mdb->f->fd = -1; mdb->f->filename = mdb_find_file(filename); if (!mdb->f->filename) { - fprintf(stderr, "Can't alloc filename\n"); + fprintf(stderr, "File not found\n"); mdb_close(mdb); return NULL; } @@ -217,11 +222,16 @@ return NULL; } mdb->f->jet_version = mdb_get_int32(mdb->pg_buf, 0x14); - if (IS_JET4(mdb)) { - mdb->fmt = &MdbJet4Constants; - } else if (IS_JET3(mdb)) { + switch(mdb->f->jet_version) { + case MDB_VER_JET3: mdb->fmt = &MdbJet3Constants; - } else { + break; + case MDB_VER_JET4: + case MDB_VER_ACCDB_2007: + case MDB_VER_ACCDB_2010: + mdb->fmt = &MdbJet4Constants; + break; + default: fprintf(stderr,"Unknown Jet version.\n"); mdb_close(mdb); return NULL; @@ -254,7 +264,7 @@ /* get the db password located at 0x42 bytes into the file */ for (pos=0;pos<14;pos++) { - j = mdb_get_int32(mdb,0x42+pos); + j = mdb_get_int32(mdb->pg_buf, 0x42+pos); j ^= key[pos]; if ( j != 0) mdb->f->db_passwd[pos] = j; @@ -359,7 +369,7 @@ fstat(mdb->f->fd, &status); if (status.st_size < offset) { - fprintf(stderr,"offset %lu is beyond EOF\n",offset); + fprintf(stderr,"offset %jd is beyond EOF\n",(intmax_t)offset); return 0; } if (mdb->stats && mdb->stats->collect) diff -Nru mdbtools-0.7/src/libmdb/iconv.c mdbtools-0.7.1/src/libmdb/iconv.c --- mdbtools-0.7/src/libmdb/iconv.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/iconv.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "mdbtools.h" -#include "errno.h" #ifdef DMALLOC #include "dmalloc.h" @@ -38,7 +38,7 @@ return 0; /* Uncompress 'Unicode Compressed' string into tmp */ - if (IS_JET4(mdb) && (slen>=2) + if (!IS_JET3(mdb) && (slen>=2) && ((src[0]&0xff)==0xff) && ((src[1]&0xff)==0xfe)) { unsigned int compress=1; src += 2; @@ -72,8 +72,8 @@ iconv(mdb->iconv_in, &in_ptr, &len_in, &out_ptr, &len_out); if ((!len_in) || (errno == E2BIG)) break; /* Don't bail if impossible conversion is encountered */ - in_ptr += (IS_JET4(mdb)) ? 2 : 1; - len_in -= (IS_JET4(mdb)) ? 2 : 1; + in_ptr += (IS_JET3(mdb)) ? 1 : 2; + len_in -= (IS_JET3(mdb)) ? 1 : 2; *out_ptr++ = '?'; len_out--; } @@ -139,7 +139,7 @@ #endif /* Unicode Compression */ - if(IS_JET4(mdb) && (dlen>4)) { + if(!IS_JET3(mdb) && (dlen>4)) { unsigned char *tmp = g_malloc(dlen); unsigned int tptr = 0, dptr = 0; int comp = 1; @@ -189,7 +189,7 @@ iconv_code = "UTF-8"; return iconv_code; #else - if (IS_JET4(mdb)) + if (!IS_JET3(mdb)) return "ISO-8859-1"; return NULL; // same as input: unknown #endif @@ -205,7 +205,7 @@ } #ifdef HAVE_ICONV - if (IS_JET4(mdb)) { + if (!IS_JET3(mdb)) { mdb->iconv_out = iconv_open("UCS-2LE", iconv_code); mdb->iconv_in = iconv_open(iconv_code, "UCS-2LE"); } else { diff -Nru mdbtools-0.7/src/libmdb/index.c mdbtools-0.7.1/src/libmdb/index.c --- mdbtools-0.7/src/libmdb/index.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/index.c 2013-10-13 08:51:24.000000000 +0000 @@ -76,14 +76,14 @@ table->indices = g_ptr_array_new(); - if (IS_JET4(mdb)) { - cur_pos = table->index_start + 52 * table->num_real_idxs; - idx2_sz = 28; - type_offset = 23; - } else { + if (IS_JET3(mdb)) { cur_pos = table->index_start + 39 * table->num_real_idxs; idx2_sz = 20; type_offset = 19; + } else { + cur_pos = table->index_start + 52 * table->num_real_idxs; + idx2_sz = 28; + type_offset = 23; } //fprintf(stderr, "num_idxs:%d num_real_idxs:%d\n", table->num_idxs, table->num_real_idxs); @@ -117,10 +117,10 @@ for (i=0;inum_idxs;i++) { pidx = g_ptr_array_index (table->indices, i); - if (IS_JET4(mdb)) { - name_sz=read_pg_if_16(mdb, &cur_pos); - } else { + if (IS_JET3(mdb)) { name_sz=read_pg_if_8(mdb, &cur_pos); + } else { + name_sz=read_pg_if_16(mdb, &cur_pos); } tmpbuf = g_malloc(name_sz); read_pg_if_n(mdb, tmpbuf, &cur_pos, name_sz); @@ -133,15 +133,17 @@ mdb_read_pg(mdb, index_start_pg); cur_pos = table->index_start; for (i=0;inum_real_idxs;i++) { - if (IS_JET4(mdb)) cur_pos += 4; + if (!IS_JET3(mdb)) cur_pos += 4; /* look for index number i */ for (j=0; jnum_idxs; ++j) { pidx = g_ptr_array_index (table->indices, j); if (pidx->index_type!=2 && pidx->index_num==i) break; } - if (j==table->num_idxs) + if (j==table->num_idxs) { fprintf(stderr, "ERROR: can't find index #%d.\n", i); + continue; + } //fprintf(stderr, "index %d #%d (%s) index_type:%d\n", i, pidx->index_num, pidx->name, pidx->index_type); pidx->num_rows = mdb_get_int32(mdb->alt_pg_buf, @@ -193,7 +195,7 @@ pidx->first_pg = read_pg_if_32(mdb, &cur_pos); pidx->flags = read_pg_if_8(mdb, &cur_pos); //fprintf(stderr, "pidx->first_pg:%d pidx->flags:0x%02x\n", pidx->first_pg, pidx->flags); - if (IS_JET4(mdb)) cur_pos += 9; + if (!IS_JET3(mdb)) cur_pos += 9; } return NULL; } diff -Nru mdbtools-0.7/src/libmdb/libmdb.map mdbtools-0.7.1/src/libmdb/libmdb.map --- mdbtools-0.7/src/libmdb/libmdb.map 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/libmdb.map 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -{ -global: - mdb_*; - _mdb_put_int16; - _mdb_put_int32; - -local: - *; -}; diff -Nru mdbtools-0.7/src/libmdb/like.c mdbtools-0.7.1/src/libmdb/like.c --- mdbtools-0.7/src/libmdb/like.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/like.c 2013-10-13 08:51:24.000000000 +0000 @@ -18,7 +18,7 @@ #include #include -#include +#include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" diff -Nru mdbtools-0.7/src/libmdb/mem.c mdbtools-0.7.1/src/libmdb/mem.c --- mdbtools-0.7/src/libmdb/mem.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/mem.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,37 +16,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef JAVA -#include "javadefines.h" -#else #include "mdbtools.h" -#include -#ifdef DMALLOC -#include "dmalloc.h" -#endif -#endif /* JAVA */ -/** - * mdb_init: - * - * Initializes the LibMDB library. This function should be called exactly once - * by calling program and prior to any other function. - * - **/ -/* METHOD */ void mdb_init() +MDB_DEPRECATED(void, +mdb_init()) { - mdb_init_backends(); + fprintf(stderr, "mdb_init() is DEPRECATED and does nothing. Stop calling it.\n"); } -/** - * mdb_exit: - * - * Cleans up the LibMDB library. This function should be called exactly once - * by the calling program prior to exiting (or prior to final use of LibMDB - * functions). - * - **/ -/* METHOD */ void mdb_exit() +MDB_DEPRECATED(void, +mdb_exit()) { - mdb_remove_backends(); + fprintf(stderr, "mdb_exit() is DEPRECATED and does nothing. Stop calling it.\n"); } diff -Nru mdbtools-0.7/src/libmdb/options.c mdbtools-0.7.1/src/libmdb/options.c --- mdbtools-0.7/src/libmdb/options.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/options.c 2013-10-13 08:51:24.000000000 +0000 @@ -20,8 +20,7 @@ #include #include #include - -#include +#include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" diff -Nru mdbtools-0.7/src/libmdb/props.c mdbtools-0.7.1/src/libmdb/props.c --- mdbtools-0.7/src/libmdb/props.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/props.c 2013-10-13 08:51:24.000000000 +0000 @@ -25,9 +25,9 @@ int pos = 0; gchar *name; GPtrArray *names = NULL; + int i=0; names = g_ptr_array_new(); - int i=0; #if MDB_DEBUG mdb_buffer_dump(kkd, 0, len); #endif @@ -50,12 +50,23 @@ } return names; } +static gboolean +free_hash_entry(gpointer key, gpointer value, gpointer user_data) +{ + g_free(key); + g_free(value); + return TRUE; +} void mdb_free_props(MdbProperties *props) { if (!props) return; if (props->name) g_free(props->name); + if (props->hash) { + g_hash_table_foreach(props->hash, (GHFunc)free_hash_entry, 0); + g_hash_table_destroy(props->hash); + } g_free(props); } @@ -148,7 +159,7 @@ /* * That function takes a raw KKD/MR2 binary buffer, * typically read from LvProp in table MSysbjects - * and returns a GPtrArray of MdbProps* + * and returns a GArray of MdbProps* */ GArray* mdb_kkd_to_props(MdbHandle *mdb, void *buffer, size_t len) { @@ -157,18 +168,20 @@ size_t pos; GPtrArray *names = NULL; MdbProperties *props; + GArray *result; #if MDB_DEBUG mdb_buffer_dump(buffer, 0, len); #endif mdb_debug(MDB_DEBUG_PROPS,"starting prop parsing of type %s", buffer); + if (strcmp("KKD", buffer) && strcmp("MR2", buffer)) { fprintf(stderr, "Unrecognized format.\n"); mdb_buffer_dump(buffer, 0, len); return NULL; } - GArray *result = g_array_new(0, 0, sizeof(MdbProperties*)); + result = g_array_new(0, 0, sizeof(MdbProperties*)); pos = 4; while (pos < len) { diff -Nru mdbtools-0.7/src/libmdb/sargs.c mdbtools-0.7.1/src/libmdb/sargs.c --- mdbtools-0.7/src/libmdb/sargs.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/sargs.c 2013-10-13 08:51:24.000000000 +0000 @@ -26,8 +26,9 @@ * datatype support is a bit weak at this point. To add more types create * a mdb_test_[type]() function and invoke it from mdb_test_sarg() */ -#include "mdbtools.h" + #include +#include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" #endif @@ -101,7 +102,9 @@ mdb_test_date(MdbSargNode *node, double td) { struct tm found; - char date_tmp[MDB_BIND_SIZE]; //you should figure out a way to pull mdb_date_to_string in here + /* TODO: you should figure out a way to pull mdb_date_to_string in here + * char date_tmp[MDB_BIND_SIZE]; + */ time_t found_t; time_t asked_t; diff -Nru mdbtools-0.7/src/libmdb/table.c mdbtools-0.7.1/src/libmdb/table.c --- mdbtools-0.7/src/libmdb/table.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/table.c 2013-10-13 08:51:24.000000000 +0000 @@ -199,11 +199,20 @@ } void mdb_free_columns(GPtrArray *columns) { - unsigned int i; + unsigned int i, j; + MdbColumn *col; if (!columns) return; - for (i=0; ilen; i++) - g_free (g_ptr_array_index(columns, i)); + for (i=0; ilen; i++) { + col = (MdbColumn *) g_ptr_array_index(columns, i); + if (col->sargs) { + for (j=0; jsargs->len; j++) { + g_free( g_ptr_array_index(col->sargs, j)); + } + g_ptr_array_free(col->sargs, TRUE); + } + g_free(col); + } g_ptr_array_free(columns, TRUE); } GPtrArray *mdb_read_columns(MdbTableDef *table) @@ -215,6 +224,7 @@ unsigned int i, j; int cur_pos; size_t name_sz; + GArray *allprops; table->columns = g_ptr_array_new(); @@ -287,14 +297,10 @@ char *tmp_buf; pcol = g_ptr_array_index(table->columns, i); - if (IS_JET4(mdb)) { - name_sz = read_pg_if_16(mdb, &cur_pos); - } else if (IS_JET3(mdb)) { + if (IS_JET3(mdb)) name_sz = read_pg_if_8(mdb, &cur_pos); - } else { - fprintf(stderr,"Unknown MDB version\n"); - continue; - } + else + name_sz = read_pg_if_16(mdb, &cur_pos); tmp_buf = (char *) g_malloc(name_sz); read_pg_if_n(mdb, tmp_buf, &cur_pos, name_sz); mdb_unicode2ascii(mdb, tmp_buf, name_sz, pcol->name, MDB_MAX_OBJ_NAME); @@ -306,7 +312,7 @@ /* Sort the columns by col_num */ g_ptr_array_sort(table->columns, (GCompareFunc)mdb_col_comparer); - GArray *allprops = table->entry->props; + allprops = table->entry->props; if (allprops) for (i=0;inum_cols;i++) { pcol = g_ptr_array_index(table->columns, i); diff -Nru mdbtools-0.7/src/libmdb/write.c mdbtools-0.7.1/src/libmdb/write.c --- mdbtools-0.7/src/libmdb/write.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/libmdb/write.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,9 +16,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include +#include #include "mdbtools.h" -#include "time.h" -#include "math.h" #ifdef DMALLOC #include "dmalloc.h" @@ -29,23 +30,47 @@ static int mdb_add_row_to_leaf_pg(MdbTableDef *table, MdbIndex *idx, MdbIndexPage *ipg, MdbField *idx_fields, guint32 pgnum, guint16 rownum); void -_mdb_put_int16(void *buf, guint32 offset, guint32 value) +mdb_put_int16(void *buf, guint32 offset, guint32 value) { value = GINT32_TO_LE(value); memcpy(buf + offset, &value, 2); } void -_mdb_put_int32(void *buf, guint32 offset, guint32 value) +_mdb_put_int16(void *buf, guint32 offset, guint32 value) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("mdb_put_int16"))); +#else +{ mdb_put_int16(buf, offset, value); } +#endif + +void +mdb_put_int32(void *buf, guint32 offset, guint32 value) { value = GINT32_TO_LE(value); memcpy(buf + offset, &value, 4); } void -_mdb_put_int32_msb(void *buf, guint32 offset, guint32 value) +_mdb_put_int32(void *buf, guint32 offset, guint32 value) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("mdb_put_int32"))); +#else +{ mdb_put_int32(buf, offset, value); } +#endif + +void +mdb_put_int32_msb(void *buf, guint32 offset, guint32 value) { value = GINT32_TO_BE(value); memcpy(buf + offset, &value, 4); } +void +_mdb_put_int32_mdb(void *buf, guint32 offset, guint32 value) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("mdb_put_int32_msb"))); +#else +{ mdb_put_int32_msb(buf, offset, value); } +#endif + ssize_t mdb_write_pg(MdbHandle *mdb, unsigned long pg) { @@ -56,7 +81,7 @@ fstat(mdb->f->fd, &status); /* is page beyond current size + 1 ? */ if (status.st_size < offset + mdb->fmt->pg_size) { - fprintf(stderr,"offset %lu is beyond EOF\n",offset); + fprintf(stderr,"offset %jd is beyond EOF\n",(intmax_t)offset); return 0; } lseek(mdb->f->fd, offset, SEEK_SET); @@ -160,12 +185,12 @@ mdb_buffer_dump(pg_buf, row_start, row_end - row_start + 1); } - if (IS_JET4(mdb)) { - row_cols = mdb_get_int16(pg_buf, row_start); - col_count_size = 2; - } else { + if (IS_JET3(mdb)) { row_cols = mdb_get_byte(pg_buf, row_start); col_count_size = 1; + } else { + row_cols = mdb_get_int16(pg_buf, row_start); + col_count_size = 2; } bitmask_sz = (row_cols + 7) / 8; @@ -173,15 +198,15 @@ /* read table of variable column locations */ if (table->num_var_cols > 0) { - row_var_cols = IS_JET4(mdb) ? - mdb_get_int16(pg_buf, row_end - bitmask_sz - 1) : - mdb_get_byte(pg_buf, row_end - bitmask_sz); + row_var_cols = IS_JET3(mdb) ? + mdb_get_byte(pg_buf, row_end - bitmask_sz) : + mdb_get_int16(pg_buf, row_end - bitmask_sz - 1); var_col_offsets = (unsigned int *)g_malloc((row_var_cols+1)*sizeof(int)); - if (IS_JET4(mdb)) { - mdb_crack_row4(mdb, row_start, row_end, bitmask_sz, + if (IS_JET3(mdb)) { + mdb_crack_row3(mdb, row_start, row_end, bitmask_sz, row_var_cols, var_col_offsets); } else { - mdb_crack_row3(mdb, row_start, row_end, bitmask_sz, + mdb_crack_row4(mdb, row_start, row_end, bitmask_sz, row_var_cols, var_col_offsets); } } @@ -403,10 +428,10 @@ } } } - if (IS_JET4(table->entry->mdb)) { - return mdb_pack_row4(table, row_buffer, num_fields, fields); - } else { + if (IS_JET3(table->entry->mdb)) { return mdb_pack_row3(table, row_buffer, num_fields, fields); + } else { + return mdb_pack_row4(table, row_buffer, num_fields, fields); } } int @@ -427,8 +452,8 @@ MdbHandle *mdb = entry->mdb; void *new_pg = g_malloc0(mdb->fmt->pg_size); - _mdb_put_int16(new_pg, 0, 0x0104); - _mdb_put_int32(new_pg, 4, entry->table_pg); + mdb_put_int16(new_pg, 0, 0x0104); + mdb_put_int32(new_pg, 4, entry->table_pg); return new_pg; } @@ -438,9 +463,9 @@ MdbFormatConstants *fmt = entry->mdb->fmt; void *new_pg = g_malloc0(fmt->pg_size); - _mdb_put_int16(new_pg, 0, 0x0101); - _mdb_put_int16(new_pg, 2, fmt->pg_size - fmt->row_count_offset - 2); - _mdb_put_int32(new_pg, 4, entry->table_pg); + mdb_put_int16(new_pg, 0, 0x0101); + mdb_put_int16(new_pg, 2, fmt->pg_size - fmt->row_count_offset - 2); + mdb_put_int32(new_pg, 4, entry->table_pg); return new_pg; } @@ -603,7 +628,7 @@ mdb_find_row(mdb, i, &row_start, &row_size); pos -= row_size; memcpy(new_pg + pos, mdb->pg_buf + row_start, row_size); - _mdb_put_int16(new_pg, (fmt->row_count_offset + 2) + (i*2), pos); + mdb_put_int16(new_pg, (fmt->row_count_offset + 2) + (i*2), pos); } } @@ -611,14 +636,14 @@ pos -= new_row_size; memcpy(new_pg + pos, row_buffer, new_row_size); /* add row to the row offset table */ - _mdb_put_int16(new_pg, (fmt->row_count_offset + 2) + (num_rows*2), pos); + mdb_put_int16(new_pg, (fmt->row_count_offset + 2) + (num_rows*2), pos); /* update number rows on this page */ num_rows++; - _mdb_put_int16(new_pg, fmt->row_count_offset, num_rows); + mdb_put_int16(new_pg, fmt->row_count_offset, num_rows); /* update the freespace */ - _mdb_put_int16(new_pg,2,pos - fmt->row_count_offset - 2 - (num_rows*2)); + mdb_put_int16(new_pg,2,pos - fmt->row_count_offset - 2 - (num_rows*2)); /* copy new page over old */ if (!table->is_temp_table) { @@ -714,7 +739,7 @@ new_pg = mdb_new_data_pg(entry); num_rows = mdb_get_int16(mdb->pg_buf, rco); - _mdb_put_int16(new_pg, rco, num_rows); + mdb_put_int16(new_pg, rco, num_rows); pos = pg_size; @@ -723,20 +748,20 @@ mdb_find_row(mdb, i, &row_start, &row_size); pos -= row_size; memcpy(new_pg + pos, mdb->pg_buf + row_start, row_size); - _mdb_put_int16(new_pg, rco + 2 + i*2, pos); + mdb_put_int16(new_pg, rco + 2 + i*2, pos); } /* our row */ pos -= new_row_size; memcpy(new_pg + pos, new_row, new_row_size); - _mdb_put_int16(new_pg, rco + 2 + row*2, pos); + mdb_put_int16(new_pg, rco + 2 + row*2, pos); /* rows after */ for (i=row+1;ipg_buf + row_start, row_size); - _mdb_put_int16(new_pg, rco + 2 + i*2, pos); + mdb_put_int16(new_pg, rco + 2 + i*2, pos); } /* almost done, copy page over current */ @@ -744,7 +769,7 @@ g_free(new_pg); - _mdb_put_int16(mdb->pg_buf, 2, mdb_pg_get_freespace(mdb)); + mdb_put_int16(mdb->pg_buf, 2, mdb_pg_get_freespace(mdb)); if (mdb_get_option(MDB_DEBUG_WRITE)) { mdb_buffer_dump(mdb->pg_buf, 0, 40); mdb_buffer_dump(mdb->pg_buf, pg_size - 160, 160); @@ -767,7 +792,7 @@ MdbHandle *mdb = entry->mdb; MdbColumn *col; guint32 pg_row; - guint16 row; + guint16 row = 0; void *new_pg; unsigned char key_hash[256]; int keycol; @@ -819,9 +844,14 @@ row++; } - //_mdb_put_int16(new_pg, mdb->fmt->row_count_offset, row); + + if (!row) { + fprintf(stderr,"missing indexes not yet supported, aborting\n"); + return 0; + } + //mdb_put_int16(new_pg, mdb->fmt->row_count_offset, row); /* free space left */ - _mdb_put_int16(new_pg, 2, mdb->fmt->pg_size - ipg->offset); + mdb_put_int16(new_pg, 2, mdb->fmt->pg_size - ipg->offset); //printf("offset = %d\n", ipg->offset); mdb_index_swap_n(idx_fields[0].value, col->col_size, key_hash); @@ -835,7 +865,7 @@ ((char *)new_pg)[ipg->offset] = 0x7f; memcpy(new_pg + ipg->offset + 1, key_hash, col->col_size); pg_row = (pgnum << 8) | ((rownum-1) & 0xff); - _mdb_put_int32_msb(new_pg, ipg->offset + 5, pg_row); + mdb_put_int32_msb(new_pg, ipg->offset + 5, pg_row); ipg->idx_starts[row++] = ipg->offset + ipg->len; //ipg->idx_starts[row] = ipg->offset + ipg->len; if (mdb_get_option(MDB_DEBUG_WRITE)) { diff -Nru mdbtools-0.7/src/odbc/Makefile.am mdbtools-0.7.1/src/odbc/Makefile.am --- mdbtools-0.7/src/odbc/Makefile.am 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/odbc/Makefile.am 2013-10-13 08:51:24.000000000 +0000 @@ -1,21 +1,15 @@ -include_HEADERS = connectparams.h -SQLDIR = ../sql -SQLSOURCES = mdbsql.c parser.c lexer.c -MDBDIR = ../libmdb -MDBSOURCES = backend.c index.c money.c catalog.c sargs.c \ - data.c like.c table.c dump.c file.c mem.c \ - map.c props.c worktable.c options.c \ - write.c stats.c iconv.c - -noinst_PROGRAMS = unittest +noinst_PROGRAMS = unittest lib_LTLIBRARIES = libmdbodbc.la -AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(ODBC_CFLAGS) -libmdbodbc_la_SOURCES= odbc.c connectparams.c -libmdbodbc_la_LIBADD= ../libmdb/libmdb.la ../sql/libmdbsql.la -libmdbodbc_la_LDFLAGS = -version-info 1:0:0 -Wl,--version-script=$(srcdir)/libmdbodbc.map +AM_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(ODBC_CFLAGS) +libmdbodbc_la_SOURCES = odbc.c connectparams.c mdbodbc.h connectparams.h +libmdbodbc_la_LIBADD = ../libmdb/libmdb.la ../sql/libmdbsql.la +libmdbodbc_la_LDFLAGS = -avoid-version -export-symbols-regex '^(SQL|ODBCINST)' +if ICONV +lib_LTLIBRARIES += libmdbodbcW.la +libmdbodbcW_la_SOURCES = $(libmdbodbc_la_SOURCES) +libmdbodbcW_la_LIBADD = $(libmdbodbc_la_LIBADD) @LIBICONV@ +libmdbodbcW_la_LDFLAGS = $(libmdbodbc_la_LDFLAGS) +libmdbodbcW_la_CFLAGS = $(AM_CFLAGS) -D ENABLE_ODBC_W=1 +endif LIBS = @LEXLIB@ $(GLIB_LIBS) $(ODBC_LIBS) unittest_LDADD = libmdbodbc.la ../libmdb/libmdb.la ../sql/libmdbsql.la - -## Need blank statement to avoid compiling odbc.c -odbc: $(EXTRA_LTLIBRARIES) - @echo '' diff -Nru mdbtools-0.7/src/odbc/connectparams.c mdbtools-0.7.1/src/odbc/connectparams.c --- mdbtools-0.7/src/odbc/connectparams.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/odbc/connectparams.c 2013-10-13 08:51:24.000000000 +0000 @@ -23,11 +23,7 @@ #include #include #include - #include "connectparams.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* * * Last resort place to check for INI file. This is usually set at compile time @@ -46,12 +42,20 @@ static char line[max_line]; static guint HashFunction (gconstpointer key); -#if !HAVE_SQLGETPRIVATEPROFILESTRING +#if HAVE_SQLGETPRIVATEPROFILESTRING +#include +extern int SQLGetPrivateProfileString( LPCSTR lpszSection, + LPCSTR lpszEntry, + LPCSTR lpszDefault, + LPSTR lpszRetBuffer, + int cbRetBuffer, + LPCSTR lpszFilename); +#else static GString* GetIniFileName (); static int FileExists (const gchar* name); static int FindSection (FILE* stream, const char* section); static int GetNextItem (FILE* stream, char** name, char** value); -#endif //!HAVE_SQLGETPRIVATEPROFILESTRING +#endif //HAVE_SQLGETPRIVATEPROFILESTRING static void visit (gpointer key, gpointer value, gpointer user_data); static gboolean cleanup (gpointer key, gpointer value, gpointer user_data); @@ -520,46 +524,7 @@ #ifdef UNIXODBC - -/* - * Begin BIG Hack. - * - * We need these from odbcinstext.h but it wants to - * include and , which are not in the - * standard include path. XXX smurph - * confirmed by unixODBC stuff, odbcinstext.h shouldn't be installed. freddy77 - */ -#define INI_MAX_LINE 1000 -#define INI_MAX_OBJECT_NAME INI_MAX_LINE -#define INI_MAX_PROPERTY_NAME INI_MAX_LINE -#define INI_MAX_PROPERTY_VALUE INI_MAX_LINE - -#define ODBCINST_PROMPTTYPE_LABEL 0 /* readonly */ -#define ODBCINST_PROMPTTYPE_TEXTEDIT 1 -#define ODBCINST_PROMPTTYPE_LISTBOX 2 -#define ODBCINST_PROMPTTYPE_COMBOBOX 3 -#define ODBCINST_PROMPTTYPE_FILENAME 4 -#define ODBCINST_PROMPTTYPE_HIDDEN 5 -#define ODBCINST_PROMPTTYPE_TEXTEDIT_PASSWORD 6 - -typedef struct tODBCINSTPROPERTY -{ - struct tODBCINSTPROPERTY *pNext; /* pointer to next property, NULL if last property */ - - char szName[INI_MAX_PROPERTY_NAME + 1]; /* property name */ - char szValue[INI_MAX_PROPERTY_VALUE + 1]; /* property value */ - int nPromptType; /* PROMPTTYPE_TEXTEDIT, PROMPTTYPE_LISTBOX, PROMPTTYPE_COMBOBOX, PROMPTTYPE_FILENAME */ - char **aPromptData; /* array of pointers terminated with a NULL value in array. */ - char *pszHelp; /* help on this property (driver setups should keep it short) */ - void *pWidget; /* CALLER CAN STORE A POINTER TO ? HERE */ - int bRefresh; /* app should refresh widget ie Driver Setup has changed aPromptData or szValue */ - void *hDLL; /* for odbcinst internal use... only first property has valid one */ -} -ODBCINSTPROPERTY, *HODBCINSTPROPERTY; - -/* - * End BIG Hack. - */ +#include int ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty) diff -Nru mdbtools-0.7/src/odbc/connectparams.h mdbtools-0.7.1/src/odbc/connectparams.h --- mdbtools-0.7/src/odbc/connectparams.h 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/odbc/connectparams.h 2013-10-13 08:51:24.000000000 +0000 @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _ODBC_INI_LOAD_ -#define _ODBC_INI_LOAD_ +#ifndef _connectparams_h_ +#define _connectparams_h_ #include diff -Nru mdbtools-0.7/src/odbc/libmdbodbc.map mdbtools-0.7.1/src/odbc/libmdbodbc.map --- mdbtools-0.7/src/odbc/libmdbodbc.map 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/odbc/libmdbodbc.map 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -{ -global: - SQL*; - ODBCINST*; - -local: - *; -}; diff -Nru mdbtools-0.7/src/odbc/mdbodbc.h mdbtools-0.7.1/src/odbc/mdbodbc.h --- mdbtools-0.7/src/odbc/mdbodbc.h 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/src/odbc/mdbodbc.h 2013-10-13 08:51:24.000000000 +0000 @@ -0,0 +1,71 @@ +/* MDB Tools - A library for reading MS Access database file + * Copyright (C) 2000 Brian Bruns + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _mdbodbc_h_ +#define _mdbodbc_h_ + +#include +#include +#if defined(UNIXODBC) +# include +#elif defined(IODBC) +# include +#endif + +#include "mdbtools.h" +#include "mdbsql.h" +#include "connectparams.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _henv { + MdbSQL *sql; + GPtrArray *connections; +}; +struct _hdbc { + struct _henv *henv; + ConnectParams* params; + GPtrArray *statements; +}; +struct _hstmt { + struct _hdbc *hdbc; + /* reminder to self: the following is here for testing purposes. + * please make dynamic before checking in + */ + char query[4096]; + struct _sql_bind_info *bind_head; + int rows_affected; + int icol; /* SQLGetData: last column */ + int pos; /* SQLGetData: last position (truncated result) */ +}; + +struct _sql_bind_info { + int column_number; + int column_bindtype; /* type/conversion required */ + int column_bindlen; /* size of varaddr buffer */ + int *column_lenbind; /* where to store length of varaddr used */ + char *varaddr; + struct _sql_bind_info *next; +}; + +#ifdef __cplusplus +} +#endif +#endif diff -Nru mdbtools-0.7/src/odbc/odbc.c mdbtools-0.7.1/src/odbc/odbc.c --- mdbtools-0.7/src/odbc/odbc.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/odbc/odbc.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,21 +16,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ENABLE_ODBC_W +#define SQL_NOUNICODEMAP +#define UNICODE +#endif //ENABLE_ODBC_W + #include #include - -#include - #include #include - -#include "connectparams.h" +#include "mdbodbc.h" //#define TRACE(x) fprintf(stderr,"Function %s\n", x); #define TRACE(x) -//#define ENABLE_ODBC_W - #ifdef ENABLE_ODBC_W static iconv_t iconv_in,iconv_out; #endif //ENABLE_ODBC_W @@ -38,15 +37,16 @@ static SQLSMALLINT _odbc_get_client_type(MdbColumn *col); static int _odbc_fix_literals(struct _hstmt *stmt); //static int _odbc_get_server_type(int clt_type); -static int _odbc_get_string_size(int size, SQLCHAR FAR *str); -static SQLRETURN SQL_API _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR *phdbc); -static SQLRETURN SQL_API _SQLAllocEnv(SQLHENV FAR *phenv); -static SQLRETURN SQL_API _SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR *phstmt); +static int _odbc_get_string_size(int size, SQLCHAR *str); +static SQLRETURN SQL_API _SQLAllocConnect(SQLHENV henv, SQLHDBC *phdbc); +static SQLRETURN SQL_API _SQLAllocEnv(SQLHENV *phenv); +static SQLRETURN SQL_API _SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT *phstmt); static SQLRETURN SQL_API _SQLFreeConnect(SQLHDBC hdbc); static SQLRETURN SQL_API _SQLFreeEnv(SQLHENV henv); static SQLRETURN SQL_API _SQLFreeStmt(SQLHSTMT hstmt, SQLUSMALLINT fOption); static void bind_columns (struct _hstmt*); +static void unbind_columns (struct _hstmt*); #define FILL_FIELD(f,v,s) mdb_fill_temp_field(f,v,s,0,0,0,0) @@ -97,7 +97,10 @@ #define MAX_TYPE_INFO 11 #ifdef ENABLE_ODBC_W -void __attribute__ ((constructor)) my_init(){ +void my_fini(); + +MDB_CONSTRUCTOR(my_init) +{ TRACE("my_init"); int endian = 1; const char* wcharset; @@ -112,8 +115,8 @@ else wcharset = "UCS-4BE"; else - fprintf(stderr, "Unsupported SQLWCHAR width %d\n", sizeof(SQLWCHAR)); - + fprintf(stderr, "Unsupported SQLWCHAR width %zd\n", sizeof(SQLWCHAR)); +//fprintf(stderr,"charset %s\n", wcharset); //fprintf(stderr, "SQLWCHAR width %d\n", sizeof(SQLWCHAR)); /* #if __SIZEOF_WCHAR_T__ == 4 || __WCHAR_MAX__ > 0x10000 @@ -124,31 +127,38 @@ */ iconv_out = iconv_open(wcharset, "UTF-8"); iconv_in = iconv_open("UTF-8", wcharset); + + atexit(my_fini); } -void __attribute__ ((destructor)) my_fini(){ +void my_fini() +{ TRACE("my_fini"); if(iconv_out != (iconv_t)-1)iconv_close(iconv_out); if(iconv_in != (iconv_t)-1)iconv_close(iconv_in); } -int unicode2ascii(char *_in,unsigned int *_lin,char *_out,unsigned int *_lout){ - char *in=_in,*out=_out; - unsigned lin=*_lin,lout=*_lout; - int ret=iconv(iconv_in,&in,&lin,&out,&lout); - *_lin-=lin,*_lout-=lout; +static int unicode2ascii(char *_in, size_t *_lin, char *_out, size_t *_lout){ + char *in=_in, *out=_out; + size_t lin=*_lin, lout=*_lout; + int ret = iconv(iconv_in, &in, &lin, &out, &lout); + *_lin -= lin; + *_lout -= lout; return ret; } -int ascii2unicode(char *_in,unsigned int *_lin,char *_out,unsigned int *_lout){ - char *in=_in,*out=_out; - unsigned lin=*_lin,lout=*_lout; - int ret=iconv(iconv_out,&in,&lin,&out,&lout); - *_lin-=lin,*_lout-=lout; +static int ascii2unicode(char *_in, size_t *_lin, char *_out, size_t *_lout){ + //fprintf(stderr,"ascii2unicode %08x %08x %08x %08x\n",_in,_lin,_out,_lout); + char *in=_in, *out=_out; + size_t lin=*_lin, lout=*_lout; + //fprintf(stderr,"ascii2unicode %zd %zd\n",lin,lout); + int ret = iconv(iconv_out, &in, &lin, &out, &lout); + *_lin -= lin; + *_lout -= lout; return ret; } -int sqlwlen(SQLWCHAR *p){ +static int sqlwlen(SQLWCHAR *p){ int r=0; for(;*p;r++) p++; @@ -169,16 +179,6 @@ lastError[_MAX_ERROR_LEN] = '\0'; /* in case we had a long message */ } -/* - * Driver specific connectionn information - */ - -typedef struct -{ - struct _hdbc hdbc; - ConnectParams* params; -} ODBCConnection; - static SQLRETURN do_connect ( SQLHDBC hdbc, char *database) @@ -192,14 +192,14 @@ return SQL_ERROR; } -SQLRETURN SQL_API SQLDriverConnect( +static SQLRETURN SQL_API _SQLDriverConnect( SQLHDBC hdbc, SQLHWND hwnd, - SQLCHAR FAR *szConnStrIn, + SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, - SQLCHAR FAR *szConnStrOut, + SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, - SQLSMALLINT FAR *pcbConnStrOut, + SQLSMALLINT *pcbConnStrOut, SQLUSMALLINT fDriverCompletion) { char* dsn = NULL; @@ -207,10 +207,10 @@ ConnectParams* params; SQLRETURN ret; - TRACE("SQLDriverConnect"); + TRACE("_SQLDriverConnect"); strcpy (lastError, ""); - params = ((ODBCConnection*) hdbc)->params; + params = ((struct _hdbc*) hdbc)->params; if ((dsn = ExtractDSN (params, (gchar*)szConnStrIn))) { if (!LookupDSN (params, dsn)){ @@ -233,26 +233,41 @@ return SQL_ERROR; } +SQLRETURN SQL_API SQLDriverConnect( + SQLHDBC hdbc, + SQLHWND hwnd, + SQLCHAR *szConnStrIn, + SQLSMALLINT cbConnStrIn, + SQLCHAR *szConnStrOut, + SQLSMALLINT cbConnStrOutMax, + SQLSMALLINT *pcbConnStrOut, + SQLUSMALLINT fDriverCompletion) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLDriverConnect"))); +#else +{ return _SQLDriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLDriverConnectW( SQLHDBC hdbc, SQLHWND hwnd, - SQLWCHAR FAR *szConnStrIn, + SQLWCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, - SQLWCHAR FAR *szConnStrOut, + SQLWCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, - SQLSMALLINT FAR *pcbConnStrOut, + SQLSMALLINT *pcbConnStrOut, SQLUSMALLINT fDriverCompletion) { - if(cbConnStrIn==SQL_NTS) - cbConnStrIn=sqlwlen(szConnStrIn); + TRACE("SQLDriverConnectW"); + if(cbConnStrIn==SQL_NTS)cbConnStrIn=sqlwlen(szConnStrIn); { - unsigned int l = cbConnStrIn*sizeof(SQLWCHAR), z = (cbConnStrIn+1)*3; + size_t l = cbConnStrIn*sizeof(SQLWCHAR), z = (cbConnStrIn+1)*3; SQLCHAR *tmp = malloc(z); SQLRETURN ret; unicode2ascii((char*)szConnStrIn, &l, (char*)tmp, &z); tmp[z] = 0; - ret=SQLDriverConnect(hdbc,hwnd,tmp,SQL_NTS,NULL,0,pcbConnStrOut,fDriverCompletion); + ret = _SQLDriverConnect(hdbc,hwnd,tmp,SQL_NTS,NULL,0,pcbConnStrOut,fDriverCompletion); free(tmp); if (szConnStrOut && cbConnStrOutMax>0) szConnStrOut[0] = 0; @@ -265,11 +280,11 @@ SQLRETURN SQL_API SQLBrowseConnect( SQLHDBC hdbc, - SQLCHAR FAR *szConnStrIn, + SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, - SQLCHAR FAR *szConnStrOut, + SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, - SQLSMALLINT FAR *pcbConnStrOut) + SQLSMALLINT *pcbConnStrOut) { TRACE("SQLBrowseConnect"); return SQL_SUCCESS; @@ -277,13 +292,13 @@ SQLRETURN SQL_API SQLColumnPrivileges( SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szTableName, + SQLCHAR *szTableName, SQLSMALLINT cbTableName, - SQLCHAR FAR *szColumnName, + SQLCHAR *szColumnName, SQLSMALLINT cbColumnName) { TRACE("SQLColumnPrivileges"); @@ -293,10 +308,10 @@ SQLRETURN SQL_API SQLDescribeParam( SQLHSTMT hstmt, SQLUSMALLINT ipar, - SQLSMALLINT FAR *pfSqlType, - SQLULEN FAR *pcbParamDef, - SQLSMALLINT FAR *pibScale, - SQLSMALLINT FAR *pfNullable) + SQLSMALLINT *pfSqlType, + SQLULEN *pcbParamDef, + SQLSMALLINT *pibScale, + SQLSMALLINT *pfNullable) { TRACE("SQLDescribeParam"); return SQL_SUCCESS; @@ -307,7 +322,7 @@ SQLUSMALLINT fFetchType, SQLLEN irow, SQLULEN *pcrow, - SQLUSMALLINT FAR *rgfRowStatus) + SQLUSMALLINT *rgfRowStatus) { struct _hstmt *stmt = (struct _hstmt *) hstmt; struct _hdbc *dbc = (struct _hdbc *) stmt->hdbc; @@ -335,17 +350,17 @@ SQLRETURN SQL_API SQLForeignKeys( SQLHSTMT hstmt, - SQLCHAR FAR *szPkCatalogName, + SQLCHAR *szPkCatalogName, SQLSMALLINT cbPkCatalogName, - SQLCHAR FAR *szPkSchemaName, + SQLCHAR *szPkSchemaName, SQLSMALLINT cbPkSchemaName, - SQLCHAR FAR *szPkTableName, + SQLCHAR *szPkTableName, SQLSMALLINT cbPkTableName, - SQLCHAR FAR *szFkCatalogName, + SQLCHAR *szFkCatalogName, SQLSMALLINT cbFkCatalogName, - SQLCHAR FAR *szFkSchemaName, + SQLCHAR *szFkSchemaName, SQLSMALLINT cbFkSchemaName, - SQLCHAR FAR *szFkTableName, + SQLCHAR *szFkTableName, SQLSMALLINT cbFkTableName) { TRACE("SQLForeignKeys"); @@ -361,11 +376,11 @@ SQLRETURN SQL_API SQLNativeSql( SQLHDBC hdbc, - SQLCHAR FAR *szSqlStrIn, + SQLCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn, - SQLCHAR FAR *szSqlStr, + SQLCHAR *szSqlStr, SQLINTEGER cbSqlStrMax, - SQLINTEGER FAR *pcbSqlStr) + SQLINTEGER *pcbSqlStr) { TRACE("SQLNativeSql"); return SQL_SUCCESS; @@ -373,7 +388,7 @@ SQLRETURN SQL_API SQLNumParams( SQLHSTMT hstmt, - SQLSMALLINT FAR *pcpar) + SQLSMALLINT *pcpar) { TRACE("SQLNumParams"); return SQL_SUCCESS; @@ -382,7 +397,7 @@ SQLRETURN SQL_API SQLParamOptions( SQLHSTMT hstmt, SQLULEN crow, - SQLULEN FAR *pirow) + SQLULEN *pirow) { TRACE("SQLParamOptions"); return SQL_SUCCESS; @@ -390,11 +405,11 @@ SQLRETURN SQL_API SQLPrimaryKeys( SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szTableName, + SQLCHAR *szTableName, SQLSMALLINT cbTableName) { TRACE("SQLPrimaryKeys"); @@ -403,13 +418,13 @@ SQLRETURN SQL_API SQLProcedureColumns( SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szProcName, + SQLCHAR *szProcName, SQLSMALLINT cbProcName, - SQLCHAR FAR *szColumnName, + SQLCHAR *szColumnName, SQLSMALLINT cbColumnName) { TRACE("SQLProcedureColumns"); @@ -418,11 +433,11 @@ SQLRETURN SQL_API SQLProcedures( SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szProcName, + SQLCHAR *szProcName, SQLSMALLINT cbProcName) { TRACE("SQLProcedures"); @@ -441,11 +456,11 @@ SQLRETURN SQL_API SQLTablePrivileges( SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szTableName, + SQLCHAR *szTableName, SQLSMALLINT cbTableName) { TRACE("SQLTablePrivileges"); @@ -455,12 +470,12 @@ SQLRETURN SQL_API SQLDrivers( SQLHENV henv, SQLUSMALLINT fDirection, - SQLCHAR FAR *szDriverDesc, + SQLCHAR *szDriverDesc, SQLSMALLINT cbDriverDescMax, - SQLSMALLINT FAR *pcbDriverDesc, - SQLCHAR FAR *szDriverAttributes, + SQLSMALLINT *pcbDriverDesc, + SQLCHAR *szDriverAttributes, SQLSMALLINT cbDrvrAttrMax, - SQLSMALLINT FAR *pcbDrvrAttr) + SQLSMALLINT *pcbDrvrAttr) { TRACE("SQLDrivers"); return SQL_SUCCESS; @@ -486,7 +501,7 @@ SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN cbValueMax, - SQLLEN FAR *pcbValue) + SQLLEN *pcbValue) { /*struct _hstmt *stmt;*/ @@ -516,42 +531,45 @@ } static SQLRETURN SQL_API _SQLAllocConnect( SQLHENV henv, - SQLHDBC FAR *phdbc) + SQLHDBC *phdbc) { struct _henv *env; -ODBCConnection* dbc; +struct _hdbc* dbc; TRACE("_SQLAllocConnect"); env = (struct _henv *) henv; - dbc = (SQLHDBC) g_malloc0(sizeof (ODBCConnection)); - dbc->hdbc.henv=env; - + dbc = (SQLHDBC) g_malloc0(sizeof(struct _hdbc)); + dbc->henv=env; + g_ptr_array_add(env->connections, dbc); dbc->params = NewConnectParams (); + dbc->statements = g_ptr_array_new(); *phdbc=dbc; return SQL_SUCCESS; } SQLRETURN SQL_API SQLAllocConnect( SQLHENV henv, - SQLHDBC FAR *phdbc) + SQLHDBC *phdbc) { TRACE("SQLAllocConnect"); return _SQLAllocConnect(henv, phdbc); } static SQLRETURN SQL_API _SQLAllocEnv( - SQLHENV FAR *phenv) + SQLHENV *phenv) { struct _henv *env; TRACE("_SQLAllocEnv"); env = (SQLHENV) g_malloc0(sizeof(struct _henv)); - *phenv=env; env->sql = mdb_sql_init(); + env->connections = g_ptr_array_new(); + *phenv=env; return SQL_SUCCESS; } + SQLRETURN SQL_API SQLAllocEnv( - SQLHENV FAR *phenv) + SQLHENV *phenv) { TRACE("SQLAllocEnv"); return _SQLAllocEnv(phenv); @@ -559,23 +577,25 @@ static SQLRETURN SQL_API _SQLAllocStmt( SQLHDBC hdbc, - SQLHSTMT FAR *phstmt) + SQLHSTMT *phstmt) { - /*struct _hdbc *dbc;*/ + struct _hdbc *dbc; struct _hstmt *stmt; TRACE("_SQLAllocStmt"); - /*dbc = (struct _hdbc *) hdbc;*/ + dbc = (struct _hdbc *) hdbc; stmt = (SQLHSTMT) g_malloc0(sizeof(struct _hstmt)); - stmt->hdbc=hdbc; - *phstmt = stmt; + stmt->hdbc=dbc; + g_ptr_array_add(dbc->statements, stmt); + *phstmt = stmt; return SQL_SUCCESS; } + SQLRETURN SQL_API SQLAllocStmt( SQLHDBC hdbc, - SQLHSTMT FAR *phstmt) + SQLHSTMT *phstmt) { TRACE("SQLAllocStmt"); return _SQLAllocStmt(hdbc,phstmt); @@ -587,7 +607,7 @@ SQLSMALLINT fCType, SQLPOINTER rgbValue, SQLLEN cbValueMax, - SQLLEN FAR *pcbValue) + SQLLEN *pcbValue) { struct _hstmt *stmt = (struct _hstmt *) hstmt; struct _sql_bind_info *cur, *newitem; @@ -603,6 +623,7 @@ /* if this is a repeat */ if (cur) { cur->column_bindtype = fCType; + cur->column_lenbind = (int *)pcbValue; cur->column_bindlen = cbValueMax; cur->varaddr = (char *) rgbValue; } else { @@ -636,23 +657,23 @@ return SQL_SUCCESS; } -SQLRETURN SQL_API SQLConnect( +static SQLRETURN SQL_API _SQLConnect( SQLHDBC hdbc, - SQLCHAR FAR *szDSN, + SQLCHAR *szDSN, SQLSMALLINT cbDSN, - SQLCHAR FAR *szUID, + SQLCHAR *szUID, SQLSMALLINT cbUID, - SQLCHAR FAR *szAuthStr, + SQLCHAR *szAuthStr, SQLSMALLINT cbAuthStr) { char* database = NULL; ConnectParams* params; SQLRETURN ret; - TRACE("SQLConnect"); + TRACE("_SQLConnect"); strcpy (lastError, ""); - params = ((ODBCConnection*) hdbc)->params; + params = ((struct _hdbc*) hdbc)->params; params->dsnName = g_string_assign (params->dsnName, (gchar*)szDSN); @@ -671,14 +692,28 @@ return ret; } +SQLRETURN SQL_API SQLConnect( + SQLHDBC hdbc, + SQLCHAR *szDSN, + SQLSMALLINT cbDSN, + SQLCHAR *szUID, + SQLSMALLINT cbUID, + SQLCHAR *szAuthStr, + SQLSMALLINT cbAuthStr) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLConnect"))); +#else +{ return _SQLConnect(hdbc, szDSN, cbDSN, szUID, cbUID, szAuthStr, cbAuthStr); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLConnectW( SQLHDBC hdbc, - SQLWCHAR FAR *szDSN, + SQLWCHAR *szDSN, SQLSMALLINT cbDSN, - SQLWCHAR FAR *szUID, + SQLWCHAR *szUID, SQLSMALLINT cbUID, - SQLWCHAR FAR *szAuthStr, + SQLWCHAR *szAuthStr, SQLSMALLINT cbAuthStr) { if(cbDSN==SQL_NTS)cbDSN=sqlwlen(szDSN); @@ -686,30 +721,30 @@ if(cbAuthStr==SQL_NTS)cbAuthStr=sqlwlen(szAuthStr); { SQLCHAR *tmp1=calloc(cbDSN*4,1),*tmp2=calloc(cbUID*4,1),*tmp3=calloc(cbAuthStr*4,1); - unsigned int l1=cbDSN*4,z1=cbDSN*2; - unsigned int l2=cbUID*4,z2=cbUID*2; - unsigned int l3=cbAuthStr*4,z3=cbAuthStr*2; + size_t l1=cbDSN*4,z1=cbDSN*2; + size_t l2=cbUID*4,z2=cbUID*2; + size_t l3=cbAuthStr*4,z3=cbAuthStr*2; SQLRETURN ret; unicode2ascii((char*)szDSN, &z1, (char*)tmp1, &l1); unicode2ascii((char*)szUID, &z2, (char*)tmp2, &l2); unicode2ascii((char*)szAuthStr, &z3, (char*)tmp3, &l3); - ret=SQLConnect(hdbc,tmp1,l1,tmp2,l2,tmp3,l3); + ret = SQLConnect(hdbc, tmp1, l1, tmp2, l2, tmp3, l3); free(tmp1),free(tmp2),free(tmp3); return ret; } } #endif //ENABLE_ODBC_W -SQLRETURN SQL_API SQLDescribeCol( +static SQLRETURN SQL_API _SQLDescribeCol( SQLHSTMT hstmt, SQLUSMALLINT icol, - SQLCHAR FAR *szColName, + SQLCHAR *szColName, SQLSMALLINT cbColNameMax, - SQLSMALLINT FAR *pcbColName, - SQLSMALLINT FAR *pfSqlType, - SQLULEN FAR *pcbColDef, /* precision */ - SQLSMALLINT FAR *pibScale, - SQLSMALLINT FAR *pfNullable) + SQLSMALLINT *pcbColName, + SQLSMALLINT *pfSqlType, + SQLULEN *pcbColDef, /* precision */ + SQLSMALLINT *pibScale, + SQLSMALLINT *pfNullable) { int namelen, i; struct _hstmt *stmt = (struct _hstmt *) hstmt; @@ -719,9 +754,11 @@ MdbSQLColumn *sqlcol; MdbColumn *col; MdbTableDef *table; + SQLRETURN ret; - TRACE("SQLDescribeCol"); + TRACE("_SQLDescribeCol"); if (icol<1 || icol>sql->num_columns) { + strcpy(sqlState, "07009"); // Invalid descriptor index return SQL_ERROR; } sqlcol = g_ptr_array_index(sql->columns,icol - 1); @@ -734,18 +771,31 @@ } if (i==table->num_cols) { fprintf(stderr, "Column %s lost\n", (char*)sqlcol->name); + strcpy(sqlState, "07009"); // Invalid descriptor index return SQL_ERROR; } + ret = SQL_SUCCESS; + namelen = strlen(sqlcol->name); + if (pcbColName) + *pcbColName=namelen; if (szColName) { - namelen = MIN(cbColNameMax,strlen(sqlcol->name)); - strncpy((char*)szColName, sqlcol->name, namelen); - szColName[namelen]='\0'; - if (pcbColName) - *pcbColName=namelen; - } else { - if (pcbColName) - *pcbColName = strlen(sqlcol->name); + if (cbColNameMax < 0) { + strcpy(sqlState, "HY090"); // Invalid string or buffer length + return SQL_ERROR; + } + if (namelen + 1 < cbColNameMax) { + // Including \0 + strcpy((char*)szColName, sqlcol->name); + } else { + if (cbColNameMax > 1) { + strncpy((char*)szColName, sqlcol->name, cbColNameMax-1); + szColName[cbColNameMax-1] = '\0'; + } + // So there is no \0 if cbColNameMax was 0 + strcpy(sqlState, "01004"); // String data, right truncated + ret = SQL_SUCCESS_WITH_INFO; + } } if (pfSqlType) { *pfSqlType = _odbc_get_client_type(col); @@ -761,28 +811,43 @@ *pfNullable = !col->is_fixed; } - return SQL_SUCCESS; + return ret; } +SQLRETURN SQL_API SQLDescribeCol( + SQLHSTMT hstmt, + SQLUSMALLINT icol, + SQLCHAR *szColName, + SQLSMALLINT cbColNameMax, + SQLSMALLINT *pcbColName, + SQLSMALLINT *pfSqlType, + SQLULEN *pcbColDef, /* precision */ + SQLSMALLINT *pibScale, + SQLSMALLINT *pfNullable) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLDescribeCol"))); +#else +{ return _SQLDescribeCol(hstmt, icol, szColName, cbColNameMax, pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLDescribeColW( SQLHSTMT hstmt, SQLUSMALLINT icol, - SQLWCHAR FAR *szColName, + SQLWCHAR *szColName, SQLSMALLINT cbColNameMax, - SQLSMALLINT FAR *pcbColName, - SQLSMALLINT FAR *pfSqlType, - SQLUINTEGER FAR *pcbColDef, /* precision */ - SQLSMALLINT FAR *pibScale, - SQLSMALLINT FAR *pfNullable) + SQLSMALLINT *pcbColName, + SQLSMALLINT *pfSqlType, + SQLULEN *pcbColDef, /* precision */ + SQLSMALLINT *pibScale, + SQLSMALLINT *pfNullable) { - if(cbColNameMax==SQL_NTS) - cbColNameMax=sqlwlen(szColName); + if(cbColNameMax==SQL_NTS)cbColNameMax=sqlwlen(szColName); { SQLCHAR *tmp=calloc(cbColNameMax*4,1); - unsigned int l=cbColNameMax*4; - SQLRETURN ret=SQLDescribeCol(hstmt,icol,tmp,cbColNameMax*4,&l,pfSqlType,pcbColDef,pibScale,pfNullable); - ascii2unicode((char*)tmp, &l, (char*)szColName, pcbColName); + size_t l=cbColNameMax*4; + SQLRETURN ret = _SQLDescribeCol(hstmt, icol, tmp, cbColNameMax*4, (SQLSMALLINT*)&l, pfSqlType, pcbColDef, pibScale, pfNullable); + ascii2unicode((char*)tmp, &l, (char*)szColName, (size_t*)pcbColName); *pcbColName/=sizeof(SQLWCHAR); free(tmp); return ret; @@ -790,14 +855,14 @@ } #endif //ENABLE_ODBC_W -SQLRETURN SQL_API SQLColAttributes( +static SQLRETURN SQL_API _SQLColAttributes( SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, - SQLSMALLINT FAR *pcbDesc, - SQLLEN FAR *pfDesc) + SQLSMALLINT *pcbDesc, + SQLLEN *pfDesc) { int namelen, i; struct _hstmt *stmt; @@ -807,8 +872,9 @@ MdbSQLColumn *sqlcol; MdbColumn *col; MdbTableDef *table; + SQLRETURN ret; - TRACE("SQLColAttributes"); + TRACE("_SQLColAttributes"); stmt = (struct _hstmt *) hstmt; dbc = (struct _hdbc *) stmt->hdbc; env = (struct _henv *) dbc->henv; @@ -817,11 +883,14 @@ /* dont check column index for these */ switch(fDescType) { case SQL_COLUMN_COUNT: + case SQL_DESC_COUNT: + *pfDesc = env->sql->num_columns; return SQL_SUCCESS; break; } if (icol<1 || icol>sql->num_columns) { + strcpy(sqlState, "07009"); // Invalid descriptor index return SQL_ERROR; } @@ -834,28 +903,64 @@ break; } } + if (i==table->num_cols) { + strcpy(sqlState, "07009"); // Invalid descriptor index + return SQL_ERROR; + } // fprintf(stderr,"fDescType = %d\n", fDescType); + ret = SQL_SUCCESS; switch(fDescType) { - case SQL_COLUMN_NAME: - case SQL_COLUMN_LABEL: - namelen = MIN(cbDescMax,strlen(sqlcol->name)); - strncpy(rgbDesc, sqlcol->name, namelen); - ((char *)rgbDesc)[namelen]='\0'; + case SQL_COLUMN_NAME: case SQL_DESC_NAME: + case SQL_COLUMN_LABEL: /* = SQL_DESC_LABEL */ + if (cbDescMax < 0) { + strcpy(sqlState, "HY090"); // Invalid string or buffer length + return SQL_ERROR; + } + namelen = strlen(sqlcol->name); + if (namelen + 1 < cbDescMax) { + strcpy(rgbDesc, sqlcol->name); + } else { + if (cbDescMax > 1) { + strncpy(rgbDesc, sqlcol->name, cbDescMax-1); + ((char*)rgbDesc)[cbDescMax-1] = '\0'; + } + // So there is no \0 if cbDescMax was 0 + strcpy(sqlState, "01004"); // String data, right truncated + ret = SQL_SUCCESS_WITH_INFO; + } break; - case SQL_COLUMN_TYPE: - *pfDesc = SQL_CHAR; + case SQL_COLUMN_TYPE: /* =SQL_DESC_CONCISE_TYPE */ + //*pfDesc = SQL_CHAR; + *pfDesc = _odbc_get_client_type(col); break; case SQL_COLUMN_LENGTH: break; - //case SQL_COLUMN_DISPLAY_SIZE: - case SQL_DESC_DISPLAY_SIZE: + case SQL_COLUMN_DISPLAY_SIZE: /* =SQL_DESC_DISPLAY_SIZE */ *pfDesc = mdb_col_disp_size(col); break; + default: + strcpy(sqlState, "HYC00"); // Driver not capable + ret = SQL_ERROR; + break; } - return SQL_SUCCESS; + return ret; } +SQLRETURN SQL_API SQLColAttributes( + SQLHSTMT hstmt, + SQLUSMALLINT icol, + SQLUSMALLINT fDescType, + SQLPOINTER rgbDesc, + SQLSMALLINT cbDescMax, + SQLSMALLINT *pcbDesc, + SQLLEN *pfDesc) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLColAttributes"))); +#else +{ return _SQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLColAttributesW( SQLHSTMT hstmt, @@ -863,16 +968,16 @@ SQLUSMALLINT fDescType, SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, - SQLSMALLINT FAR *pcbDesc, - SQLINTEGER FAR *pfDesc) + SQLSMALLINT *pcbDesc, + SQLLEN *pfDesc) { if (fDescType!=SQL_COLUMN_NAME && fDescType!=SQL_COLUMN_LABEL) - return SQLColAttributes(hstmt,icol,fDescType,rgbDesc,cbDescMax,pcbDesc,pfDesc); + return _SQLColAttributes(hstmt,icol,fDescType,rgbDesc,cbDescMax,pcbDesc,pfDesc); else{ SQLCHAR *tmp=calloc(cbDescMax*4,1); - unsigned int l=cbDescMax*4; - SQLRETURN ret=SQLColAttributes(hstmt,icol,fDescType,tmp,cbDescMax*4,l,pfDesc); - ascii2unicode((char*)tmp, &l, (char*)rgbDesc, pcbDesc); + size_t l=cbDescMax*4; + SQLRETURN ret=_SQLColAttributes(hstmt,icol,fDescType,tmp,cbDescMax*4,(SQLSMALLINT*)&l,pfDesc); + ascii2unicode((char*)tmp, &l, (char*)rgbDesc, (size_t*)pcbDesc); *pcbDesc/=sizeof(SQLWCHAR); free(tmp); return ret; @@ -890,24 +995,28 @@ dbc = (struct _hdbc *) hdbc; env = (struct _henv *) dbc->henv; + // Automatically close all statements: + while (dbc->statements->len) + _SQLFreeStmt(g_ptr_array_index(dbc->statements, 0), SQL_DROP); mdb_sql_close(env->sql); return SQL_SUCCESS; } -SQLRETURN SQL_API SQLError( +static SQLRETURN SQL_API _SQLError( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, - SQLCHAR FAR *szSqlState, - SQLINTEGER FAR *pfNativeError, - SQLCHAR FAR *szErrorMsg, + SQLCHAR *szSqlState, + SQLINTEGER *pfNativeError, + SQLCHAR *szErrorMsg, SQLSMALLINT cbErrorMsgMax, - SQLSMALLINT FAR *pcbErrorMsg) + SQLSMALLINT *pcbErrorMsg) { SQLRETURN result = SQL_NO_DATA_FOUND; - TRACE("SQLError"); + TRACE("_SQLError"); + //if(pfNativeError)fprintf(stderr,"NativeError %05d\n", *pfNativeError); if (strlen (lastError) > 0) { strcpy ((char*)szSqlState, "08001"); @@ -924,16 +1033,31 @@ return result; } +SQLRETURN SQL_API SQLError( + SQLHENV henv, + SQLHDBC hdbc, + SQLHSTMT hstmt, + SQLCHAR *szSqlState, + SQLINTEGER *pfNativeError, + SQLCHAR *szErrorMsg, + SQLSMALLINT cbErrorMsgMax, + SQLSMALLINT *pcbErrorMsg) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLError"))); +#else +{ return _SQLError(henv, hdbc, hstmt, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLErrorW( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, - SQLWCHAR FAR *szSqlState, - SQLINTEGER FAR *pfNativeError, - SQLWCHAR FAR *szErrorMsg, + SQLWCHAR *szSqlState, + SQLINTEGER *pfNativeError, + SQLWCHAR *szErrorMsg, SQLSMALLINT cbErrorMsgMax, - SQLSMALLINT FAR *pcbErrorMsg) + SQLSMALLINT *pcbErrorMsg) { SQLCHAR szSqlState8[6]; SQLCHAR szErrorMsg8[3*cbErrorMsgMax+1]; @@ -942,12 +1066,12 @@ TRACE("SQLErrorW"); - result = SQLError(henv, hdbc, hstmt, szSqlState8, pfNativeError, szErrorMsg8, 3*cbErrorMsgMax+1, &pcbErrorMsg8); + result = _SQLError(henv, hdbc, hstmt, szSqlState8, pfNativeError, szErrorMsg8, 3*cbErrorMsgMax+1, &pcbErrorMsg8); if (result == SQL_SUCCESS) { - unsigned int l=6, z=6*sizeof(SQLWCHAR); + size_t l=6, z=6*sizeof(SQLWCHAR); ascii2unicode((char*)szSqlState8, &l, (char*)szSqlState, &z); l = cbErrorMsgMax; - ascii2unicode((char*)szErrorMsg8, (unsigned int*)&pcbErrorMsg8, (char*)szErrorMsg, &l); + ascii2unicode((char*)szErrorMsg8, (size_t*)&pcbErrorMsg8, (char*)szErrorMsg, &l); if (pcbErrorMsg) *pcbErrorMsg = l; } @@ -978,33 +1102,44 @@ } } -SQLRETURN SQL_API SQLExecDirect( +static SQLRETURN SQL_API _SQLExecDirect( SQLHSTMT hstmt, - SQLCHAR FAR *szSqlStr, + SQLCHAR *szSqlStr, SQLINTEGER cbSqlStr) { struct _hstmt *stmt = (struct _hstmt *) hstmt; - TRACE("SQLExecDirect"); + TRACE("_SQLExecDirect"); strcpy(stmt->query, (char*)szSqlStr); return _SQLExecute(hstmt); } +SQLRETURN SQL_API SQLExecDirect( + SQLHSTMT hstmt, + SQLCHAR *szSqlStr, + SQLINTEGER cbSqlStr) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLExecDirect"))); +#else +{ return _SQLExecDirect(hstmt, szSqlStr, cbSqlStr); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLExecDirectW( SQLHSTMT hstmt, - SQLWCHAR FAR *szSqlStr, + SQLWCHAR *szSqlStr, SQLINTEGER cbSqlStr) { - if(cbSqlStr==SQL_NTS) - cbSqlStr=sqlwlen(szSqlStr); + TRACE("SQLExecDirectW"); + if(cbSqlStr==SQL_NTS)cbSqlStr=sqlwlen(szSqlStr); { SQLCHAR *tmp=calloc(cbSqlStr*4,1); - unsigned int l=cbSqlStr*4,z=cbSqlStr*2; + size_t l=cbSqlStr*4,z=cbSqlStr*2; SQLRETURN ret; unicode2ascii((char*)szSqlStr, &z, (char*)tmp, &l); - ret=SQLExecDirect(hstmt,tmp,l); + ret = _SQLExecDirect(hstmt, tmp, l); + TRACE("SQLExecDirectW end"); free(tmp); return ret; } @@ -1025,6 +1160,8 @@ struct _henv *env = (struct _henv *) dbc->henv; struct _sql_bind_info *cur; + TRACE("bind_columns"); + if (stmt->rows_affected==0) { cur = stmt->bind_head; while (cur) { @@ -1040,6 +1177,23 @@ } } +static void +unbind_columns(struct _hstmt *stmt) +{ + struct _sql_bind_info *cur, *next; + + TRACE("unbind_columns"); + + //Free the memory allocated for bound columns + cur = stmt->bind_head; + while(cur) { + next = cur->next; + g_free(cur); + cur = next; + } + stmt->bind_head = NULL; +} + SQLRETURN SQL_API SQLFetch( SQLHSTMT hstmt) { @@ -1089,15 +1243,28 @@ static SQLRETURN SQL_API _SQLFreeConnect( SQLHDBC hdbc) { - ODBCConnection* dbc = (ODBCConnection*) hdbc; + struct _hdbc* dbc = (struct _hdbc*) hdbc; + struct _henv* env; TRACE("_SQLFreeConnect"); + env = dbc->henv; + + if (dbc->statements->len) { + // Function sequence error + strcpy(sqlState, "HY010"); + return SQL_ERROR; + } + if (!g_ptr_array_remove(env->connections, dbc)) + return SQL_INVALID_HANDLE; + FreeConnectParams(dbc->params); + g_ptr_array_free(dbc->statements, TRUE); g_free(dbc); return SQL_SUCCESS; } + SQLRETURN SQL_API SQLFreeConnect( SQLHDBC hdbc) { @@ -1108,7 +1275,17 @@ static SQLRETURN SQL_API _SQLFreeEnv( SQLHENV henv) { + struct _henv* env = (struct _henv*)henv; + TRACE("_SQLFreeEnv"); + + if (env->connections->len) { + // Function sequence error + strcpy(sqlState, "HY010"); + return SQL_ERROR; + } + g_ptr_array_free(env->connections, TRUE); + return SQL_SUCCESS; } SQLRETURN SQL_API SQLFreeEnv( @@ -1129,9 +1306,17 @@ TRACE("_SQLFreeStmt"); if (fOption==SQL_DROP) { + if (!g_ptr_array_remove(dbc->statements, stmt)) + return SQL_INVALID_HANDLE; mdb_sql_reset(sql); + unbind_columns(stmt); g_free(stmt); } else if (fOption==SQL_CLOSE) { + stmt->rows_affected = 0; + } else if (fOption==SQL_UNBIND) { + unbind_columns(stmt); + } else if (fOption==SQL_RESET_PARAMS) { + /* Bound parameters not currently implemented */ } else { } return SQL_SUCCESS; @@ -1157,9 +1342,9 @@ SQLRETURN SQL_API SQLGetCursorName( SQLHSTMT hstmt, - SQLCHAR FAR *szCursor, + SQLCHAR *szCursor, SQLSMALLINT cbCursorMax, - SQLSMALLINT FAR *pcbCursor) + SQLSMALLINT *pcbCursor) { TRACE("SQLGetCursorName"); return SQL_SUCCESS; @@ -1167,7 +1352,7 @@ SQLRETURN SQL_API SQLNumResultCols( SQLHSTMT hstmt, - SQLSMALLINT FAR *pccol) + SQLSMALLINT *pccol) { struct _hstmt *stmt = (struct _hstmt *) hstmt; struct _hdbc *dbc = (struct _hdbc *) stmt->hdbc; @@ -1180,7 +1365,7 @@ SQLRETURN SQL_API SQLPrepare( SQLHSTMT hstmt, - SQLCHAR FAR *szSqlStr, + SQLCHAR *szSqlStr, SQLINTEGER cbSqlStr) { struct _hstmt *stmt=(struct _hstmt *)hstmt; @@ -1196,7 +1381,7 @@ SQLRETURN SQL_API SQLRowCount( SQLHSTMT hstmt, - SQLLEN FAR *pcrow) + SQLLEN *pcrow) { struct _hstmt *stmt=(struct _hstmt *)hstmt; @@ -1207,7 +1392,7 @@ SQLRETURN SQL_API SQLSetCursorName( SQLHSTMT hstmt, - SQLCHAR FAR *szCursor, + SQLCHAR *szCursor, SQLSMALLINT cbCursor) { TRACE("SQLSetCursorName"); @@ -1232,21 +1417,21 @@ SQLULEN cbParamDef, SQLSMALLINT ibScale, SQLPOINTER rgbValue, - SQLLEN FAR *pcbValue) + SQLLEN *pcbValue) { TRACE("SQLSetParam"); return SQL_SUCCESS; } -SQLRETURN SQL_API SQLColumns( +static SQLRETURN SQL_API _SQLColumns( SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szTableName, + SQLCHAR *szTableName, SQLSMALLINT cbTableName, - SQLCHAR FAR *szColumnName, + SQLCHAR *szColumnName, SQLSMALLINT cbColumnName) { struct _hstmt *stmt = (struct _hstmt *) hstmt; @@ -1271,7 +1456,7 @@ SQLSMALLINT sqldatatype; /* For datetime, use nonconcise data type */ SQLINTEGER ordinal; - TRACE("SQLColumns"); + TRACE("_SQLColumns"); mdb_read_catalog(mdb, MDB_ANY); @@ -1338,25 +1523,41 @@ return SQL_SUCCESS; } +SQLRETURN SQL_API SQLColumns( + SQLHSTMT hstmt, + SQLCHAR *szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR *szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR *szTableName, + SQLSMALLINT cbTableName, + SQLCHAR *szColumnName, + SQLSMALLINT cbColumnName) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLColumns"))); +#else +{ return _SQLColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLColumnsW( SQLHSTMT hstmt, - SQLWCHAR FAR *szCatalogName, + SQLWCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLWCHAR FAR *szSchemaName, + SQLWCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLWCHAR FAR *szTableName, + SQLWCHAR *szTableName, SQLSMALLINT cbTableName, - SQLWCHAR FAR *szColumnName, + SQLWCHAR *szColumnName, SQLSMALLINT cbColumnName) { if(cbTableName==SQL_NTS)cbTableName=sqlwlen(szTableName); { SQLCHAR *tmp=calloc(cbTableName*4,1); - unsigned int l=cbTableName*4,z=cbTableName*2; + size_t l=cbTableName*4,z=cbTableName*2; SQLRETURN ret; unicode2ascii((char*)szTableName, &z, (char*)tmp, &l); - ret=SQLColumns(hstmt,NULL,0,NULL,0,tmp,l,NULL,0); + ret = _SQLColumns(hstmt, NULL, 0, NULL, 0, tmp, l, NULL, 0); free(tmp); return ret; } @@ -1372,13 +1573,13 @@ return SQL_SUCCESS; } -SQLRETURN SQL_API SQLGetData( +static SQLRETURN SQL_API _SQLGetData( SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgbValue, SQLLEN cbValueMax, - SQLLEN FAR *pcbValue) + SQLLEN *pcbValue) { struct _hstmt *stmt; struct _hdbc *dbc; @@ -1388,9 +1589,9 @@ MdbSQLColumn *sqlcol; MdbColumn *col; MdbTableDef *table; - int i; + int i, intValue; - TRACE("SQLGetData"); + TRACE("_SQLGetData"); stmt = (struct _hstmt *) hstmt; dbc = (struct _hdbc *) stmt->hdbc; env = (struct _henv *) dbc->henv; @@ -1410,6 +1611,8 @@ break; } } + if (i==table->num_cols) + return SQL_ERROR; if (icol!=stmt->icol) { stmt->icol=icol; @@ -1420,10 +1623,6 @@ strcpy(sqlState, "HY009"); return SQL_ERROR; } - if (pcbValue && *pcbValue<0) { - strcpy(sqlState, "HY090"); - return SQL_ERROR; - } if (col->col_type == MDB_BOOL) { // bool cannot be null @@ -1443,21 +1642,96 @@ return SQL_SUCCESS; } + if (fCType==SQL_ARD_TYPE) { + // Get _sql_bind_info + struct _sql_bind_info *cur; + for (cur = stmt->bind_head; cur; cur=cur->next) { + if (cur->column_number == icol) { + fCType = cur->column_bindtype; + goto found_bound_type; + } + } + strcpy(sqlState, "07009"); + return SQL_ERROR; + } + found_bound_type: + if (fCType==SQL_C_DEFAULT) + fCType = _odbc_get_client_type(col); + if (fCType == SQL_C_CHAR) + goto to_c_char; switch(col->col_type) { case MDB_BYTE: - *(SQLSMALLINT*)rgbValue = mdb_get_byte(mdb->pg_buf, col->cur_value_start); - if (pcbValue) - *pcbValue = sizeof(SQLSMALLINT); - break; + intValue = (int)mdb_get_byte(mdb->pg_buf, col->cur_value_start); + goto to_integer_type; case MDB_INT: - *(SQLSMALLINT*)rgbValue = (SQLSMALLINT)mdb_get_int16(mdb->pg_buf, col->cur_value_start); - if (pcbValue) - *pcbValue = sizeof(SQLSMALLINT); - break; + intValue = mdb_get_int16(mdb->pg_buf, col->cur_value_start); + goto to_integer_type; case MDB_LONGINT: - *(SQLINTEGER*)rgbValue = mdb_get_int32(mdb->pg_buf, col->cur_value_start); - if (pcbValue) - *pcbValue = sizeof(SQLINTEGER); + intValue = mdb_get_int32(mdb->pg_buf, col->cur_value_start); + goto to_integer_type; + to_integer_type: + switch (fCType) { + case SQL_C_UTINYINT: + if (intValue<0 || intValue>UCHAR_MAX) { + strcpy(sqlState, "22003"); // Numeric value out of range + return SQL_ERROR; + } + *(SQLCHAR*)rgbValue = (SQLCHAR)intValue; + if (pcbValue) + *pcbValue = sizeof(SQLCHAR); + break; + case SQL_C_TINYINT: + case SQL_C_STINYINT: + if (intValueSCHAR_MAX) { + strcpy(sqlState, "22003"); // Numeric value out of range + return SQL_ERROR; + } + *(SQLSCHAR*)rgbValue = (SQLSCHAR)intValue; + if (pcbValue) + *pcbValue = sizeof(SQLSCHAR); + break; + case SQL_C_USHORT: + case SQL_C_SHORT: + if (intValue<0 || intValue>USHRT_MAX) { + strcpy(sqlState, "22003"); // Numeric value out of range + return SQL_ERROR; + } + *(SQLSMALLINT*)rgbValue = (SQLSMALLINT)intValue; + if (pcbValue) + *pcbValue = sizeof(SQLSMALLINT); + break; + case SQL_C_SSHORT: + if (intValueSHRT_MAX) { + strcpy(sqlState, "22003"); // Numeric value out of range + return SQL_ERROR; + } + *(SQLSMALLINT*)rgbValue = (SQLSMALLINT)intValue; + if (pcbValue) + *pcbValue = sizeof(SQLSMALLINT); + break; + case SQL_C_ULONG: + if (intValue<0 || intValue>UINT_MAX) { + strcpy(sqlState, "22003"); // Numeric value out of range + return SQL_ERROR; + } + *(SQLUINTEGER*)rgbValue = (SQLINTEGER)intValue; + if (pcbValue) + *pcbValue = sizeof(SQLINTEGER); + break; + case SQL_C_LONG: + case SQL_C_SLONG: + if (intValueLONG_MAX) { + strcpy(sqlState, "22003"); // Numeric value out of range + return SQL_ERROR; + } + *(SQLINTEGER*)rgbValue = intValue; + if (pcbValue) + *pcbValue = sizeof(SQLINTEGER); + break; + default: + strcpy(sqlState, "HYC00"); // Not implemented + return SQL_ERROR; + } break; // case MDB_MONEY: TODO case MDB_FLOAT: @@ -1470,8 +1744,10 @@ if (pcbValue) *pcbValue = sizeof(double); break; - case MDB_DATETIME: ; #if ODBCVER >= 0x0300 + // returns text if old odbc + case MDB_DATETIME: + { struct tm tmp_t; mdb_date_to_tm(mdb_get_double(mdb->pg_buf, col->cur_value_start), &tmp_t); @@ -1499,13 +1775,18 @@ *pcbValue = sizeof(TIMESTAMP_STRUCT); } break; -#endif // returns text if old odbc - default: ; + } +#endif + default: /* FIXME here we assume fCType == SQL_C_CHAR */ + to_c_char: + { char *str = mdb_col_to_string(mdb, mdb->pg_buf, col->cur_value_start, col->col_type, col->cur_value_len); - int len = strlen(str); - if (stmt->pos >= len) + int len = strlen(str) + 1; // including \0 + if (stmt->pos >= len) { + free(str); return SQL_NO_DATA; + } if (!cbValueMax) { if (pcbValue) *pcbValue = len; @@ -1529,32 +1810,48 @@ stmt->pos += len - stmt->pos; free(str); break; + } } return SQL_SUCCESS; } +SQLRETURN SQL_API SQLGetData( + SQLHSTMT hstmt, + SQLUSMALLINT icol, + SQLSMALLINT fCType, + SQLPOINTER rgbValue, + SQLLEN cbValueMax, + SQLLEN *pcbValue) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLGetData"))); +#else +{ return _SQLGetData(hstmt, icol, fCType, rgbValue, cbValueMax, pcbValue); } +#endif + #ifdef ENABLE_ODBC_W SQLRETURN SQL_API SQLGetDataW( SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgbValue, - SQLINTEGER cbValueMax, - SQLINTEGER FAR *pcbValue) + SQLLEN cbValueMax, + SQLLEN *pcbValue) { + //todo: treat numbers correctly + SQLCHAR *tmp=calloc(cbValueMax*4,1); - unsigned int l=cbValueMax*4; - SQLRETURN ret=SQLGetData(hstmt,icol,fCType,tmp,cbValueMax*4,(SQLINTEGER FAR*)&l); - ascii2unicode((char*)tmp, &l, (char*)rgbValue, (unsigned int*)pcbValue); + size_t l=cbValueMax*4; + SQLRETURN ret = _SQLGetData(hstmt, icol, fCType, tmp, cbValueMax*4, (SQLLEN*)&l); + ascii2unicode((char*)tmp, &l, (char*)rgbValue, (size_t*)pcbValue); *pcbValue/=sizeof(SQLWCHAR); free(tmp); return ret; } #endif //ENABLE_ODBC_W -static void _set_func_exists(SQLUSMALLINT FAR *pfExists, SQLUSMALLINT fFunction) +static void _set_func_exists(SQLUSMALLINT *pfExists, SQLUSMALLINT fFunction) { - SQLUSMALLINT FAR *mod; + SQLUSMALLINT *mod; mod = pfExists + (fFunction >> 4); *mod |= (1 << (fFunction & 0x0f)); } @@ -1562,7 +1859,7 @@ SQLRETURN SQL_API SQLGetFunctions( SQLHDBC hdbc, SQLUSMALLINT fFunction, - SQLUSMALLINT FAR *pfExists) + SQLUSMALLINT *pfExists) { TRACE("SQLGetFunctions"); @@ -1725,44 +2022,104 @@ return SQL_SUCCESS; } -SQLRETURN SQL_API SQLGetInfo( +static SQLRETURN SQL_API _SQLGetInfo( SQLHDBC hdbc, SQLUSMALLINT fInfoType, SQLPOINTER rgbInfoValue, SQLSMALLINT cbInfoValueMax, - SQLSMALLINT FAR *pcbInfoValue) + SQLSMALLINT *pcbInfoValue) { - TRACE("SQLGetInfo"); + TRACE("_SQLGetInfo"); switch (fInfoType) { case SQL_MAX_STATEMENT_LEN: - *((SQLUINTEGER *)rgbInfoValue) = (SQLUINTEGER) 65000; - *pcbInfoValue = sizeof(SQLUINTEGER); + if (rgbInfoValue) + *((SQLUINTEGER *)rgbInfoValue) = (SQLUINTEGER)65000; + if (pcbInfoValue) + *pcbInfoValue = sizeof(SQLUINTEGER); break; case SQL_SCHEMA_USAGE: - *((SQLSMALLINT *)rgbInfoValue) = (SQLSMALLINT) 0; - *pcbInfoValue = sizeof(SQLSMALLINT); + if (rgbInfoValue) + *((SQLSMALLINT *)rgbInfoValue) = (SQLSMALLINT)0; + if (pcbInfoValue) + *pcbInfoValue = sizeof(SQLSMALLINT); break; case SQL_CATALOG_NAME_SEPARATOR: - rgbInfoValue = "."; - *pcbInfoValue = 1; + if (rgbInfoValue) + memcpy(rgbInfoValue, ".", 1); + if (pcbInfoValue) + *pcbInfoValue = 1; break; case SQL_CATALOG_LOCATION: - *((SQLSMALLINT *)rgbInfoValue) = (SQLSMALLINT) 1; - *pcbInfoValue = sizeof(SQLSMALLINT); + if (rgbInfoValue) + *((SQLSMALLINT *)rgbInfoValue) = (SQLSMALLINT)1; + if (pcbInfoValue) + *pcbInfoValue = sizeof(SQLSMALLINT); break; case SQL_IDENTIFIER_QUOTE_CHAR: - rgbInfoValue = "\""; - *pcbInfoValue = 1; + if (rgbInfoValue) + memcpy(rgbInfoValue, "\"", 1); + if (pcbInfoValue) + *pcbInfoValue = 1; break; case SQL_DBMS_NAME: - rgbInfoValue = "MDBTOOLS"; - *pcbInfoValue = 8; + if (rgbInfoValue) + strncpy(rgbInfoValue, "MDBTOOLS", cbInfoValueMax); + if (pcbInfoValue) + *pcbInfoValue = 9; + break; + case SQL_DBMS_VER: + if (rgbInfoValue) + strncpy(rgbInfoValue, VERSION, cbInfoValueMax); + if (pcbInfoValue) + *pcbInfoValue = sizeof(VERSION)+1; break; + default: + if (pcbInfoValue) + *pcbInfoValue = 0; + strcpy(sqlState, "HYC00"); + return SQL_ERROR; } return SQL_SUCCESS; } +SQLRETURN SQL_API SQLGetInfo( + SQLHDBC hdbc, + SQLUSMALLINT fInfoType, + SQLPOINTER rgbInfoValue, + SQLSMALLINT cbInfoValueMax, + SQLSMALLINT *pcbInfoValue) +#ifdef HAVE_ATTRIBUTE_ALIAS +__attribute__((alias("_SQLGetInfo"))); +#else +{ return _SQLGetInfo(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue); } +#endif + +#ifdef ENABLE_ODBC_W +SQLRETURN SQL_API SQLGetInfoW( + SQLHDBC hdbc, + SQLUSMALLINT fInfoType, + SQLPOINTER rgbInfoValue, + SQLSMALLINT cbInfoValueMax, + SQLSMALLINT *pcbInfoValue) +{ + TRACE("SQLGetInfoW"); + + if(fInfoType==SQL_MAX_STATEMENT_LEN||fInfoType==SQL_SCHEMA_USAGE||fInfoType==SQL_CATALOG_LOCATION) + return _SQLGetInfo(hdbc,fInfoType,rgbInfoValue,cbInfoValueMax,pcbInfoValue); + + SQLCHAR *tmp=calloc(cbInfoValueMax*4,1); + size_t l=cbInfoValueMax*4; + SQLRETURN ret = _SQLGetInfo(hdbc, fInfoType, tmp, cbInfoValueMax*4,(SQLSMALLINT*)&l); + size_t pcb=cbInfoValueMax; + ascii2unicode((char*)tmp, &l, (char*)rgbInfoValue, &pcb); + pcb/=sizeof(SQLWCHAR); + if(pcbInfoValue)*pcbInfoValue=pcb; + free(tmp); + return ret; +} +#endif //ENABLE_ODBC_W + SQLRETURN SQL_API SQLGetStmtOption( SQLHSTMT hstmt, SQLUSMALLINT fOption, @@ -1859,7 +2216,7 @@ SQLRETURN SQL_API SQLParamData( SQLHSTMT hstmt, - SQLPOINTER FAR *prgbValue) + SQLPOINTER *prgbValue) { TRACE("SQLParamData"); return SQL_SUCCESS; @@ -1895,11 +2252,11 @@ SQLRETURN SQL_API SQLSpecialColumns( SQLHSTMT hstmt, SQLUSMALLINT fColType, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szTableName, + SQLCHAR *szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fScope, SQLUSMALLINT fNullable) @@ -1910,11 +2267,11 @@ SQLRETURN SQL_API SQLStatistics( SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szTableName, + SQLCHAR *szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fUnique, SQLUSMALLINT fAccuracy) @@ -1925,13 +2282,13 @@ SQLRETURN SQL_API SQLTables( //sz* not used, so Unicode API not required. SQLHSTMT hstmt, - SQLCHAR FAR *szCatalogName, + SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, - SQLCHAR FAR *szSchemaName, + SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, - SQLCHAR FAR *szTableName, + SQLCHAR *szTableName, SQLSMALLINT cbTableName, - SQLCHAR FAR *szTableType, + SQLCHAR *szTableType, SQLSMALLINT cbTableType) { struct _hstmt *stmt = (struct _hstmt *) hstmt; @@ -1998,12 +2355,12 @@ SQLRETURN SQL_API SQLDataSources( SQLHENV henv, SQLUSMALLINT fDirection, - SQLCHAR FAR *szDSN, + SQLCHAR *szDSN, SQLSMALLINT cbDSNMax, - SQLSMALLINT FAR *pcbDSN, - SQLCHAR FAR *szDescription, + SQLSMALLINT *pcbDSN, + SQLCHAR *szDescription, SQLSMALLINT cbDescriptionMax, - SQLSMALLINT FAR *pcbDescription) + SQLSMALLINT *pcbDescription) { TRACE("SQLDataSources"); return SQL_SUCCESS; @@ -2049,7 +2406,7 @@ return 0; } -static int _odbc_get_string_size(int size, SQLCHAR FAR *str) +static int _odbc_get_string_size(int size, SQLCHAR *str) { if (!str) { return 0; diff -Nru mdbtools-0.7/src/odbc/unittest.c mdbtools-0.7.1/src/odbc/unittest.c --- mdbtools-0.7/src/odbc/unittest.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/odbc/unittest.c 2013-10-13 08:51:24.000000000 +0000 @@ -17,11 +17,10 @@ */ /* #include */ +#include #include #include -#include - #define SALES_PERSON_LEN 2 #define STATUS_LEN 6 diff -Nru mdbtools-0.7/src/sql/Makefile.am mdbtools-0.7.1/src/sql/Makefile.am --- mdbtools-0.7/src/sql/Makefile.am 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/sql/Makefile.am 2013-10-13 08:51:24.000000000 +0000 @@ -1,11 +1,8 @@ lib_LTLIBRARIES = libmdbsql.la libmdbsql_la_SOURCES= mdbsql.c parser.y lexer.l -libmdbsql_la_LDFLAGS = -version-info 2:0:0 -Wl,--version-script=$(srcdir)/libmdbsql.map -DISTCLEANFILES = parser.c parser.h lexer.c -AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) +libmdbsql_la_LDFLAGS = -version-info 2:0:0 -export-symbols-regex '^mdb_sql_' +CLEANFILES = parser.c parser.h lexer.c +AM_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) LIBS = $(GLIB_LIBS) libmdbsql_la_LIBADD = ../libmdb/libmdb.la YACC = @YACC@ -d - -dist-hook: - rm -f $(distdir)/parser.c $(distdir)/parser.h $(distdir)/lexer.c diff -Nru mdbtools-0.7/src/sql/lexer.l mdbtools-0.7.1/src/sql/lexer.l --- mdbtools-0.7/src/sql/lexer.l 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/sql/lexer.l 2013-10-13 08:51:24.000000000 +0000 @@ -23,6 +23,9 @@ extern int mdb_sql_yyinput(char *buf, int need); %} +%option nounput +%option noinput + %% select { return SELECT; } from { return FROM; } diff -Nru mdbtools-0.7/src/sql/libmdbsql.map mdbtools-0.7.1/src/sql/libmdbsql.map --- mdbtools-0.7/src/sql/libmdbsql.map 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/sql/libmdbsql.map 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -{ -global: - mdb_sql_*; - -local: - *; -}; diff -Nru mdbtools-0.7/src/sql/mdbsql.c mdbtools-0.7.1/src/sql/mdbsql.c --- mdbtools-0.7/src/sql/mdbsql.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/sql/mdbsql.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "mdbsql.h" #include +#include "mdbsql.h" #ifdef DMALLOC #include "dmalloc.h" @@ -51,10 +51,10 @@ va_list ap; va_start(ap, fmt); - vfprintf (stderr, fmt, ap); - vsprintf(sql->error_msg, fmt, ap); + vsnprintf(sql->error_msg, sizeof(sql->error_msg), fmt, ap); va_end(ap); - fprintf(stderr,"\n"); + + fprintf(stderr, "%s\n", sql->error_msg); } int mdb_sql_yyinput(char *buf, int need) @@ -74,7 +74,6 @@ { MdbSQL *sql; - mdb_init(); sql = (MdbSQL *) g_malloc0(sizeof(MdbSQL)); sql->columns = g_ptr_array_new(); sql->tables = g_ptr_array_new(); @@ -209,6 +208,7 @@ if (tree->left) mdb_sql_free_tree(tree->left); if (tree->right) mdb_sql_free_tree(tree->right); + if (tree->parent) g_free(tree->parent); g_free(tree); } void @@ -457,24 +457,18 @@ } void mdb_sql_exit(MdbSQL *sql) { - mdb_sql_free_columns(sql->columns); - mdb_sql_free_tables(sql->tables); - - if (sql->sarg_tree) { - mdb_sql_free_tree(sql->sarg_tree); - sql->sarg_tree = NULL; - } - g_list_free(sql->sarg_stack); - sql->sarg_stack = NULL; - - if (sql->mdb) { + mdb_sql_reset(sql); // Free memory + if (sql->mdb) mdb_close(sql->mdb); - } } void mdb_sql_reset(MdbSQL *sql) { if (sql->cur_table) { mdb_index_scan_free(sql->cur_table); + if (sql->cur_table->sarg_tree) { + mdb_sql_free_tree(sql->cur_table->sarg_tree); + sql->cur_table->sarg_tree = NULL; + } mdb_free_tabledef(sql->cur_table); sql->cur_table = NULL; } @@ -548,9 +542,9 @@ /* add all user tables in catalog to list */ for (i=0; i < mdb->num_catalog; i++) { - entry = g_ptr_array_index (mdb->catalog, i); - if (mdb_is_user_table(entry)) { - //col = g_ptr_array_index(table->columns,0); + entry = g_ptr_array_index (mdb->catalog, i); + if (mdb_is_user_table(entry)) { + //col = g_ptr_array_index(table->columns,0); tmpsiz = mdb_ascii2unicode(mdb, entry->object_name, 0, tmpstr, 100); mdb_fill_temp_field(&fields[0],tmpstr, tmpsiz, 0,0,0,0); row_size = mdb_pack_row(ttable, row_buffer, 1, fields); @@ -612,9 +606,9 @@ mdb_sql_add_temp_col(sql, ttable, 1, "Type", MDB_TEXT, 20, 0); mdb_sql_add_temp_col(sql, ttable, 2, "Size", MDB_TEXT, 10, 0); - for (i=0;inum_cols;i++) { + for (i=0;inum_cols;i++) { - col = g_ptr_array_index(table->columns,i); + col = g_ptr_array_index(table->columns,i); tmpsiz = mdb_ascii2unicode(mdb, col->name, 0, col_name, 100); mdb_fill_temp_field(&fields[0],col_name, tmpsiz, 0,0,0,0); @@ -629,7 +623,7 @@ row_size = mdb_pack_row(ttable, row_buffer, 3, fields); mdb_add_row_to_pg(ttable,row_buffer, row_size); ttable->num_rows++; - } + } /* the column and table names are no good now */ //mdb_sql_reset(sql); diff -Nru mdbtools-0.7/src/util/Makefile.am mdbtools-0.7.1/src/util/Makefile.am --- mdbtools-0.7/src/util/Makefile.am 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/Makefile.am 2013-10-13 08:51:24.000000000 +0000 @@ -2,7 +2,7 @@ noinst_PROGRAMS = mdb-import prtable prcat prdata prkkd prdump prole updrow prindex LIBS = $(GLIB_LIBS) @LIBS@ @LEXLIB@ DEFS = @DEFS@ -DLOCALEDIR=\"$(localedir)\" -AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) +AM_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) LDADD = ../libmdb/libmdb.la if SQL mdb_sql_LDADD = ../libmdb/libmdb.la ../sql/libmdbsql.la $(LIBREADLINE) diff -Nru mdbtools-0.7/src/util/mdb-array.c mdbtools-0.7.1/src/util/mdb-array.c --- mdbtools-0.7/src/util/mdb-array.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-array.c 2013-10-13 08:51:24.000000000 +0000 @@ -45,8 +45,9 @@ exit (1); } - mdb_init(); mdb = mdb_open (argv [1], MDB_NOFLAGS); + if (!mdb) + exit(1); table = mdb_read_table_by_name (mdb, argv[2], MDB_TABLE); if (table) @@ -117,12 +118,11 @@ } mdb_close (mdb); - mdb_exit(); fprintf (stdout, "const int %s_array_length = %d;\n", argv [2], count); - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/mdb-check.c mdbtools-0.7.1/src/util/mdb-check.c --- mdbtools-0.7/src/util/mdb-check.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-check.c 2013-10-13 08:51:24.000000000 +0000 @@ -59,8 +59,6 @@ } } - mdb_init(); - /* open the database */ mdb = mdb_open (argv[optind], MDB_NOFLAGS); @@ -101,8 +99,7 @@ g_free(tabname); mdb_close (mdb); - mdb_exit(); - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/mdb-export.c mdbtools-0.7.1/src/util/mdb-export.c --- mdbtools-0.7/src/util/mdb-export.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-export.c 2013-10-13 08:51:24.000000000 +0000 @@ -25,14 +25,16 @@ #undef MDB_BIND_SIZE #define MDB_BIND_SIZE 200000 -#define is_quote_type(x) (x==MDB_TEXT || x==MDB_OLE || x==MDB_MEMO || x==MDB_DATETIME || x==MDB_BINARY) -#define is_binary_type(x) (x==MDB_OLE || x==MDB_BINARY) +#define is_quote_type(x) (x==MDB_TEXT || x==MDB_OLE || x==MDB_MEMO || x==MDB_DATETIME || x==MDB_BINARY || x==MDB_REPID) +#define is_binary_type(x) (x==MDB_OLE || x==MDB_BINARY || x==MDB_REPID) static char *escapes(char *s); //#define DONT_ESCAPE_ESCAPE static void -print_col(gchar *col_val, int quote_text, int col_type, int bin_len, char *quote_char, char *escape_char) +print_col(FILE *outfile, gchar *col_val, int quote_text, int col_type, int bin_len, char *quote_char, char *escape_char, int bin_mode) +/* quote_text: Don't quote if 0. + */ { size_t quote_len = strlen(quote_char); /* multibyte */ @@ -43,9 +45,11 @@ escape_char = quote_char; if (quote_text && is_quote_type(col_type)) { - fputs(quote_char,stdout); + fputs(quote_char, outfile); while (1) { if (is_binary_type(col_type)) { + if (bin_mode == MDB_BINEXPORT_STRIP) + break; if (!bin_len--) break; } else /* use \0 sentry */ @@ -53,29 +57,32 @@ break; if (quote_len && !strncmp(col_val, quote_char, quote_len)) { - fprintf(stdout, "%s%s", escape_char, quote_char); + fprintf(outfile, "%s%s", escape_char, quote_char); col_val += quote_len; #ifndef DONT_ESCAPE_ESCAPE } else if (orig_escape_len && !strncmp(col_val, escape_char, orig_escape_len)) { - fprintf(stdout, "%s%s", escape_char, escape_char); + fprintf(outfile, "%s%s", escape_char, escape_char); col_val += orig_escape_len; #endif - } else - putc(*col_val++, stdout); + } else if (is_binary_type(col_type) && *col_val <= 0 && bin_mode == MDB_BINEXPORT_OCTAL) + fprintf(outfile, "\\%03o", *(unsigned char*)col_val++); + else + putc(*col_val++, outfile); } - fputs(quote_char,stdout); + fputs(quote_char, outfile); } else - fputs(col_val,stdout); + fputs(col_val, outfile); } int main(int argc, char **argv) { - unsigned int j; + unsigned int i; MdbHandle *mdb; MdbTableDef *table; MdbColumn *col; char **bound_values; int *bound_lens; + FILE *outfile = stdout; char *delimiter = NULL; char *row_delimiter = NULL; char *quote_char = NULL; @@ -84,11 +91,12 @@ char quote_text = 1; char *insert_dialect = NULL; char *namespace = NULL; + int bin_mode = MDB_BINEXPORT_RAW; int opt; char *value; size_t length; - while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:N:"))!=-1) { + while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:N:b:"))!=-1) { switch (opt) { case 'H': header_row = 0; @@ -118,6 +126,18 @@ case 'N': namespace = (char *) g_strdup(optarg); break; + case 'b': + if (!strcmp(optarg, "strip")) + bin_mode = MDB_BINEXPORT_STRIP; + else if (!strcmp(optarg, "raw")) + bin_mode = MDB_BINEXPORT_RAW; + else if (!strcmp(optarg, "octal")) + bin_mode = MDB_BINEXPORT_OCTAL; + else { + fprintf(stderr, "Invalid binary mode\n"); + exit(1); + } + break; default: break; } @@ -139,15 +159,16 @@ if (argc-optind < 2) { fprintf(stderr,"Usage: %s [options] \n",argv[0]); fprintf(stderr,"where options are:\n"); - fprintf(stderr," -H supress header row\n"); - fprintf(stderr," -Q don't wrap text-like fields in quotes\n"); - fprintf(stderr," -d specify a column delimiter\n"); - fprintf(stderr," -R specify a row delimiter\n"); - fprintf(stderr," -I INSERT statements (instead of CSV)\n"); - fprintf(stderr," -D set the date format (see strftime(3) for details)\n"); - fprintf(stderr," -q Use to wrap text-like fields. Default is \".\n"); - fprintf(stderr," -X Use to escape quoted characters within a field. Default is doubling.\n"); - fprintf(stderr," -N Prefix identifiers with namespace\n"); + fprintf(stderr," -H supress header row\n"); + fprintf(stderr," -Q don't wrap text-like fields in quotes\n"); + fprintf(stderr," -d specify a column delimiter\n"); + fprintf(stderr," -R specify a row delimiter\n"); + fprintf(stderr," -I INSERT statements (instead of CSV)\n"); + fprintf(stderr," -D set the date format (see strftime(3) for details)\n"); + fprintf(stderr," -q Use to wrap text-like fields. Default is \".\n"); + fprintf(stderr," -X Use to escape quoted characters within a field. Default is doubling.\n"); + fprintf(stderr," -N Prefix identifiers with namespace\n"); + fprintf(stderr," -b strip|raw|octal Binary export mode.\n"); g_free (delimiter); g_free (row_delimiter); g_free (quote_char); @@ -155,14 +176,11 @@ exit(1); } - mdb_init(); - if (!(mdb = mdb_open(argv[optind], MDB_NOFLAGS))) { g_free (delimiter); g_free (row_delimiter); g_free (quote_char); if (escape_char) g_free (escape_char); - mdb_exit(); exit(1); } @@ -170,7 +188,6 @@ if (!mdb_set_default_backend(mdb, insert_dialect)) { fprintf(stderr, "Invalid backend type\n"); if (escape_char) g_free (escape_char); - mdb_exit(); exit(1); } @@ -182,27 +199,28 @@ g_free (quote_char); if (escape_char) g_free (escape_char); mdb_close(mdb); - mdb_exit(); exit(1); } + /* read table */ mdb_read_columns(table); mdb_rewind_table(table); bound_values = (char **) g_malloc(table->num_cols * sizeof(char *)); bound_lens = (int *) g_malloc(table->num_cols * sizeof(int)); - for (j=0;jnum_cols;j++) { - bound_values[j] = (char *) g_malloc0(MDB_BIND_SIZE); - mdb_bind_column(table, j+1, bound_values[j], &bound_lens[j]); + for (i=0;inum_cols;i++) { + /* bind columns */ + bound_values[i] = (char *) g_malloc0(MDB_BIND_SIZE); + mdb_bind_column(table, i+1, bound_values[i], &bound_lens[i]); } if (header_row) { - for (j=0; jnum_cols; j++) { - col=g_ptr_array_index(table->columns,j); - if (j) - fputs(delimiter, stdout); - fputs(col->name, stdout); + for (i=0; inum_cols; i++) { + col=g_ptr_array_index(table->columns,i); + if (i) + fputs(delimiter, outfile); + fputs(col->name, outfile); } - fputs("\n", stdout); + fputs(row_delimiter, outfile); } while(mdb_fetch_row(table)) { @@ -210,42 +228,45 @@ if (insert_dialect) { char *quoted_name; quoted_name = mdb->default_backend->quote_schema_name(namespace, argv[optind + 1]); - fprintf(stdout, "INSERT INTO %s (", quoted_name); + fprintf(outfile, "INSERT INTO %s (", quoted_name); free(quoted_name); - for (j=0;jnum_cols;j++) { - if (j>0) fputs(", ", stdout); - col=g_ptr_array_index(table->columns,j); + for (i=0;inum_cols;i++) { + if (i>0) fputs(", ", outfile); + col=g_ptr_array_index(table->columns,i); quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name); - fputs(quoted_name, stdout); + fputs(quoted_name, outfile); free(quoted_name); } - fputs(") VALUES (", stdout); + fputs(") VALUES (", outfile); } - for (j=0;jnum_cols;j++) { - if (j>0) - fputs(delimiter, stdout); - col=g_ptr_array_index(table->columns,j); - if (!bound_lens[j]) { + for (i=0;inum_cols;i++) { + if (i>0) + fputs(delimiter, outfile); + col=g_ptr_array_index(table->columns,i); + if (!bound_lens[i]) { + /* Don't quote NULLs */ if (insert_dialect) - fputs("NULL", stdout); + fputs("NULL", outfile); } else { if (col->col_type == MDB_OLE) { value = mdb_ole_read_full(mdb, col, &length); } else { - value = bound_values[j]; - length = bound_lens[j]; + value = bound_values[i]; + length = bound_lens[i]; } - print_col(value, quote_text, col->col_type, length, quote_char, escape_char); + print_col(outfile, value, quote_text, col->col_type, length, quote_char, escape_char, bin_mode); if (col->col_type == MDB_OLE) free(value); } } - if (insert_dialect) fputs(");", stdout); - fputs(row_delimiter, stdout); + if (insert_dialect) fputs(");", outfile); + fputs(row_delimiter, outfile); } - for (j=0;jnum_cols;j++) { - g_free(bound_values[j]); + + /* free the memory used to bind */ + for (i=0;inum_cols;i++) { + g_free(bound_values[i]); } g_free(bound_values); g_free(bound_lens); @@ -255,9 +276,8 @@ g_free (row_delimiter); g_free (quote_char); if (escape_char) g_free (escape_char); + mdb_close(mdb); - mdb_exit(); - return 0; } diff -Nru mdbtools-0.7/src/util/mdb-header.c mdbtools-0.7.1/src/util/mdb-header.c --- mdbtools-0.7/src/util/mdb-header.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-header.c 2013-10-13 08:51:24.000000000 +0000 @@ -18,8 +18,9 @@ /* this utility dumps the C headers for an existing database */ /* it will create three files - types.h and dump_types.[ch] */ -#include "mdbtools.h" + #include +#include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" @@ -50,13 +51,10 @@ exit (1); } - mdb_init(); - /* open the database */ mdb = mdb_open (argv[1], MDB_NOFLAGS); if (!mdb) { - mdb_exit(); exit(1); } @@ -148,7 +146,6 @@ fclose (cfile); mdb_close (mdb); - mdb_exit(); if (unsupported) fputs("ERROR: unsupported type.\n", stderr); diff -Nru mdbtools-0.7/src/util/mdb-import.c mdbtools-0.7.1/src/util/mdb-import.c --- mdbtools-0.7/src/util/mdb-import.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-import.c 2013-10-13 08:51:24.000000000 +0000 @@ -55,14 +55,14 @@ if (*c) return 1; field->siz = mdb_col_fixed_size(col); field->value = g_malloc(field->siz); - _mdb_put_int16(field->value, 0, any.i); + mdb_put_int16(field->value, 0, any.i); break; case MDB_LONGINT: any.i = strtol(s, &c, 16); if (*c) return 1; field->siz = mdb_col_fixed_size(col); field->value = g_malloc(field->siz); - _mdb_put_int32(field->value, 0, any.i); + mdb_put_int32(field->value, 0, any.i); break; case MDB_BOOL: if (*s == '1') { @@ -78,13 +78,13 @@ any.d = strtod(s, &c); if (*c) return 1; field.value = g_malloc(mdb_col_fixed_size(col)); - _mdb_put_single(field.value, 0, any.i); + mdb_put_single(field.value, 0, any.i); break; case MDB_DOUBLE: any.d = strtod(s, &c); if (*c) return 1; field.value = g_malloc(mdb_col_fixed_size(col)); - _mdb_put_double(field.value, 0, any.i); + mdb_put_double(field.value, 0, any.i); break; */ /* @@ -185,8 +185,6 @@ exit(1); } - mdb_init(); - if (!(mdb = mdb_open(argv[optind], MDB_WRITABLE))) { exit(1); } @@ -230,8 +228,6 @@ mdb_free_tabledef(table); fclose(in); mdb_close(mdb); - mdb_exit(); - - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/mdb-parsecsv.c mdbtools-0.7.1/src/util/mdb-parsecsv.c --- mdbtools-0.7/src/util/mdb-parsecsv.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-parsecsv.c 2013-10-13 08:51:24.000000000 +0000 @@ -19,6 +19,7 @@ /* this utility converts a CSV from an existing database to a C file */ /* input FOO.txt, output FOO.c */ /* generates an array of type FOO */ + #include #include #include @@ -164,6 +165,5 @@ fprintf (stdout, "count = %d\n", count); - - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/mdb-prop.c mdbtools-0.7.1/src/util/mdb-prop.c --- mdbtools-0.7/src/util/mdb-prop.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-prop.c 2013-10-13 08:51:24.000000000 +0000 @@ -41,18 +41,14 @@ else propColName = argv[3]; - mdb_init(); - mdb = mdb_open(argv[1], MDB_NOFLAGS); if (!mdb) { - mdb_exit(); return 1; } table = mdb_read_table_by_name(mdb, "MSysObjects", MDB_ANY); if (!table) { mdb_close(mdb); - mdb_exit(); return 1; } mdb_read_columns(table); @@ -65,7 +61,6 @@ g_free(buf); mdb_free_tabledef(table); mdb_close(mdb); - mdb_exit(); printf("Column %s not found in MSysObjects!\n", argv[3]); return 1; } @@ -81,15 +76,17 @@ MdbColumn *col = g_ptr_array_index(table->columns, col_num-1); size_t size; void *kkd = mdb_ole_read_full(mdb, col, &size); - dump_kkd(mdb, kkd, size); + if (size) + dump_kkd(mdb, kkd, size); + else + printf("No properties.\n"); free(kkd); } g_free(buf); mdb_free_tabledef(table); mdb_close(mdb); - mdb_exit(); - + return 0; } void dump_kkd(MdbHandle *mdb, void *kkd, size_t len) diff -Nru mdbtools-0.7/src/util/mdb-schema.c mdbtools-0.7.1/src/util/mdb-schema.c --- mdbtools-0.7/src/util/mdb-schema.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-schema.c 2013-10-13 08:51:24.000000000 +0000 @@ -143,20 +143,16 @@ } } - mdb_init(); - /* open the database */ mdb = mdb_open (argv[optind], MDB_NOFLAGS); if (!mdb) { fprintf(stderr, "Could not open file\n"); - mdb_exit(); exit(1); } if (argc - optind >= 2) { if (!mdb_set_default_backend(mdb, argv[optind + 1])) { fprintf(stderr, "Invalid backend type\n"); - mdb_exit(); exit(1); } } @@ -172,7 +168,6 @@ g_free(namespace); g_free(tabname); mdb_close (mdb); - mdb_exit(); return 0; } diff -Nru mdbtools-0.7/src/util/mdb-sql.c mdbtools-0.7.1/src/util/mdb-sql.c --- mdbtools-0.7/src/util/mdb-sql.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-sql.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,8 +16,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include - #include #ifdef HAVE_LIBREADLINE @@ -211,7 +209,6 @@ mdb_sql_reset(sql); return; } - mdb_sql_bind_all(sql); if (pretty_print) dump_results_pp(out, sql); else @@ -490,13 +487,13 @@ } #endif - exit(0); + return 0; } #else int main(int argc, char **argv) { fprintf(stderr,"You must configure using --enable-sql to get SQL support\n"); - exit(-1); + return -1; } #endif diff -Nru mdbtools-0.7/src/util/mdb-tables.c mdbtools-0.7.1/src/util/mdb-tables.c --- mdbtools-0.7/src/util/mdb-tables.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-tables.c 2013-10-13 08:51:24.000000000 +0000 @@ -17,6 +17,7 @@ */ /* this utility dumps the schema for an existing database */ + #include "mdbtools.h" #ifdef DMALLOC @@ -84,22 +85,26 @@ char *delimiter = NULL; int line_break=0; int skip_sys=1; + int show_type=0; int opt; int objtype = MDB_TABLE; if (argc < 2) { - fprintf (stderr, "Usage: %s [-S] [-1 | -d] [-t ] \n",argv[0]); + fprintf (stderr, "Usage: %s [-S] [-1 | -d] [-t ] [-T] \n",argv[0]); fprintf (stderr, " Valid types are: %s\n",valid_types()); exit (1); } - while ((opt=getopt(argc, argv, "S1d:t:"))!=-1) { + while ((opt=getopt(argc, argv, "S1Td:t:"))!=-1) { switch (opt) { case 'S': skip_sys = 0; break; + case 'T': + show_type = 1; + break; case '1': line_break = 1; break; @@ -117,9 +122,6 @@ } - /* initialize the library */ - mdb_init(); - /* open the database */ if (!(mdb = mdb_open (argv[optind], MDB_NOFLAGS))) { fprintf(stderr,"Couldn't open database.\n"); @@ -142,20 +144,24 @@ if (skip_sys && mdb_is_system_table(entry)) continue; - if (line_break) - fprintf (stdout, "%s\n", entry->object_name); + if (show_type) { + if (delimiter) + puts(delimiter); + printf("%d ", entry->object_type); + } + if (line_break) + printf ("%s\n", entry->object_name); else if (delimiter) - fprintf (stdout, "%s%s", entry->object_name, delimiter); + printf ("%s%s", entry->object_name, delimiter); else - fprintf (stdout, "%s ", entry->object_name); + printf ("%s ", entry->object_name); } if (!line_break) fprintf (stdout, "\n"); mdb_close(mdb); - mdb_exit(); g_free(delimiter); - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/mdb-ver.c mdbtools-0.7.1/src/util/mdb-ver.c --- mdbtools-0.7/src/util/mdb-ver.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/mdb-ver.c 2013-10-13 08:51:24.000000000 +0000 @@ -16,10 +16,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include "mdbtools.h" #include "mdbver.h" #include "mdbprivate.h" -#include #ifdef DMALLOC #include "dmalloc.h" @@ -59,24 +59,30 @@ exit(1); } - mdb_init(); - if (!(mdb = mdb_open(argv[optind], MDB_NOFLAGS))) { fprintf(stderr,_("Error: unable to open file %s\n"),argv[optind]); - mdb_exit(); exit(1); } - if (IS_JET3(mdb)) { + switch(mdb->f->jet_version) { + case MDB_VER_JET3: printf("JET3\n"); - } else if (IS_JET4(mdb)) { + break; + case MDB_VER_JET4: printf("JET4\n"); - } else { + break; + case MDB_VER_ACCDB_2007: + printf("ACE12\n"); + break; + case MDB_VER_ACCDB_2010: + printf("ACE14\n"); + break; + default: printf(_("unknown database version\n")); + break; } mdb_close(mdb); - mdb_exit(); - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/prcat.c mdbtools-0.7.1/src/util/prcat.c --- mdbtools-0.7/src/util/prcat.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prcat.c 2013-10-13 08:51:24.000000000 +0000 @@ -24,20 +24,18 @@ MdbHandle *mdb; - if (argc<2) { - fprintf(stderr,"Usage: %s []\n",argv[0]); + if (argc<2 || argc>3) { + fprintf(stderr, "Usage: %s []\n", argv[0]); + fprintf(stderr, "Use objtype -1 for all\n"); exit(1); } - mdb_init(); - mdb = mdb_open(argv[1], MDB_NOFLAGS); mdb_dump_catalog(mdb,(argc > 2) ? atoi(argv[2]) : MDB_TABLE); mdb_close(mdb); - mdb_exit(); - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/prdata.c mdbtools-0.7.1/src/util/prdata.c --- mdbtools-0.7/src/util/prdata.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prdata.c 2013-10-13 08:51:24.000000000 +0000 @@ -29,7 +29,6 @@ exit(1); } - mdb_init(); mdb = mdb_open(argv[1], MDB_NOFLAGS); table = mdb_read_table_by_name(mdb, argv[2], MDB_TABLE); @@ -40,8 +39,7 @@ } mdb_close(mdb); - mdb_exit(); - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/prdump.c mdbtools-0.7.1/src/util/prdump.c --- mdbtools-0.7/src/util/prdump.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prdump.c 2013-10-13 08:51:24.000000000 +0000 @@ -30,7 +30,6 @@ exit(1); } - mdb_init(); mdb = mdb_open(argv[1], MDB_NOFLAGS); mdb_read_catalog(mdb, MDB_TABLE); @@ -45,8 +44,7 @@ } mdb_close(mdb); - mdb_exit(); - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/prfreemap.c mdbtools-0.7.1/src/util/prfreemap.c --- mdbtools-0.7/src/util/prfreemap.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prfreemap.c 2013-10-13 08:51:24.000000000 +0000 @@ -33,7 +33,6 @@ exit(1); } - mdb_init(); mdb = mdb_open(argv[1], MDB_NOFLAGS); mdb_read_pg (mdb, 1); @@ -57,8 +56,6 @@ if (coln!=1) printf("\n"); mdb_close(mdb); - mdb_exit(); - - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/prindex.c mdbtools-0.7.1/src/util/prindex.c --- mdbtools-0.7/src/util/prindex.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prindex.c 2013-10-13 08:51:24.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "mdbtools.h" + extern char idx_to_text[]; void walk_index(MdbHandle *mdb, MdbIndex *idx); @@ -34,7 +35,6 @@ exit(1); } - mdb_init(); if (!(mdb = mdb_open(argv[1], MDB_NOFLAGS))) { fprintf(stderr,"Unable to open database.\n"); exit(1); @@ -57,9 +57,7 @@ } mdb_close(mdb); - mdb_exit(); - - exit(0); + return 0; } char * page_name(int page_type) @@ -74,7 +72,7 @@ default: return "Unknown"; } } -void check_row(MdbHandle *mdb, MdbIndex *idx, guint32 pg, int row, unsigned char *idxrow, int len) +void check_row(MdbHandle *mdb, MdbIndex *idx, guint32 pg, int row) { MdbField fields[256]; unsigned int num_fields, i, j; @@ -101,6 +99,10 @@ break; } } + if (j==num_fields) { + fprintf(stderr, "ERROR Lost field #%d\n", idx->key_col_num[i]); + continue; + } //j = idx->key_col_num[i]; strncpy(buf, fields[elem].value, fields[elem].siz); buf[fields[elem].siz]=0; @@ -113,7 +115,6 @@ void walk_index(MdbHandle *mdb, MdbIndex *idx) { - int start, len; guint32 pg; guint16 row; MdbHandle *mdbidx; @@ -139,7 +140,7 @@ //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, (long unsigned) pg); - check_row(mdb, idx, pg, row, &mdbidx->pg_buf[start], len - 4); + check_row(mdb, idx, pg, row); } mdb_close(mdbidx); } diff -Nru mdbtools-0.7/src/util/prkkd.c mdbtools-0.7.1/src/util/prkkd.c --- mdbtools-0.7/src/util/prkkd.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prkkd.c 2013-10-13 08:51:24.000000000 +0000 @@ -31,7 +31,6 @@ exit(1); } - mdb_init(); mdb = mdb_open(argv[1], MDB_NOFLAGS); table = mdb_read_table_by_name(mdb, argv[2], MDB_TABLE); @@ -43,7 +42,6 @@ mdb_kkd_dump(table->entry); mdb_close(mdb); - mdb_exit(); #endif - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/prole.c mdbtools-0.7.1/src/util/prole.c --- mdbtools-0.7/src/util/prole.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prole.c 2013-10-13 08:51:24.000000000 +0000 @@ -34,7 +34,6 @@ exit(1); } - mdb_init(); mdb = mdb_open(argv[1], MDB_NOFLAGS); dot = strchr(argv[2],'.'); if (argc>3) sargname = argv[3]; @@ -56,9 +55,7 @@ } mdb_close(mdb); - mdb_exit(); - - exit(0); + return 0; } void dump_ole(MdbTableDef *table, char *colname, char *sargname) diff -Nru mdbtools-0.7/src/util/prtable.c mdbtools-0.7.1/src/util/prtable.c --- mdbtools-0.7/src/util/prtable.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/prtable.c 2013-10-13 08:51:24.000000000 +0000 @@ -32,7 +32,6 @@ exit(1); } - mdb_init(); mdb = mdb_open(argv[1], MDB_NOFLAGS); mdb_read_catalog(mdb, MDB_TABLE); @@ -50,8 +49,6 @@ fprintf(stderr,"No table named %s found.\n", argv[2]); } mdb_close(mdb); - mdb_exit(); - - exit(0); + return 0; } diff -Nru mdbtools-0.7/src/util/sargtest.c mdbtools-0.7.1/src/util/sargtest.c --- mdbtools-0.7/src/util/sargtest.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/sargtest.c 2013-10-13 08:51:24.000000000 +0000 @@ -29,8 +29,6 @@ MdbHandle *mdb; MdbTableDef *table; - mdb_init(); - if (!(mdb = mdb_open(MDB_FILE, MDB_NOFLAGS))) { exit(1); } @@ -43,9 +41,7 @@ } mdb_close(mdb); - mdb_exit(); - - exit(0); + return 0; } void print_table(MdbTableDef *table) diff -Nru mdbtools-0.7/src/util/updrow.c mdbtools-0.7.1/src/util/updrow.c --- mdbtools-0.7/src/util/updrow.c 2012-06-28 21:51:22.000000000 +0000 +++ mdbtools-0.7.1/src/util/updrow.c 2013-10-13 08:51:24.000000000 +0000 @@ -39,7 +39,6 @@ exit(1); } - mdb_init(); mdb = mdb_open(argv[1], MDB_WRITABLE); tabname = argv[2]; sargname = argv[3]; @@ -64,9 +63,7 @@ } mdb_close(mdb); - mdb_exit(); - - exit(0); + return 0; } void read_to_row(MdbTableDef *table, char *sargname) diff -Nru mdbtools-0.7/xmldocs.make mdbtools-0.7.1/xmldocs.make --- mdbtools-0.7/xmldocs.make 1970-01-01 00:00:00.000000000 +0000 +++ mdbtools-0.7.1/xmldocs.make 2013-10-13 08:51:24.000000000 +0000 @@ -0,0 +1,101 @@ +# +# No modifications of this Makefile should be necessary. +# +# To use this template: +# 1) Define: figdir, docname, lang, omffile, and entities in +# your Makefile.am file for each document directory, +# although figdir, omffile, and entities may be empty +# 2) Make sure the Makefile in (1) also includes +# "include $(top_srcdir)/xmldocs.make" and +# "dist-hook: app-dist-hook". +# 3) Optionally define 'entities' to hold xml entities which +# you would also like installed +# 4) Figures must go under $(figdir)/ and be in PNG format +# 5) You should only have one document per directory +# 6) Note that the figure directory, $(figdir)/, should not have its +# own Makefile since this Makefile installs those figures. +# +# example Makefile.am: +# figdir = figures +# docname = scrollkeeper-manual +# lang = C +# omffile=scrollkeeper-manual-C.omf +# entities = fdl.xml +# include $(top_srcdir)/xmldocs.make +# dist-hook: app-dist-hook +# +# About this file: +# This file was taken from scrollkeeper_example2, a package illustrating +# how to install documentation and OMF files for use with ScrollKeeper +# 0.3.x and 0.4.x. For more information, see: +# http://scrollkeeper.sourceforge.net/ +# Version: 0.1.2 (last updated: March 20, 2002) +# + + +# ********** Begin of section some packagers may need to modify ********** +# This variable (docdir) specifies where the documents should be installed. +# This default value should work for most packages. +docdir = $(datadir)/gnome/help/$(docname)/$(lang) + +# ********** You should not have to edit below this line ********** +xml_files = $(entities) $(docname).xml + +EXTRA_DIST = $(xml_files) $(omffile) +CLEANFILES = omf_timestamp + +include $(top_srcdir)/omf.make + +all: omf + +$(docname).xml: $(entities) + -ourdir=`pwd`; \ + cd $(srcdir); \ + cp $(entities) $$ourdir + +app-dist-hook: + if test "$(figdir)"; then \ + $(mkinstalldirs) $(distdir)/$(figdir); \ + for file in $(srcdir)/$(figdir)/*.png; do \ + basefile=`echo $$file | sed -e 's,^.*/,,'`; \ + $(INSTALL_DATA) $$file $(distdir)/$(figdir)/$$basefile; \ + done \ + fi + +install-data-local: omf + $(mkinstalldirs) $(DESTDIR)$(docdir) + for file in $(xml_files); do \ + cp $(srcdir)/$$file $(DESTDIR)$(docdir); \ + done + if test "$(figdir)"; then \ + $(mkinstalldirs) $(DESTDIR)$(docdir)/$(figdir); \ + for file in $(srcdir)/$(figdir)/*.png; do \ + basefile=`echo $$file | sed -e 's,^.*/,,'`; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/$(figdir)/$$basefile; \ + done \ + fi + +install-data-hook: install-data-hook-omf + +uninstall-local: uninstall-local-doc uninstall-local-omf + +uninstall-local-doc: + -if test "$(figdir)"; then \ + for file in $(srcdir)/$(figdir)/*.png; do \ + basefile=`echo $$file | sed -e 's,^.*/,,'`; \ + rm -f $(DESTDIR)$(docdir)/$(figdir)/$$basefile; \ + done; \ + rmdir $(DESTDIR)$(docdir)/$(figdir); \ + fi + -for file in $(xml_files); do \ + rm -f $(DESTDIR)$(docdir)/$$file; \ + done + -rmdir $(DESTDIR)$(docdir) + +clean-local: clean-local-doc clean-local-omf + +# for non-srcdir builds, remove the copied entities. +clean-local-doc: + if test $(srcdir) != .; then \ + rm -f $(entities); \ + fi