summaryrefslogtreecommitdiff
path: root/startup.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-11-09 07:11:22 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:21 -0400
commite1d0dbf220a5301f6125a1548a380492ad488515 (patch)
treedf7a5de60353d3558b00d21ee83cf01e8da56331 /startup.cc
parent6f4957c8c31395bca44d078972690eb2b3258a8f (diff)
downloadfork-ledger-e1d0dbf220a5301f6125a1548a380492ad488515.tar.gz
fork-ledger-e1d0dbf220a5301f6125a1548a380492ad488515.tar.bz2
fork-ledger-e1d0dbf220a5301f6125a1548a380492ad488515.zip
Restructed the code that it can build and be used as a shared library.
The command-line version is still statically bound in the build process by default (for the sake of speed).
Diffstat (limited to 'startup.cc')
-rw-r--r--startup.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/startup.cc b/startup.cc
new file mode 100644
index 00000000..ad462e36
--- /dev/null
+++ b/startup.cc
@@ -0,0 +1,54 @@
+#include "ledger.h"
+
+using namespace ledger;
+
+namespace ledger {
+ parser_t * binary_parser_ptr = NULL;
+ parser_t * xml_parser_ptr = NULL;
+ parser_t * gnucash_parser_ptr = NULL;
+ parser_t * ofx_parser_ptr = NULL;
+ parser_t * qif_parser_ptr = NULL;
+ parser_t * textual_parser_ptr = NULL;
+}
+
+namespace {
+ binary_parser_t binary_parser;
+#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE)
+ xml_parser_t xml_parser;
+ gnucash_parser_t gnucash_parser;
+#endif
+#ifdef HAVE_LIBOFX
+ ofx_parser_t ofx_parser;
+#endif
+ qif_parser_t qif_parser;
+ textual_parser_t textual_parser;
+
+ static class startup {
+ public:
+ startup();
+ ~startup();
+ } _startup;
+
+ startup::startup()
+ {
+ std::ios::sync_with_stdio(false);
+
+ initialize_parser_support();
+
+ register_parser(&binary_parser); binary_parser_ptr = &binary_parser;
+#if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE)
+ register_parser(&xml_parser); xml_parser_ptr = &xml_parser;
+ register_parser(&gnucash_parser); gnucash_parser_ptr = &gnucash_parser;
+#endif
+#ifdef HAVE_LIBOFX
+ register_parser(&ofx_parser); ofx_parser_ptr = &ofx_parser;
+#endif
+ register_parser(&qif_parser); qif_parser_ptr = &qif_parser;
+ register_parser(&textual_parser); textual_parser_ptr = &textual_parser;
+ }
+
+ startup::~startup()
+ {
+ shutdown_parser_support();
+ }
+}