GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gncmod-app-utils.c
1 /*********************************************************************
2  * gncmod-app-utils.c
3  * module definition/initialization for the report infrastructure
4  *
5  * Copyright (c) 2001 Linux Developers Group, Inc.
6  *********************************************************************/
7 
8 #include "config.h"
9 #include <gmodule.h>
10 #include <libguile.h>
11 
12 #include "gnc-module.h"
13 #include "gnc-module-api.h"
14 
15 #include "gnc-component-manager.h"
16 #include "gnc-hooks.h"
17 #include "gnc-exp-parser.h"
18 
19 GNC_MODULE_API_DECL(libgncmod_app_utils)
20 
21 /* version of the gnc module system interface we require */
22 int libgncmod_app_utils_gnc_module_system_interface = 0;
23 
24 /* module versioning uses libtool semantics. */
25 int libgncmod_app_utils_gnc_module_current = 0;
26 int libgncmod_app_utils_gnc_module_revision = 0;
27 int libgncmod_app_utils_gnc_module_age = 0;
28 
29 
30 char *
31 libgncmod_app_utils_gnc_module_path(void)
32 {
33  return g_strdup("gnucash/app-utils");
34 }
35 
36 char *
37 libgncmod_app_utils_gnc_module_description(void)
38 {
39  return g_strdup("Utilities for building gnc applications");
40 }
41 
42 static void
43 lmod(char * mn)
44 {
45  char * form = g_strdup_printf("(use-modules %s)\n", mn);
46  scm_c_eval_string(form);
47  g_free(form);
48 }
49 
50 static void
51 app_utils_shutdown(void)
52 {
53  gnc_exp_parser_shutdown();
54  gnc_hook_run(HOOK_SAVE_OPTIONS, NULL);
55 }
56 
57 
58 extern SCM scm_init_sw_app_utils_module(void);
59 
60 int
61 libgncmod_app_utils_gnc_module_init(int refcount)
62 {
63  /* load the engine (we depend on it) */
64  if (!gnc_module_load("gnucash/engine", 0))
65  {
66  return FALSE;
67  }
68 
69  scm_init_sw_app_utils_module();
70  /* publish swig bindings */
71  /* load the scheme code */
72  lmod("(sw_app_utils)");
73  lmod("(gnucash app-utils)");
74 
75  if (refcount == 0)
76  {
77  gnc_component_manager_init ();
78  gnc_hook_add_dangler(HOOK_STARTUP, (GFunc)gnc_exp_parser_init, NULL);
79  gnc_hook_add_dangler(HOOK_SHUTDOWN, (GFunc)app_utils_shutdown, NULL);
80  }
81 
82  return TRUE;
83 }
84 
85 int
86 libgncmod_app_utils_gnc_module_end(int refcount)
87 {
88  if (refcount == 0)
89  gnc_component_manager_shutdown ();
90 
91  return TRUE;
92 }