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
|
|
|
*********************************************************************/
|
2015-09-29 12:08:48 -07:00
|
|
|
/********************************************************************\
|
|
|
|
|
* 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, contact: *
|
|
|
|
|
* *
|
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
|
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
|
|
|
|
* *
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2017-10-26 11:14:21 +02: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
|
|
|
}
|