From 9eff25ed385dbf924d679ab381c5e228907837e5 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sun, 7 Mar 2010 12:54:33 +0000 Subject: [PATCH] Add variant of gnc_engine_init which is suitable for statically the linked-in library. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18863 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/gnc-engine.c | 54 +++++++++++++++++++++++++++++------------ src/engine/gnc-engine.h | 7 ++++++ src/gnc/main.cpp | 2 +- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/engine/gnc-engine.c b/src/engine/gnc-engine.c index a288a7e737..0f96b60c09 100644 --- a/src/engine/gnc-engine.c +++ b/src/engine/gnc-engine.c @@ -72,9 +72,23 @@ gnucash_micro_version (void) * initialize backend, load any necessary databases, etc. ********************************************************************/ -void -gnc_engine_init(int argc, char ** argv) +static void +gnc_engine_init_part1() { + if (1 == engine_is_initialized) return; + + /* initialize QOF */ + qof_init(); + qof_set_alt_dirty_mode(TRUE); + + /* Now register our core types */ + cashobjects_register(); +} + +static void +gnc_engine_init_part2() +{ + gchar *pkglibdir = gnc_path_get_pkglibdir (); static struct { const gchar* lib; @@ -87,20 +101,7 @@ gnc_engine_init(int argc, char ** argv) { "gncmod-backend-xml", TRUE }, { NULL, FALSE } }, *lib; - gnc_engine_init_hook_t hook; - GList * cur; - gchar *pkglibdir; - if (1 == engine_is_initialized) return; - - /* initialize QOF */ - qof_init(); - qof_set_alt_dirty_mode(TRUE); - - /* Now register our core types */ - cashobjects_register(); - - pkglibdir = gnc_path_get_pkglibdir (); for (lib = libs; lib->lib ; lib++) { if (qof_load_backend_library(pkglibdir, lib->lib)) @@ -118,17 +119,38 @@ gnc_engine_init(int argc, char ** argv) } } g_free (pkglibdir); +} +static void +gnc_engine_init_part3(int argc, char ** argv) +{ + GList * cur; /* call any engine hooks */ for (cur = engine_init_hooks; cur; cur = cur->next) { - hook = (gnc_engine_init_hook_t)cur->data; + gnc_engine_init_hook_t hook = (gnc_engine_init_hook_t)cur->data; if (hook) (*hook)(argc, argv); } } +void +gnc_engine_init(int argc, char ** argv) +{ + gnc_engine_init_part1(); + gnc_engine_init_part2(); + gnc_engine_init_part3(argc, argv); +} + +void +gnc_engine_init_static(int argc, char ** argv) +{ + gnc_engine_init_part1(); + gnc_engine_init_part3(argc, argv); +} + + /******************************************************************** * gnc_engine_shutdown * shutdown backend, destroy any global data, etc. diff --git a/src/engine/gnc-engine.h b/src/engine/gnc-engine.h index 4eee78cde5..674fc02e34 100644 --- a/src/engine/gnc-engine.h +++ b/src/engine/gnc-engine.h @@ -231,6 +231,13 @@ unsigned int gnucash_micro_version (void); * method that does not require Guile. */ void gnc_engine_init(int argc, char ** argv); +/** This is the statically linked-in version of gnc_engine_init. It is + * identically to that function except that it doesn't load the + * loadable shared module, which means this function will not load the + * "(gnucash engine)" scheme module. + */ +void gnc_engine_init_static(int argc, char ** argv); + /** Called to shutdown the engine, see also ::qof_close * for use without Guile. */ void gnc_engine_shutdown (void); diff --git a/src/gnc/main.cpp b/src/gnc/main.cpp index 91c05793ce..97cfc9ce26 100644 --- a/src/gnc/main.cpp +++ b/src/gnc/main.cpp @@ -175,7 +175,7 @@ main(int argc, char ** argv) qof_init(); gnc_module_system_init(); - gnc_engine_init(argc, argv); + gnc_engine_init_static(argc, argv); // Call the statically-linked versions of the backend init // functions