2001-08-17 00:44:01 +00:00
|
|
|
/*********************************************************************
|
|
|
|
|
* gncmod-app-utils.c
|
2007-01-06 00:41:51 +00:00
|
|
|
* module definition/initialization for the report infrastructure
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2001 Linux Developers Group, Inc.
|
2001-08-17 00:44:01 +00:00
|
|
|
*********************************************************************/
|
|
|
|
|
|
2003-02-22 08:15:53 +00:00
|
|
|
#include "config.h"
|
2007-01-06 00:41:51 +00:00
|
|
|
#include <gmodule.h>
|
2003-02-22 08:15:53 +00:00
|
|
|
#include <libguile.h>
|
2001-08-17 00:44:01 +00:00
|
|
|
|
|
|
|
|
#include "gnc-module.h"
|
2001-08-17 22:49:17 +00:00
|
|
|
#include "gnc-module-api.h"
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2001-12-20 11:00:58 +00:00
|
|
|
#include "gnc-component-manager.h"
|
2006-01-19 05:18:27 +00:00
|
|
|
#include "gnc-hooks.h"
|
|
|
|
|
#include "gnc-exp-parser.h"
|
2001-12-20 11:00:58 +00:00
|
|
|
|
2007-04-18 23:23:04 +00:00
|
|
|
GNC_MODULE_API_DECL(libgncmod_app_utils)
|
|
|
|
|
|
2001-08-17 00:44:01 +00:00
|
|
|
/* version of the gnc module system interface we require */
|
2007-04-18 23:23:04 +00:00
|
|
|
int libgncmod_app_utils_gnc_module_system_interface = 0;
|
2001-08-17 00:44:01 +00:00
|
|
|
|
|
|
|
|
/* module versioning uses libtool semantics. */
|
2007-04-18 23:23:04 +00:00
|
|
|
int libgncmod_app_utils_gnc_module_current = 0;
|
|
|
|
|
int libgncmod_app_utils_gnc_module_revision = 0;
|
|
|
|
|
int libgncmod_app_utils_gnc_module_age = 0;
|
2002-06-24 05:58:58 +00:00
|
|
|
|
|
|
|
|
|
2001-08-17 00:44:01 +00:00
|
|
|
char *
|
2009-12-29 20:12:48 +00:00
|
|
|
libgncmod_app_utils_gnc_module_path(void)
|
|
|
|
|
{
|
|
|
|
|
return g_strdup("gnucash/app-utils");
|
2001-08-17 00:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
2007-01-06 00:41:51 +00:00
|
|
|
char *
|
2009-12-29 20:12:48 +00:00
|
|
|
libgncmod_app_utils_gnc_module_description(void)
|
|
|
|
|
{
|
|
|
|
|
return g_strdup("Utilities for building gnc applications");
|
2001-08-17 00:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2007-01-06 00:41:51 +00:00
|
|
|
lmod(char * mn)
|
2001-08-17 00:44:01 +00:00
|
|
|
{
|
2009-12-29 20:12:48 +00:00
|
|
|
char * form = g_strdup_printf("(use-modules %s)\n", mn);
|
|
|
|
|
scm_c_eval_string(form);
|
|
|
|
|
g_free(form);
|
2001-08-17 00:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-19 05:18:27 +00:00
|
|
|
static void
|
|
|
|
|
app_utils_shutdown(void)
|
|
|
|
|
{
|
|
|
|
|
gnc_exp_parser_shutdown();
|
|
|
|
|
gnc_hook_run(HOOK_SAVE_OPTIONS, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-15 19:02:05 +00:00
|
|
|
|
|
|
|
|
extern SCM scm_init_sw_app_utils_module(void);
|
|
|
|
|
|
2001-08-17 00:44:01 +00:00
|
|
|
int
|
2007-04-18 23:23:04 +00:00
|
|
|
libgncmod_app_utils_gnc_module_init(int refcount)
|
2001-12-20 11:00:58 +00:00
|
|
|
{
|
2009-12-29 20:12:48 +00:00
|
|
|
/* load the engine (we depend on it) */
|
|
|
|
|
if (!gnc_module_load("gnucash/engine", 0))
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scm_init_sw_app_utils_module();
|
|
|
|
|
/* publish swig bindings */
|
|
|
|
|
/* load the scheme code */
|
|
|
|
|
lmod("(sw_app_utils)");
|
|
|
|
|
lmod("(gnucash app-utils)");
|
|
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
|
{
|
|
|
|
|
gnc_component_manager_init ();
|
|
|
|
|
gnc_hook_add_dangler(HOOK_STARTUP, (GFunc)gnc_exp_parser_init, NULL);
|
|
|
|
|
gnc_hook_add_dangler(HOOK_SHUTDOWN, (GFunc)app_utils_shutdown, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2001-08-17 00:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
2001-08-17 22:49:17 +00:00
|
|
|
int
|
2007-04-18 23:23:04 +00:00
|
|
|
libgncmod_app_utils_gnc_module_end(int refcount)
|
2001-12-20 11:00:58 +00:00
|
|
|
{
|
2009-12-29 20:12:48 +00:00
|
|
|
if (refcount == 0)
|
|
|
|
|
gnc_component_manager_shutdown ();
|
2001-12-20 11:00:58 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
return TRUE;
|
2001-08-17 00:44:01 +00:00
|
|
|
}
|