Skip to content

Commit

Permalink
Switch to using db1 for database access.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3336 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
jdavisp3 committed Dec 21, 2000
1 parent 7703433 commit df875ea
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 45 deletions.
6 changes: 1 addition & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ EXTRA_DIST = \
old/country.sql \
old/currencynames \
old/Gnucash.app-defaults \
old/gnome/graph/Makefile \
old/gnome/graph/colors.c \
old/gnome/graph/design.txt \
old/gnome/graph/plot-test.c \
old/perl-reports/report-baln.phtml \
old/perl-reports/report-folio.phtml \
old/perl-reports/report-formtest.html \
Expand All @@ -60,7 +56,7 @@ make-gnucash-patch: make-gnucash-patch.in
chmod +x $@.tmp
mv $@.tmp $@

CLEANFILES += cscope.files etags.files make-gnucash-patch
CLEANFILES += cscope.files etags.files make-gnucash-patch

cscope.files:
find . -name '*.[ch]' > cscope.files
Expand Down
4 changes: 2 additions & 2 deletions acconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
/* New or old Guile Smob for G-wrap */
#undef GWRAP_OLD_GUILE_SMOB

/* The db2 database library */
#undef HAVE_DB2
/* The db1 database library */
#undef PREFER_DB1

/* Use the new gtkhtml widget instead of the old xmhtml widget */
#undef HAVE_LIBGTKHTML
Expand Down
40 changes: 34 additions & 6 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,42 @@ LIBS="$LIBS -lm"


### --------------------------------------------------------------------------
DB2_LIBS="-ldb2"
### Berkeley db
AC_ARG_ENABLE(prefer-db1, [ --enable-prefer-db1 Prefer Berkeley DB 1.x],[prefer_db1="$enableval"],[prefer_db1=yes])

DB_LIBS=
AC_CHECK_FUNC(dbopen, [],
if test "$prefer_db1" = "yes"; then
AC_CHECK_LIB(db1, dbopen, DB_LIBS="-ldb1",
AC_CHECK_LIB(db, dbopen, DB_LIBS="-ldb",
AC_MSG_ERROR([Your db library is missing db 1.85 compatibility mode])
)
)
else
AC_CHECK_LIB(db, dbopen, DB_LIBS="-ldb",
AC_CHECK_LIB(db1, dbopen, DB_LIBS="-ldb1",
AC_MSG_ERROR([Your db library is missing db 1.85 compatibility mode])
)
)
fi
)

dnl look for db headers
if test "$prefer_db1" = "yes"; then
AC_CHECK_HEADERS(db_185.h db1/db.h)
if test "$ac_cv_header_db_185_h$ac_cv_header_db1_db_h" = nono; then
AC_MSG_ERROR([Berkeley db library required for GnuCash])
fi
AC_DEFINE(PREFER_DB1)
else
AC_CHECK_HEADERS(db.h db_185.h db1/db.h)

AC_CHECK_LIB(db2, db_open,
AC_DEFINE(HAVE_DB2),
AC_MSG_ERROR([Cannot find db2. See the README for more info.]),
$DB2_LIBS)
if test "$ac_cv_header_db_h$ac_cv_header_db_185_h$ac_cv_header_db1_db_h" = nonono; then
AC_MSG_ERROR([Berkeley db library required for GnuCash])
fi
fi

AC_SUBST(DB2_LIBS)
AC_SUBST(DB_LIBS)


### --------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ src/gnome/gnc-datedelta.c
src/gnome/gnc-dateedit.c
src/gnome/print-session.c
src/gnome/reconcile-list.c
src/gnome/window-help.c
src/gnome/window-main.c
src/gnome/window-reconcile.c
src/gnome/window-register.c
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LDADD = \
${GTKHTML_LIBS} \
${GHTTP_LIBS} \
${GUPPI_LIBS} \
${DB2_LIBS} \
${DB_LIBS} \
${INTLLIBS}

gnucash_SOURCES = \
Expand Down
81 changes: 51 additions & 30 deletions src/gnome/window-help.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,42 @@
\********************************************************************/

#include "config.h"
#include <gnome.h>

#include <guile/gh.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <gnome.h>
#include <guile/gh.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <db2/db.h>

/* needed for db.h with 'gcc -ansi -pedantic' */
#ifndef _BSD_SOURCE
# define _BSD_SOURCE 1
#endif

#ifdef PREFER_DB1
#ifdef HAVE_DB1_DB_H
# include <db1/db.h>
#else
# ifdef HAVE_DB_185_H
# include <db_185.h>
# else
# include <db.h>
# endif
#endif
#else
#ifdef HAVE_DB_185_H
# include <db_185.h>
#else
# ifdef HAVE_DB_H
# include <db.h>
# else
# include <db1/db.h>
# endif
#endif
#endif

#include "glade-gnc-dialogs.h"
#include "glade-cb-gnc-dialogs.h"
Expand Down Expand Up @@ -344,30 +371,32 @@ gnc_help_window_search_button_cb(GtkButton * button, gpointer data) {
/* initialize search key/value */
memset(&key, 0, sizeof(DBT));
memset(&value, 0, sizeof(DBT));

key.data = search_string;
key.size = strlen(search_string);
value.flags = DB_DBT_MALLOC;

/* do the search */
if(help->index_db) {
err = help->index_db->get(help->index_db, NULL, &key, &value, 0);
err = help->index_db->get(help->index_db, &key, &value, 0);
}

if((err == 0) || (err == DB_NOTFOUND)) {
if(err == 0) {
/* the data in the DB is a newline-separated list of filenames */
show_search_results(help, value.data);
}
}

void
gnc_help_window_search_help_button_cb(GtkButton * button, gpointer data) {
#if 0
GtkObject * hw = data;
gnc_help_window * help = gtk_object_get_data(hw, "help_window_struct");

#endif

printf("help on help\n");
}

void
static void
gnc_help_window_search_result_select_cb(GtkWidget * list, GtkWidget * child,
gpointer user_data) {
gnc_help_window * help = user_data;
Expand All @@ -385,24 +414,21 @@ gnc_help_window_new() {

gnc_help_window * help = g_new0(gnc_help_window, 1);
GtkObject * tlo;
DB_INFO dbinfo;
DB_ENV dbenv;
char * indexfile;
int err;
GnomeUIInfo toolbar_data[] =
{
{ GNOME_APP_UI_ITEM,
_("Back"),
_("Move back one step in the history"),
N_("Back"),
N_("Move back one step in the history"),
gnc_help_window_back_cb, help,
NULL,
GNOME_APP_PIXMAP_STOCK,
GNOME_STOCK_PIXMAP_BACK,
0, 0, NULL
},
{ GNOME_APP_UI_ITEM,
_("Forward"),
_("Move forward one step in the history"),
N_("Forward"),
N_("Move forward one step in the history"),
gnc_help_window_fwd_cb, help,
NULL,
GNOME_APP_PIXMAP_STOCK,
Expand All @@ -411,8 +437,8 @@ gnc_help_window_new() {
},
GNOMEUIINFO_SEPARATOR,
{ GNOME_APP_UI_ITEM,
_("Print"),
_("Print Help window"),
N_("Print"),
N_("Print Help window"),
gnc_help_window_print_cb, help,
NULL,
GNOME_APP_PIXMAP_STOCK,
Expand All @@ -421,8 +447,8 @@ gnc_help_window_new() {
},
GNOMEUIINFO_SEPARATOR,
{ GNOME_APP_UI_ITEM,
_("Close"),
_("Close this Help window"),
N_("Close"),
N_("Close this Help window"),
gnc_help_window_destroy_cb, help,
NULL,
GNOME_APP_PIXMAP_STOCK,
Expand Down Expand Up @@ -476,12 +502,10 @@ gnc_help_window_new() {
(gpointer)help);

indexfile = gncFindFile("help-search-index.db");
if((err = db_open(indexfile,
DB_UNKNOWN, DB_RDONLY, 0644,
NULL, NULL, &(help->index_db))) != 0) {
help->index_db = dbopen(indexfile, O_RDONLY, 0644, DB_HASH, NULL);
if (!help->index_db) {
PERR("Failed to open help index DB '%s' : %s\n",
indexfile, strerror(err));
help->index_db = NULL;
indexfile, strerror(errno));
}
g_free(indexfile);

Expand All @@ -508,7 +532,7 @@ gnc_help_window_destroy(gnc_help_window * help) {
(gpointer)help);
/* close the help index db */
if(help->index_db) {
help->index_db->close(help->index_db, 0);
help->index_db->close(help->index_db);
}

/* take care of the gnc-html object specially */
Expand Down Expand Up @@ -550,6 +574,3 @@ gnc_ui_destroy_help_windows() {
gnc_help_window_destroy((gnc_help_window *)(open_help_windows->data));
}
}



3 changes: 2 additions & 1 deletion src/gnome/window-help.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define __GNC_HELP_WINDOW_H__

#include <gnome.h>

#include "gnc-html.h"

typedef struct _gnc_help_window gnc_help_window;
Expand All @@ -32,7 +33,7 @@ typedef struct _gnc_help_window gnc_help_window;

void helpWindow(GtkWidget *parent, const char *title, const char * htmlfile);

gnc_help_window * gnc_help_window_new();
gnc_help_window * gnc_help_window_new(void);
void gnc_help_window_destroy(gnc_help_window * help);
void gnc_help_window_show_help(gnc_help_window * hw,
const gchar * loc,
Expand Down

0 comments on commit df875ea

Please sign in to comment.