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
This commit is contained in:
Christian Stimming 2010-03-07 12:54:33 +00:00
parent c1c706c0ef
commit 9eff25ed38
3 changed files with 46 additions and 17 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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