[Gnucash-changes] New home for functions that cannot be in QOF
Neil Williams
codehelp at cvs.gnucash.org
Thu Oct 20 10:51:09 EDT 2005
Log Message:
-----------
New home for functions that cannot be in QOF
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash/src/engine:
gnc-engine.c
gnc-engine.h
Revision Data
-------------
Index: gnc-engine.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-engine.c,v
retrieving revision 1.17.4.8
retrieving revision 1.17.4.9
diff -Lsrc/engine/gnc-engine.c -Lsrc/engine/gnc-engine.c -u -r1.17.4.8 -r1.17.4.9
--- src/engine/gnc-engine.c
+++ src/engine/gnc-engine.c
@@ -24,7 +24,7 @@
#include "config.h"
#include <glib.h>
-
+#include <dlfcn.h>
#include "gnc-engine.h"
#include "qof.h"
#include "cashobjects.h"
@@ -43,9 +43,12 @@
#define GNC_LIB_NAME "libgnc-backend-file.la"
/** init_fcn for gnc file backend library. */
#define GNC_LIB_INIT "gnc_provider_init"
+/* gnc-backend-file location */
+#include "gncla-dir.h"
static GList * engine_init_hooks = NULL;
static int engine_is_initialized = 0;
+static QofLogModule log_module = GNC_MOD_ENGINE;
/* GnuCash version functions */
unsigned int
@@ -96,7 +99,7 @@
g_return_if_fail((qof_load_backend_library
(QOF_LIB_DIR, "libqof-backend-qsf.la", "qsf_provider_init")));
g_return_if_fail((qof_load_backend_library
- (QOF_LIB_DIR, GNC_LIB_NAME, GNC_LIB_INIT)));
+ (GNC_LIBDIR, GNC_LIB_NAME, GNC_LIB_INIT)));
engine_is_initialized = 1;
/* call any engine hooks */
@@ -143,3 +146,83 @@
*/
return (engine_is_initialized == 1) ? TRUE : FALSE;
}
+
+/* ====================================================================== */
+/* XXX This exports the list of accounts to a file. It does not export
+ * any transactions. Its a place-holder until full book-closing is implemented.
+ */
+
+gboolean
+qof_session_export (QofSession *tmp_session,
+ QofSession *real_session,
+ QofPercentageFunc percentage_func)
+{
+ QofBook *book, *book2;
+ QofBackend *be;
+ int err;
+
+ if ((!tmp_session) || (!real_session)) return FALSE;
+
+ book = qof_session_get_book (real_session);
+ ENTER ("tmp_session=%p real_session=%p book=%p book_id=%s",
+ tmp_session, real_session, book,
+ qof_session_get_url(tmp_session)
+ ? qof_session_get_url(tmp_session) : "(null)");
+
+ /* There must be a backend or else. (It should always be the file
+ * backend too.)
+ */
+ book2 = qof_session_get_book(tmp_session);
+ be = qof_book_get_backend(book2);
+ if (!be)
+ return FALSE;
+
+ be->percentage = percentage_func;
+ if (be->export)
+ {
+
+ (be->export)(be, book);
+ err = qof_backend_get_error(be);
+
+ if (ERR_BACKEND_NO_ERR != err) { return FALSE; }
+ }
+
+ return TRUE;
+}
+
+void
+gnc_run_rpc_server (void)
+{
+ const char * dll_err;
+ void * dll_handle;
+ int (*rpc_run)(short);
+ int ret;
+
+ /* open and resolve all symbols now (we don't want mystery
+ * failure later) */
+#ifndef RTLD_NOW
+# ifdef RTLD_LAZY
+# define RTLD_NOW RTLD_LAZY
+# endif
+#endif
+ dll_handle = dlopen ("libgnc_rpc.so", RTLD_NOW);
+ if (! dll_handle)
+ {
+ dll_err = dlerror();
+ PWARN (" can't load library: %s\n", dll_err ? dll_err : "");
+ return;
+ }
+
+ rpc_run = dlsym (dll_handle, "rpc_server_run");
+ dll_err = dlerror();
+ if (dll_err)
+ {
+ dll_err = dlerror();
+ PWARN (" can't find symbol: %s\n", dll_err ? dll_err : "");
+ return;
+ }
+
+ ret = (*rpc_run)(0);
+
+ /* XXX How do we force an exit? */
+}
Index: gnc-engine.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-engine.h,v
retrieving revision 1.16.4.9
retrieving revision 1.16.4.10
diff -Lsrc/engine/gnc-engine.h -Lsrc/engine/gnc-engine.h -u -r1.16.4.9 -r1.16.4.10
--- src/engine/gnc-engine.h
+++ src/engine/gnc-engine.h
@@ -228,5 +228,12 @@
* it will be called during the evaluation of gnc_engine_init */
void gnc_engine_add_init_hook(gnc_engine_init_hook_t hook);
+gboolean
+qof_session_export (QofSession *tmp_session,
+ QofSession *real_session,
+ QofPercentageFunc percentage_func);
+
+void gnc_run_rpc_server(void);
+
#endif
/** @} */
More information about the gnucash-changes
mailing list