pax_global_header00006660000000000000000000000064131575434170014524gustar00rootroot0000000000000052 comment=c426e22d808055a6645a83f219fff1684dd1ac79 libofx-0.9.12/000077500000000000000000000000001315754341700131005ustar00rootroot00000000000000libofx-0.9.12/.gitignore000066400000000000000000000003701315754341700150700ustar00rootroot00000000000000*.la *.lo *~ .cproject .deps .directory .libs .project INSTALL Makefile Makefile.in aclocal.m4 autom4te.cache build config config.h config.h.in config.log config.status configure libofx.pc libofx.spec libofx.lsm libtool stamp-h stamp-h.in stamp-h1 libofx-0.9.12/AUTHORS000066400000000000000000000002341315754341700141470ustar00rootroot00000000000000Benoit Gr�goire Peter O'Gorman Ace Jones Martin Preuss Contributors: libofx-0.9.12/COPYING000066400000000000000000000355641315754341700141500ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS libofx-0.9.12/ChangeLog000066400000000000000000000651441315754341700146640ustar00rootroot000000000000002017-09-17 Christian Stimming * lib/ofx_preproc.cpp: Fix buffer overflow, reported in TALOS-2017-0317 2016-08-14 Christian Stimming * inc/libofx.h.in: Add support for client uid, from KDE bug 366326 2011-01-12 Christian Stimming * configure.in: Release 0.9.2 with the previous bugfixes. * lib/ofx_preproc.cpp: Win32: Add gnucash patch that looks up the dtd installation directory from the current executable's location. 2010-10-26 Benoit Grégoire * Apply patch by Geert Janssens to fix crash on invalid date format 2010-04-27 Benoit Grégoire * Patch by ajseward with some additional fixes to allow wraping the library in python. 2010-02-04 Benoit Grégoire * Applied a patch provided by Thomas Baumgart which fixes bug #5 (Transaction posting date off by one) 2009-05-15 Benoit Grégoire * Various C++ include fixes for building with recent compilers. Patch by Bill Nottingham 2009-02-09 Christian Stimming * configure.in: Release 0.9.1 with the bugfix for gnucash 2008-12-06 Christian Stimming * lib/ofx_preproc.cpp: Add more sanity checks on string length. I forgot the bug which required those to be fixed, but I fixed them anyway. * lib/ofx_preproc.cpp: Fix gnucash crash on OFX files with non-ascii characters and very long lines. See http://bugzilla.gnome.org/show_bug.cgi?id=528306 and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=493597. Patch was copied from the latter. Patch by Jerome Vouillon. 20/11/2007 Martin Preuss * updated specfile 19/11/2007 Martin Preuss * Release 0.9.0 12/11/2007 Martin Preuss * ofx_preproc.cpp: Increased size of file name buffer (50 was too small) 28/9/2007 Martin Preuss * libofx.h: added some fields to OfxFiLogin: - header_version - appid - appver It seems to become necessary with some new servers to modify these fields by the application. 27/9/2007 Martin Preuss * ofx_request_statement.cpp: Incremented versions written to the request * libofx.h, ofx_utilities.cpp: replaced some char* with "const char*" to make GCC happy, wrapped arithmetic calculations in macro definitions in brackets to avoid mathematical problems * libofx.h: Removed this file, replaced it with libofx.h.in. This is used to create libofx.h which now includes some subst variables conveying the version of LibOFX to source files. Introduced LIBOFX_BUILD_VERSION and LIBOFX_VERSION_RELEASE_STRING to distinguish even CVS versions. Added function libofx_set_dtd_dir() which allows to set the folder in which DTD files are stored. This is needed for local installations (e.g. WIN32) * libofx.pc.in: depending libraries don't need to link against OpenSP themselves, since LibOFX encapsulates it, no need to propagate unnecessary dependencies * ofx_utilities.{cpp,h}: added a function to generate a temp file name (works on WIN32 and Linux) 24/1/2007: Benoit Grégoire * ofx_preproc.cpp: Now parses the OFX headers to determine the input charset and encoding, and uses libiconv (if available) to convert the encoding since OpenSP can't do it. The default output is now UTF-8. This will "do the right thing" for Gnucash 2 and any client that uses UTF-8 strings, but we should add an interface to let the client chose his prefered output encoding. 9/1/2007: Benoit Grégoire * Adapted patch by Christian Lupien to add processing of the different bank account types in OfxPaymentRequest. Took this oportunity to correct an API duplication problem before it get's even more complicated to fix: deleted OfxAccountInfo (OfxAccountData should be used instead) and the global scopt AccountType enum (use the one in OfxAccountData). Both of these changes will require source code change in aqbanking. * Bump the version and soname right now so aqbanking can detect it. 8/1/2007: Benoit Grégoire * Release 0.8.3 27/9/2006 Martin Preuss * lib/ofx_preproc.cpp: Make sure all results of string::find are inside the string's length; make sure to erase parts of the string only if the string is long enough. Fixes crash http://bugzilla.gnome.org/show_bug.cgi?id=353986 Patch supplied by Christian Stimming from GnuCash 25/8/2006: Benoit Grégoire * Fix datatype mismatch in ofx_preproc.cpp * Fix gengetopt related build problems on debian based distribution. * Remove massage about dependency on Qt, qhich is no longuer true * Fix ofxconnect headers not being distributed * Remove cmdline.c and cmdline.h which shouldn't be versionned * Release 0.8.2 3/8/2006 David Resier * Added fields used in stock splits (newunits, oldunits) Patch applied by Ace Jones 28/7/2006 Ace Jones * Fixed a compilation bug on GCC 4.1 20/7/2006: Benoit Grégoire * Revert last change to ofxdump, as it requires a system-dependent header (plus it didn't compile on my system) * Make both curl and libxml++ optional for compilation. * Add some debug output. * Update tree.hh 15/7/2006 Ace Jones * Modified build script to not build ofxconnect if libxml++1.0 is missing. 12/6/2006 Ace Jones * Fixed a compilation bug on GCC 4.1 28/3/2006 Ace Jones * Fixed an improper header reference in ofxpartner.cpp/h * Fixed a segfault if ofxdump is run without a file 28/2/2006 Ace Jones * Removed Qt requirement accidentally introduced in my last checkin 20/2/2006 Ace Jones * Added sample code to ofxconnect to demonstrate how to contact the OFX partner server 15/2/2006 Ace Jones * Fixed #1408764. Buffer overrun in MESSAGE tag handling. * Fixed a memory leak in OfxStatusContainer::add_attribute() 20/1/2006 Ace Jones * Print out bank id, branch id, and account number in ofxdump * Fixed a bug under gcc 4.0.2 64-bit where errno is not found in ofxdump * Fixed a build problem where @LIBOBJ@ was not being substituted 16/1/2006 Ace Jones * Added OfxFiServiceInfo struct. Need this for communicating with the partner server. Will add the code for that next. * Added broker_id to OfxAccountData 17/12/2005 Ace Jones * Fixed ofxdump to give a reasonable error if you run it on a file that doesn't exist. * Added proper libcurl.m4 to check for existence & compilability of libcurl * Make libcurl optional again by handling its absense in ofxconnect 17/11/2005 Martin Preuss * added pkg-config file to spec file * fixed spec file (was mentioning libraries twice) 1/10/2005 Ace Jones * Bumped version to 0.8.1 (due to transaction struct change) * Added a pkg-config file 25/9/2005 Ace Jones * Brought in new tree.hh from http://www.aei.mpg.de/~peekas/tree * Removed a workaround in all uses of tree::number_of_siblings(). This appears to work around a bug in tree.h which caused the siblings to be overcounted. That bug is fixed, so this workaround is not needed. 24/9/2005 Ace Jones * Fixed a namespace bug that's fatal on GCC4.0 Submitted by Christian Stimming 27/8/2005 Ace Jones * Added fees and commission fields to transaction structure (and fill them in) 31/7/2005: Benoit Grégoire * Release 0.8.0 * configure.in: Update libtool version number. Make curl check fatal untill there is code to conditionally not compile ofxconnect when CURL is unavailable. * Fix the build system so that discheck will finally run properly. 11/7/2005 Ace Jones * Upgraded the app version for OFX Requests (some banks are denying the old version now) * Moved bank & broker ID's from OfxFiLogin to OfxAccountInfo, which is more accurate * Renamed a couple AccountType enums to be consistent with the others 22/4/2005 Martin Preuss * added fields bank_id, bank_id_valid, branch_id, branch_id_valid, account_number and account_number_valid to OfxAccountData according to discussion on LibOFX mailinglist. 19/4/2005 Ace Jones * Improved ofxconnect to do the POST operation itself * Improved the ofxconnect unit test to be mostly cleartext except the server login information. 20/4/2005 Martin Preuss * inserted an \"#ifndef\" before definition of static variables to allow include from multiple source files of a project 18/4/2005: Ace Jones * Added libofx_request_statement API, and underlying support classes, to create an OFX statement request * Added libofx_request_accountinfo API to create an OFX account into request * Added ofxconnect sample app to demonstrate & test new API's (try "make check" in the ofxconnect folder). Read README.privateserver first. 24/11/2004: Benoit Grégoire * Apply Christian Stimming's patch for rpm building. Also adds a make rpm target. 08/10/2004: Benoit Grégoire * Release 0.7.0 * configure.in: Update libtool version number. 21/9/2004 Benoit Grégoire * Really remove callback.hh and callback.cpp * Fix compile with gcc 3.4. This also needs to be applied to the stable branch. * Fix tree handling for securities, which caused the callbacks never to be called. 31/8/2004 Benoit Grégoire * Remove obsolete files callback.hh and callback.cpp * More makefile fixes in lib 1/9/2004 Martin Preuss * simplified internal callback mechanism (removed CallbackRegistry, it is easier this way) * protected members of LibOfxContext (you need to call methods to get/set them) * added functions which allow to set each callback individually. If you are not interested in a particular callback you don't need to set it * removed the all-callback setter * all callbacks now pass LibOfxContext which either propagates the callback or silently ignores it (for callbacks which haven't been set) * a few Makefile fixes in lib * adjusted ofxdump and ofx2qif to these changes 31/8/2004 Benoit Grégoire * Revamp the callback architecture according to discussion with Martin Preuss. This is much cleaner and extensible, although a long way from perfect. * Autoconf fixes from Martin Preuss 23/4/2004 Benoit Grégoire * At long last, a flexible and extendable command line parser is used in ofxdump. This was essential for debuging, and even more essential for developing Direct Connect. Immediate benefits are that you can set the desired debug output without recompiling. Check ofxdump --help for options. * configure.in: gengetopt will be used if available. * lib/Makefile.am: * ofxdump/Makefile.am * ofxdump/ofxdump.cpp * lib/getopt.c lib/getopt1.c lib/gnugetopt.h: Required in case getopt_long() isn't available. * ofxdump/cmdline.ggo: Command line argument definitions. * ofxdump/cmdline.c,h: Files generated by gengetopt, must be in CVS so developers don't have to have gengetopt installed. * Much improved file format handling. Supported file formats can now be listed and described. * inc/libofx.h: * lib/context.hh * lib/file_preproc.cpp * lib/file_preproc.hh 8/4/2004 Benoit Grégoire * Multiple files: Working (but incomplete) OFC import. Still need cleanup. Pass context everywhere. Begin cleaning up tree handling. * lib/tree.hh: Upgrade to latest version 31/3/2004 Benoit Grégoire * lib/context.cpp,hh: New files. Create a global libofx object to allow the library to cleanly keep state. This will allow much cleanup, and is needed for the move to a DOM style interface. Other files ajusted to match. 7/3/2004 Benoit Grégoire * lib/ofc_sgml.cpp/hh: New files. Splits code path for OFC and OFX to keep things understandeable. Some more OFC parsing. Now waiting to implement global libofx context object passed everywhere to make further progress. * lib/messages.cpp: Move the definition of the required globals for displaying line numbers there, as it's the only place they are read. 3/3/2004 Benoit Grégoire * Many... * lib/file_preproc.cpp, lib/file_preproc.hh: Add file format autodetection architecture, can currently distinguish between OFX and OFC files. Note that because of this change, the main entry point of the library is now in file_preproc.cpp. * dtd/ofc.dtd, lib/ofx_sgml.cpp, lib/ofx_preproc.cpp: Add embryo of OFC (Microsoft Open Financial Connectivity) to LibOFX. The SGML parses succesfully, but LibOFX does not yet know what to do with it. Big thanks to Jeremy Jongsma jeremy at jongsma.org for finally finding the required DTD. I haven't yet decided if its better to to add this support to ofx_proc_sgml.cpp (easier to maintain, less code duplication), or to create a ofc_proc_sgml.cpp (easier to understand, cleaner code). 3/2/2004 Benoit Grégoire * inc/libofx.h lib/ofx_preproc.cpp lib/tree.hh ofx2qif/ofx2qif.c ofxdump/ofxdump.cpp: Make it compile. I may have misunderstood what Ryan wanted to do with the prototypes in libofx.h. If so, sorry. Note: I don't think that the void * passed as arguments are saved in the registry yet. 18/1/2004 Ryan P Bobko * inc/libofx.h * lib/ofx_container_statement.cpp * lib/ofx_container_account.cpp * lib/ofx_container_transaction.cpp * lib/ofx_container_security.cpp * lib/ofx_containers_misc.cpp * ofxdump/ofxdump.cpp * ofx2qif/ofx2qif.c: all these files: improved callback registry by including a void pointer to arbitrary data (which can be set by the client in ofx_prep_cb). The pointer gets passed to the callback function as the second argument. 14/1/2004 Benoit Grégoire * Merge initial Callback registration patch by Ryan P Bobko. Touches most files. 14/1/2004 Benoit Grégoire RELEASE LibOfx 0.6.6 * configure.in: Change version number * NEWS: Update for release * Makefile.am: Add version number to docdir name * libofx.spec.in: Remove known_bugs.txt 14/1/2004 Benoit Grégoire * dtd/Makefile.am, dtd/opensp.dcl, * lib/ofx_preproc.[cpp,hh],: Add SGML declaration to be parsed before the DTD. Makes us immune to changes to default settings. Should get rid of "end tag for "MEMO" omitted, but OMITTAG NO was specified" type of messages and greatly help the parser. * lib/ofx_sgml.cpp: Get rid of OpenSP 1.3.1 compatibility code, which makes the code much easier to understand and debug. Combined with the change obove, it should practically eliminate the parsing ambiguity that made libofx so verbose and ocasionally miss data. More defensive coding to warn of malformed files. This probably means that compatibility with OpenSP 1.3.1 cannot come back. However with the change above it may work after all. Somebody please test this... * lib/messages.cpp: Finally implement displaying line numbers in the error output. This can be turned off by the clients by setting the ofx_show_position global. These should all get setter functions in the API re-write. 6/12/2003 Benoit Grégoire * lib/ofx_container_transaction.cpp: Fix an infinite loop when searching for a parent statement for a transaction if it isn't the immediate parent. Thanks to stephen.a.prior A T ntlworld.ie for the catch. 12/9/2003 Benoit Grégoire RELEASE LibOfx 0.6.5 * configure.in: Change version number * NEWS: Update for release * lib/ofx_utilities.cpp: Change date handling to fix problems with the majority of banks diverging from the specs. Should fix problems with the day being off by one for some countries. * doc/implementation_notes.txt: Moved contents in the doxygen docs. * doc/Makefile.am: Fix the path for the html docs. 2/5/2003 Benoit Grégoire * lib/ofx_utilities.cpp: Add #include to fix compile error on freebsd and possibly all gcc2 based distro. 15/4/2003 Benoit Grégoire * lib/ofx_preproc.cpp: Fix for really broken files that do not have a newline after the ofx header. Fixes bug #721732 12/4/2003 Benoit Grégoire RELEASE LibOfx 0.6.4 * configure.in: Change version number * NEWS: Update for release * lib/ofx_utilities.cpp: Fix bug in ofxamount_to_double() triggered by the client setting the locale. If the locale used ',' as decimal separator, it would get normalised to '.' and atof() would fail. Now normalises to (localeconv())->decimal_point. Closes gnucash bug 105481 18/3/2003 Benoit Grégoire RELEASE LibOfx 0.6.3 * NEWS: Update for release * Makefile.am: Remove references to known_bugx.txt 16/3/2003 Benoit Grégoire * configure.in: Remove --with-opensp-multibyte configure option (it is now the default). There is now a --with-no-opensp-multibyte instead, to force libofx to assume that OpenSP was NOT compiled with SP_MULTI_BYTE defined. * doc/doxygen.cfg: Remove, this file is now generated from doc/doxygen.cfg.in * known_bugx.txt: Remove file, since we now have a bugtracker. * README: Update * INSTALL: Delete and replace by FAQ, update content. 11/3/2003 Benoit Grégoire * ofxdump/ofxdump.cpp: Remove comand line arguments debug output. * lib/ofx_container_main.cpp: Fix compiler warnings reported by Derek Atkins * Misc build system cleanup 24/2/2003 Benoit Grégoire * ofx2qif/ofx2qif.c: Apply patch by Scott Gifford to fix ofx2qif crash. * Add a bunch of .cvsignore files 3/2/2003 Benoit Grégoire * dtd/ofx160.dtd: Correct the dtd to fix the "content model is ambiguous" errors reported by opensp. 27/1/2003 Thomas Frayne * ofxdump/ofxdump.cpp: Add command options: --version, -V, --help 3/2/2003 Benoit Grégoire * lib/ofx_utilities.cpp: Fix ofxdate_to_time_t() that wouldn't compile on sun. 23/1/2003 Benoit Grégoire * lib/ofx_container_transaction.cpp: Explicitely ignore since it should always be equal to UNITS*UNITPRICE, and using it may lead to rounding errors. 22/1/2003 Benoit Grégoire * autogen.sh: Run libtoolize, and reorder the commands. The order is now: libtoolize,aclocal, autoheader, automake, autoconf and configure 11/1/2003 Benoit Grégoire * lib/ofx_utilities.cpp: Really fix problems for big endian machines. * INSTALL: Document the --with-opensp-multibyte workaround for when headers in package lie about the compile option of OpenSP (usually because they were not compiled at the same time). This is the case with the OpenJade package distributed in Mandrake cooker, and perhaps others. * configure.in: add --with-opensp-multibyte option 10/1/2003 Benoit Grégoire * lib/ofx_utilities.cpp: Try to fix problems for big endian machines. 9/1/2003 Benoit Grégoire * configure.in: Add /usr/local/include to OpenSP's include search path. * INSTALL: Add FAQ for "bug" http://sourceforge.net/tracker/index.php?func=detail&aid=654591&group_id=61170&atid=496353 9/1/2003 Benoit Grégoire * lib/ofx_utilities.cpp: Remove the ugly get_sp_char_size() hack and use SP_MULTI_BYTE in config.h instead. This probably fixes the "libofx not working on big endian machines" bug. 9/1/2003 Benoit Grégoire * configure.in: Now detect if OpenSP was compiled with SP_MULTI_BYTE, and put the result in config. * INSTALL: Update for GNU build system. 04/12/2002 Peter O'Gorman * doc/Makefile.am: Make DESTDIR work * lib/Makefile.am: Changed version_info to version-info and modified the version to be what libtool expects. 24/11/2002 Chris Lyttle * libofx.spec.in: updated for new docs 24/11/2002 Benoit Grégoire * configure.in, doc/Makefile.am: Improve doxygen doc generation, and enable make install without the doc. 24/11/2002 Benoit Grégoire * ofx_sgml.cpp: Hopefully fix incompatibilities with BOTH OpenSP 1.3.x and OpenSP >= 1.4 * Makefile.am, doc/Makefile.am: Doxygen API and internal doc now integrated in the build system. It will be distributed and install with the tarballs, and can be build in libofx-cvs using make doc. * autogen.sh: Re-enable maintainer-mode. * doc/Makefile: Deleted * doc/resume_presentation.pdf: Deleted, too outdated. See project report on the libofx website instead. 23/11/2002 Chris Lyttle * libofx.spec.in: added for rpm builds * Makefile.am: added lines spec to EXTRA_DIST * configure.in: added spec.in line * autogen.sh: changed configure line to see arguments 18/11/2002 Benoit Grégoire * ofx_sgml.cpp: Fix critical bug. Parsing of a file would fail and hang for users of OpenSP 1.5pre5 (and possibly others). Simplify workaround of OpenSP 1.3 bugs, more code is now shared. * configure.in: Update for release 0.6.1 18/11/2002 Benoit Grégoire * Update build files for release of libofx 0.6.0 30/10/2002 Benoit Grégoire * inc/libofx.h lib/ofx_container_transaction.cpp ofxdump/ofxdump.cpp: Created a new invtransactiontype enum to replace the invtranstype string 30/10/2002 Benoit Grégoire * lib/ofx_sgml.cpp: Added yet more spagetti code and global variables to improve the work around for OpenSP 1.3 bugs. I beg of you, please convince your distro to make openjade and the OpenSP library independently upgradable. 30/10/2002 Benoit Grégoire * configure.in: Apply Derek Atkins patch needed to build on > RH7.3 using the "distributed" version of openjade. 29/10/2002 Benoit Grégoire * lib/ofx_preproc.cpp doc/tag_striper_test.txt: Proprietary tag striper is now much smarter and read routines have been fixed. Importing a file written on a single line should now be possible. Added a test file for the proprietary tag striper . 29/10/2002 Benoit Grégoire * configure.in: Work around autoconf 2.1 not supporting AC_LANG() 21/10/2002 Benoit Grégoire * ofxdump/ofxdump.cpp: Add support for invtranstype in ofx_proc_transaction_cb() 21/10/2002 Benoit Grégoire * lib/ofx_preproc.cpp: Abort if DTD was not found 20/10/2002 Benoit Grégoire * Fix debug output * Begin fixing ofx2qif for the new transaction ordering code 17/10/2002 Benoit Grégoire * Implemented internal container trees, allowing transaction reordering and security lookups * Complete investment transaction support * Converted the build system to automake/autoconf, mostly contributed by "Peter O'Gorman" LibOFX 0.?????????: -Add an account_name to the OfxAccountData struct. It contains a human readable identifier of the account. -Include file location seems to have changed in recent versions of OpenSP. Included old and new case. -Profiling now possible. It is now posible to use "make static". Statically linked ofxdump and ofx2qif will be created, with profiling enabled. LibOFX 0.3: -MUCH improved documentation. Full API and internals reference in doc/html/ -Major update to ofx2qif. It will now generate the !Account QIF construct, which should improbe compatibility with other accounting software. -gcc3.2 caused problems with ld, now use gcc to link. Should solve the "undefined symbol:__dso_handle" runtime problem with Mandrake cooker. -There is now a workaround in the code to make it work with the OpenSP version (1.3.4) distributed with OpenJADE. However, this is not guaranteed to work, and it might cause errors in your financial data, and might not be present in future versions. Use at your own risk, you've been warned. -LibOFX can now be installed in "unorthodox" directories, such as ~/experimental, and still find it's dtd. You must modify the prefix in common.m (recommended) or put it in the command line of BOTH make and make install. -LibOFX is now officially in beta. Since one application now uses it (GnuCash), from now on, the library soname will be bumped if binary compatibility is broken. LibOFX 0.24: -Fix include files for gcc2 LibOFX 0.23: -Hacked in runtime detection of OpenSP's SGMLApplication::Char size. This should fix the hairy problems some people were experiencing with garbled Output with some versions of OpenSP. -Installation instruction have been improved. -OpenSP include files are no longer distributed with LibOFX. LibOFX 0.22: -make install will now copy libofx.h in the appropriate include directory. LibOFX 0.21: -Files were still created in current directory. Now force /tmp to be used LibOFX 0.2: -The input OFX file's directory no longer need to be writable, and no stale files are left behind. -Prefixed all enum names with OFX to avoid collision with client software (Gnucash in particular) -Changed all money amounts from float to double -Fixed constructors to avoid some "holdover" data LibOFX 0.122: -Always show two decimals for money in ofxdump. -Fix dates off by two month (Scott Drennan) -Fix ofx2qif account type for CREDITCARD (Scott Drennan) LibOFX 0.121: -Fix makefiles for users who do not have ldconfig in their path to create local links. LibOFX 0.12: -LibOFX can now be transparently used by both C and C++, using the same include file (libofx.h) -ofx2qif rewritten in C, to ensure that C compatibility will be maintained and tested. -Added target uninstall to all makefiles -Various other makefile improvements LibOFX 0.11: -Added ofx sample files extracted from the OFX 1.60 and 2.01 specifications in DOC. -Fix compile problems with G++2.9.6 -Makefiles updated -Require a recent version of OpenSP, doesn't work well the one included in OpenJADE (At least on Mandrake). -Fixed the algorithm for proprietary tag striping. LibOFX 0.1: -Initial public release libofx-0.9.12/FAQ000066400000000000000000000060511315754341700134340ustar00rootroot00000000000000INSTALL: -------------------------------------------------------------------------------- Make sure you have the OpenSP library installed (libosp.so) before compiling. Yo can grab it at http://openjade.sourceforge.net/ The recommended version is OpenSP 1.5 If you have a version of OpenJade or OpenSP already installed before compiling OpenSP, make sure that you use ./configure --prefix=/usr to build OpenSP. Otherwise, LibOFX will probably link with the older, incompatible version of OpenSP. Then type: ./autogen.sh (For libofx CVS) ./configure (For a distributed tarball) make And as root type: make install LibOFX <==> OpenSP compatibility matrix: OpenSP version Status 1.3.4 (included in most NOT COMPATIBLE distro with OpenJADE 1.3.1) OpenSP doesn't parse OFX files correctly LibOFX < 0.23 will probably only output garbage. 1.4 NOT TESTED 1.5pre5 COMPATIBLE with all versions 1.5pre8 COMPATIBLE with LibOFX >= 0.23 1.5 COMPATIBLE with LibOFX >= 0.23 FAQ: -------------------------------------------------------------------------------- (1) Getting "configure: error: unable to link a test program, is OpenSP installed?" -BE CAREFULL: When you compile OpenSP, by default it will install in /usr/local. On many versions of linux (Most RedHat, All Mandrake up to 8.3) /usr/local/lib/ is not part of /etc/ld.so.conf . In this case LibOFX will either 1-Fail to link at all 2-Link with libosp.so.0 (1.3.4, wich probably got installed as part of OpenJade) and not work. Even if you add /usr/local/lib/ to /etc/ld.so.conf, LibOFX will probably still link with OpenSP 1.3.4 at runtime. Symptoms will be complaints of many unclosed statements when running ofxdump on an ofx file. I STRONGLY URGE YOU to avoid theese problems and compile OpenSP using ./configure --prefix=/usr If you really want to install OpenSP in /usr/local/lib, you must add --with-opensp-libs=/usr/local/lib to libofx's ./configure or ./autogen.sh (2) Problems compiling OpenSP 1.4 If you are getting errors like: ../include/Message.h:157: `class OpenSP::Messenger' is inaccessible nsgmls.cxx:60: within this context) Try to change private to protected in file OpenSP-1.4/nsgmls/RasEventHandler.h, on line 105. (3) ofxdump does now work right. It seems some values are cut in half, or one out of two letter is missing. LibOFX must know if OpenSP's was compiled with SP_MULTI_BYTE defined. The default is to assume that it was. If you see things such as "SAEET" instead of "STATEMENT" in ofxdump's output, try the following: You can force libofx to assume that OpenSP was NOT compiled with SP_MULTI_BYTE defined by using: ./configure --with-no-opensp-multibyte or for CVS: ./autogen.sh --with-no-opensp-multibyte Unfortunately, the auto-detection of this option was too fragile to release, because distros do not always distribute the config.h OpenSP was truly compiled with. If the devel package for opensp was not compiled at the same time as the lib, it may give wrong value. libofx-0.9.12/Makefile.am000066400000000000000000000013431315754341700151350ustar00rootroot00000000000000ACLOCAL_AMFLAGS = -I m4 if BUILD_OFXCONNECT MAYBE_OFXCONNECT = ofxconnect endif DIST_SUBDIRS = m4 inc dtd lib doc . ofx2qif ofxdump ofxconnect SUBDIRS = m4 inc dtd lib doc . ofx2qif ofxdump $(MAYBE_OFXCONNECT) docdir = $(datadir)/doc/libofx doc_DATA = \ AUTHORS \ COPYING \ INSTALL \ NEWS \ README \ ChangeLog \ totest.txt EXTRA_DIST = \ libofx.spec.in \ libofx.spec \ libofx.pc \ totest.txt \ libofx.lsm.in \ libofx.lsm pkgconfigdir=$(libdir)/pkgconfig pkgconfig_DATA=libofx.pc .PHONY: doc doc: $(MAKE) -C doc doc rpm: $(PACKAGE).spec dist rpmbuild="rpm" && \ if [ `rpm --version | awk '{ print $$3 }'` > /dev/null ]; then rpmbuild="rpmbuild"; fi && \ $$rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz libofx-0.9.12/NEWS000066400000000000000000000276361315754341700136150ustar00rootroot000000000000002017-09-17, LibOFX 0.9.12: - Fix a buffer overflow on unexpected tag names. 2016-08-14, LibOFX 0.9.11: - Add support for client uid, from KDE bug 366326 2014-09-12, LibOFX 0.9.10: - Fix missing balance dates (ledger_balance_date, available_balance_date) 2013-09-09, LibOFX 0.9.9: - Fix missing increment of SO_CURRENT number in libofx-0.9.6 to avoid crashes when mixing this with older applications - bug#41: Fix a crash that occurs while importing a possibly invalid OFX file. Patch by Cristian Onet. 2013-04-17, LibOFX 0.9.8: - Fix errorneous reading of files with empty lines - bug#24: Fix build error on solaris. - bug#40: Fix compiler warnings of OFX clang 2013-04-11, LibOFX 0.9.7: - Fix errorneous reading of files with long lines 2013-03-30, LibOFX 0.9.6: - Extend buffer for TRANSACTION_NAME to 96 bytes due to UTF-8 multibyte characters. - Patch by Geert Janssens to fix typo in info message - Patch by Geert Janssens to allow lines longer than 1024 caracters - Fix treatment of empty date strings: Must return a zero date instead of a bogus one. - Replace unlink() with remove() to fix compile problems with gcc 4.7 - Make configure fail if gengetopt is missing and generated files are not present (as is the case when we checkout from git) - Fix garbled character encoding for UTF-8 encoded OFX 2.0 (XML) files. Sadly, because of a bug in OpenSP with xml decoding this currently means that iso-8859-1 OFX-2.0 files will still not be properly decoded. LibOFX 0.9.5: Benoit Grégoire - Workaround OFX files specifying invalid encoding values (specifically: UNICODE and CP1252). This should fix most encoding problems reported. - Look for DTD in source directory (simplifies developpement) Christian Stimming - Add minor argument checking - Expose field: OfxSecurityData::fiid in API - Make string arguments a const reference where appropriate - Add configure check for help2man tool Ryan Donlan - Improve build system and autoconf 2.68 compatibility - Improve generated man pages - Use GCC's -fvisibility=hidden to hide internal symbols from external users. LibOFX 0.9.4: - Patch to fix segfault on some malformed date formats. Inspired by Zach's patch on launchpad. - Packages-oriented changes: - LibOFX will now look for DTDs in env variable OFX_DTD_PATH (if present). - Better handling of paths (tolerates trailing path separator, or lack thereof) - No longer ignore return value of mkstemp() - Integrate all changes in Ubuntu's package that weren't already upstream - Move to LibXML++ 2.6, as 1.0 is deprecated - Add generated man pages with html2man LibOFX 0.9.3: - Fix segfault on some files containing missing closing tags (bug #2969817) LibOFX 0.9.2: - Win32: Add gnucash patch that looks up the dtd installation directory from the current executable's location. - Apply patch by Geert Janssens to fix a crash on invalid date format - Apply patch by ajseward with some additional fixes to allow wraping the library in python. - Apply patch by Thomas Baumgart which fixes bug #5 (Transaction posting date off by one) - Apply patch by Bill Nottingham with various C++ include fixes for building with recent compilers. LibOFX 0.9.1: - Add more sanity checks on string length. - Fix gnucash crash on OFX files with non-ascii characters and very long lines. See http://bugzilla.gnome.org/show_bug.cgi?id=528306 and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=493597. Patch by Jerome Vouillon copied from the latter. LibOFX 0.9.0: - this release now exports version information thus allowing depending applications to determine the version of LibOFX to compile against - some fields have been added to OfxFiLogin to allow for modification of some OFX header fields in outgoing requests. Together with the latest AqBanking3 this should fix the problem with servers suddenly rejecting connections from LibOFX applications - the calling application can now tell libofx where the data files reside. This allows for relocatable binaries (most importantly on Windows) - some warnings from recent versions of GCC have been fixed - libOFX can now easily be cross-compiled for Windows on Linux - the OFX header is now scanned for a hint regarding the encoding of the document and convert the data to UTF8 if iconv is available at compile time. - the API for online requests has been cleaned up LibOFX 0.8.3: - Fix problem with string lengths. Fixes Gnucash bug http://bugzilla.gnome.org/show_bug.cgi?id=353986 LibOFX 0.8.2:         - bug fixes for GCC4.x and 64-bit compatibility         - fix to enable OFXDirectConnect in Aqbanking         - improvements to ofxpartner functionality         - minor build system modifications         - new fields for fees, commissions and stock split data - fix a memory leak and a potential crashing bug LibOFX 0.8.0: - New DirectConnect API for statement downloads, thanks to Ace Jones and Martin Preuss - Added ofxconnect sample app to demonstrate & test new API's (try "make check" in the ofxconnect folder). Read README.privateserver first. - Apply Christian Stimming's patch for rpm building. Also adds a make rpm target. LibOFX 0.7.0: - Fix compile with gcc 3.4. This also needs to be applied to the stable branch. - Now uses a proper callback architecture (many thanks to Martin Preuss and Ryan P Bobko who contributed to it). - Now uses gengetopt. You can now set the desired debug output from the command line without recompiling. Check ofxdump --help. - File formet autodetection. - Working (but incomplete) Open Financial Connectivity (OFC) support. - Can now display line number in the debug output - Add file format autodetection architecture, can currently distinguish between OFX and OFC files. LibOFX 0.6.6: -Important code cleanup in the parsing code. The parser should be much more independent of OpenSP default settings. Should get rid of "end tag for "MEMO" omitted, but OMITTAG NO was specified" type messages and many other parser failures. -The very old OpenSP 1.3.1 will probably no longuer work. -Fix an infinite loop in some circumstances while the library was searching for a parent statement for a transaction. Would mostly manifest on complex investments transactions. Thanks to stephen.a.prior A T ntlworld.ie for the catch. -Implement displaying file line numbers in the error output. Note that data won't be valid if the message occurs before the file is opened. LibOFX 0.6.5: -Fix for really broken files that do not have a newline after the ofx header (bug #721732) -Add #include to fix compile error on freebsd and possibly all gcc2 based distro. -Change date handling to fix problems with the majority of banks diverging from the specs. Should fix problems with the day being off by one for some countries. (bug #778615) LibOFX 0.6.4: -Fix critical bug that caused the decimals to be ignored after the decimal separator in some locale (no matter what the decimal separator was in the original file). For example, importing in gnucash with a locale of fr_FR caused an amount of 19,95 to be imported as 19,00. LibOFX 0.6.3: -Fix incompatibilities with big endian machines -Fix compilation on sun -Fix error in the DTD that caused "content model is ambiguous" errors -Fix ofx2qif crash -ofxdump can now report the library version number. LibOFX 0.6.2: -Hopefully fix incompatibilities with BOTH OpenSP 1.3.x and OpenSP >= 1.4 -Building as rpm is now available, thanks to Chris Lyttle. -Doxygen API and internal doc now integrated in the build system. It will be distributed and install with the tarballs, and can be build in libofx-cvs using make doc. LibOFX 0.6.1: -Fix a critical bug in 0.6.0. Parsing of a file would fail and hang for users of OpenSP 1.5pre5 (and possibly others). LibOFX 0.6: -Beta version, released to accompany the new GnuCash 1.7.3 beta release. -Full investment transaction support (ofx2qif not yet updated however). -Now uses an Autoconf/Automake build system. -Proprietary tag striper is now much smarter and read routines have been corrected. Importing a file written on a single line will no longer cause an infinite loop. -Added yet more spagetti code and global variables to improve the work around for OpenSP 1.3 bugs. I beg of you, please convince your distro to make openjade and the OpenSP library independently upgradable. LibOFX 0.5: -Alpha version, released to accompany the new GnuCash 1.7.1 alpha release. -Add an account_name to the OfxAccountData struct. It contains a human readable identifier of the account. -Include file location seems to have changed in recent versions of OpenSP. Included old and new case. -Profiling now possible. It is now posible to use "make static". Statically linked ofxdump and ofx2qif will be created, with profiling enabled. -Basic work for investment account and securities. LibOFX 0.3: -MUCH improved documentation. Full API and internals reference in doc/html/ -Major update to ofx2qif. It will now generate the !Account QIF construct, which should improbe compatibility with other accounting software. -gcc3.2 caused problems with ld, now use gcc to link. Should solve the "undefined symbol:__dso_handle" runtime problem with Mandrake cooker. -There is now a workaround in the code to make it work with the OpenSP version (1.3.4) distributed with OpenJADE. However, this is not guaranteed to work, and it might cause errors in your financial data, and might not be present in future versions. Use at your own risk, you've been warned. -LibOFX can now be installed in "unorthodox" directories, such as ~/experimental, and still find it's dtd. You must modify the prefix in common.m (recommended) or put it in the command line of BOTH make and make install. -LibOFX is now officially in beta. Since one application now uses it (GnuCash), from now on, the library soname will be bumped if binary compatibility is broken. LibOFX 0.24: -Fix include files for gcc2 LibOFX 0.23: -Hacked in runtime detection of OpenSP's SGMLApplication::Char size. This should fix the hairy problems some people were experiencing with garbled Output with some versions of OpenSP. -Installation instruction have been improved. -OpenSP include files are no longer distributed with LibOFX. LibOFX 0.22: -make install will now copy libofx.h in the appropriate include directory. LibOFX 0.21: -Files were still created in current directory. Now force /tmp to be used LibOFX 0.2: -The input OFX file's directory no longer need to be writable, and no stale files are left behind. -Prefixed all enum names with OFX to avoid collision with client software (Gnucash in particular) -Changed all money amounts from float to double -Fixed constructors to avoid some "holdover" data LibOFX 0.122: -Always show two decimals for money in ofxdump. -Fix dates off by two month (Scott Drennan) -Fix ofx2qif account type for CREDITCARD (Scott Drennan) LibOFX 0.121: -Fix makefiles for users who do not have ldconfig in their path to create local links. LibOFX 0.12: -LibOFX can now be transparently used by both C and C++, using the same include file (libofx.h) -ofx2qif rewritten in C, to ensure that C compatibility will be maintained and tested. -Added target uninstall to all makefiles -Various other makefile improvements LibOFX 0.11: -Added ofx sample files extracted from the OFX 1.60 and 2.01 specifications in DOC. -Fix compile problems with G++2.9.6 -Makefiles updated -Require a recent version of OpenSP, doesn't work well the one included in OpenJADE (At least on Mandrake). -Fixed the algorithm for proprietary tag striping. LibOFX 0.1: -Initial public release libofx-0.9.12/README000066400000000000000000000102011315754341700137520ustar00rootroot00000000000000Copyright (c) 2002-2010 Benoit Grégoire This is the LibOFX library. It is a API designed to allow applications to very easily support OFX command responses, usually provided by financial institutions. See http://www.ofx.net/ for details and specification. This project was first started as my end of degree project, with the objective to add OFX support to GnuCash https://www.gnucash.org/ If you can read French, the original project presentation is included in the doc directory. I finally decided to make it into a generic library, so all OpenSource financial software can benefit. LibOFX is based on the excellent OpenSP library written by James Clark, and now part of the OpenJADE http://openjade.sourceforge.net/ project. OpenSP by itself is not widely distributed. OpenJADE 1.3.1 includes a version on OpenSP that will link, however, it has some major problems with LibOFX and isn't recommended. Since LibOFX uses the generic interface to OpenSP, it should be compatible with all recent versions of OpenSP (It has been developed with OpenSP-1.5pre5). LibOFX is written in C++, but provides a C style interface usable transparently from both C and C++ using a single include file. In addition to the library, three utilities are included with libofx ofxdump: ofxdump prints to stdout, in human readable form, everything the library understands about a particular ofx response file, and sends errors to stderr. It is as C++ code example and demo of the library (it uses every functions and every structures of LibOFX) usage: ofxdump path_to_ofx_file/ofx_filename ofx2qif: ofx2qif is a OFX "file" to QIF (Quicken Interchange Format) converter. It was written as a C code example, and as a way for LibOFX to immediately provide something usefull, as an incentive for people to try out the library. It is not recommended that financial software use the output of this utility for OFX support. The QIF file format is very primitive, and much information is lost. The utility curently supports every tansaction tags of the qif format except the address lines, and supports many of the tags of !Account. It should generate QIF files that will import sucesfully in just about every software with QIF support. I do not plan on working on this utility much further, but I would be more than happy to accept contributions. usage: ofx2qif path_to_ofx_file/ofx_filename > output_filename.qif ofxconnect: sample app to demonstrate & test new direct connect API's (try "make check" in the ofxconnect folder). Read README.privateserver first. LibOFX strives to achieve the following design goals: -Simplicity: OFX is a VERY complex spec. However, few if any software needs all this complexity. The library tries to hide this complexity by "flattening" the data structures, doing timezone conversions, currency conversion, etc. -Data directly usable from C, without conversion: A date is a C time_t, money is a float, strings are char[], etc. -C style interface: Although LibOFX is written in C++, it provides an interface usable transparently from both C and C++, using a single header file. LibOFX was implemented directly from the full OFX 1.6 spec, and currently supports: * Banking transactions and statements. * Credit card and statements. * Investment transactions. * OFX 2.0 Future projects for libofx include: * Header parsing * DTD autodetection * Currency conversion * QIF import * QIF export (integrated inside the library) * OFX export Full documentation of the API and library internals generated using doxygen is available. For a quick start, you should learn all you need to know to get started by reading the libofx.h file in the INC directory, and ofxdump.cpp in the ofxdump directory. Call for help: -Please note that despite a very detailled spec, OFX is by nature very hard to test. I only have access to the specifications examples, and my own bank (Desjardins). But I need people to run as many ofx files from different banks as they can thru libofx, and report the result. -This is my first attempt at writing an API. I need comments from financial software writers about inc/libofx.h What do YOU need? Benoit Grégoire benoitg@coeus.ca libofx-0.9.12/autogen.sh000077500000000000000000000006671315754341700151120ustar00rootroot00000000000000#!/bin/sh # Run this to generate all the initial makefiles, etc. echo "Running mkdir -p config" mkdir -p config echo "Running libtoolize --force" libtoolize --force echo "Running aclocal" aclocal -I ./m4 echo "Running autoheader" autoheader echo "Running automake -a" automake -a echo "Running autoconf" autoconf echo "You can now run ./configure $conf_flags $@ (potentially in a separate build directory)" #./configure $conf_flags "$@" libofx-0.9.12/configure.ac000066400000000000000000000314531315754341700153740ustar00rootroot00000000000000## -*-m4-*- dnl Process this file with autoconf to produce a configure script. # FILE: # configure.in # # FUNCTION: # implements checks for a variety of system-specific functions AC_INIT(inc/libofx.h.in) AM_CONFIG_HEADER(config.h) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(m4) AC_PROG_CC AC_PROG_CXX m4_include([libcurl.m4]) LIBOFX_MAJOR_VERSION=0 LIBOFX_MINOR_VERSION=9 LIBOFX_MICRO_VERSION=12 # this number is just incremented for every major change in CVS, also across # releases to emulate the Revision variable of SVN (which isn't available # with CVS) LIBOFX_BUILD_VERSION=0 LIBOFX_TAG_VERSION="stable" case "$LIBOFX_TAG_VERSION" in cvs|svn|git) LIBOFX_VERSION_RELEASE_STRING="$LIBOFX_MAJOR_VERSION.$LIBOFX_MINOR_VERSION.$LIBOFX_MICRO_VERSION.$LIBOFX_TAG_VERSION${LIBOFX_BUILD_VERSION}" ;; stable) LIBOFX_VERSION_RELEASE_STRING="$LIBOFX_MAJOR_VERSION.$LIBOFX_MINOR_VERSION.$LIBOFX_MICRO_VERSION" ;; *) LIBOFX_VERSION_RELEASE_STRING="$LIBOFX_MAJOR_VERSION.$LIBOFX_MINOR_VERSION.$LIBOFX_MICRO_VERSION" # add TAG LIBOFX_VERSION_RELEASE_STRING="${LIBOFX_VERSION_RELEASE_STRING}${GWENHYWFAR_VERSION_TAG}" ;; esac ### Check for GCC symbol visibility extensions AC_CACHE_CHECK([for symbol visibility extensions], ac_cv_sym_visibility, [ echo '#pragma GCC visibility push(default)' > conftest.c echo 'int foo (void) { return 1; }' >> conftest.c echo '#pragma GCC visibility pop' >> conftest.c echo 'int bar (void) { return 1; }' >> conftest.c ac_cv_sym_visibility=no if AC_TRY_COMMAND(${CXX-cxx} -fvisibility-inlines-hidden -fvisibility=hidden -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then if grep '\.hidden.*bar' conftest.s > /dev/null && grep -v '\.hidden.*foo' conftest.s >/dev/null; then ac_cv_sym_visibility=yes fi fi rm -f conftest.* ]) if test $ac_cv_sym_visibility = yes; then AC_DEFINE(HAVE_GCC_VISIBILITY_EXTS, 1, [Define if GCC visibility extensions are supported]) VISIBILITY_FLAGS="-fvisibility=hidden" CFLAGS="$VISIBILITY_FLAGS $CFLAGS" CXXFLAGS="$VISIBILITY_FLAGS -fvisibility-inlines-hidden $CFLAGS" fi ## Pass -DIN_LIBOFX to the compiler so we can detect it and include config.h ## in libofx.h safely CFLAGS="-DIN_LIBOFX $CFLAGS" CXXFLAGS="-DIN_LIBOFX $CXXFLAGS" LIBOFX_VERSION=$LIBOFX_MAJOR_VERSION.$LIBOFX_MINOR_VERSION.$LIBOFX_MICRO_VERSION AC_SUBST(LIBOFX_MAJOR_VERSION) AC_SUBST(LIBOFX_MINOR_VERSION) AC_SUBST(LIBOFX_MICRO_VERSION) AC_SUBST(LIBOFX_BUILD_VERSION) AC_SUBST(LIBOFX_VERSION_RELEASE_STRING) AC_SUBST(LIBOFX_VERSION) AM_INIT_AUTOMAKE(libofx,$LIBOFX_VERSION_RELEASE_STRING) LIBOFX_SO_CURRENT=7 LIBOFX_SO_REVISION=1 LIBOFX_SO_AGE=0 LIBOFX_SO_EFFECTIVE="`echo \$(($LIBOFX_SO_CURRENT-$LIBOFX_SO_AGE))`" AC_SUBST(LIBOFX_SO_CURRENT) AC_SUBST(LIBOFX_SO_REVISION) AC_SUBST(LIBOFX_SO_AGE) #AM_MAINTAINER_MODE AC_PROG_INSTALL AC_PROG_LIBTOOL AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_LIBTOOL_RC AC_ISC_POSIX AC_C_BIGENDIAN AC_PROG_MAKE_SET AC_HEADER_STDC AC_ARG_WITH(opensp-includes, [ --with-opensp-includes=PATH specify where to look for OpenSP includes - default is /usr/include/OpenSP)], OPENSPINCLUDES="$with_opensp_includes", OPENSPINCLUDES="" ) AC_ARG_WITH(opensp-libs, [ --with-opensp-libs=PATH specify where to look for libosp - default is /usr/lib], OPENSPLIBPATH="$with_opensp_libs", OPENSPLIBPATH="/usr/lib") echo $OPENSPLIBPATH for d in /usr/include/OpenSP /usr/local/include/OpenSP /usr/include/sp/generic /usr/local/include/sp/generic; do if test "x$OPENSPINCLUDES" = x; then save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$d" AC_MSG_CHECKING(for ParserEventGenerator.h in $d) AC_TRY_CPP([#include ], [ AC_MSG_RESULT(yes); OPENSPINCLUDES=$d ], [ AC_MSG_RESULT(no) ]) CPPFLAGS="$save_CPPFLAGS" fi done ##Detect if OpenSP was compiled with SP_MULTI_BYTE, and put the result in config.h ## #if 0 ##This test works for me, but breaks for most distro because the config.h installed isn't really the one that was used to compile OpenSP ## So --with-opensp-multibyte is now the default. AC_DEFUN([CHECK_SP_MULTI_BYTE], [ AC_CACHE_VAL(ox_sp_multibyte, [ for d in $OPENSPINCLUDES/config.h $OPENSPINCLUDES/../config.h $OPENSPINCLUDES/../include/config.h ; do if test "x$OPENSPCONFIG_H" = x; then save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -DOPENSPCONFIG_H=\"$d\"" AC_MSG_CHECKING(for OpenSP's config.h in $d) AC_TRY_CPP([#include OPENSPCONFIG_H], [ AC_MSG_RESULT(yes); OPENSPCONFIG_H=$d ], [ AC_MSG_RESULT(no) ]) CPPFLAGS="$save_CPPFLAGS" fi done if test "x$OPENSPCONFIG_H" = x; then AC_MSG_ERROR([OpenSP's config.h not found]) fi AC_MSG_CHECKING(for if OpenSP's was compiled with SP_MULTI_BYTE) ox_sp_multibyte=`sed 's/^#.*SP_MULTI_BYTE[ \t]*\([01]\)/\1/;t;d' < \ $OPENSPCONFIG_H`]) if test x"$ox_sp_multibyte" != x ;then AC_DEFINE_UNQUOTED(SP_MULTI_BYTE, $ox_sp_multibyte, [SP_MULTI_BYTE value from when OpenSP was compiled]) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi ]) #endif AC_ARG_WITH(no-opensp-multibyte, [ --with-no-opensp-multibyte Force libofx to compile with the assumption that OpenSP was NOT compiled with SP_MULTI_BYTE defined], , AC_DEFINE(SP_MULTI_BYTE, 1, [SP_MULTI_BYTE value from when OpenSP was compiled]) ) ##if test x"$SP_MULTI_BYTE" == x ;then ##CHECK_SP_MULTI_BYTE ##fi ac_save_CPPFLAGS="$CPPFLAGS" if test "x$OPENSPINCLUDES" != x ; then CPPFLAGS="-I$OPENSPINCLUDES $CPPFLAGS" fi AC_LANG_CPLUSPLUS AC_CHECK_HEADERS([ParserEventGeneratorKit.h SGMLApplication.h EventGenerator.h], [] , [ AC_MSG_ERROR([OpenSP includes not found]) ], [] ) OPENSPLIBS="-L$OPENSPLIBPATH -losp" ac_save_LIBS="$LIBS" LIBS="$OPENSPLIBS $LIBS" AC_MSG_CHECKING([for libosp]) ##dnl This is code from the opensp documentation, I modified it a little ##dnl It is really just a link test rather than a run test, it does nothing AC_LANG_CPLUSPLUS AC_TRY_RUN([ #include "ParserEventGeneratorKit.h" using namespace std; class OutlineApplication : public SGMLApplication { public: OutlineApplication() { } void startElement(const StartElementEvent &event) { } void endElement(const EndElementEvent &) { } }; int main(int argc, char **argv) { ParserEventGeneratorKit parserKit; EventGenerator *egp = parserKit.makeEventGenerator(argc - 1, argv + 1); OutlineApplication app; } ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_MSG_ERROR([unable to link a test program, is OpenSP installed?])], [AC_MSG_RESULT([unknown, assumed OK])]) CPPFLAGS="$ac_save_CPPFLAGS" LIBS="$ac_save_LIBS" # check for doxygen, mostly stolen from http://log4cpp.sourceforge.net/ # ---------------------------------------------------------------------------- AC_DEFUN([BB_ENABLE_DOXYGEN], [ AC_ARG_ENABLE(doxygen, [ --enable-doxygen enable documentation generation with doxygen (auto)]) AC_ARG_ENABLE(dot, [ --enable-dot use 'dot' to generate graphs in doxygen (auto)]) AC_ARG_ENABLE(html-docs, [ --enable-html-docs enable HTML generation with doxygen (yes)], [], [ enable_html_docs=yes]) AC_ARG_ENABLE(latex-docs, [ --enable-latex-docs enable LaTeX documentation generation with doxygen (no)], [], [ enable_latex_docs=no]) if test "x$enable_doxygen" = xno; then enable_doc=no else AC_PATH_PROG(DOXYGEN, doxygen, , $PATH) if test x$DOXYGEN = x; then if test "x$enable_doxygen" = xyes; then AC_MSG_ERROR([could not find doxygen]) fi enable_doc=no else enable_doc=yes AC_PATH_PROG(DOT, dot, , $PATH) fi fi AM_CONDITIONAL(DOC, test x$enable_doc = xyes) if test x$DOT = x; then if test "x$enable_dot" = xyes; then AC_MSG_ERROR([could not find dot]) fi enable_dot=no else enable_dot=yes fi AM_CONDITIONAL(ENABLE_DOXYGEN, test x$enable_doc = xtrue) AC_SUBST(enable_dot) AC_SUBST(enable_html_docs) AC_SUBST(enable_latex_docs) ]) # check for doxygen # ---------------------------------------------------------------------------- BB_ENABLE_DOXYGEN # Check if getopt_long is available # ---------------------------------------------------------------------------- dnl Available from the GNU Autoconf Macro Archive at: dnl http://www.gnu.org/software/ac-archive/htmldoc/adl_func_getopt_long.html dnl AC_DEFUN([adl_FUNC_GETOPT_LONG], [AC_PREREQ(2.49)dnl # clean out junk possibly left behind by a previous configuration rm -f lib/getopt.h # Check for getopt_long support AC_CHECK_HEADERS([getopt.h]) AC_CHECK_FUNCS([getopt_long],, [# FreeBSD has a gnugetopt library for this AC_CHECK_LIB([gnugetopt],[getopt_long],[AC_DEFINE([HAVE_GETOPT_LONG])], [# use the GNU replacement AC_LIBOBJ(getopt) AC_LIBOBJ(getopt1) AC_CONFIG_LINKS([lib/getopt.h:lib/gnugetopt.h])])])]) dnl check for getopt in standard library adl_FUNC_GETOPT_LONG AM_CONDITIONAL(NO_GETOPTLONG, test "$ac_cv_func_getopt_long" = no ) # gengetopt command line parser generation AC_ARG_ENABLE(gengetopt, AS_HELP_STRING(--disable-gengetopt,Disable rebuilding of command line parser with gengetopt), [case "${enableval}" in yes) gengetopt=yes ;; no) gengetopt=no ;; *) AC_MSG_ERROR([bad value ${enableval} for --disable-gengetopt]) ;; esac],[gengetopt=yes]) if test x$gengetopt = xyes ; then AC_CHECK_PROG(have_gengetopt, gengetopt, yes, no) if test x$have_gengetopt = xno; then if test -f "${srcdir}/ofxdump/cmdline.c"; then AC_MSG_WARN([*** Not rebuilding command line parser as gengetopt is not found ***]) else AC_MSG_ERROR([*** Gengetopt is not found, and generated files (cmdline.c) are missing (probably because you checked out from git). You need to install gengetopt ***]) fi gengetopt=no fi fi AM_CONDITIONAL(USE_GENGETOPT, test "x$gengetopt" = xyes) AC_PATH_PROG([HELP2MAN], [help2man], [no]) AM_CONDITIONAL(HAVE_HELP2MAN, test "x$HELP2MAN" != "xno") # check for curl # ---------------------------------------------------------------------------- LIBCURL_CHECK_CONFIG([yes],[7.9.7], [libcurl_available=yes], [libcurl_available=no]) if test "$libcurl_available" = no; then AC_MSG_WARN([libcurl is not available. ofxconnect (Direct connect samples) will NOT be built.]) fi PKG_CHECK_MODULES(LIBXMLPP,libxml++-2.6 >= 2.6, [ AC_DEFINE(HAVE_LIBXMLPP, 1, [Defined if libxml++ is available]) have_libxmlpp=yes], [AC_MSG_WARN([libxml++ 2.6 is not available. ofxconnect (Direct connect samples) will NOT be built.]) have_libxmlpp=no]) #PKG_CHECK_MODULES(QT,qt-mt >= 3.2, # [AC_DEFINE(HAVE_QT, 1, [Defined if Qt Gui is available])], # [AC_MSG_WARN([Qt is not available. Some experimental direct connect samples will not be fully functional.])]) build_ofxconnect=no if test "$libcurl_available" = yes; then if test "$have_libxmlpp" = yes; then build_ofxconnect=yes fi fi AM_CONDITIONAL([BUILD_OFXCONNECT], [test "$build_ofxconnect" = yes]) # check for iconv # ---------------------------------------------------------------------------- AC_ARG_WITH(iconv, [ --with-iconv[[=DIR]] add ICONV support (on)]) WITH_ICONV=0 if test "$with_iconv" = "no" ; then echo Disabling ICONV support else if test "$with_iconv" != "yes" -a "$with_iconv" != "" ; then CPPFLAGS="${CPPFLAGS} -I$with_iconv/include" # Export this since our headers include iconv.h XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_iconv/include" ICONV_LIBS="-L$with_iconv/lib" fi AC_CHECK_HEADER(iconv.h, AC_MSG_CHECKING(for iconv) AC_TRY_LINK([#include #include ],[ iconv_t cd = iconv_open ("",""); iconv (cd, NULL, NULL, NULL, NULL);],[ AC_MSG_RESULT(yes) WITH_ICONV=1],[ AC_MSG_RESULT(no) AC_MSG_CHECKING(for iconv in -liconv) _ldflags="${LDFLAGS}" _libs="${LIBS}" LDFLAGS="${LDFLAGS} ${ICONV_LIBS}" LIBS="${LIBS} -liconv" AC_TRY_LINK([#include #include ],[ iconv_t cd = iconv_open ("",""); iconv (cd, NULL, NULL, NULL, NULL);],[ AC_MSG_RESULT(yes) WITH_ICONV=1 ICONV_LIBS="${ICONV_LIBS} -liconv" LIBS="${_libs}" LDFLAGS="${_ldflags}"],[ AC_MSG_RESULT(no) LIBS="${_libs}" LDFLAGS="${_ldflags}"])])) fi AC_DEFINE_UNQUOTED(HAVE_ICONV, $WITH_ICONV, [Defined if libxml++ is available]) AC_SUBST(WITH_ICONV) AC_SUBST(ICONV_LIBS) AC_SUBST(ofxconnect) AC_SUBST(OPENSPINCLUDES) AC_SUBST(OPENSPLIBS) AC_SUBST(LIBXMLPP_CFLAGS) AC_SUBST(LIBXMLPP_LIBS) AC_SUBST(QT_CFLAGS) AC_SUBST(QT_CFLAGS) LIBOFX_DTD_DIR='${datadir}/libofx/dtd' AC_SUBST(LIBOFX_DTD_DIR) AC_CONFIG_FILES([Makefile]) AC_OUTPUT( libofx.spec libofx.pc libofx.lsm m4/Makefile lib/Makefile inc/Makefile inc/libofx.h dtd/Makefile doc/Makefile ofx2qif/Makefile ofxdump/Makefile ofxconnect/Makefile ) libofx-0.9.12/doc/000077500000000000000000000000001315754341700136455ustar00rootroot00000000000000libofx-0.9.12/doc/.gitignore000066400000000000000000000000741315754341700156360ustar00rootroot00000000000000*.la *.lo .deps .libs Makefile Makefile.in html doxygen.log libofx-0.9.12/doc/Makefile.am000066400000000000000000000015651315754341700157100ustar00rootroot00000000000000SUBDIRS = docdir = ${prefix}/share/doc/libofx EXTRA_DIST = \ doxygen.cfg \ ofx_sample_files \ tag_striper_test.txt \ html all: doc: html/ html/: doxygen.cfg echo "doc: " && pwd && echo "distdir: " && echo $(distdir) rm -rf html/ refman.pdf $(DOXYGEN) $(srcdir)/doxygen.cfg # $(MAKE) -C latex/ # mv latex/refman.pdf ./refman.pdf dist-hook: maintainer-clean-local doc echo "dist-hook: " && pwd clean-local: echo "clean-local: " && pwd rm -rf latex/ rm -f *~ rm -f doxygen.log maintainer-clean-local: clean-local echo "maintainer-clean-local: " && pwd rm -rf html refman.pdf install-data-hook: $(mkinstalldirs) $(DESTDIR)$(docdir) mkdir -p html #Workaround to allow libofx-cvs user to install without doc. cp -rp html $(DESTDIR)$(docdir) uninstall-hook: chmod +w -R $(DESTDIR)${docdir}/html #Why chmod is needed is a mystery rm -rf $(DESTDIR)${docdir}/html libofx-0.9.12/doc/doxygen.cfg000066400000000000000000002116211315754341700160060ustar00rootroot00000000000000# Doxyfile 1.7.3 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = LibOFX # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description for a project that appears at the top of each page and should give viewer a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even if there is only one candidate or it is obvious which candidate to choose by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = NO # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = NO # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = NO # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = YES # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = doxygen.log #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ../ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [0,1..20]) # that doxygen will group on one line in the generated HTML documentation. # Note that a value of 0 will completely suppress the enum values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the mathjax.org site, so you can quickly see the result without installing # MathJax, but it is strongly recommended to install a local copy of MathJax # before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = letter # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will write a font called Helvetica to the output # directory and reference it in all dot files that doxygen generates. # When you want a differently looking font you can specify the font name # using DOT_FONTNAME. You need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, svg, gif or svg. # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES libofx-0.9.12/doc/main_doc.c000066400000000000000000000025661315754341700155730ustar00rootroot00000000000000 /*! \mainpage LibOFX developer's manual \section intro Introduction This is the documentation for the LibOFX library and it's utilities. It should always be up to date since it is generated directly from the source files using Doxygen. This documentation covers the internals as well as the API of libofx. Before you dive into this documentation, you should have read the README and the other files included at the top level of the distribution. \section quicklinks Quick links These are the most important sections of the doc. The rest covers the library internals and is a work in progress. The documentation for the different functions is mostly complete, but documention for the objects is not. \subsection api API documentation If you are only interested in the API. It's covered entirely in the libofx.h section. \subsection ofxdump ofxdump documentation The user documentation for the ofxdump utility is on the ofxdump.cpp page. \subsection ofx2qif ofx2qif documentation The user documentation for the ofx2qif converter is on the ofx2qif.c page. \section contact Contacts \subsection web Web Site News about LibOFX as well as the latest version can always be found at http://libofx.sourceforge.net/ \subsection email Email If you have any questions not covered in this documentation or the web site, do not hesitate to email me: Benoit Gr�goire mailto:benoitg@coeus.ca */ libofx-0.9.12/doc/ofx_sample_files/000077500000000000000000000000001315754341700171645ustar00rootroot00000000000000libofx-0.9.12/doc/ofx_sample_files/ofx_spec160_stmtrs_example.sgml000077500000000000000000000067371315754341700252540ustar00rootroot00000000000000 0 INFO 19961029101003 ENG 19961029101003 19961029101003 1001 0 INFO USD 121099999 999988 CHECKING 19961001 19961028 CHECK 19961004 -200.00 00002 1000 ATM 19961020 19961020 -300.00 00003 200.29 199610291120 200.29 199610291120 libofx-0.9.12/doc/ofx_sample_files/ofx_spec201_stmtrs_example.xml000066400000000000000000000101361315754341700250670ustar00rootroot00000000000000 0 INFO 19991029101003 ENG 19991029101003 19991029101003 NCH 1001 1001 0 INFO USD 121099999 999988 CHECKING 19991001 19991028 CHECK 19991004 -200.00 00002 1000 ATM 19991020 19991020 -300.00 00003 200.29 199910291120 200.29 199910291120 libofx-0.9.12/doc/tag_striper_test.txt000066400000000000000000000012111315754341700177630ustar00rootroot00000000000000 This should be strippedThis should not be stripped This should not be strippedThis should be strippedThis should not be stripped This should not be strippedThis should be stripped This should not be strippedThis should be strippedThis should not be stripped This should not be strippedThis should be stripped This should be stripped libofx-0.9.12/dtd/000077500000000000000000000000001315754341700136535ustar00rootroot00000000000000libofx-0.9.12/dtd/.gitignore000066400000000000000000000000531315754341700156410ustar00rootroot00000000000000*.la *.lo .deps .libs Makefile Makefile.in libofx-0.9.12/dtd/Makefile.am000066400000000000000000000002201315754341700157010ustar00rootroot00000000000000docdir = ${LIBOFX_DTD_DIR} doc_DATA = opensp.dcl ofx160.dtd ofx201.dtd ofc.dtd EXTRA_DIST = \ opensp.dcl \ ofx160.dtd \ ofx201.dtd \ ofc.dtdlibofx-0.9.12/dtd/ofc.dtd000066400000000000000000000462571315754341700151350ustar00rootroot00000000000000 ]> libofx-0.9.12/dtd/ofx160.dtd000066400000000000000000004243241315754341700154040ustar00rootroot00000000000000 ]> libofx-0.9.12/dtd/ofx201.dtd000066400000000000000000004224021315754341700153730ustar00rootroot00000000000000 libofx-0.9.12/dtd/opensp.dcl000066400000000000000000000034721315754341700156510ustar00rootroot00000000000000 libofx-0.9.12/inc/000077500000000000000000000000001315754341700136515ustar00rootroot00000000000000libofx-0.9.12/inc/.gitignore000066400000000000000000000000651315754341700156420ustar00rootroot00000000000000*.la *.lo .deps .libs Makefile Makefile.in libofx.h libofx-0.9.12/inc/Makefile.am000066400000000000000000000000361315754341700157040ustar00rootroot00000000000000pkginclude_HEADERS = libofx.h libofx-0.9.12/inc/libofx.h.in000066400000000000000000001041301315754341700157110ustar00rootroot00000000000000/*-*-c-*-******************************************************************* libofx.h - Main header file for the libofx API ------------------- copyright : (C) 2002-2011 by Benoit Grégoire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Main header file containing the LibOfx API * This file should be included for all applications who use this API. This header file will work with both C and C++ programs. The entire API is made of the following structures and functions. * All of the following ofx_proc_* functions are callbacks (Except ofx_proc_file which is the entry point). They must be implemented by your program, but can be left empty if not needed. They are called each time the associated structure is filled by the library. * Important note: The variables associated with every data element have a *_valid companion. Always check that data_valid == true before using. Not only will you ensure that the data is meaningfull, but also that pointers are valid and strings point to a null terminated string. Elements listed as mandatory are for information purpose only, do not trust the bank not to send you non-conforming data... */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef LIBOFX_H #define LIBOFX_H #include #define LIBOFX_MAJOR_VERSION @LIBOFX_MAJOR_VERSION@ #define LIBOFX_MINOR_VERSION @LIBOFX_MINOR_VERSION@ #define LIBOFX_MICRO_VERSION @LIBOFX_MICRO_VERSION@ #define LIBOFX_BUILD_VERSION @LIBOFX_BUILD_VERSION@ #define LIBOFX_VERSION_RELEASE_STRING "@LIBOFX_VERSION_RELEASE_STRING@" #ifdef IN_LIBOFX # include "config.h" # ifdef HAVE_GCC_VISIBILITY_EXTS # pragma GCC visibility push(default) # endif #endif #ifdef __cplusplus extern "C" { #else #define true 1 #define false 0 #endif #define OFX_ELEMENT_NAME_LENGTH 100 #define OFX_SVRTID2_LENGTH (36 + 1) #define OFX_CHECK_NUMBER_LENGTH (12 + 1) #define OFX_REFERENCE_NUMBER_LENGTH (32 + 1) #define OFX_FITID_LENGTH (255 + 1) #define OFX_TOKEN2_LENGTH (36 + 1) #define OFX_MEMO_LENGTH (255 + 1) #define OFX_FIID_LENGTH (32 + 1) #define OFX_MEMO2_LENGTH (390 + 1) #define OFX_BALANCE_NAME_LENGTH (32 + 1) #define OFX_BALANCE_DESCRIPTION_LENGTH (80 + 1) #define OFX_CURRENCY_LENGTH (3 + 1) /* In ISO-4217 format */ #define OFX_BANKID_LENGTH (9 + 1) #define OFX_BRANCHID_LENGTH (22 + 1) #define OFX_ACCTID_LENGTH (22 + 1) #define OFX_ACCTKEY_LENGTH (22 + 1) #define OFX_BROKERID_LENGTH (22 + 1) /* Must be MAX of ++, + and + */ #define OFX_ACCOUNT_ID_LENGTH (OFX_BANKID_LENGTH + OFX_BRANCHID_LENGTH + OFX_ACCTID_LENGTH + 1) #define OFX_ACCOUNT_NAME_LENGTH 255 #define OFX_MARKETING_INFO_LENGTH (360 + 1) #define OFX_TRANSACTION_NAME_LENGTH (96 + 1) #define OFX_UNIQUE_ID_LENGTH (32 + 1) #define OFX_UNIQUE_ID_TYPE_LENGTH (10 + 1) #define OFX_SECNAME_LENGTH (32 + 1) #define OFX_TICKER_LENGTH (32 + 1) #define OFX_ORG_LENGTH (32 + 1) #define OFX_FID_LENGTH (32 + 1) #define OFX_USERID_LENGTH (32 + 1) #define OFX_USERPASS_LENGTH (32 + 1) #define OFX_URL_LENGTH (500 + 1) #define OFX_APPID_LENGTH (32) #define OFX_APPVER_LENGTH (32) #define OFX_HEADERVERSION_LENGTH (32) #define OFX_CLIENTUID_LENGTH (36 + 1) /* #define OFX_STATEMENT_CB 0; #define OFX_ACCOUNT_CB 1; #define OFX_TRACSACTION_CB 2; #define OFX_SECURITY_CB 3; #define OFX_STATUS_CB 4; */ typedef void * LibofxContextPtr; /** * \brief Initialise the library and return a new context. * @return the new context, to be used by the other functions. */ LibofxContextPtr libofx_get_new_context(); /** * \brief Free all ressources used by this context. * @return 0 if successfull. */ int libofx_free_context( LibofxContextPtr ); void libofx_set_dtd_dir(LibofxContextPtr libofx_context, const char *s); /** List of possible file formats */ enum LibofxFileFormat { AUTODETECT, /**< Not really a file format, used to tell the library to try to autodetect the format*/ OFX, /**< Open Financial eXchange (OFX/QFX) file */ OFC, /**< Microsoft Open Financial Connectivity (OFC)*/ QIF, /**< Intuit Quicken Interchange Format (QIF) */ UNKNOWN, /**< Unknown file format */ LAST /**< Not a file format, meant as a loop breaking condition */ }; struct LibofxFileFormatInfo { enum LibofxFileFormat format;/**< The file format enum */ const char * format_name; /**< Text version of the enum */ const char * description; /**< Description of the file format */ }; #ifndef OFX_AQUAMANIAC_UGLY_HACK1 const struct LibofxFileFormatInfo LibofxImportFormatList[] = { {AUTODETECT, "AUTODETECT", "AUTODETECT (File format will be automatically detected later)"}, {OFX, "OFX", "OFX (Open Financial eXchange (OFX or QFX))"}, {OFC, "OFC", "OFC (Microsoft Open Financial Connectivity)"}, {QIF, "QIF", "QIF (Intuit Quicken Interchange Format) NOT IMPLEMENTED"}, {LAST, "LAST", "Not a file format, meant as a loop breaking condition"} }; const struct LibofxFileFormatInfo LibofxExportFormatList[] = { {QIF, "QIF", "QIF (Intuit Quicken Interchange Format) NOT IMPLEMENTED"}, {LAST, "LAST", "Not a file format, meant as a loop breaking condition"} }; /** * \brief libofx_get_file_type returns a proper enum from a file type string. * @format_list The file format list in which the format string should be found, usually LibofxImportFormatList or LibofxExportFormatList @file_type_string The string which contain the file format matching one of the format_name of the list. @return the file format, or UNKNOWN if the format wasn't recognised. */ enum LibofxFileFormat libofx_get_file_format_from_str(const struct LibofxFileFormatInfo format_list[], const char * file_type_string); /** * \brief get_file_format_description returns a string description of a LibofxFileType. * @format_list The file format list in which the format should be looked up, usually LibofxImportFormatList or LibofxExportFormatList @file_format The file format which should match one of the formats in the list. @return null terminated string suitable for debugging output or user communication. */ const char * libofx_get_file_format_description(const struct LibofxFileFormatInfo format_list[], enum LibofxFileFormat file_format); #endif /** * \brief libofx_proc_file is the entry point of the library. * * libofx_proc_file must be called by the client, with a list of 1 * or more OFX files to be parsed in command line format. */ int libofx_proc_file(LibofxContextPtr libofx_context, const char * p_filename, enum LibofxFileFormat ftype); /** * \brief An abstraction of an OFX STATUS element. * * The OfxStatusData structure represents a STATUS OFX element sent by the OFX server. Be carefull, you do not have much context except the entity name so your application should probably ignore this status if code==0. However, you should display a message if the status in non-zero, since an error probably occurred on the server side. * * In a future version of this API, OfxStatusData structures might be linked from the OFX structures they are related to. */ struct OfxStatusData { /** @name Additional information * To give a minimum of context, the name of the OFX SGML element where this is located is available. */ char ofx_element_name[OFX_ELEMENT_NAME_LENGTH];/** Name of the OFX element this status is relevant to */ int ofx_element_name_valid; /** @name OFX mandatory elements * The OFX spec defines the following elements as mandatory. The associated variables should all contain valid data but you should not trust the servers. Check if the associated *_valid is true before using them. */ int code; /**< Status code */ const char* name; /**< Code short name */ const char* description; /**< Code long description, from ofx_error_msg.h */ int code_valid; /**< If code_valid is true, so is name and description (They are obtained from a lookup table) */ /** Severity of the error */ enum Severity { INFO, /**< The status is an informational message */ WARN, /**< The status is a warning */ ERROR /**< The status is a true error */ } severity; int severity_valid; /** @name OFX optional elements * The OFX spec defines the following elements as optional. If the associated *_valid is true, the corresponding element is present and the associated variable contains valid data. */ char* server_message; /**< Explanation given by the server for the Status Code. Especially important for generic errors. */ int server_message_valid; /*@}*/ }; /** * \brief The callback function for the OfxStatusData stucture. * * An ofx_proc_status_cb event is sent everytime the server has * generated a OFX STATUS element. As such, it could be received at * any time(but not during other events). An OfxStatusData * structure is passed to this event, as well as a pointer to an * arbitrary data structure. */ typedef int (*LibofxProcStatusCallback)(const struct OfxStatusData data, void * status_data); /** * \brief An abstraction of an account * * The OfxAccountData structure gives information about a specific * account, including it's type, currency and unique id. * * When an OfxAccountData must be passed to functions which create * OFX requests related to a specific account, it must contain all * the info needed for an OFX request to identify an account. That * is: account_type, account_number, bank_id and branch_id */ struct OfxAccountData { /** @name OFX mandatory elements * The OFX spec defines the following elements as mandatory. The associated variables should all contain valid data but you should not trust the servers. Check if the associated *_valid is true before using them. */ /** The account_id is actually built from for a bank account, and for a credit card account. account_id is meant to be computer-readable. It is a worldwide OFX unique identifier wich can be used for account matching, even in system with multiple users.*/ char account_id[OFX_ACCOUNT_ID_LENGTH]; /** The account_id_name is a string meant to allow the user to identify the account. Currently it is for a bank account and a credit card account an : for investment accounts. account_id_name is not meant to be computer-readable and is not garanteed to be unique.*/ char account_name[OFX_ACCOUNT_NAME_LENGTH]; int account_id_valid;/* Use for both account_id and account_name */ /** account_type tells you what kind of account this is. See the * AccountType enum */ enum AccountType { OFX_CHECKING, /**< A standard checking account */ OFX_SAVINGS, /**< A standard savings account */ OFX_MONEYMRKT, /**< A money market account */ OFX_CREDITLINE,/**< A line of credit */ OFX_CMA, /**< Cash Management Account */ OFX_CREDITCARD,/**< A credit card account */ OFX_INVESTMENT /**< An investment account */ } account_type; int account_type_valid; /** The currency is a string in ISO-4217 format */ char currency[OFX_CURRENCY_LENGTH]; int currency_valid; /** Corresponds to OFX */ char account_number[OFX_ACCTID_LENGTH]; int account_number_valid; /** Corresponds to OFX */ char bank_id[OFX_BANKID_LENGTH]; int bank_id_valid; char broker_id[OFX_BROKERID_LENGTH]; int broker_id_valid; char branch_id[OFX_BRANCHID_LENGTH]; int branch_id_valid; }; /** * \brief The callback function for the OfxAccountData stucture. * * The ofx_proc_account_cb event is always generated first, to allow * the application to create accounts or ask the user to match an * existing account before the ofx_proc_statement and * ofx_proc_transaction event are received. An OfxAccountData is * passed to this event. * Note however that this OfxAccountData structure will also be available as part of OfxStatementData structure passed to ofx_proc_statement event, as well as a pointer to an arbitrary data structure. */ typedef int (*LibofxProcAccountCallback)(const struct OfxAccountData data, void * account_data); /** * \brief An abstraction of a security, such as a stock, mutual fund, etc. * * The OfxSecurityData stucture is used to hols the securyty * information inside a OfxTransactionData struct for investment * transactions. */ struct OfxSecurityData { /** @name OFX mandatory elements * * The OFX spec defines the following elements as mandatory. The * associated variables should all contain valid data but you * should not trust the servers. Check if the associated *_valid * is true before using them. */ char unique_id[OFX_UNIQUE_ID_LENGTH]; /**< The id of the security being traded.*/ int unique_id_valid; char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH];/**< Usially "CUSIP" for FIs in north america*/ int unique_id_type_valid; char secname[OFX_SECNAME_LENGTH];/**< The full name of the security */ int secname_valid; /** @name OFX optional elements * The OFX spec defines the following elements as optional. If the associated *_valid is true, the corresponding element is present and the associated variable contains valid data. */ char ticker[OFX_TICKER_LENGTH];/**< The ticker symbol of the security */ int ticker_valid; double unitprice;/**< The price of each unit of the security, as of date_unitprice */ int unitprice_valid; time_t date_unitprice;/**< The date as of which the unit price was valid. */ int date_unitprice_valid; /** The currency is a string in ISO-4217 format. It overrides the one defined in the statement for the unit price */ char currency[OFX_CURRENCY_LENGTH]; int currency_valid; char memo[OFX_MEMO2_LENGTH];/**< Extra information not included in name */ int memo_valid; /** The currency is a string in ISO-4217 format. It overrides the one defined in the statement for the unit price */ char fiid[OFX_FIID_LENGTH]; int fiid_valid; };/* end struct OfxSecurityData */ /** * \brief The callback function for the OfxSecurityData stucture. * * An ofx_proc_security_cb event is generated for any securities * listed in the ofx file. It is generated after ofx_proc_statement * but before ofx_proc_transaction. It is meant to be used to allow * the client to create a new commodity or security (such as a new * stock type). Please note however that this information is * usually also available as part of each OfxtransactionData. An OfxSecurityData structure is passed to this event, as well as a pointer to an arbitrary data structure. */ typedef int (*LibofxProcSecurityCallback)(const struct OfxSecurityData data, void * security_data); typedef enum { OFX_CREDIT, /**< Generic credit */ OFX_DEBIT, /**< Generic debit */ OFX_INT, /**< Interest earned or paid (Note: Depends on signage of amount) */ OFX_DIV, /**< Dividend */ OFX_FEE, /**< FI fee */ OFX_SRVCHG, /**< Service charge */ OFX_DEP, /**< Deposit */ OFX_ATM, /**< ATM debit or credit (Note: Depends on signage of amount) */ OFX_POS, /**< Point of sale debit or credit (Note: Depends on signage of amount) */ OFX_XFER, /**< Transfer */ OFX_CHECK, /**< Check */ OFX_PAYMENT, /**< Electronic payment */ OFX_CASH, /**< Cash withdrawal */ OFX_DIRECTDEP, /**< Direct deposit */ OFX_DIRECTDEBIT,/**< Merchant initiated debit */ OFX_REPEATPMT, /**< Repeating payment/standing order */ OFX_OTHER /**< Somer other type of transaction */ } TransactionType; typedef enum { OFX_BUYDEBT, /**< Buy debt security */ OFX_BUYMF, /**< Buy mutual fund */ OFX_BUYOPT, /**< Buy option */ OFX_BUYOTHER, /**< Buy other security type */ OFX_BUYSTOCK, /**< Buy stock */ OFX_CLOSUREOPT, /**< Close a position for an option */ OFX_INCOME, /**< Investment income is realized as cash into the investment account */ OFX_INVEXPENSE, /**< Misc investment expense that is associated with a specific security */ OFX_JRNLFUND, /**< Journaling cash holdings between subaccounts within the same investment account */ OFX_JRNLSEC, /**< Journaling security holdings between subaccounts within the same investment account */ OFX_MARGININTEREST, /**< Margin interest expense */ OFX_REINVEST, /**< Reinvestment of income */ OFX_RETOFCAP, /**< Return of capital */ OFX_SELLDEBT, /**< Sell debt security. Used when debt is sold, called, or reached maturity */ OFX_SELLMF, /**< Sell mutual fund */ OFX_SELLOPT, /**< Sell option */ OFX_SELLOTHER, /**< Sell other type of security */ OFX_SELLSTOCK, /**< Sell stock */ OFX_SPLIT, /**< Stock or mutial fund split */ OFX_TRANSFER /**< Transfer holdings in and out of the investment account */ } InvTransactionType; typedef enum { DELETE, /**< The transaction with a fi_id matching fi_id_corrected should be deleted */ REPLACE /**< The transaction with a fi_id matching fi_id_corrected should be replaced with this one */ } FiIdCorrectionAction; /** * \brief An abstraction of a transaction in an account. * * The OfxTransactionData stucture contains all available * information about an actual transaction in an account. */ struct OfxTransactionData { /** @name OFX mandatory elements * The OFX spec defines the following elements as mandatory. The associated variables should all contain valid data but you should not trust the servers. Check if the associated *_valid is true before using them. */ char account_id[OFX_ACCOUNT_ID_LENGTH];/**< Use this for matching with the relevant account in your application */ struct OfxAccountData * account_ptr; /**< Pointer to the full account structure, see OfxAccountData */ int account_id_valid; TransactionType transactiontype; int transactiontype_valid; /**< Investment transaction type. You should read this if transactiontype == OFX_OTHER. See OFX spec 1.6 p.442 to 445 for details*/ InvTransactionType invtransactiontype; int invtransactiontype_valid; /** Variation of the number of units of the commodity Suppose units is -10, ave unitprice is 1. If the commodity is stock, you have 10 less stock, but 10 more dollars in you amccount (fees not considered, see amount). If commodity is money, you have 10 less dollars in your pocket, but 10 more in your account */ double units; int units_valid; double unitprice; /**< Value of each unit, 1.00 if the commodity is money */ int unitprice_valid; double amount; /**< Total monetary amount of the transaction, signage will determine if money went in or out. amount is the total amount: -(units) * unitprice - various fees */ int amount_valid; char fi_id[256]; /**< Generated by the financial institution (fi), unique id of the transaction, to be used to detect duplicate downloads */ int fi_id_valid; /** @name OFX optional elements * The OFX spec defines the following elements as optional. If the associated *_valid is true, the corresponding element is present and the associated variable contains valid data. */ /** The id of the security being traded. Mandatory for investment transactions */ char unique_id[OFX_UNIQUE_ID_LENGTH]; int unique_id_valid; char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH];/**< Usially "CUSIP" for FIs in north america*/ int unique_id_type_valid; struct OfxSecurityData *security_data_ptr; /** A pointer to the security's data.*/ int security_data_valid; time_t date_posted;/**< Date the transaction took effect (ex: date it appeared on your credit card bill). Setlement date; for stock split, execution date. * Mandatory for bank and credit card transactions */ int date_posted_valid; time_t date_initiated;/**< Date the transaction was initiated (ex: date you bought something in a store for credit card; trade date for stocks; day of record for stock split) * Mandatory for investment transactions */ int date_initiated_valid; time_t date_funds_available;/**< Date the funds are available (not always provided) (ex: the date you are allowed to withdraw a deposit */ int date_funds_available_valid; /** IMPORTANT: if fi_id_corrected is present, this transaction is meant to replace or delete the transaction with this fi_id. See OfxTransactionData::fi_id_correction_action to know what to do. */ char fi_id_corrected[256]; int fi_id_corrected_valid; /** The OfxTransactionData::FiIdCorrectionAction enum contains the action to be taken */ FiIdCorrectionAction fi_id_correction_action; int fi_id_correction_action_valid; /** Used for user initiated transaction such as payment or funds transfer. Can be seen as a confirmation number. */ char server_transaction_id[OFX_SVRTID2_LENGTH]; int server_transaction_id_valid; /** The check number is most likely an integer and can probably be converted properly with atoi(). However the spec allows for up to 12 digits, so it is not garanteed to work */ char check_number[OFX_CHECK_NUMBER_LENGTH]; int check_number_valid; /** Might present in addition to or instead of a check_number. Not necessarily a number */ char reference_number[OFX_REFERENCE_NUMBER_LENGTH]; int reference_number_valid; long int standard_industrial_code;/**< The standard industrial code can have at most 6 digits */ int standard_industrial_code_valid; char payee_id[OFX_SVRTID2_LENGTH];/**< The identifier of the payee */ int payee_id_valid; char name[OFX_TRANSACTION_NAME_LENGTH];/**< Can be the name of the payee or the description of the transaction */ int name_valid; char memo[OFX_MEMO2_LENGTH];/**< Extra information not included in name */ int memo_valid; double commission;/**< Commission paid to broker (investment transactions only) */ int commission_valid; double fees;/**< Fees applied to trade (investment transactions only) */ int fees_valid; double oldunits; /*number of units held before stock split */ int oldunits_valid; double newunits; /*number of units held after stock split */ int newunits_valid; /*********** NOT YET COMPLETE!!! *********************/ }; /** * \brief The callback function for the OfxTransactionData stucture. * * An ofx_proc_transaction_cb event is generated for every * transaction in the ofx response, after ofx_proc_statement (and * possibly ofx_proc_security is generated. An OfxTransactionData * structure is passed to this event, as well as a pointer to an * arbitrary data structure. */ typedef int (*LibofxProcTransactionCallback)(const struct OfxTransactionData data, void * transaction_data); /** * \brief An abstraction of an account statement. * * The OfxStatementData structure contains information about your * account at the time the ofx response was generated, including the * balance. A client should check that the total of his recorded * transactions matches the total given here, and warn the user if * they dont. */ struct OfxStatementData { /** @name OFX mandatory elements * The OFX spec defines the following elements as mandatory. The associated variables should all contain valid data but you should not trust the servers. Check if the associated *_valid is true before using them. */ char currency[OFX_CURRENCY_LENGTH]; /**< The currency is a string in ISO-4217 format */ int currency_valid; char account_id[OFX_ACCOUNT_ID_LENGTH];/**< Use this for matching this statement with the relevant account in your application */ struct OfxAccountData * account_ptr; /**< Pointer to the full account structure, see OfxAccountData */ int account_id_valid; /** The actual balance, according to the FI. The user should be warned of any discrepency between this and the balance in the application */ double ledger_balance; int ledger_balance_valid; time_t ledger_balance_date;/**< Time of the ledger_balance snapshot */ int ledger_balance_date_valid; /** @name OFX optional elements * The OFX spec defines the following elements as optional. If the associated *_valid is true, the corresponding element is present and the associated variable contains valid data. */ double available_balance; /**< Amount of money available from the account. Could be the credit left for a credit card, or amount that can be withdrawn using INTERAC) */ int available_balance_valid; time_t available_balance_date;/** Time of the available_balance snapshot */ int available_balance_date_valid; /** The start time of this statement. * All the transactions between date_start and date_end should have been provided */ time_t date_start; int date_start_valid; /** The end time of this statement. * If provided, the user can use this date as the start date of his next statement request. He is then assured not to miss any transactions. */ time_t date_end; int date_end_valid; /** marketing_info could be special offers or messages from the bank, or just about anything else */ char marketing_info[OFX_MARKETING_INFO_LENGTH]; int marketing_info_valid; }; /** * \brief The callback function for the OfxStatementData stucture. * * The ofx_proc_statement_cb event is sent after all ofx_proc_transaction events have been sent. An OfxStatementData is passed to this event, as well as a pointer to an arbitrary data structure. */ typedef int (*LibofxProcStatementCallback)(const struct OfxStatementData data, void * statement_data); /** \brief NOT YET SUPPORTED */ struct OfxCurrency { char currency[OFX_CURRENCY_LENGTH]; /**< Currency in ISO-4217 format */ double exchange_rate; /**< Exchange rate from the normal currency of the account */ int must_convert; /**< true or false */ }; /** * Set the status callback in the given context. * @param ctx context * @param cb callback function * @param user_data user data to be passed to the callback */ void ofx_set_status_cb(LibofxContextPtr ctx, LibofxProcStatusCallback cb, void *user_data); /** * Set the account callback in the given context. * @param ctx context * @param cb callback function * @param user_data user data to be passed to the callback */ void ofx_set_account_cb(LibofxContextPtr ctx, LibofxProcAccountCallback cb, void *user_data); /** * Set the security callback in the given context. * @param ctx context * @param cb callback function * @param user_data user data to be passed to the callback */ void ofx_set_security_cb(LibofxContextPtr ctx, LibofxProcSecurityCallback cb, void *user_data); /** * Set the transaction callback in the given context. * @param ctx context * @param cb callback function * @param user_data user data to be passed to the callback */ void ofx_set_transaction_cb(LibofxContextPtr ctx, LibofxProcTransactionCallback cb, void *user_data); /** * Set the statement callback in the given context. * @param ctx context * @param cb callback function * @param user_data user data to be passed to the callback */ void ofx_set_statement_cb(LibofxContextPtr ctx, LibofxProcStatementCallback cb, void *user_data); /** * Parses the content of the given buffer. */ int libofx_proc_buffer(LibofxContextPtr ctx, const char *s, unsigned int size); /* **************************************** */ /** @name Creating OFX Files * * This group deals with creating OFX files */ //@{ /** * \brief Information returned by the OFX Partner Server about a financial institution */ struct OfxFiServiceInfo { char fid[OFX_FID_LENGTH]; char org[OFX_ORG_LENGTH]; char url[OFX_URL_LENGTH]; int accountlist; /**< Whether the FI makes a list of accounts available */ int statements; /**< Whether the FI supports online statement download */ int billpay; /**< Whether the FI supports online bill payment */ int investments; /**< Whether the FI supports investments */ }; /** * \brief Information sufficient to log into an financial institution * * Contains all the info needed for a user to log into a financial * institution and make requests for statements or post transactions. * An OfxFiLogin must be passed to all functions which create OFX * requests. */ struct OfxFiLogin { char fid[OFX_FID_LENGTH]; char org[OFX_ORG_LENGTH]; char userid[OFX_USERID_LENGTH]; char userpass[OFX_USERPASS_LENGTH]; char header_version[OFX_HEADERVERSION_LENGTH]; char appid[OFX_APPID_LENGTH]; char appver[OFX_APPVER_LENGTH]; char clientuid[OFX_CLIENTUID_LENGTH]; }; #define OFX_AMOUNT_LENGTH (32 + 1) #define OFX_PAYACCT_LENGTH (32 + 1) #define OFX_STATE_LENGTH (5 + 1) #define OFX_POSTALCODE_LENGTH (11 + 1) #define OFX_NAME_LENGTH (32 + 1) struct OfxPayment { char amount[OFX_AMOUNT_LENGTH]; char account[OFX_PAYACCT_LENGTH]; char datedue[9]; char memo[OFX_MEMO_LENGTH]; }; struct OfxPayee { char name[OFX_NAME_LENGTH]; char address1[OFX_NAME_LENGTH]; char city[OFX_NAME_LENGTH]; char state[OFX_STATE_LENGTH]; char postalcode[OFX_POSTALCODE_LENGTH]; char phone[OFX_NAME_LENGTH]; }; /** * \brief Creates an OFX statement request in string form * * Creates a string which should be passed to an OFX server. This string is * an OFX request suitable to retrieve a statement for the @p account from the * @p fi * * @param fi Identifies the financial institution and the user logging in. * @param account Idenfities the account for which a statement is desired * @return string pointer to the request. This is allocated via malloc(), and is the callers responsibility to free. */ char* libofx_request_statement( const struct OfxFiLogin* fi, const struct OfxAccountData* account, time_t date_from ); /** * \brief Creates an OFX account info (list) request in string form * * Creates a string which should be passed to an OFX server. This string is * an OFX request suitable to retrieve a list of accounts from the * @p fi * * @param fi Identifies the financial institution and the user logging in. * @return string pointer to the request. This is allocated via malloc(), and is the callers responsibility to free. */ char* libofx_request_accountinfo( const struct OfxFiLogin* login ); char* libofx_request_payment( const struct OfxFiLogin* login, const struct OfxAccountData* account, const struct OfxPayee* payee, const struct OfxPayment* payment ); char* libofx_request_payment_status( const struct OfxFiLogin* login, const char* transactionid ); //@} extern int ofx_PARSER_msg; /**< If set to true, parser events will be printed to the console */ extern int ofx_DEBUG_msg;/**< If set to true, general debug messages will be printed to the console */ extern int ofx_DEBUG1_msg;/**< If set to true, debug level 1 messages will be printed to the console */ extern int ofx_DEBUG2_msg;/**< If set to true, debug level 2 messages will be printed to the console */ extern int ofx_DEBUG3_msg;/**< If set to true, debug level 3 messages will be printed to the console */ extern int ofx_DEBUG4_msg;/**< If set to true, debug level 4 messages will be printed to the console */ extern int ofx_DEBUG5_msg;/**< If set to true, debug level 5 messages will be printed to the console */ extern int ofx_STATUS_msg;/**< If set to true, status messages will be printed to the console */ extern int ofx_INFO_msg;/**< If set to true, information messages will be printed to the console */ extern int ofx_WARNING_msg;/**< If set to true, warning messages will be printed to the console */ extern int ofx_ERROR_msg;/**< If set to true, error messages will be printed to the console */ extern int ofx_show_position;/**< If set to true, the line number will be shown after any error */ #ifdef __cplusplus } // end of extern "C" #endif #if defined(HAVE_GCC_VISIBILITY_EXTS) && defined(IN_LIBOFX) # pragma GCC visibility pop #endif #endif // end of LIBOFX_H libofx-0.9.12/lib/000077500000000000000000000000001315754341700136465ustar00rootroot00000000000000libofx-0.9.12/lib/.gitignore000066400000000000000000000000571315754341700156400ustar00rootroot00000000000000*.la *.lo *.o .deps .libs Makefile Makefile.in libofx-0.9.12/lib/Makefile.am000066400000000000000000000022601315754341700157020ustar00rootroot00000000000000lib_LTLIBRARIES = libofx.la EXTRA_DIST = gnugetopt.h getopt.c getopt1.c libofx_la_SOURCES = messages.cpp \ ofx_utilities.cpp \ file_preproc.cpp \ context.cpp \ ofx_preproc.cpp \ ofx_container_generic.cpp \ ofx_container_main.cpp \ ofx_container_security.cpp \ ofx_container_statement.cpp \ ofx_container_account.cpp \ ofx_container_transaction.cpp \ ofx_containers_misc.cpp \ ofx_request.cpp \ ofx_request_accountinfo.cpp \ ofx_request_statement.cpp \ ofx_sgml.cpp \ ofc_sgml.cpp \ win32.cpp noinst_HEADERS = ${top_builddir}/inc/libofx.h \ messages.hh \ ofx_preproc.hh \ file_preproc.hh \ context.hh \ ofx_sgml.hh \ ofc_sgml.hh \ ofx_aggregate.hh \ ofx_error_msg.hh \ ofx_containers.hh \ ofx_request.hh \ ofx_request_accountinfo.hh \ ofx_request_statement.hh \ ofx_utilities.hh \ tree.hh \ win32.hh AM_CPPFLAGS = \ -I. \ -I${top_builddir}/inc \ -I${OPENSPINCLUDES} \ -DMAKEFILE_DTD_PATH=\"${LIBOFX_DTD_DIR}\" #libofx_la_LIBADD = @LIBOBJS@ ${OPENSPLIBS} -lstdc++ libofx_la_LIBADD = $(OPENSPLIBS) $(ICONV_LIBS) -lstdc++ libofx_la_LDFLAGS = -no-undefined -version-info @LIBOFX_SO_CURRENT@:@LIBOFX_SO_REVISION@:@LIBOFX_SO_AGE@ libofx-0.9.12/lib/context.cpp000066400000000000000000000110241315754341700160340ustar00rootroot00000000000000/**@file libofx_context.hh @brief Main state object passed everywhere in the library @author (C) 2004 by Benoit Gr�goire */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include "context.hh" using namespace std; LibofxContext::LibofxContext() : _current_file_type(OFX) , _statusCallback(0) , _accountCallback(0) , _securityCallback(0) , _transactionCallback(0) , _statementCallback(0) , _statementData(0) , _accountData(0) , _transactionData(0) , _securityData(0) , _statusData(0) { } LibofxContext::~LibofxContext() { } LibofxFileFormat LibofxContext::currentFileType() const { return _current_file_type; } void LibofxContext::setCurrentFileType(LibofxFileFormat t) { _current_file_type = t; } int LibofxContext::statementCallback(const struct OfxStatementData data) { if (_statementCallback) return _statementCallback(data, _statementData); return 0; } int LibofxContext::accountCallback(const struct OfxAccountData data) { if (_accountCallback) return _accountCallback(data, _accountData); return 0; } int LibofxContext::transactionCallback(const struct OfxTransactionData data) { if (_transactionCallback) return _transactionCallback(data, _transactionData); return 0; } int LibofxContext::securityCallback(const struct OfxSecurityData data) { if (_securityCallback) return _securityCallback(data, _securityData); return 0; } int LibofxContext::statusCallback(const struct OfxStatusData data) { if (_statusCallback) return _statusCallback(data, _statusData); return 0; } void LibofxContext::setStatusCallback(LibofxProcStatusCallback cb, void *user_data) { _statusCallback = cb; _statusData = user_data; } void LibofxContext::setAccountCallback(LibofxProcAccountCallback cb, void *user_data) { _accountCallback = cb; _accountData = user_data; } void LibofxContext::setSecurityCallback(LibofxProcSecurityCallback cb, void *user_data) { _securityCallback = cb; _securityData = user_data; } void LibofxContext::setTransactionCallback(LibofxProcTransactionCallback cb, void *user_data) { _transactionCallback = cb; _transactionData = user_data; } void LibofxContext::setStatementCallback(LibofxProcStatementCallback cb, void *user_data) { _statementCallback = cb; _statementData = user_data; } /** @note: Actual object returned is LibofxContext * */ LibofxContextPtr libofx_get_new_context() { return new LibofxContext(); } int libofx_free_context( LibofxContextPtr libofx_context_param) { delete (LibofxContext *)libofx_context_param; return 0; } void libofx_set_dtd_dir(LibofxContextPtr libofx_context, const char *s) { ((LibofxContext*)libofx_context)->setDtdDir(s); } extern "C" { void ofx_set_status_cb(LibofxContextPtr ctx, LibofxProcStatusCallback cb, void *user_data) { ((LibofxContext*)ctx)->setStatusCallback(cb, user_data); } void ofx_set_account_cb(LibofxContextPtr ctx, LibofxProcAccountCallback cb, void *user_data) { ((LibofxContext*)ctx)->setAccountCallback(cb, user_data); } void ofx_set_security_cb(LibofxContextPtr ctx, LibofxProcSecurityCallback cb, void *user_data) { ((LibofxContext*)ctx)->setSecurityCallback(cb, user_data); } void ofx_set_transaction_cb(LibofxContextPtr ctx, LibofxProcTransactionCallback cb, void *user_data) { ((LibofxContext*)ctx)->setTransactionCallback(cb, user_data); } void ofx_set_statement_cb(LibofxContextPtr ctx, LibofxProcStatementCallback cb, void *user_data) { ((LibofxContext*)ctx)->setStatementCallback(cb, user_data); } } libofx-0.9.12/lib/context.hh000066400000000000000000000045211315754341700156550ustar00rootroot00000000000000/**@file libofx_context.hh @brief Main state object passed everywhere in the library @author (C) 2004 by Benoit Grégoire */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef CONTEXT_H #define CONTEXT_H #include #include // for time_t #include "libofx.h" #include "ParserEventGeneratorKit.h" #include using namespace std; class LibofxContext { private: LibofxFileFormat _current_file_type; LibofxProcStatusCallback _statusCallback; LibofxProcAccountCallback _accountCallback; LibofxProcSecurityCallback _securityCallback; LibofxProcTransactionCallback _transactionCallback; LibofxProcStatementCallback _statementCallback; void * _statementData; void * _accountData; void * _transactionData; void * _securityData; void * _statusData; std::string _dtdDir; public: LibofxContext(); ~LibofxContext(); LibofxFileFormat currentFileType() const; void setCurrentFileType(LibofxFileFormat t); const std::string &dtdDir() const { return _dtdDir; }; void setDtdDir(const std::string &s) { _dtdDir = s; }; int statementCallback(const struct OfxStatementData data); int accountCallback(const struct OfxAccountData data); int transactionCallback(const struct OfxTransactionData data); int securityCallback(const struct OfxSecurityData data); int statusCallback(const struct OfxStatusData data); void setStatusCallback(LibofxProcStatusCallback cb, void *user_data); void setAccountCallback(LibofxProcAccountCallback cb, void *user_data); void setSecurityCallback(LibofxProcSecurityCallback cb, void *user_data); void setTransactionCallback(LibofxProcTransactionCallback cb, void *user_data); void setStatementCallback(LibofxProcStatementCallback cb, void *user_data); };//End class LibofxContext #endif libofx-0.9.12/lib/file_preproc.cpp000066400000000000000000000127601315754341700170310ustar00rootroot00000000000000/*************************************************************************** file_preproc.cpp ------------------- copyright : (C) 2004 by Benoit Grégoire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief File type detection, etc. * * Implements AutoDetection of file type, and handoff to specific parsers. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include #include #include #include #include "libofx.h" #include "messages.hh" #include "ofx_preproc.hh" #include "context.hh" #include "file_preproc.hh" using namespace std; const unsigned int READ_BUFFER_SIZE = 1024; /* get_file_type_description returns a string description of a LibofxFileType * suitable for debugging output or user communication. */ const char * libofx_get_file_format_description(const struct LibofxFileFormatInfo format_list[], enum LibofxFileFormat file_format) { const char * retval = "UNKNOWN (File format couldn't be successfully identified)"; for (int i = 0; LibofxImportFormatList[i].format != LAST; i++) { if (LibofxImportFormatList[i].format == file_format) { retval = LibofxImportFormatList[i].description; } } return retval; }; /* libofx_get_file_type returns a proper enum from a file type string. */ enum LibofxFileFormat libofx_get_file_format_from_str(const struct LibofxFileFormatInfo format_list[], const char * file_type_string) { enum LibofxFileFormat retval = UNKNOWN; for (int i = 0; LibofxImportFormatList[i].format != LAST; i++) { if (strcmp(LibofxImportFormatList[i].format_name, file_type_string) == 0) { retval = LibofxImportFormatList[i].format; } } return retval; } int libofx_proc_file(LibofxContextPtr p_libofx_context, const char * p_filename, LibofxFileFormat p_file_type) { LibofxContext * libofx_context = (LibofxContext *) p_libofx_context; if (p_file_type == AUTODETECT) { message_out(INFO, string("libofx_proc_file(): File format not specified, autodetecting...")); libofx_context->setCurrentFileType(libofx_detect_file_type(p_filename)); message_out(INFO, string("libofx_proc_file(): Detected file format: ") + libofx_get_file_format_description(LibofxImportFormatList, libofx_context->currentFileType() )); } else { libofx_context->setCurrentFileType(libofx_detect_file_type(p_filename)); message_out(INFO, string("libofx_proc_file(): File format forced to: ") + libofx_get_file_format_description(LibofxImportFormatList, libofx_context->currentFileType() )); } switch (libofx_context->currentFileType()) { case OFX: ofx_proc_file(libofx_context, p_filename); break; case OFC: ofx_proc_file(libofx_context, p_filename); break; default: message_out(ERROR, string("libofx_proc_file(): Detected file format not yet supported ou couldn't detect file format; aborting.")); } return 0; } enum LibofxFileFormat libofx_detect_file_type(const char * p_filename) { enum LibofxFileFormat retval = UNKNOWN; ifstream input_file; char buffer[READ_BUFFER_SIZE]; string s_buffer; bool type_found = false; if (p_filename != NULL && strcmp(p_filename, "") != 0) { message_out(DEBUG, string("libofx_detect_file_type():Opening file: ") + p_filename); input_file.open(p_filename); if (!input_file) { message_out(ERROR, "libofx_detect_file_type():Unable to open the input file " + string(p_filename)); return retval; } else { do { input_file.getline(buffer, sizeof(buffer), '\n'); //cout<") != string::npos || s_buffer.find("") != string::npos) { message_out(DEBUG, "libofx_detect_file_type(): tag has been found"); retval = OFX; type_found = true; } else if (s_buffer.find("") != string::npos || s_buffer.find("") != string::npos) { message_out(DEBUG, "libofx_detect_file_type(): tag has been found"); retval = OFC; type_found = true; } } while (type_found == false && !input_file.eof() && !input_file.bad()); } input_file.close(); } else { message_out(ERROR, "libofx_detect_file_type(): No input file specified"); } if (retval == UNKNOWN) message_out(ERROR, "libofx_detect_file_type(): Failed to identify input file format"); return retval; } libofx-0.9.12/lib/file_preproc.hh000066400000000000000000000027721315754341700166500ustar00rootroot00000000000000/*************************************************************************** file_preproc.hh ------------------- copyright : (C) 2004 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Preprocessing of the OFX files before parsing * Implements the pre-treatement of the OFX file prior to parsing: OFX header striping, OFX proprietary tags and SGML comment striping, locating the appropriate DTD. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef FILE_PREPROC_H #define FILE_PREPROC_H /** * \brief libofx_detect_file_type tries to analyze a file to determine it's format. * @param p_filename File name of the file to process @return Detected file format, UNKNOWN if unsuccessfull. */ enum LibofxFileFormat libofx_detect_file_type(const char * p_filename); #endif libofx-0.9.12/lib/getopt.c000066400000000000000000000727031315754341700153250ustar00rootroot00000000000000/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO # define _NO_PROTO #endif #ifdef HAVE_CONFIG_H # include #endif #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 # include # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION # define ELIDE_CODE # endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ # include # include #endif /* GNU C library. */ #ifdef VMS # include # if HAVE_STRING_H - 0 # include # endif #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. */ # if defined HAVE_LIBINTL_H || defined _LIBC # include # ifndef _ # define _(msgid) gettext (msgid) # endif # else # define _(msgid) (msgid) # endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ # include # define my_index strchr #else # if HAVE_STRING_H # include # else # include # endif /* Avoid depending on library functions or files whose names are inconsistent. */ #ifndef getenv extern char *getenv (); #endif static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ # if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); # endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Stored original parameters. XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ extern int __libc_argc; extern char **__libc_argv; /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ # ifdef USE_NONOPTION_FLAGS /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; # endif # ifdef USE_NONOPTION_FLAGS # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } # else # define SWAP_FLAGS(ch1, ch2) # endif #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined __STDC__ && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #if defined _LIBC && defined USE_NONOPTION_FLAGS /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memset (__mempcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len), '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined __STDC__ && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #if defined _LIBC && defined USE_NONOPTION_FLAGS if (posixly_correct == NULL && argc == __libc_argc && argv == __libc_argv) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), '\0', nonoption_flags_max_len - len); } } nonoption_flags_len = nonoption_flags_max_len; } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int print_errors = opterr; if (optstring[0] == ':') print_errors = 0; if (argc < 1) return -1; optarg = NULL; if (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #if defined _LIBC && defined USE_NONOPTION_FLAGS # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && __getopt_nonoption_flags[optind] == '1')) #else # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (print_errors) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (print_errors) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ libofx-0.9.12/lib/getopt1.c000066400000000000000000000106501315754341700153770ustar00rootroot00000000000000/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifdef HAVE_CONFIG_H #include #endif #include "getopt.h" #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #endif /* Not ELIDE_CODE. */ #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == -1) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case 'd': printf ("option d with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ libofx-0.9.12/lib/gnugetopt.h000066400000000000000000000144571315754341700160460ustar00rootroot00000000000000/* Declarations for getopt. Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but that does not exist if we are standalone. So: if __GNU_LIBRARY__ is not defined, include , which will pull in for us if it's from glibc. (Why ctype.h? It's guaranteed to exist and it doesn't flood the namespace with stuff the way some other headers do.) */ #if !defined __GNU_LIBRARY__ # include #endif #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if (defined __STDC__ && __STDC__) || defined __cplusplus const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if (defined __STDC__ && __STDC__) || defined __cplusplus # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int __argc, char *const *__argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* getopt.h */ libofx-0.9.12/lib/messages.cpp000066400000000000000000000115721315754341700161670ustar00rootroot00000000000000/*************************************************************************** ofx_messages.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Message IO functionality */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include #include #include "ParserEventGeneratorKit.h" #include "ofx_utilities.hh" #include "messages.hh" #include "config.h" #include "libofx.h" SGMLApplication::OpenEntityPtr entity_ptr; /**< Global for determining the line number in OpenSP */ SGMLApplication::Position position; /**< Global for determining the line number in OpenSP */ int ofx_PARSER_msg = false; /**< If set to true, parser events will be printed to the console */ int ofx_DEBUG_msg = false;/**< If set to true, general debug messages will be printed to the console */ int ofx_DEBUG1_msg = false;/**< If set to true, debug level 1 messages will be printed to the console */ int ofx_DEBUG2_msg = false;/**< If set to true, debug level 2 messages will be printed to the console */ int ofx_DEBUG3_msg = false;/**< If set to true, debug level 3 messages will be printed to the console */ int ofx_DEBUG4_msg = false;/**< If set to true, debug level 4 messages will be printed to the console */ int ofx_DEBUG5_msg = false;/**< If set to true, debug level 5 messages will be printed to the console */ int ofx_STATUS_msg = false;/**< If set to true, status messages will be printed to the console */ int ofx_INFO_msg = false;/**< If set to true, information messages will be printed to the console */ int ofx_WARNING_msg = false;/**< If set to true, warning messages will be printed to the console */ int ofx_ERROR_msg = false;/**< If set to true, error messages will be printed to the console */ int ofx_show_position = true;/**< If set to true, the line number will be shown after any error */ void show_line_number() { extern SGMLApplication::OpenEntityPtr entity_ptr; extern SGMLApplication::Position position; if (ofx_show_position == true) { SGMLApplication::Location *location = new SGMLApplication::Location(entity_ptr, position); cerr << "(Above message occurred on Line " << location->lineNumber << ", Column " << location->columnNumber << ")" << endl; delete location; } } /** Prints a message to stdout, if the corresponding message OfxMsgType given in the parameters is enabled */ int message_out(OfxMsgType error_type, const string message) { switch (error_type) { case DEBUG : if (ofx_DEBUG_msg == true) { cerr << "LibOFX DEBUG: " << message << "\n"; show_line_number(); } break; case DEBUG1 : if (ofx_DEBUG1_msg == true) { cerr << "LibOFX DEBUG1: " << message << "\n"; show_line_number(); } break; case DEBUG2 : if (ofx_DEBUG2_msg == true) { cerr << "LibOFX DEBUG2: " << message << "\n"; show_line_number(); } break; case DEBUG3 : if (ofx_DEBUG3_msg == true) { cerr << "LibOFX DEBUG3: " << message << "\n"; show_line_number(); } break; case DEBUG4 : if (ofx_DEBUG4_msg == true) { cerr << "LibOFX DEBUG4: " << message << "\n"; show_line_number(); } break; case DEBUG5 : if (ofx_DEBUG5_msg == true) { cerr << "LibOFX DEBUG5: " << message << "\n"; show_line_number(); } break; case STATUS : if (ofx_STATUS_msg == true) { cerr << "LibOFX STATUS: " << message << "\n"; show_line_number(); } break; case INFO : if (ofx_INFO_msg == true) { cerr << "LibOFX INFO: " << message << "\n"; show_line_number(); } break; case WARNING : if (ofx_WARNING_msg == true) { cerr << "LibOFX WARNING: " << message << "\n"; show_line_number(); } break; case ERROR : if (ofx_ERROR_msg == true) { cerr << "LibOFX ERROR: " << message << "\n"; show_line_number(); } break; case PARSER : if (ofx_PARSER_msg == true) { cerr << "LibOFX PARSER: " << message << "\n"; show_line_number(); } break; default: cerr << "LibOFX UNKNOWN ERROR CLASS, This is a bug in LibOFX\n"; show_line_number(); } return 0; } libofx-0.9.12/lib/messages.hh000066400000000000000000000034201315754341700157750ustar00rootroot00000000000000/*************************************************************************** ofx_messages.h ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Message IO functionality */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_MESSAGES_H #define OFX_MESSAGES_H /** The OfxMsgType enum describe's the type of message being sent, so the application/user/library can decide if it will be printed to stdout */ enum OfxMsgType { DEBUG, /**< General debug messages */ DEBUG1, /**< Debug level 1 */ DEBUG2, /**< Debug level 2 */ DEBUG3, /**< Debug level 3 */ DEBUG4, /**< Debug level 4 */ DEBUG5, /**< Debug level 5 */ STATUS = 10, /**< For major processing event (End of parsing, etc.) */ INFO, /**< For minor processing event */ WARNING, /**< Warning message */ ERROR, /**< Error message */ PARSER /**< Parser events */ }; using namespace std; /// Message output function int message_out(OfxMsgType type, const string message); #endif libofx-0.9.12/lib/ofc_sgml.cpp000066400000000000000000000341401315754341700161450ustar00rootroot00000000000000/*************************************************************************** ofx_sgml.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file \brief OFX/SGML parsing functionnality. * Almost all of the SGML parser specific code is contained in this file (some is in messages.cpp and ofx_utilities.cpp). To understand this file you must read the documentation of OpenSP's generic interface: see http://openjade.sourceforge.net/ */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "ParserEventGeneratorKit.h" #include "libofx.h" #include "ofx_utilities.hh" #include "messages.hh" #include "ofx_containers.hh" #include "ofc_sgml.hh" using namespace std; extern SGMLApplication::OpenEntityPtr entity_ptr; extern SGMLApplication::Position position; extern OfxMainContainer * MainContainer; /** \brief This object is driven by OpenSP as it parses the SGML from the ofx file(s) */ class OFCApplication : public SGMLApplication { private: OfxGenericContainer *curr_container_element; /**< The currently open object from ofx_proc_rs.cpp */ OfxGenericContainer *tmp_container_element; bool is_data_element; /**< If the SGML element contains data, this flag is raised */ string incoming_data; /**< The raw data from the SGML data element */ LibofxContext * libofx_context; public: OFCApplication (LibofxContext * p_libofx_context) { MainContainer = NULL; curr_container_element = NULL; is_data_element = false; libofx_context = p_libofx_context; } /** \brief Callback: Start of an OFX element * An OpenSP callback, get's called when the opening tag of an OFX element appears in the file */ void startElement (const StartElementEvent & event) { string identifier; CharStringtostring (event.gi, identifier); message_out(PARSER, "startElement event received from OpenSP for element " + identifier); position = event.pos; switch (event.contentType) { case StartElementEvent::empty: message_out(ERROR, "StartElementEvent::empty\n"); break; case StartElementEvent::cdata: message_out(ERROR, "StartElementEvent::cdata\n"); break; case StartElementEvent::rcdata: message_out(ERROR, "StartElementEvent::rcdata\n"); break; case StartElementEvent::mixed: message_out(PARSER, "StartElementEvent::mixed"); is_data_element = true; break; case StartElementEvent::element: message_out(PARSER, "StartElementEvent::element"); is_data_element = false; break; default: message_out(ERROR, "Unknown SGML content type?!?!?!? OpenSP interface changed?"); } if (is_data_element == false) { /*------- The following are OFC entities ---------------*/ if (identifier == "OFC") { message_out (PARSER, "Element " + identifier + " found"); MainContainer = new OfxMainContainer (libofx_context, curr_container_element, identifier); curr_container_element = MainContainer; } else if (identifier == "STATUS") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxStatusContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "ACCTSTMT") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxStatementContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "STMTRS") { message_out (PARSER, "Element " + identifier + " found"); //STMTRS ignored, we will process it's attributes directly inside the STATEMENT, if (curr_container_element->type != "STATEMENT") { message_out(ERROR, "Element " + identifier + " found while not inside a STATEMENT container"); } else { curr_container_element = new OfxPushUpContainer (libofx_context, curr_container_element, identifier); } } else if (identifier == "GENTRN" || identifier == "STMTTRN") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxBankTransactionContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "BUYDEBT" || identifier == "BUYMF" || identifier == "BUYOPT" || identifier == "BUYOTHER" || identifier == "BUYSTOCK" || identifier == "CLOSUREOPT" || identifier == "INCOME" || identifier == "INVEXPENSE" || identifier == "JRNLFUND" || identifier == "JRNLSEC" || identifier == "MARGININTEREST" || identifier == "REINVEST" || identifier == "RETOFCAP" || identifier == "SELLDEBT" || identifier == "SELLMF" || identifier == "SELLOPT" || identifier == "SELLOTHER" || identifier == "SELLSTOCK" || identifier == "SPLIT" || identifier == "TRANSFER" ) { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxInvestmentTransactionContainer (libofx_context, curr_container_element, identifier); } /*The following is a list of OFX elements whose attributes will be processed by the parent container*/ else if (identifier == "INVBUY" || identifier == "INVSELL" || identifier == "INVTRAN" || identifier == "SECID") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxPushUpContainer (libofx_context, curr_container_element, identifier); } /* The different types of accounts */ else if (identifier == "ACCOUNT" || identifier == "ACCTFROM" ) { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxAccountContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "SECINFO") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxSecurityContainer (libofx_context, curr_container_element, identifier); } /* The different types of balances */ else if (identifier == "LEDGERBAL" || identifier == "AVAILBAL") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxBalanceContainer (libofx_context, curr_container_element, identifier); } else { /* We dont know this OFX element, so we create a dummy container */ curr_container_element = new OfxDummyContainer(libofx_context, curr_container_element, identifier); } } else { /* The element was a data element. OpenSP will call one or several data() callback with the data */ message_out (PARSER, "Data element " + identifier + " found"); /* There is a bug in OpenSP 1.3.4, which won't send endElement Event for some elements, and will instead send an error like "document type does not allow element "MESSAGE" here". Incoming_data should be empty in such a case, but it will not be if the endElement event was skiped. So we empty it, so at least the last element has a chance of having valid data */ if (incoming_data != "") { message_out (ERROR, "startElement: incoming_data should be empty! You are probably using OpenSP <= 1.3.4. The following data was lost: " + incoming_data ); incoming_data.assign (""); } } } /** \brief Callback: End of an OFX element * An OpenSP callback, get's called at the end of an OFX element (the closing tags are not always present in OFX) in the file. */ void endElement (const EndElementEvent & event) { string identifier; bool end_element_for_data_element; CharStringtostring (event.gi, identifier); end_element_for_data_element = is_data_element; message_out(PARSER, "endElement event received from OpenSP for element " + identifier); position = event.pos; if (curr_container_element == NULL) { message_out (ERROR, "Tried to close a " + identifier + " without a open element (NULL pointer)"); incoming_data.assign (""); } else //curr_container_element != NULL { if (end_element_for_data_element == true) { incoming_data = strip_whitespace(incoming_data); curr_container_element->add_attribute (identifier, incoming_data); message_out (PARSER, "endElement: Added data '" + incoming_data + "' from " + identifier + " to " + curr_container_element->type + " container_element"); incoming_data.assign (""); is_data_element = false; } else { if (identifier == curr_container_element->tag_identifier) { if (incoming_data != "") { message_out(ERROR, "End tag for non data element " + identifier + ", incoming data should be empty but contains: " + incoming_data + " DATA HAS BEEN LOST SOMEWHERE!"); } if (identifier == "OFX") { /* The main container is a special case */ tmp_container_element = curr_container_element; curr_container_element = curr_container_element->getparent (); MainContainer->gen_event(); delete MainContainer; MainContainer = NULL; message_out (DEBUG, "Element " + identifier + " closed, MainContainer destroyed"); } else { tmp_container_element = curr_container_element; curr_container_element = curr_container_element->getparent (); if (MainContainer != NULL) { tmp_container_element->add_to_main_tree(); message_out (PARSER, "Element " + identifier + " closed, object added to MainContainer"); } else { message_out (ERROR, "MainContainer is NULL trying to add element " + identifier); } } } else { message_out (ERROR, "Tried to close a " + identifier + " but a " + curr_container_element->type + " is currently open."); } } } } /** \brief Callback: Data from an OFX element * An OpenSP callback, get's called when the raw data of an OFX element appears in the file. Is usually called more than once for a single element, so we must concatenate the data. */ void data (const DataEvent & event) { string tmp; position = event.pos; AppendCharStringtostring (event.data, incoming_data); message_out(PARSER, "data event received from OpenSP, incoming_data is now: " + incoming_data); } /** \brief Callback: SGML parse error * An OpenSP callback, get's called when a parser error has occurred. */ void error (const ErrorEvent & event) { string message; string string_buf; OfxMsgType error_type = ERROR; position = event.pos; message = message + "OpenSP parser: "; switch (event.type) { case SGMLApplication::ErrorEvent::quantity: message = message + "quantity (Exceeding a quantity limit):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::idref: message = message + "idref (An IDREF to a non-existent ID):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::capacity: message = message + "capacity (Exceeding a capacity limit):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::otherError: message = message + "otherError (misc parse error):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::warning: message = message + "warning (Not actually an error.):"; error_type = WARNING; break; case SGMLApplication::ErrorEvent::info: message = message + "info (An informationnal message. Not actually an error):"; error_type = INFO; break; default: message = message + "OpenSP sent an unknown error to LibOFX (You probably have a newer version of OpenSP):"; } message = message + "\n" + CharStringtostring (event.message, string_buf); message_out (error_type, message); } /** \brief Callback: Receive internal OpenSP state * An Internal OpenSP callback, used to be able to generate line number. */ void openEntityChange (const OpenEntityPtr & para_entity_ptr) { message_out(DEBUG, "openEntityChange()\n"); entity_ptr = para_entity_ptr; }; private: }; /** ofc_proc_sgml will take a list of files in command line format. The first file must be the DTD, and then any number of OFX files. */ int ofc_proc_sgml(LibofxContext * libofx_context, int argc, char * const* argv) { message_out(DEBUG, "Begin ofx_proc_sgml()"); assert(argc >= 3); message_out(DEBUG, argv[0]); message_out(DEBUG, argv[1]); message_out(DEBUG, argv[2]); ParserEventGeneratorKit parserKit; parserKit.setOption (ParserEventGeneratorKit::showOpenEntities); EventGenerator *egp = parserKit.makeEventGenerator (argc, argv); egp->inhibitMessages (true); /* Error output is handled by libofx not OpenSP */ OFCApplication *app = new OFCApplication(libofx_context); unsigned nErrors = egp->run (*app); /* Begin parsing */ delete egp; return nErrors > 0; } libofx-0.9.12/lib/ofc_sgml.hh000066400000000000000000000023301315754341700157560ustar00rootroot00000000000000/*************************************************************************** ofx_sgml.h ------------------- begin : Tue Mar 19 2002 copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /** @file * \brief OFX/SGML parsing functionnality. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFC_SGML_H #define OFC_SGML_H #include "context.hh" ///Parses a DTD and OFX file(s) int ofc_proc_sgml(LibofxContext * libofx_context, int argc, char * const* argv); #endif libofx-0.9.12/lib/ofx_aggregate.hh000066400000000000000000000055161315754341700170000ustar00rootroot00000000000000/*************************************************************************** ofx_aggregate.hh ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Declaration of OfxAggregate which allows you to construct a single * OFX aggregate. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_AGGREGATE_H #define OFX_AGGREGATE_H #include using namespace std; /** * \brief A single aggregate as described in the OFX 1.02 specification * * This aggregate has a tag, and optionally a number of subordinate elements and aggregates. * * An example is: * * * 1234 * * Y * ACTIVE * */ class OfxAggregate { public: /** * Creates a new aggregate, using this tag * * @param tag The tag of this aggregate */ OfxAggregate( const string& tag ): m_tag( tag ) {} /** * Adds an element to this aggregate * * @param tag The tag of the element to be added * @param data The data of the element to be added */ void Add( const string& tag, const string& data ) { m_contents += string("<") + tag + string(">") + data + string("\r\n"); } /** * Adds a subordinate aggregate to this aggregate * * @param sub The aggregate to be added */ void Add( const OfxAggregate& sub ) { m_contents += sub.Output(); } /** * Composes this aggregate into a string * * @return string form of this aggregate */ string Output( void ) const { return string("<") + m_tag + string(">\r\n") + m_contents + string("\r\n"); } private: string m_tag; string m_contents; }; #endif // OFX_AGGREGATE_H libofx-0.9.12/lib/ofx_container_account.cpp000066400000000000000000000160341315754341700207300ustar00rootroot00000000000000/*************************************************************************** ofx_container_account.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Implementation of OfxAccountContainer for bank, credit card and investment accounts. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include "messages.hh" #include "libofx.h" #include "ofx_containers.hh" #include "ofx_utilities.hh" extern OfxMainContainer * MainContainer; /*************************************************************************** * OfxAccountContainer * ***************************************************************************/ OfxAccountContainer::OfxAccountContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { memset(&data, 0, sizeof(data)); type = "ACCOUNT"; strcpy(bankid, ""); strcpy(branchid, ""); strcpy(acctid, ""); strcpy(acctkey, ""); strcpy(brokerid, ""); if (para_tag_identifier == "CCACCTFROM") { /*Set the type for a creditcard account. Bank account specific OFX elements will set this attribute elsewhere */ data.account_type = data.OFX_CREDITCARD; data.account_type_valid = true; } if (para_tag_identifier == "INVACCTFROM") { /*Set the type for an investment account. Bank account specific OFX elements will set this attribute elsewhere */ data.account_type = data.OFX_INVESTMENT; data.account_type_valid = true; } if (parentcontainer != NULL && ((OfxStatementContainer*)parentcontainer)->data.currency_valid == true) { strncpy(data.currency, ((OfxStatementContainer*)parentcontainer)->data.currency, OFX_CURRENCY_LENGTH); /* In ISO-4217 format */ data.currency_valid = true; } } OfxAccountContainer::~OfxAccountContainer() { /* if (parentcontainer->type == "STATEMENT") { ((OfxStatementContainer*)parentcontainer)->add_account(data); } ofx_proc_account_cb (data);*/ } void OfxAccountContainer::add_attribute(const string identifier, const string value) { if ( identifier == "BANKID") { strncpy(bankid, value.c_str(), OFX_BANKID_LENGTH); data.bank_id_valid = true; strncpy(data.bank_id, value.c_str(), OFX_BANKID_LENGTH); } else if ( identifier == "BRANCHID") { strncpy(branchid, value.c_str(), OFX_BRANCHID_LENGTH); data.branch_id_valid = true; strncpy(data.branch_id, value.c_str(), OFX_BRANCHID_LENGTH); } else if ( identifier == "ACCTID") { strncpy(acctid, value.c_str(), OFX_ACCTID_LENGTH); data.account_number_valid = true; strncpy(data.account_number, value.c_str(), OFX_ACCTID_LENGTH); } else if ( identifier == "ACCTKEY") { strncpy(acctkey, value.c_str(), OFX_ACCTKEY_LENGTH); } else if ( identifier == "BROKERID") /* For investment accounts */ { strncpy(brokerid, value.c_str(), OFX_BROKERID_LENGTH); data.broker_id_valid = true; strncpy(data.broker_id, value.c_str(), OFX_BROKERID_LENGTH); } else if ((identifier == "ACCTTYPE") || (identifier == "ACCTTYPE2")) { data.account_type_valid = true; if (value == "CHECKING") { data.account_type = data.OFX_CHECKING; } else if (value == "SAVINGS") { data.account_type = data.OFX_SAVINGS; } else if (value == "MONEYMRKT") { data.account_type = data.OFX_MONEYMRKT; } else if (value == "CREDITLINE") { data.account_type = data.OFX_CREDITLINE; } else if (value == "CMA") { data.account_type = data.OFX_CMA; } /* AccountType CREDITCARD is set at object creation, if appropriate */ else { data.account_type_valid = false; } } else { /* Redirect unknown identifiers to the base class */ OfxGenericContainer::add_attribute(identifier, value); } }//end OfxAccountContainer::add_attribute() int OfxAccountContainer::gen_event() { libofx_context->accountCallback(data); return true; } int OfxAccountContainer::add_to_main_tree() { gen_account_id (); if (MainContainer != NULL) { return MainContainer->add_container(this); } else { return false; } } void OfxAccountContainer::gen_account_id(void) { if (data.account_type == OfxAccountData::OFX_CREDITCARD) { strncat(data.account_id, acctid, OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, " ", OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, acctkey, OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_name, "Credit card ", OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); strncat(data.account_name, acctid, OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); } else if (data.account_type == OfxAccountData::OFX_INVESTMENT) { strncat(data.account_id, brokerid, OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, " ", OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, acctid, OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_name, "Investment account ", OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); strncat(data.account_name, acctid, OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); strncat(data.account_name, " at broker ", OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); strncat(data.account_name, brokerid, OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); } else { strncat(data.account_id, bankid, OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, " ", OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, branchid, OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, " ", OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_id, acctid, OFX_ACCOUNT_ID_LENGTH - strlen(data.account_id)); strncat(data.account_name, "Bank account ", OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); strncat(data.account_name, acctid, OFX_ACCOUNT_NAME_LENGTH - strlen(data.account_name)); } //if (strlen(data.account_id) >= 0) // The strlen() is always non-negative { data.account_id_valid = true; } }//end OfxAccountContainer::gen_account_id() libofx-0.9.12/lib/ofx_container_generic.cpp000066400000000000000000000055731315754341700207160ustar00rootroot00000000000000/*************************************************************************** ofx_container_generic.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Implementation of OfxGenericContainer */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include "ParserEventGeneratorKit.h" #include "messages.hh" #include "libofx.h" #include "ofx_containers.hh" extern OfxMainContainer * MainContainer; OfxGenericContainer::OfxGenericContainer(LibofxContext *p_libofx_context) { parentcontainer = NULL; type = ""; tag_identifier = ""; libofx_context = p_libofx_context; } OfxGenericContainer::OfxGenericContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer) { libofx_context = p_libofx_context; parentcontainer = para_parentcontainer; if (parentcontainer != NULL && parentcontainer->type == "DUMMY") { message_out(DEBUG, "OfxGenericContainer(): The parent is a DummyContainer!"); } } OfxGenericContainer::OfxGenericContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier) { libofx_context = p_libofx_context; parentcontainer = para_parentcontainer; tag_identifier = para_tag_identifier; if (parentcontainer != NULL && parentcontainer->type == "DUMMY") { message_out(DEBUG, "OfxGenericContainer(): The parent for this " + tag_identifier + " is a DummyContainer!"); } } void OfxGenericContainer::add_attribute(const string identifier, const string value) { /*If an attribute has made it all the way up to the Generic Container's add_attribute, we don't know what to do with it! */ message_out(ERROR, "WRITEME: " + identifier + " (" + value + ") is not supported by the " + type + " container"); } OfxGenericContainer* OfxGenericContainer::getparent() { return parentcontainer; } int OfxGenericContainer::gen_event() { /* No callback is ever generated for pure virtual containers */ return false; } int OfxGenericContainer::add_to_main_tree() { if (MainContainer != NULL) { return MainContainer->add_container(this); } else { return false; } } libofx-0.9.12/lib/ofx_container_main.cpp000066400000000000000000000150741315754341700202230ustar00rootroot00000000000000/*************************************************************************** ofx_container_main.cpp ------------------- copyright : (C) 2002 by Benoit Grégoire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Implementation of OfxMainContainer */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "ParserEventGeneratorKit.h" #include "messages.hh" #include "libofx.h" #include "ofx_containers.hh" OfxMainContainer::OfxMainContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { //statement_tree_top=statement_tree.insert(statement_tree_top, NULL); //security_tree_top=security_tree.insert(security_tree_top, NULL); } OfxMainContainer::~OfxMainContainer() { message_out(DEBUG, "Entering the main container's destructor"); tree::iterator tmp = security_tree.begin(); while (tmp != security_tree.end()) { message_out(DEBUG, "Deleting " + (*tmp)->type); delete (*tmp); ++tmp; } tmp = account_tree.begin(); while (tmp != account_tree.end()) { message_out(DEBUG, "Deleting " + (*tmp)->type); delete (*tmp); ++tmp; } } int OfxMainContainer::add_container(OfxGenericContainer * container) { message_out(DEBUG, "OfxMainContainer::add_container for element " + container->tag_identifier + "; destroying the generic container"); /* Call gen_event anyway, it could be a status container or similar */ container->gen_event(); delete container; return 0; } int OfxMainContainer::add_container(OfxSecurityContainer * container) { message_out(DEBUG, "OfxMainContainer::add_container, adding a security"); security_tree.insert(security_tree.begin(), container); return true; } int OfxMainContainer::add_container(OfxAccountContainer * container) { message_out(DEBUG, "OfxMainContainer::add_container, adding an account"); if ( account_tree.size() == 0) { message_out(DEBUG, "OfxMainContainer::add_container, account is the first account"); account_tree.insert(account_tree.begin(), container); } else { message_out(DEBUG, "OfxMainContainer::add_container, account is not the first account"); tree::sibling_iterator tmp = account_tree.begin(); tmp += (account_tree.number_of_siblings(tmp)); //Find last account account_tree.insert_after(tmp, container); } return true; } int OfxMainContainer::add_container(OfxStatementContainer * container) { message_out(DEBUG, "OfxMainContainer::add_container, adding a statement"); tree::sibling_iterator tmp = account_tree.begin(); //cerr<< "size="<::iterator child = account_tree.begin(tmp); if (account_tree.number_of_children(tmp) != 0) { message_out(DEBUG, "There are already children for this account"); account_tree.insert(tmp.begin(), container); } else { message_out(DEBUG, "There are no children for this account"); account_tree.append_child(tmp, container); } container->add_account(&( ((OfxAccountContainer *)(*tmp))->data)); return true; } else { message_out(ERROR, "OfxMainContainer::add_container, no accounts are present (tmp is invalid)"); return false; } } int OfxMainContainer::add_container(OfxTransactionContainer * container) { message_out(DEBUG, "OfxMainContainer::add_container, adding a transaction"); if ( account_tree.size() != 0) { tree::sibling_iterator tmp = account_tree.begin(); //cerr<< "size="<add_account(&(((OfxAccountContainer *)(*tmp))->data)); return true; } else { message_out(ERROR, "OfxMainContainer::add_container: tmp is invalid!"); return false; } } else { message_out(ERROR, "OfxMainContainer::add_container: the tree is empty!"); return false; } } int OfxMainContainer::gen_event() { message_out(DEBUG, "Begin walking the trees of the main container to generate events"); tree::iterator tmp = security_tree.begin(); //cerr<<"security_tree.size(): "<gen_event(); ++tmp; } tmp = account_tree.begin(); //cerr<::sibling_iterator tmp = security_tree.begin(); OfxSecurityData * retval = NULL; while (tmp != security_tree.end() && retval == NULL) { if (((OfxSecurityContainer*)(*tmp))->data.unique_id == unique_id) { message_out(DEBUG, (string)"Security " + ((OfxSecurityContainer*)(*tmp))->data.unique_id + " found."); retval = &((OfxSecurityContainer*)(*tmp))->data; } ++tmp; } return retval; } libofx-0.9.12/lib/ofx_container_security.cpp000066400000000000000000000070041315754341700211400ustar00rootroot00000000000000/*************************************************************************** ofx_container_security.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Implementation of OfxSecurityContainer for stocks, bonds, mutual funds, etc. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include "messages.hh" #include "libofx.h" #include "ofx_containers.hh" #include "ofx_utilities.hh" extern OfxMainContainer * MainContainer; /*************************************************************************** * OfxSecurityContainer * ***************************************************************************/ OfxSecurityContainer::OfxSecurityContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { memset(&data, 0, sizeof(data)); type = "SECURITY"; } OfxSecurityContainer::~OfxSecurityContainer() { } void OfxSecurityContainer::add_attribute(const string identifier, const string value) { if (identifier == "UNIQUEID") { strncpy(data.unique_id, value.c_str(), sizeof(data.unique_id)); data.unique_id_valid = true; } else if (identifier == "UNIQUEIDTYPE") { strncpy(data.unique_id_type, value.c_str(), sizeof(data.unique_id_type)); data.unique_id_type_valid = true; } else if (identifier == "SECNAME") { strncpy(data.secname, value.c_str(), sizeof(data.secname)); data.secname_valid = true; } else if (identifier == "TICKER") { strncpy(data.ticker, value.c_str(), sizeof(data.ticker)); data.ticker_valid = true; } else if (identifier == "UNITPRICE") { data.unitprice = ofxamount_to_double(value); data.unitprice_valid = true; } else if (identifier == "DTASOF") { data.date_unitprice = ofxdate_to_time_t(value); data.date_unitprice_valid = true; } else if (identifier == "CURDEF") { strncpy(data.currency, value.c_str(), OFX_CURRENCY_LENGTH); data.currency_valid = true; } else if (identifier == "MEMO" || identifier == "MEMO2") { strncpy(data.memo, value.c_str(), sizeof(data.memo)); data.memo_valid = true; } else if (identifier == "FIID") { strncpy(data.fiid, value.c_str(), OFX_FIID_LENGTH); data.fiid_valid = true; } else { /* Redirect unknown identifiers to the base class */ OfxGenericContainer::add_attribute(identifier, value); } } int OfxSecurityContainer::gen_event() { libofx_context->securityCallback(data); return true; } int OfxSecurityContainer::add_to_main_tree() { if (MainContainer != NULL) { return MainContainer->add_container(this); } else { return false; } } libofx-0.9.12/lib/ofx_container_statement.cpp000066400000000000000000000104261315754341700212770ustar00rootroot00000000000000/*************************************************************************** ofx_container_statement.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Implementation of OfxStatementContainer for bank statements, credit cart statements, etc. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include "messages.hh" #include "libofx.h" #include "ofx_containers.hh" #include "ofx_utilities.hh" extern OfxMainContainer * MainContainer; /*************************************************************************** * OfxStatementContainer * ***************************************************************************/ OfxStatementContainer::OfxStatementContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { memset(&data, 0, sizeof(data)); type = "STATEMENT"; } OfxStatementContainer::~OfxStatementContainer() { /* while(transaction_queue.empty()!=true) { ofx_proc_transaction_cb(transaction_queue.front()); transaction_queue.pop(); }*/ } void OfxStatementContainer::add_attribute(const string identifier, const string value) { if (identifier == "CURDEF") { strncpy(data.currency, value.c_str(), OFX_CURRENCY_LENGTH); data.currency_valid = true; } else if (identifier == "MKTGINFO") { strncpy(data.marketing_info, value.c_str(), OFX_MARKETING_INFO_LENGTH); data.marketing_info_valid = true; } else if (identifier == "DTSTART") { data.date_start = ofxdate_to_time_t(value); data.date_start_valid = true; } else if (identifier == "DTEND") { data.date_end = ofxdate_to_time_t(value); data.date_end_valid = true; } else { OfxGenericContainer::add_attribute(identifier, value); } }//end OfxStatementContainer::add_attribute() void OfxStatementContainer::add_balance(OfxBalanceContainer* ptr_balance_container) { if (ptr_balance_container->tag_identifier == "LEDGERBAL") { data.ledger_balance = ptr_balance_container->amount; data.ledger_balance_valid = ptr_balance_container->amount_valid; data.ledger_balance_date = ptr_balance_container->date; data.ledger_balance_date_valid = ptr_balance_container->date_valid; } else if (ptr_balance_container->tag_identifier == "AVAILBAL") { data.available_balance = ptr_balance_container->amount; data.available_balance_valid = ptr_balance_container->amount_valid; data.available_balance_date = ptr_balance_container->date; data.available_balance_date_valid = ptr_balance_container->date_valid; } else { message_out(ERROR, "OfxStatementContainer::add_balance(): the balance has unknown tag_identifier: " + ptr_balance_container->tag_identifier); } } int OfxStatementContainer::add_to_main_tree() { if (MainContainer != NULL) { return MainContainer->add_container(this); } else { return false; } } int OfxStatementContainer::gen_event() { libofx_context->statementCallback(data); return true; } void OfxStatementContainer::add_account(OfxAccountData * account_data) { if (account_data->account_id_valid == true) { data.account_ptr = account_data; strncpy(data.account_id, account_data->account_id, OFX_ACCOUNT_ID_LENGTH); data.account_id_valid = true; } } /*void OfxStatementContainer::add_transaction(const OfxTransactionData transaction_data) { transaction_queue.push(transaction_data); }*/ libofx-0.9.12/lib/ofx_container_transaction.cpp000066400000000000000000000314231315754341700216200ustar00rootroot00000000000000/*************************************************************************** ofx_container_account.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Implementation of OfxTransactionContainer, OfxBankTransactionContainer and OfxInvestmentTransactionContainer. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "messages.hh" #include "libofx.h" #include "ofx_containers.hh" #include "ofx_utilities.hh" extern OfxMainContainer * MainContainer; /*************************************************************************** * OfxTransactionContainer * ***************************************************************************/ OfxTransactionContainer::OfxTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { OfxGenericContainer * tmp_parentcontainer = parentcontainer; memset(&data, 0, sizeof(data)); type = "TRANSACTION"; /* Find the parent statement container*/ while (tmp_parentcontainer != NULL && tmp_parentcontainer->type != "STATEMENT") { tmp_parentcontainer = tmp_parentcontainer->parentcontainer; } if (tmp_parentcontainer != NULL) { parent_statement = (OfxStatementContainer*)tmp_parentcontainer; } else { parent_statement = NULL; message_out(ERROR, "Unable to find the enclosing statement container this transaction"); } if (parent_statement != NULL && parent_statement->data.account_id_valid == true) { strncpy(data.account_id, parent_statement->data.account_id, OFX_ACCOUNT_ID_LENGTH); data.account_id_valid = true; } } OfxTransactionContainer::~OfxTransactionContainer() { } int OfxTransactionContainer::gen_event() { if (data.unique_id_valid == true && MainContainer != NULL) { data.security_data_ptr = MainContainer->find_security(data.unique_id); if (data.security_data_ptr != NULL) { data.security_data_valid = true; } } libofx_context->transactionCallback(data); return true; } int OfxTransactionContainer::add_to_main_tree() { if (MainContainer != NULL) { return MainContainer->add_container(this); } else { return false; } } void OfxTransactionContainer::add_attribute(const string identifier, const string value) { if (identifier == "DTPOSTED") { data.date_posted = ofxdate_to_time_t(value); data.date_posted_valid = true; } else if (identifier == "DTUSER") { data.date_initiated = ofxdate_to_time_t(value); data.date_initiated_valid = true; } else if (identifier == "DTAVAIL") { data.date_funds_available = ofxdate_to_time_t(value); data.date_funds_available_valid = true; } else if (identifier == "FITID") { strncpy(data.fi_id, value.c_str(), sizeof(data.fi_id)); data.fi_id_valid = true; } else if (identifier == "CORRECTFITID") { strncpy(data.fi_id_corrected, value.c_str(), sizeof(data.fi_id)); data.fi_id_corrected_valid = true; } else if (identifier == "CORRECTACTION") { data.fi_id_correction_action_valid = true; if (value == "REPLACE") { data.fi_id_correction_action = REPLACE; } else if (value == "DELETE") { data.fi_id_correction_action = DELETE; } else { data.fi_id_correction_action_valid = false; } } else if ((identifier == "SRVRTID") || (identifier == "SRVRTID2")) { strncpy(data.server_transaction_id, value.c_str(), sizeof(data.server_transaction_id)); data.server_transaction_id_valid = true; } else if (identifier == "MEMO" || identifier == "MEMO2") { strncpy(data.memo, value.c_str(), sizeof(data.memo)); data.memo_valid = true; } else { /* Redirect unknown identifiers to the base class */ OfxGenericContainer::add_attribute(identifier, value); } }// end OfxTransactionContainer::add_attribute() void OfxTransactionContainer::add_account(OfxAccountData * account_data) { if (account_data->account_id_valid == true) { data.account_ptr = account_data; strncpy(data.account_id, account_data->account_id, OFX_ACCOUNT_ID_LENGTH); data.account_id_valid = true; } } /*************************************************************************** * OfxBankTransactionContainer * ***************************************************************************/ OfxBankTransactionContainer::OfxBankTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { ; } void OfxBankTransactionContainer::add_attribute(const string identifier, const string value) { if ( identifier == "TRNTYPE") { data.transactiontype_valid = true; if (value == "CREDIT") { data.transactiontype = OFX_CREDIT; } else if (value == "DEBIT") { data.transactiontype = OFX_DEBIT; } else if (value == "INT") { data.transactiontype = OFX_INT; } else if (value == "DIV") { data.transactiontype = OFX_DIV; } else if (value == "FEE") { data.transactiontype = OFX_FEE; } else if (value == "SRVCHG") { data.transactiontype = OFX_SRVCHG; } else if (value == "DEP") { data.transactiontype = OFX_DEP; } else if (value == "ATM") { data.transactiontype = OFX_ATM; } else if (value == "POS") { data.transactiontype = OFX_POS; } else if (value == "XFER") { data.transactiontype = OFX_XFER; } else if (value == "CHECK") { data.transactiontype = OFX_CHECK; } else if (value == "PAYMENT") { data.transactiontype = OFX_PAYMENT; } else if (value == "CASH") { data.transactiontype = OFX_CASH; } else if (value == "DIRECTDEP") { data.transactiontype = OFX_DIRECTDEP; } else if (value == "DIRECTDEBIT") { data.transactiontype = OFX_DIRECTDEBIT; } else if (value == "REPEATPMT") { data.transactiontype = OFX_REPEATPMT; } else if (value == "OTHER") { data.transactiontype = OFX_OTHER; } else { data.transactiontype_valid = false; } }//end TRANSTYPE else if (identifier == "TRNAMT") { data.amount = ofxamount_to_double(value); data.amount_valid = true; data.units = -data.amount; data.units_valid = true; data.unitprice = 1.00; data.unitprice_valid = true; } else if (identifier == "CHECKNUM") { strncpy(data.check_number, value.c_str(), sizeof(data.check_number)); data.check_number_valid = true; } else if (identifier == "REFNUM") { strncpy(data.reference_number, value.c_str(), sizeof(data.reference_number)); data.reference_number_valid = true; } else if (identifier == "SIC") { data.standard_industrial_code = atoi(value.c_str()); data.standard_industrial_code_valid = true; } else if ((identifier == "PAYEEID") || (identifier == "PAYEEID2")) { strncpy(data.payee_id, value.c_str(), sizeof(data.payee_id)); data.payee_id_valid = true; } else if (identifier == "NAME") { strncpy(data.name, value.c_str(), sizeof(data.name)); data.name_valid = true; } else { /* Redirect unknown identifiers to base class */ OfxTransactionContainer::add_attribute(identifier, value); } }//end OfxBankTransactionContainer::add_attribute /*************************************************************************** * OfxInvestmentTransactionContainer * ***************************************************************************/ OfxInvestmentTransactionContainer::OfxInvestmentTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxTransactionContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { type = "INVESTMENT"; data.transactiontype = OFX_OTHER; data.transactiontype_valid = true; data.invtransactiontype_valid = true; if (para_tag_identifier == "BUYDEBT") { data.invtransactiontype = OFX_BUYDEBT; } else if (para_tag_identifier == "BUYMF") { data.invtransactiontype = OFX_BUYMF; } else if (para_tag_identifier == "BUYOPT") { data.invtransactiontype = OFX_BUYOPT; } else if (para_tag_identifier == "BUYOTHER") { data.invtransactiontype = OFX_BUYOTHER; } else if (para_tag_identifier == "BUYSTOCK") { data.invtransactiontype = OFX_BUYSTOCK; } else if (para_tag_identifier == "CLOSUREOPT") { data.invtransactiontype = OFX_CLOSUREOPT; } else if (para_tag_identifier == "INCOME") { data.invtransactiontype = OFX_INCOME; } else if (para_tag_identifier == "INVEXPENSE") { data.invtransactiontype = OFX_INVEXPENSE; } else if (para_tag_identifier == "JRNLFUND") { data.invtransactiontype = OFX_JRNLFUND; } else if (para_tag_identifier == "JRNLSEC") { data.invtransactiontype = OFX_JRNLSEC; } else if (para_tag_identifier == "MARGININTEREST") { data.invtransactiontype = OFX_MARGININTEREST; } else if (para_tag_identifier == "REINVEST") { data.invtransactiontype = OFX_REINVEST; } else if (para_tag_identifier == "RETOFCAP") { data.invtransactiontype = OFX_RETOFCAP; } else if (para_tag_identifier == "SELLDEBT") { data.invtransactiontype = OFX_SELLDEBT; } else if (para_tag_identifier == "SELLMF") { data.invtransactiontype = OFX_SELLMF; } else if (para_tag_identifier == "SELLOPT") { data.invtransactiontype = OFX_SELLOPT; } else if (para_tag_identifier == "SELLOTHER") { data.invtransactiontype = OFX_SELLOTHER; } else if (para_tag_identifier == "SELLSTOCK") { data.invtransactiontype = OFX_SELLSTOCK; } else if (para_tag_identifier == "SPLIT") { data.invtransactiontype = OFX_SPLIT; } else if (para_tag_identifier == "TRANSFER") { data.invtransactiontype = OFX_TRANSFER; } else { message_out(ERROR, "This should not happen, " + para_tag_identifier + " is an unknown investment transaction type"); data.invtransactiontype_valid = false; } } void OfxInvestmentTransactionContainer::add_attribute(const string identifier, const string value) { if (identifier == "UNIQUEID") { strncpy(data.unique_id, value.c_str(), sizeof(data.unique_id)); data.unique_id_valid = true; } else if (identifier == "UNIQUEIDTYPE") { strncpy(data.unique_id_type, value.c_str(), sizeof(data.unique_id_type)); data.unique_id_type_valid = true; } else if (identifier == "UNITS") { data.units = ofxamount_to_double(value); data.units_valid = true; } else if (identifier == "UNITPRICE") { data.unitprice = ofxamount_to_double(value); data.unitprice_valid = true; } else if (identifier == "MKTVAL") { message_out(DEBUG, "MKTVAL of " + value + " ignored since MKTVAL should always be UNITS*UNITPRICE"); } else if (identifier == "TOTAL") { data.amount = ofxamount_to_double(value); data.amount_valid = true; } else if (identifier == "DTSETTLE") { data.date_posted = ofxdate_to_time_t(value); data.date_posted_valid = true; } else if (identifier == "DTTRADE") { data.date_initiated = ofxdate_to_time_t(value); data.date_initiated_valid = true; } else if (identifier == "COMMISSION") { data.commission = ofxamount_to_double(value); data.commission_valid = true; } else if (identifier == "FEES") { data.fees = ofxamount_to_double(value); data.fees_valid = true; } else if (identifier == "OLDUNITS") { data.oldunits = ofxamount_to_double(value); data.oldunits_valid = true; } else if (identifier == "NEWUNITS") { data.newunits = ofxamount_to_double(value); data.newunits_valid = true; } else { /* Redirect unknown identifiers to the base class */ OfxTransactionContainer::add_attribute(identifier, value); } }//end OfxInvestmentTransactionContainer::add_attribute libofx-0.9.12/lib/ofx_containers.hh000066400000000000000000000253501315754341700172150ustar00rootroot00000000000000/*************************************************************************** ofx_proc_rs.h ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief LibOFX internal object code. * * These objects will process the elements returned by ofx_sgml.cpp and add them to their data members. * \warning Object documentation is not yet complete. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_PROC_H #define OFX_PROC_H #include "libofx.h" #include "tree.hh" #include "context.hh" using namespace std; /** \brief A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer. * A hierarchy of containers is built as the file is parsed. The supported OFX elements all have a matching container. The others are assigned a OfxDummyContainer, so every OFX element creates a container as the file is par Note however that containers are destroyed as soon as the corresponding SGML element is closed. */ class OfxGenericContainer { public: string type;/**< The type of the object, often == tag_identifier */ string tag_identifier; /**< The identifer of the creating tag */ OfxGenericContainer *parentcontainer; LibofxContext *libofx_context; OfxGenericContainer(LibofxContext *p_libofx_context); OfxGenericContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer); OfxGenericContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); virtual ~OfxGenericContainer() {}; /** \brief Add data to a container object. * Must be called once completed parsing an OFX SGML data element. The parent container should know what to do with it. \param identifier The name of the data element \param value The concatenated string of the data */ virtual void add_attribute(const string identifier, const string value); /** \brief Generate libofx.h events. * gen_event will call the appropriate ofx_proc_XXX_cb defined in libofx.h if one is available. \return true if a callback function vas called, false otherwise. */ virtual int gen_event(); /** \brief Add this container to the main tree. * add_to_main_treegen_event will add the container to the main trees stored int the OfxMainContainer. \return true if successfull, false otherwise. */ virtual int add_to_main_tree(); /// Returns the parent container object (the one representing the containing OFX SGML element) OfxGenericContainer* getparent(); };//End class OfxGenericObject /** \brief A container to holds OFX SGML elements that LibOFX knows nothing about * The OfxDummyContainer is used for elements (not data elements) that are not recognised. Note that recognised objects may very well be a children of an OfxDummyContainer. */ class OfxDummyContainer: public OfxGenericContainer { public: OfxDummyContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); void add_attribute(const string identifier, const string value); }; /** \brief A container to hold a OFX SGML element for which you want the parent to process it's data elements * When you use add_attribute on an OfxPushUpContainer, the add_attribute is redirected to the parent container. */ class OfxPushUpContainer: public OfxGenericContainer { public: OfxPushUpContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); void add_attribute(const string identifier, const string value); }; /** \brief Represents the OFX SGML entity */ class OfxStatusContainer: public OfxGenericContainer { public: OfxStatusData data; OfxStatusContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); ~OfxStatusContainer(); void add_attribute(const string identifier, const string value); }; /** \brief Represents the OFX SGML entity * OfxBalanceContainer is an auxiliary container (there is no matching data object in libofx.h) */ class OfxBalanceContainer: public OfxGenericContainer { public: /* Not yet complete see spec 1.6 p.63 */ //char name[OFX_BALANCE_NAME_LENGTH]; //char description[OFX_BALANCE_DESCRIPTION_LENGTH]; //enum BalanceType{DOLLAR, PERCENT, NUMBER} balance_type; double amount; /**< Interpretation depends on balance_type */ int amount_valid; time_t date; /**< Effective date of the given balance */ int date_valid; OfxBalanceContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); ~OfxBalanceContainer(); void add_attribute(const string identifier, const string value); }; /*************************************************************************** * OfxStatementContainer * ***************************************************************************/ /** \brief Represents a statement for either a bank account or a credit card account. * Can be built from either a or a OFX SGML entity */ class OfxStatementContainer: public OfxGenericContainer { public: OfxStatementData data; OfxStatementContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); ~OfxStatementContainer(); void add_attribute(const string identifier, const string value); virtual int add_to_main_tree(); virtual int gen_event(); void add_account(OfxAccountData * account_data); void add_balance(OfxBalanceContainer* ptr_balance_container); // void add_transaction(const OfxTransactionData transaction_data); }; /*************************************************************************** * OfxAccountContaine r * ***************************************************************************/ /** \brief Represents a bank account or a credit card account. * Can be built from either a or OFX SGML entity */ class OfxAccountContainer: public OfxGenericContainer { public: OfxAccountData data; OfxAccountContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); ~OfxAccountContainer(); void add_attribute(const string identifier, const string value); int add_to_main_tree(); virtual int gen_event(); private: void gen_account_id(void); char bankid[OFX_BANKID_LENGTH]; char branchid[OFX_BRANCHID_LENGTH]; char acctid[OFX_ACCTID_LENGTH];/**< This field is used by both and */ char acctkey[OFX_ACCTKEY_LENGTH]; char brokerid[OFX_BROKERID_LENGTH]; }; /*************************************************************************** * OfxSecurityContainer * ***************************************************************************/ /** \brief Represents a security, such as a stock or bond. */ class OfxSecurityContainer: public OfxGenericContainer { public: OfxSecurityData data; OfxSecurityContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); ~OfxSecurityContainer(); void add_attribute(const string identifier, const string value); virtual int gen_event(); virtual int add_to_main_tree(); private: OfxStatementContainer * parent_statement; }; /*************************************************************************** * OfxTransactionContainer * ***************************************************************************/ /** \brief Represents a generic transaction. */ class OfxTransactionContainer: public OfxGenericContainer { public: OfxTransactionData data; OfxTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); ~OfxTransactionContainer(); virtual void add_attribute(const string identifier, const string value); void add_account(OfxAccountData * account_data); virtual int gen_event(); virtual int add_to_main_tree(); private: OfxStatementContainer * parent_statement; }; /** \brief Represents a bank or credid card transaction. * Built from OFX SGML entity */ class OfxBankTransactionContainer: public OfxTransactionContainer { public: OfxBankTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); void add_attribute(const string identifier, const string value); }; /** \brief Represents a bank or credid card transaction. * Built from the diferent investment transaction OFX entity */ class OfxInvestmentTransactionContainer: public OfxTransactionContainer { public: OfxInvestmentTransactionContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); void add_attribute(const string identifier, const string value); }; /*************************************************************************** * OfxMainContainer * ***************************************************************************/ /** \brief The root container. Created by the OFX element or by the export functions. * The OfxMainContainer maintains trees of processed ofx data structures which can be used to generate events in the right order, and eventually export in OFX and QIF formats and even generate matching OFX querys. */ class OfxMainContainer: public OfxGenericContainer { public: OfxMainContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier); ~OfxMainContainer(); int add_container(OfxGenericContainer * container); int add_container(OfxStatementContainer * container); int add_container(OfxAccountContainer * container); int add_container(OfxTransactionContainer * container); int add_container(OfxSecurityContainer * container); int gen_event(); OfxSecurityData * find_security(string unique_id); private: tree security_tree; tree account_tree; }; #endif libofx-0.9.12/lib/ofx_containers_misc.cpp000066400000000000000000000145411315754341700204130ustar00rootroot00000000000000/*************************************************************************** ofx_proc_rs.cpp ------------------- copyright : (C) 2002 by Benoit Grégoire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief LibOFX internal object code. * * These objects will process the elements returned by ofx_sgml.cpp and add them to their data members. * \warning Object documentation is not yet done. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "messages.hh" #include "libofx.h" #include "ofx_error_msg.hh" #include "ofx_utilities.hh" #include "ofx_containers.hh" extern OfxMainContainer * MainContainer; /*************************************************************************** * OfxDummyContainer * ***************************************************************************/ OfxDummyContainer::OfxDummyContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { type = "DUMMY"; message_out(INFO, "Created OfxDummyContainer to hold unsupported aggregate " + para_tag_identifier); } void OfxDummyContainer::add_attribute(const string identifier, const string value) { message_out(DEBUG, "OfxDummyContainer for " + tag_identifier + " ignored a " + identifier + " (" + value + ")"); } /*************************************************************************** * OfxPushUpContainer * ***************************************************************************/ OfxPushUpContainer::OfxPushUpContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { type = "PUSHUP"; message_out(DEBUG, "Created OfxPushUpContainer to hold aggregate " + tag_identifier); } void OfxPushUpContainer::add_attribute(const string identifier, const string value) { //message_out(DEBUG, "OfxPushUpContainer for "+tag_identifier+" will push up a "+identifier+" ("+value+") to a "+ parentcontainer->type + " container"); parentcontainer->add_attribute(identifier, value); } /*************************************************************************** * OfxStatusContainer * ***************************************************************************/ OfxStatusContainer::OfxStatusContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { memset(&data, 0, sizeof(data)); type = "STATUS"; if (parentcontainer != NULL) { strncpy(data.ofx_element_name, parentcontainer->tag_identifier.c_str(), OFX_ELEMENT_NAME_LENGTH); data.ofx_element_name_valid = true; } } OfxStatusContainer::~OfxStatusContainer() { message_out(DEBUG, "Entering the status's container's destructor"); libofx_context->statusCallback(data); if ( data.server_message_valid ) delete [] data.server_message; } void OfxStatusContainer::add_attribute(const string identifier, const string value) { ErrorMsg error_msg; if ( identifier == "CODE") { data.code = atoi(value.c_str()); error_msg = find_error_msg(data.code); data.name = error_msg.name;//memory is already allocated data.description = error_msg.description;//memory is already allocated data.code_valid = true; } else if (identifier == "SEVERITY") { data.severity_valid = true; if (value == "INFO") { data.severity = OfxStatusData::INFO; } else if (value == "WARN") { data.severity = OfxStatusData::WARN; } else if (value == "ERROR") { data.severity = OfxStatusData::ERROR; } else { message_out(ERROR, "WRITEME: Unknown severity " + value + " inside a " + type + " container"); data.severity_valid = false; } } else if ((identifier == "MESSAGE") || (identifier == "MESSAGE2")) { data.server_message = new char[value.length()+1]; strcpy(data.server_message, value.c_str()); data.server_message_valid = true; } else { /* Redirect unknown identifiers to the base class */ OfxGenericContainer::add_attribute(identifier, value); } } /*************************************************************************** * OfxBalanceContainer (does not directly abstract a object in libofx.h) * ***************************************************************************/ OfxBalanceContainer::OfxBalanceContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier): OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier) { amount_valid = false; date_valid = false; type = "BALANCE"; } OfxBalanceContainer::~OfxBalanceContainer() { if (parentcontainer->type == "STATEMENT") { ((OfxStatementContainer*)parentcontainer)->add_balance(this); } else { message_out (ERROR, "I completed a " + type + " element, but I haven't found a suitable parent to save it"); } } void OfxBalanceContainer::add_attribute(const string identifier, const string value) { if (identifier == "BALAMT") { amount = ofxamount_to_double(value); amount_valid = true; } else if (identifier == "DTASOF") { date = ofxdate_to_time_t(value); date_valid = true; } else { /* Redirect unknown identifiers to the base class */ OfxGenericContainer::add_attribute(identifier, value); } } libofx-0.9.12/lib/ofx_error_msg.hh000066400000000000000000000322421315754341700170450ustar00rootroot00000000000000/*************************************************************************** ofx_data_struct.h - description ------------------- begin : Tue Mar 19 2002 copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief OFX error code management functionnality. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_DATA_STRUCT_H #define OFX_DATA_STRUCT_H ///An abstraction of an OFX error code sent by an OFX server. struct ErrorMsg { int code; /**< The error's code */ const char * name; /**< The error's name */ const char * description; /**< The long description of the error */ }; /// List known error codes. /** The error_msgs_list table contains all past and present OFX error codes up to the OFX 2.01 specification */ const ErrorMsg error_msgs_list[] = { {0, "Success", "The server successfully processed the request."}, {1, "Client is up-to-date", "Based on the client timestamp, the client has the latest information. The response does not supply any additional information."}, {2000, "General error", "Error other than those specified by the remaining error codes. (Note: Servers should provide a more specific error whenever possible. Error code 2000 should be reserved for cases in which a more specific code is not available.)"}, {2001, "Invalid account", ""}, {2002, "General account error", "Account error not specified by the remaining error codes."}, {2003, "Account not found", "The specified account number does not correspond to one of the user's accounts."}, {2004, "Account closed", "The specified account number corresponds to an account that has been closed."}, {2005, "Account not authorized", "The user is not authorized to perform this action on the account, or the server does not allow this type of action to be performed on the account."}, {2006, "Source account not found", "The specified account number does not correspond to one of the user's accounts."}, {2007, "Source account closed", "The specified account number corresponds to an account that has been closed."}, {2008, "Source account not authorized", "The user is not authorized to perform this action on the account, or the server does not allow this type of action to be performed on the account."}, {2009, "Destination account not found", "The specified account number does not correspond to one of the user's accounts."}, {2010, "Destination account closed", "The specified account number corresponds to an account that has been closed."}, {2011, "Destination account not authorized", "The user is not authorized to perform this action on the account, or the server does not allow this type of action to be performed on the account."}, {2012, "Invalid amount", "The specified amount is not valid for this action; for example, the user specified a negative payment amount."}, {2014, "Date too soon", "The server cannot process the requested action by the date specified by the user."}, {2015, "Date too far in future", "The server cannot accept requests for an action that far in the future."}, {2016, "Transaction already committed", "Transaction has entered the processing loop and cannot be modified/cancelled using OFX. The transaction may still be cancelled or modified using other means (for example, a phone call to Customer Service)."}, {2017, "Already canceled", "The transaction cannot be canceled or modified because it has already been canceled."}, {2018, "Unknown server ID", "The specified server ID does not exist or no longer exists."}, {2019, "Duplicate request", "A request with this has already been received and processed."}, {2020, "Invalid date", "The specified datetime stamp cannot be parsed; for instance, the datetime stamp specifies 25:00 hours."}, {2021, "Unsupported version", "The server does not support the requested version. The version of the message set specified by the client is not supported by this server."}, {2022, "Invalid TAN", "The server was unable to validate the TAN sent in the request."}, {2023, "Unknown FITID", "The specified FITID/BILLID does not exist or no longer exists. [BILLID not found in the billing message sets]"}, {2025, "Branch ID missing", "A value must be provided in the aggregate for this country system, but this field is missing."}, {2026, "Bank name doesn't match bank ID", "The value of in the aggregate is inconsistent with the value of in the aggregate."}, {2027, "Invalid date range", "Response for non-overlapping dates, date ranges in the future, et cetera."}, {2028, "Requested element unknown", "One or more elements of the request were not recognized by the server or the server (as noted in the FI Profile) does not support the elements. The server executed the element transactions it understood and supported. For example, the request file included private tags in a but the server was able to execute the rest of the request."}, {6500, "Y invalid without ", "This error code may appear element of an wrapper (in and V2 message set responses) or the contained in any embedded transaction wrappers within a sync response. The corresponding sync request wrapper included Y with Y or Y, which is illegal."}, {6501, "Embedded transactions in request failed to process: Out of date", "Y and embedded transactions appeared in the request sync wrapper and the provided was out of date. This code should be used in the of the response sync wrapper."}, {6502, "Unable to process embedded transaction due to out-of-date ", "Used in response transaction wrapper for embedded transactions when 6501 appears in the surrounding sync wrapper."}, {10000, "Stop check in process", "Stop check is already in process."}, {10500, "Too many checks to process", "The stop-payment request specifies too many checks."}, {10501, "Invalid payee", "Payee error not specified by the remainingerror codes."}, {10502, "Invalid payee address", "Some portion of the payee's address is incorrect or unknown."}, {10503, "Invalid payee account number", "The account number of the requested payee is invalid."}, {10504, "Insufficient funds", "The server cannot process the request because the specified account does not have enough funds."}, {10505, "Cannot modify element", "The server does not allow modifications to one or more values in a modification request."}, {10506, "Cannot modify source account", "Reserved for future use."}, {10507, "Cannot modify destination account", "Reserved for future use."}, {10508, "Invalid frequency", "The specified frequency does not match one of the accepted frequencies for recurring transactions."}, {10509, "Model already canceled", "The server has already canceled the specified recurring model."}, {10510, "Invalid payee ID", "The specified payee ID does not exist or no longer exists."}, {10511, "Invalid payee city", "The specified city is incorrect or unknown."}, {10512, "Invalid payee state", "The specified state is incorrect or unknown."}, {10513, "Invalid payee postal code", "The specified postal code is incorrect or unknown."}, {10514, "Transaction already processed", "Transaction has already been sent or date due is past"}, {10515, "Payee not modifiable by client", "The server does not allow clients to change payee information."}, {10516, "Wire beneficiary invalid", "The specified wire beneficiary does not exist or no longer exists."}, {10517, "Invalid payee name", "The server does not recognize the specified payee name."}, {10518, "Unknown model ID", "The specified model ID does not exist or no longer exists."}, {10519, "Invalid payee list ID", "The specified payee list ID does not exist or no longer exists."}, {10600, "Table type not found", "The specified table type is not recognized or does not exist."}, {12250, "Investment transaction download not supported (WARN)", "The server does not support investment transaction download."}, {12251, "Investment position download not supported (WARN)", "The server does not support investment position download."}, {12252, "Investment positions for specified date not available", "The server does not support investment positions for the specified date."}, {12253, "Investment open order download not supported (WARN)", "The server does not support open order download."}, {12254, "Investment balances download not supported (WARN)", "The server does not support investment balances download."}, {12255, "401(k) not available for this account", "401(k) information requested from a non-401(k) account."}, {12500, "One or more securities not found", "The server could not find the requested securities."}, {13000, "User ID & password will be sent out-of-band (INFO)", "The server will send the user ID and password via postal mail, e-mail, or another means. The accompanying message will provide details."}, {13500, "Unable to enroll user", "The server could not enroll the user."}, {13501, "User already enrolled", "The server has already enrolled the user."}, {13502, "Invalid service", "The server does not support the service specified in the service-activation request."}, {13503, "Cannot change user information", "The server does not support the request."}, {13504, " Missing or Invalid in ", "The FI requires the client to provide the aggregate in the request, but either none was provided, or the one provided was invalid."}, {14500, "1099 forms not available", "1099 forms are not yet available for the tax year requested."}, {14501, "1099 forms not available for user ID", "This user does not have any 1099 forms available."}, {14600, "W2 forms not available", "W2 forms are not yet available for the tax year requested."}, {14601, "W2 forms not available for user ID", "The user does not have any W2 forms available."}, {14700, "1098 forms not available", "1098 forms are not yet available for the tax year requested."}, {14701, "1098 forms not available for user ID", "The user does not have any 1098 forms available."}, {15000, "Must change USERPASS", "The user must change his or her number as part of the next OFX request."}, {15500, "Signon invalid", "The user cannot signon because he or she entered an invalid user ID or password."}, {15501, "Customer account already in use", "The server allows only one connection at a time, and another user is already signed on. Please try again later."}, {15502, "USERPASS lockout", "The server has received too many failed signon attempts for this user. Please call the FI's technical support number."}, {15503, "Could not change USERPASS", "The server does not support the request."}, {15504, "Could not provide random data", "The server could not generate random data as requested by the ."}, {15505, "Country system not supported", "The server does not support the country specified in the field of the aggregate."}, {15506, "Empty signon not supported", "The server does not support signons not accompanied by some other transaction."}, {15507, "Signon invalid without supporting pin change request", "The OFX block associated with the signon does not contain a pin change request and should."}, {15508, "Transaction not authorized", "Current user is not authorized to perform this action on behalf of the ."}, {16500, "HTML not allowed", "The server does not accept HTML formatting in the request."}, {16501, "Unknown mail To:", "The server was unable to send mail to the specified Internet address."}, {16502, "Invalid URL", "The server could not parse the URL."}, {16503, "Unable to get URL", "The server was unable to retrieve the information at this URL (e.g., an HTTP 400 or 500 series error)."}, { -1, "Unknown code", "The description of this code is unknown to libOfx"} }; ///Retreive error code descriptions /** The find_error_msg function will take an ofx error number, and return an ErrorMsg structure with detailled information about the error, including the error name and long description */ const ErrorMsg find_error_msg(int param_code) { ErrorMsg return_val; int i; bool code_found = false; for (i = 0; i < 2000 && (code_found == false); i++) { if ((error_msgs_list[i].code == param_code) || (error_msgs_list[i].code == -1)) { return_val = error_msgs_list[i]; code_found = true; } } return return_val; }; #endif libofx-0.9.12/lib/ofx_preproc.cpp000066400000000000000000000540511315754341700167050ustar00rootroot00000000000000/*************************************************************************** ofx_preproc.cpp ------------------- copyright : (C) 2002 by Benoit Gr�oir email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Preprocessing of the OFX files before parsing * Implements the pre-treatement of the OFX file prior to parsing: OFX header striping, OFX proprietary tags and SGML comment striping, locating the appropriate DTD. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "../config.h" #include #include #include #include #include #include "ParserEventGeneratorKit.h" #include "libofx.h" #include "messages.hh" #include "ofx_sgml.hh" #include "ofc_sgml.hh" #include "ofx_preproc.hh" #include "ofx_utilities.hh" #ifdef HAVE_ICONV #include #endif #ifdef OS_WIN32 # define DIRSEP "\\" #else # define DIRSEP "/" #endif #ifdef OS_WIN32 # include "win32.hh" # include // for GetModuleFileName() # undef ERROR # undef DELETE #endif #define LIBOFX_DEFAULT_INPUT_ENCODING "CP1252" #define LIBOFX_DEFAULT_OUTPUT_ENCODING "UTF-8" using namespace std; /** \brief The number of different paths to search for DTDs. */ #ifdef MAKEFILE_DTD_PATH const int DTD_SEARCH_PATH_NUM = 4; #else const int DTD_SEARCH_PATH_NUM = 3; #endif /** \brief The list of paths to search for the DTDs. */ const char *DTD_SEARCH_PATH[DTD_SEARCH_PATH_NUM] = { #ifdef MAKEFILE_DTD_PATH MAKEFILE_DTD_PATH , #endif "/usr/local/share/libofx/dtd", "/usr/share/libofx/dtd", "~" }; const unsigned int READ_BUFFER_SIZE = 1024; /** @brief File pre-processing of OFX AND for OFC files * * Takes care of comment striping, dtd locating, etc. */ int ofx_proc_file(LibofxContextPtr ctx, const char * p_filename) { LibofxContext *libofx_context; bool ofx_start = false; bool ofx_end = false; bool file_is_xml = false; ifstream input_file; ofstream tmp_file; char buffer[READ_BUFFER_SIZE]; char *iconv_buffer; string s_buffer; char *filenames[3]; char tmp_filename[256]; int tmp_file_fd; #ifdef HAVE_ICONV iconv_t conversion_descriptor; #endif libofx_context = (LibofxContext*)ctx; if (p_filename != NULL && strcmp(p_filename, "") != 0) { message_out(DEBUG, string("ofx_proc_file():Opening file: ") + p_filename); input_file.open(p_filename); if (!input_file) { message_out(ERROR, "ofx_proc_file():Unable to open the input file " + string(p_filename)); } mkTempFileName("libofxtmpXXXXXX", tmp_filename, sizeof(tmp_filename)); message_out(DEBUG, "ofx_proc_file(): Creating temp file: " + string(tmp_filename)); tmp_file_fd = mkstemp(tmp_filename); if (tmp_file_fd) { tmp_file.open(tmp_filename); if (!tmp_file) { message_out(ERROR, "ofx_proc_file():Unable to open the created temp file " + string(tmp_filename)); return -1; } } else { message_out(ERROR, "ofx_proc_file():Unable to create a temp file at " + string(tmp_filename)); return -1; } if (input_file && tmp_file) { int header_separator_idx; string header_name; string header_value; string ofx_encoding; string ofx_charset; do { s_buffer.clear(); bool end_of_line = false; do { input_file.get(buffer, sizeof(buffer), '\n'); //cout<< "got: \"" << buffer<<"\"\n"; s_buffer.append(buffer); // Watch out: If input_file is in eof(), any subsequent read or // peek() will fail and we must exit this loop. if (input_file.eof()) break; //cout<<"input_file.gcount(): "<currentFileType() == OFX && ((ofx_start_idx = s_buffer.find("")) != string::npos || (ofx_start_idx = s_buffer.find("")) != string::npos)) || (libofx_context->currentFileType() == OFC && ((ofx_start_idx = s_buffer.find("")) != string::npos || (ofx_start_idx = s_buffer.find("")) != string::npos)) ) ) { ofx_start = true; if (file_is_xml == false) { s_buffer.erase(0, ofx_start_idx); //Fix for really broken files that don't have a newline after the header. } message_out(DEBUG, "ofx_proc_file(): or has been found"); if (file_is_xml == true) { static char sp_charset_fixed[] = "SP_CHARSET_FIXED=1"; if (putenv(sp_charset_fixed) != 0) { message_out(ERROR, "ofx_proc_file(): putenv failed"); } /* Normally the following would be "xml". * Unfortunately, opensp's generic api will garble UTF-8 if this is * set to xml. So we set any single byte encoding to avoid messing * up UTF-8. Unfortunately this means that non-UTF-8 files will not * get properly translated. We'd need to manually detect the * encoding in the XML header and convert the xml with iconv like we * do for SGML to work around the problem. Most unfortunate. */ static char sp_encoding[] = "SP_ENCODING=ms-dos"; if (putenv(sp_encoding) != 0) { message_out(ERROR, "ofx_proc_file(): putenv failed"); } } else { static char sp_charset_fixed[] = "SP_CHARSET_FIXED=1"; if (putenv(sp_charset_fixed) != 0) { message_out(ERROR, "ofx_proc_file(): putenv failed"); } static char sp_encoding[] = "SP_ENCODING=ms-dos"; //Any single byte encoding will do, we don't want opensp messing up UTF-8; if (putenv(sp_encoding) != 0) { message_out(ERROR, "ofx_proc_file(): putenv failed"); } #ifdef HAVE_ICONV string fromcode; string tocode; if (ofx_encoding.compare("USASCII") == 0) { if (ofx_charset.compare("ISO-8859-1") == 0 || ofx_charset.compare("8859-1") == 0) { //Only "ISO-8859-1" is actually a legal value, but since the banks follows the spec SO well... fromcode = "ISO-8859-1"; } else if (ofx_charset.compare("1252") == 0 || ofx_charset.compare("CP1252") == 0) { //Only "1252" is actually a legal value, but since the banks follows the spec SO well... fromcode = "CP1252"; } else if (ofx_charset.compare("NONE") == 0) { fromcode = LIBOFX_DEFAULT_INPUT_ENCODING; } else { fromcode = LIBOFX_DEFAULT_INPUT_ENCODING; } } else if (ofx_encoding.compare("UTF-8") == 0 || ofx_encoding.compare("UNICODE") == 0) { //While "UNICODE" isn't a legal value, some cyrilic files do specify it as such... fromcode = "UTF-8"; } else { fromcode = LIBOFX_DEFAULT_INPUT_ENCODING; } tocode = LIBOFX_DEFAULT_OUTPUT_ENCODING; message_out(DEBUG, "ofx_proc_file(): Setting up iconv for fromcode: " + fromcode + ", tocode: " + tocode); conversion_descriptor = iconv_open (tocode.c_str(), fromcode.c_str()); #endif } } else { //We are still in the headers if ((header_separator_idx = s_buffer.find(':')) != string::npos) { //Header processing header_name.assign(s_buffer.substr(0, header_separator_idx)); header_value.assign(s_buffer.substr(header_separator_idx + 1)); while ( header_value[header_value.length() -1 ] == '\n' || header_value[header_value.length() -1 ] == '\r' ) header_value.erase(header_value.length() - 1); message_out(DEBUG, "ofx_proc_file():Header: " + header_name + " with value: " + header_value + " has been found"); if (header_name.compare("ENCODING") == 0) { ofx_encoding.assign(header_value); } if (header_name.compare("CHARSET") == 0) { ofx_charset.assign(header_value); } } } if (file_is_xml == true || (ofx_start == true && ofx_end == false)) { if (ofx_start == true) { /* The above test won't help us if the tag is on the same line * as the xml header, but as opensp can't be used to parse it anyway * this isn't a great loss for now. */ s_buffer = sanitize_proprietary_tags(s_buffer); } //cout<< s_buffer<<"\n"; if (file_is_xml == false) { #ifdef HAVE_ICONV size_t inbytesleft = strlen(s_buffer.c_str()); size_t outbytesleft = inbytesleft * 2 - 1; iconv_buffer = (char*) malloc (inbytesleft * 2); memset(iconv_buffer, 0, inbytesleft * 2); #if defined(OS_WIN32) || defined(__sun) || defined(__NetBSD__) const char * inchar = (const char *)s_buffer.c_str(); #else char * inchar = (char *)s_buffer.c_str(); #endif char * outchar = iconv_buffer; int iconv_retval = iconv (conversion_descriptor, &inchar, &inbytesleft, &outchar, &outbytesleft); if (iconv_retval == -1) { message_out(ERROR, "ofx_proc_file(): Conversion error"); } s_buffer = iconv_buffer; free (iconv_buffer); #endif } //cout << s_buffer << "\n"; tmp_file.write(s_buffer.c_str(), s_buffer.length()); } if (ofx_start == true && ( (libofx_context->currentFileType() == OFX && ((ofx_start_idx = s_buffer.find("")) != string::npos || (ofx_start_idx = s_buffer.find("")) != string::npos)) || (libofx_context->currentFileType() == OFC && ((ofx_start_idx = s_buffer.find("")) != string::npos || (ofx_start_idx = s_buffer.find("")) != string::npos)) ) ) { ofx_end = true; message_out(DEBUG, "ofx_proc_file(): or has been found"); } } while (!input_file.eof() && !input_file.bad()); } input_file.close(); tmp_file.close(); #ifdef HAVE_ICONV if (file_is_xml == false) { iconv_close(conversion_descriptor); } #endif char filename_openspdtd[255]; char filename_dtd[255]; char filename_ofx[255]; strncpy(filename_openspdtd, find_dtd(ctx, OPENSPDCL_FILENAME).c_str(), 255); //The opensp sgml dtd file if (libofx_context->currentFileType() == OFX) { strncpy(filename_dtd, find_dtd(ctx, OFX160DTD_FILENAME).c_str(), 255); //The ofx dtd file } else if (libofx_context->currentFileType() == OFC) { strncpy(filename_dtd, find_dtd(ctx, OFCDTD_FILENAME).c_str(), 255); //The ofc dtd file } else { message_out(ERROR, string("ofx_proc_file(): Error unknown file format for the OFX parser")); } if ((string)filename_dtd != "" && (string)filename_openspdtd != "") { strncpy(filename_ofx, tmp_filename, 255); //The processed ofx file filenames[0] = filename_openspdtd; filenames[1] = filename_dtd; filenames[2] = filename_ofx; if (libofx_context->currentFileType() == OFX) { ofx_proc_sgml(libofx_context, 3, filenames); } else if (libofx_context->currentFileType() == OFC) { ofc_proc_sgml(libofx_context, 3, filenames); } else { message_out(ERROR, string("ofx_proc_file(): Error unknown file format for the OFX parser")); } if (remove(tmp_filename) != 0) { message_out(ERROR, "ofx_proc_file(): Error deleting temporary file " + string(tmp_filename)); } } else { message_out(ERROR, "ofx_proc_file(): FATAL: Missing DTD, aborting"); } } else { message_out(ERROR, "ofx_proc_file():No input file specified"); } return 0; } /** This function will strip all the OFX proprietary tags and SGML comments from the SGML string passed to it */ string sanitize_proprietary_tags(string input_string) { unsigned int i; bool strip = false; bool tag_open = false; int tag_open_idx = 0; //Are we within < > ? bool closing_tag_open = false; //Are we within ? int orig_tag_open_idx = 0; bool proprietary_tag = false; //Are we within a proprietary element? bool proprietary_closing_tag = false; int crop_end_idx = 0; char buffer[READ_BUFFER_SIZE] = ""; char tagname[READ_BUFFER_SIZE] = ""; int tagname_idx = 0; char close_tagname[READ_BUFFER_SIZE] = ""; for (i = 0; i < READ_BUFFER_SIZE; i++) { buffer[i] = 0; tagname[i] = 0; close_tagname[i] = 0; } size_t input_string_size = input_string.size(); // Minimum workaround to prevent buffer overflow: Stop iterating // once the (fixed!) size of the output buffers is reached. In // response to // https://www.talosintelligence.com/vulnerability_reports/TALOS-2017-0317 // // However, this code is a huge mess anyway and is in no way // anything like up-to-date C++ code. Please, anyone, replace it // with something more modern. Thanks. - cstim, 2017-09-17. for (i = 0; i < std::min(input_string_size, size_t(READ_BUFFER_SIZE)); i++) { if (input_string.c_str()[i] == '<') { tag_open = true; tag_open_idx = i; if (proprietary_tag == true && input_string.c_str()[i+1] == '/') { //We are now in a closing tag closing_tag_open = true; //cout<<"Comparaison: "<') { tag_open = false; closing_tag_open = false; tagname[tagname_idx] = 0; tagname_idx = 0; if (proprietary_closing_tag == true) { crop_end_idx = i; strip = true; } } else if (tag_open == true && closing_tag_open == false) { if (input_string.c_str()[i] == '.') { if (proprietary_tag != true) { orig_tag_open_idx = tag_open_idx; proprietary_tag = true; } } tagname[tagname_idx] = input_string.c_str()[i]; tagname_idx++; } //cerr <(ctx)->dtdDir(); if (!dtd_path_filename.empty()) { dtd_path_filename.append(dtd_filename); ifstream dtd_file(dtd_path_filename.c_str()); if (dtd_file) { message_out(STATUS, "find_dtd():DTD found: " + dtd_path_filename); return dtd_path_filename; } } #ifdef OS_WIN32 dtd_path_filename = get_dtd_installation_directory(); if (!dtd_path_filename.empty()) { dtd_path_filename.append(DIRSEP); dtd_path_filename.append(dtd_filename); ifstream dtd_file(dtd_path_filename.c_str()); if (dtd_file) { message_out(STATUS, "find_dtd():DTD found: " + dtd_path_filename); return dtd_path_filename; } } #endif /* Search in environement variable OFX_DTD_PATH */ env_dtd_path = getenv("OFX_DTD_PATH"); if (env_dtd_path) { dtd_path_filename.append(env_dtd_path); dtd_path_filename.append(DIRSEP); dtd_path_filename.append(dtd_filename); ifstream dtd_file(dtd_path_filename.c_str()); if (!dtd_file) { message_out(STATUS, "find_dtd():OFX_DTD_PATH env variable was was present, but unable to open the file " + dtd_path_filename); } else { message_out(STATUS, "find_dtd():DTD found: " + dtd_path_filename); return dtd_path_filename; } } for (int i = 0; i < DTD_SEARCH_PATH_NUM; i++) { dtd_path_filename = DTD_SEARCH_PATH[i]; dtd_path_filename.append(DIRSEP); dtd_path_filename.append(dtd_filename); ifstream dtd_file(dtd_path_filename.c_str()); if (!dtd_file) { message_out(DEBUG, "find_dtd():Unable to open the file " + dtd_path_filename); } else { message_out(STATUS, "find_dtd():DTD found: " + dtd_path_filename); return dtd_path_filename; } } /* Last resort, look in source tree relative path (useful for development) */ dtd_path_filename = ""; dtd_path_filename.append(".."); dtd_path_filename.append(DIRSEP); dtd_path_filename.append("dtd"); dtd_path_filename.append(DIRSEP); dtd_path_filename.append(dtd_filename); ifstream dtd_file(dtd_path_filename.c_str()); if (!dtd_file) { message_out(DEBUG, "find_dtd(): Unable to open the file " + dtd_path_filename + ", most likely we are not in the source tree."); } else { message_out(STATUS, "find_dtd():DTD found: " + dtd_path_filename); return dtd_path_filename; } message_out(ERROR, "find_dtd():Unable to find the DTD named " + dtd_filename); return ""; } libofx-0.9.12/lib/ofx_preproc.hh000066400000000000000000000034731315754341700165240ustar00rootroot00000000000000/*************************************************************************** ofx_preproc.h ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Preprocessing of the OFX files before parsing * Implements the pre-treatement of the OFX file prior to parsing: OFX header striping, OFX proprietary tags and SGML comment striping, locating the appropriate DTD. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_PREPROC_H #define OFX_PREPROC_H #include "context.hh" #define OPENSPDCL_FILENAME "opensp.dcl" #define OFX160DTD_FILENAME "ofx160.dtd" #define OFCDTD_FILENAME "ofc.dtd" ///Removes proprietary tags and comments. string sanitize_proprietary_tags(string input_string); ///Find the appropriate DTD for the file version. std::string find_dtd(LibofxContextPtr ctx, const std::string& dtd_filename); /** * \brief ofx_proc_file process an ofx or ofc file. * * libofx_proc_file must be called with a list of 1 or more OFX files to be parsed in command line format. */ int ofx_proc_file(LibofxContextPtr libofx_context, const char *); #endif libofx-0.9.12/lib/ofx_request.cpp000066400000000000000000000075171315754341700167300ustar00rootroot00000000000000/*************************************************************************** ofx_request.cpp ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Implementation of an OfxRequests to create an OFX file * containing a generic request . */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "messages.hh" #include "libofx.h" #include "ofx_request.hh" using namespace std; string time_t_to_ofxdatetime( time_t time ) { static char buffer[51]; strftime( buffer, 50, "%Y%m%d%H%M%S.000", localtime(&time) ); buffer[50] = 0; return string(buffer); } string time_t_to_ofxdate( time_t time ) { static char buffer[51]; strftime( buffer, 50, "%Y%m%d", localtime(&time) ); buffer[50] = 0; return string(buffer); } string OfxHeader(const char *hver) { if (hver == NULL || hver[0] == 0) hver = "102"; if (strcmp(hver, "103") == 0) /* TODO: check for differences in version 102 and 103 */ return string("OFXHEADER:100\r\n" "DATA:OFXSGML\r\n" "VERSION:103\r\n" "SECURITY:NONE\r\n" "ENCODING:USASCII\r\n" "CHARSET:1252\r\n" "COMPRESSION:NONE\r\n" "OLDFILEUID:NONE\r\n" "NEWFILEUID:") + time_t_to_ofxdatetime( time(NULL) ) + string("\r\n\r\n"); else return string("OFXHEADER:100\r\n" "DATA:OFXSGML\r\n" "VERSION:102\r\n" "SECURITY:NONE\r\n" "ENCODING:USASCII\r\n" "CHARSET:1252\r\n" "COMPRESSION:NONE\r\n" "OLDFILEUID:NONE\r\n" "NEWFILEUID:") + time_t_to_ofxdatetime( time(NULL) ) + string("\r\n\r\n"); } OfxAggregate OfxRequest::SignOnRequest(void) const { OfxAggregate fiTag("FI"); fiTag.Add( "ORG", m_login.org ); if ( strlen(m_login.fid) > 0 ) fiTag.Add( "FID", m_login.fid ); OfxAggregate sonrqTag("SONRQ"); sonrqTag.Add( "DTCLIENT", time_t_to_ofxdatetime( time(NULL) ) ); sonrqTag.Add( "USERID", m_login.userid); sonrqTag.Add( "USERPASS", m_login.userpass); sonrqTag.Add( "LANGUAGE", "ENG"); sonrqTag.Add( fiTag ); if ( strlen(m_login.appid) > 0 ) sonrqTag.Add( "APPID", m_login.appid); else sonrqTag.Add( "APPID", "QWIN"); if ( strlen(m_login.appver) > 0 ) sonrqTag.Add( "APPVER", m_login.appver); else sonrqTag.Add( "APPVER", "1400"); if ( strlen(m_login.clientuid) > 0 ) sonrqTag.Add( "CLIENTUID", m_login.clientuid); OfxAggregate signonmsgTag("SIGNONMSGSRQV1"); signonmsgTag.Add( sonrqTag ); return signonmsgTag; } OfxAggregate OfxRequest::RequestMessage(const string& _msgType, const string& _trnType, const OfxAggregate& _request) const { OfxAggregate trnrqTag( _trnType + "TRNRQ" ); trnrqTag.Add( "TRNUID", time_t_to_ofxdatetime( time(NULL) ) ); trnrqTag.Add( "CLTCOOKIE", "1" ); trnrqTag.Add( _request ); OfxAggregate result( _msgType + "MSGSRQV1" ); result.Add( trnrqTag ); return result; } libofx-0.9.12/lib/ofx_request.hh000066400000000000000000000055031315754341700165360ustar00rootroot00000000000000/*************************************************************************** ofx_request.hh ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Declaration of an OfxRequests to create an OFX file * containing a generic request . */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_REQUEST_H #define OFX_REQUEST_H #include #include "libofx.h" #include "ofx_aggregate.hh" using namespace std; /** * \brief A generic request * * This is an entire OFX aggregate, with all subordinate aggregates needed to log onto * the OFX server of a single financial institution and process a request. The details * of the particular request are up to subclasses of this one. */ class OfxRequest: public OfxAggregate { public: /** * Creates the generic request aggregate. * * @param fi The information needed to log on user into one financial * institution */ OfxRequest(const OfxFiLogin& fi): OfxAggregate("OFX"), m_login(fi) {} //protected: public: /** * Creates a signon request aggregate, & , sufficient * to log this user into this financial institution. * * @return The request aggregate created */ OfxAggregate SignOnRequest(void) const; /** * Creates a message aggregate * * @param msgtype The type of message. This will be prepended to "MSGSRQV1" * to become the tagname of the overall aggregate * @param trntype The type of transactions being requested. This will be * prepended to "TRNRQ" to become the tagname of the subordinate aggregate. * @param aggregate The actual contents of the message, which will be a sub * aggregate of the xxxTRNRQ aggregate. * @return The message aggregate created */ OfxAggregate RequestMessage(const string& msgtype, const string& trntype, const OfxAggregate& aggregate ) const; protected: OfxFiLogin m_login; }; /** * @name Some general helper functions */ //@{ string time_t_to_ofxdatetime( time_t time ); string time_t_to_ofxdate( time_t time ); string OfxHeader(const char *hver); //@} #endif // OFX_REQUEST_H libofx-0.9.12/lib/ofx_request_accountinfo.cpp000066400000000000000000000043551315754341700213150ustar00rootroot00000000000000/*************************************************************************** ofx_request_accountinfo.cpp ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Implementation of libofx_request_accountinfo to create an OFX file * containing a request for all account info at this FI for this user. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "libofx.h" #include "ofx_request_accountinfo.hh" using namespace std; char* libofx_request_accountinfo( const OfxFiLogin* login ) { OfxAccountInfoRequest strq( *login ); string request = OfxHeader(login->header_version) + strq.Output(); unsigned size = request.size(); char* result = (char*)malloc(size + 1); request.copy(result, size); result[size] = 0; return result; } /* 20050417210306 GnuCash gcash ENG ReferenceFI 00000 QWIN 1100 FFAAA4AA-A9B1-47F4-98E9-DE635EB41E77 4 19700101000000 */ OfxAccountInfoRequest::OfxAccountInfoRequest( const OfxFiLogin& fi ): OfxRequest(fi) { Add( SignOnRequest() ); OfxAggregate acctinforqTag("ACCTINFORQ"); acctinforqTag.Add( "DTACCTUP", time_t_to_ofxdate( 0 ) ); Add ( RequestMessage("SIGNUP", "ACCTINFO", acctinforqTag) ); } libofx-0.9.12/lib/ofx_request_accountinfo.hh000066400000000000000000000034751315754341700211340ustar00rootroot00000000000000/*************************************************************************** ofx_request_accountinfo.hh ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Declaration of OfxRequestAccountInfo create an OFX file * containing a request for all account info at this FI for this user. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_REQ_ACCOUNTINFO_H #define OFX_REQ_ACCOUNTINFO_H #include #include "libofx.h" #include "ofx_request.hh" using namespace std; /** * \brief An account information request * * This is an entire OFX aggregate, with all subordinate aggregates needed to log onto * the OFX server of a single financial institution and download a list of all accounts * for this user. */ class OfxAccountInfoRequest: public OfxRequest { public: /** * Creates the request aggregate to obtain an account list from this @p fi. * * @param fi The information needed to log on user into one financial * institution */ OfxAccountInfoRequest( const OfxFiLogin& fi ); }; #endif // OFX_REQ_ACCOUNTINFO_H libofx-0.9.12/lib/ofx_request_statement.cpp000066400000000000000000000175471315754341700210200ustar00rootroot00000000000000/*************************************************************************** ofx_request_statement.cpp ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Implementation of libofx_request_statement to create an OFX file * containing a request for a statement. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "libofx.h" #include "ofx_utilities.hh" #include "ofx_request_statement.hh" using namespace std; char* libofx_request_statement( const OfxFiLogin* login, const OfxAccountData* account, time_t date_from ) { OfxStatementRequest strq( *login, *account, date_from ); string request = OfxHeader(login->header_version) + strq.Output(); unsigned size = request.size(); char* result = (char*)malloc(size + 1); request.copy(result, size); result[size] = 0; return result; } OfxStatementRequest::OfxStatementRequest( const OfxFiLogin& fi, const OfxAccountData& account, time_t from ): OfxRequest(fi), m_account(account), m_date_from(from) { Add( SignOnRequest() ); if ( account.account_type == account.OFX_CREDITCARD ) Add(CreditCardStatementRequest()); else if ( account.account_type == account.OFX_INVESTMENT ) Add(InvestmentStatementRequest()); else Add(BankStatementRequest()); } OfxAggregate OfxStatementRequest::BankStatementRequest(void) const { OfxAggregate bankacctfromTag("BANKACCTFROM"); bankacctfromTag.Add( "BANKID", m_account.bank_id ); bankacctfromTag.Add( "ACCTID", m_account.account_number ); if ( m_account.account_type == m_account.OFX_CHECKING ) bankacctfromTag.Add( "ACCTTYPE", "CHECKING" ); else if ( m_account.account_type == m_account.OFX_SAVINGS ) bankacctfromTag.Add( "ACCTTYPE", "SAVINGS" ); else if ( m_account.account_type == m_account.OFX_MONEYMRKT ) bankacctfromTag.Add( "ACCTTYPE", "MONEYMRKT" ); else if ( m_account.account_type == m_account.OFX_CREDITLINE ) bankacctfromTag.Add( "ACCTTYPE", "CREDITLINE" ); else if ( m_account.account_type == m_account.OFX_CMA ) bankacctfromTag.Add( "ACCTTYPE", "CMA" ); OfxAggregate inctranTag("INCTRAN"); inctranTag.Add( "DTSTART", time_t_to_ofxdate( m_date_from ) ); inctranTag.Add( "INCLUDE", "Y" ); OfxAggregate stmtrqTag("STMTRQ"); stmtrqTag.Add( bankacctfromTag ); stmtrqTag.Add( inctranTag ); return RequestMessage("BANK", "STMT", stmtrqTag); } OfxAggregate OfxStatementRequest::CreditCardStatementRequest(void) const { /* QString dtstart_string = _dtstart.toString(Qt::ISODate).remove(QRegExp("[^0-9]")); return message("CREDITCARD","CCSTMT",Tag("CCSTMTRQ") .subtag(Tag("CCACCTFROM").element("ACCTID",accountnum())) .subtag(Tag("INCTRAN").element("DTSTART",dtstart_string).element("INCLUDE","Y"))); } */ OfxAggregate ccacctfromTag("CCACCTFROM"); ccacctfromTag.Add( "ACCTID", m_account.account_number ); OfxAggregate inctranTag("INCTRAN"); inctranTag.Add( "DTSTART", time_t_to_ofxdate( m_date_from ) ); inctranTag.Add( "INCLUDE", "Y" ); OfxAggregate ccstmtrqTag("CCSTMTRQ"); ccstmtrqTag.Add( ccacctfromTag ); ccstmtrqTag.Add( inctranTag ); return RequestMessage("CREDITCARD", "CCSTMT", ccstmtrqTag); } OfxAggregate OfxStatementRequest::InvestmentStatementRequest(void) const { OfxAggregate invacctfromTag("INVACCTFROM"); invacctfromTag.Add( "BROKERID", m_account.broker_id ); invacctfromTag.Add( "ACCTID", m_account.account_number ); OfxAggregate inctranTag("INCTRAN"); inctranTag.Add( "DTSTART", time_t_to_ofxdate( m_date_from ) ); inctranTag.Add( "INCLUDE", "Y" ); OfxAggregate incposTag("INCPOS"); incposTag.Add( "DTASOF", time_t_to_ofxdatetime( time(NULL) ) ); incposTag.Add( "INCLUDE", "Y" ); OfxAggregate invstmtrqTag("INVSTMTRQ"); invstmtrqTag.Add( invacctfromTag ); invstmtrqTag.Add( inctranTag ); invstmtrqTag.Add( "INCOO", "Y" ); invstmtrqTag.Add( incposTag ); invstmtrqTag.Add( "INCBAL", "Y" ); return RequestMessage("INVSTMT", "INVSTMT", invstmtrqTag); } char* libofx_request_payment( const OfxFiLogin* login, const OfxAccountData* account, const OfxPayee* payee, const OfxPayment* payment ) { OfxPaymentRequest strq( *login, *account, *payee, *payment ); string request = OfxHeader(login->header_version) + strq.Output(); unsigned size = request.size(); char* result = (char*)malloc(size + 1); request.copy(result, size); result[size] = 0; return result; } OfxPaymentRequest::OfxPaymentRequest( const OfxFiLogin& fi, const OfxAccountData& account, const OfxPayee& payee, const OfxPayment& payment ): OfxRequest(fi), m_account(account), m_payee(payee), m_payment(payment) { Add( SignOnRequest() ); OfxAggregate bankacctfromTag("BANKACCTFROM"); bankacctfromTag.Add( "BANKID", m_account.bank_id ); bankacctfromTag.Add( "ACCTID", m_account.account_number ); if ( m_account.account_type == m_account.OFX_CHECKING) bankacctfromTag.Add( "ACCTTYPE", "CHECKING" ); else if ( m_account.account_type == m_account.OFX_SAVINGS ) bankacctfromTag.Add( "ACCTTYPE", "SAVINGS" ); else if ( m_account.account_type == m_account.OFX_MONEYMRKT ) bankacctfromTag.Add( "ACCTTYPE", "MONEYMRKT" ); else if ( m_account.account_type == m_account.OFX_CREDITLINE ) bankacctfromTag.Add( "ACCTTYPE", "CREDITLINE" ); else if ( m_account.account_type == m_account.OFX_CMA ) bankacctfromTag.Add( "ACCTTYPE", "CMA" ); OfxAggregate payeeTag("PAYEE"); payeeTag.Add( "NAME", m_payee.name ); payeeTag.Add( "ADDR1", m_payee.address1 ); payeeTag.Add( "CITY", m_payee.city ); payeeTag.Add( "STATE", m_payee.state ); payeeTag.Add( "POSTALCODE", m_payee.postalcode ); payeeTag.Add( "PHONE", m_payee.phone ); OfxAggregate pmtinfoTag("PMTINFO"); pmtinfoTag.Add( bankacctfromTag ); pmtinfoTag.Add( "TRNAMT", m_payment.amount ); pmtinfoTag.Add( payeeTag ); pmtinfoTag.Add( "PAYACCT", m_payment.account ); pmtinfoTag.Add( "DTDUE", m_payment.datedue ); pmtinfoTag.Add( "MEMO", m_payment.memo ); OfxAggregate pmtrqTag("PMTRQ"); pmtrqTag.Add( pmtinfoTag ); Add( RequestMessage("BILLPAY", "PMT", pmtrqTag) ); } char* libofx_request_payment_status( const struct OfxFiLogin* login, const char* transactionid ) { #if 0 OfxAggregate pmtinqrqTag( "PMTINQRQ" ); pmtinqrqTag.Add( "SRVRTID", transactionid ); OfxRequest ofx(*login); ofx.Add( ofx.SignOnRequest() ); ofx.Add( ofx.RequestMessage("BILLPAY", "PMTINQ", pmtinqrqTag) ); string request = OfxHeader() + ofx.Output(); unsigned size = request.size(); char* result = (char*)malloc(size + 1); request.copy(result, size); result[size] = 0; #else OfxAggregate payeesyncrq( "PAYEESYNCRQ" ); payeesyncrq.Add( "TOKEN", "0" ); payeesyncrq.Add( "TOKENONLY", "N" ); payeesyncrq.Add( "REFRESH", "Y" ); payeesyncrq.Add( "REJECTIFMISSING", "N" ); OfxAggregate message( "BILLPAYMSGSRQV1" ); message.Add( payeesyncrq ); OfxRequest ofx(*login); ofx.Add( ofx.SignOnRequest() ); ofx.Add( message ); string request = OfxHeader(login->header_version) + ofx.Output(); unsigned size = request.size(); char* result = (char*)malloc(size + 1); request.copy(result, size); result[size] = 0; #endif return result; } // vim:cin:si:ai:et:ts=2:sw=2: libofx-0.9.12/lib/ofx_request_statement.hh000066400000000000000000000072141315754341700206230ustar00rootroot00000000000000/*************************************************************************** ofx_request_statement.hh ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Declaration of libofx_request_statement to create an OFX file * containing a request for a statement. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_REQ_STATEMENT_H #define OFX_REQ_STATEMENT_H #include #include "libofx.h" #include "ofx_request.hh" using namespace std; /** * \brief A statement request * * This is an entire OFX aggregate, with all subordinate aggregates needed to log onto * the OFX server of a single financial institution and download a statement for * a single account. */ class OfxStatementRequest: public OfxRequest { public: /** * Creates the request aggregate to obtain a statement from this @p fi for * this @p account, starting on this @p start date, ending today. * * @param fi The information needed to log on user into one financial * institution * @param account The account for which a statement is desired * @param start The beginning time of the statement period desired */ OfxStatementRequest( const OfxFiLogin& fi, const OfxAccountData& account, time_t from ); protected: /** * Creates a bank statement request aggregate, , * & for this account. Should only be used if this account is a * BANK account. * * @return The request aggregate created */ OfxAggregate BankStatementRequest(void) const; /** * Creates a credit card statement request aggregate, , * & for this account. Should only be used if this * account is a CREDIT CARD account. * * @return The request aggregate created */ OfxAggregate CreditCardStatementRequest(void) const; /** * Creates an investment statement request aggregate, , * & for this account. Should only be used if this * account is an INVESTMENT account. * * @return The request aggregate created */ OfxAggregate InvestmentStatementRequest(void) const; private: OfxAccountData m_account; time_t m_date_from; }; class OfxPaymentRequest: public OfxRequest { public: /** * Creates the request aggregate to submit a payment to this @p fi on * this @p account, to this @p payee as described by this @payment. * * @param fi The information needed to log on user into one financial * institution * @param account The account from which the payment should be made * @param payee The payee who should receive the payment * @param payment The details of the payment */ OfxPaymentRequest( const OfxFiLogin& fi, const OfxAccountData& account, const OfxPayee& payee, const OfxPayment& payment ); protected: private: OfxAccountData m_account; OfxPayee m_payee; OfxPayment m_payment; }; #endif // OFX_REQ_STATEMENT_H libofx-0.9.12/lib/ofx_sgml.cpp000066400000000000000000000354721315754341700162030ustar00rootroot00000000000000/*************************************************************************** ofx_sgml.cpp ------------------- copyright : (C) 2002 by Benoit Grégoire email : benoitg@coeus.ca ***************************************************************************/ /**@file \brief OFX/SGML parsing functionnality. * Almost all of the SGML parser specific code is contained in this file (some is in messages.cpp and ofx_utilities.cpp). To understand this file you must read the documentation of OpenSP's generic interface: see http://openjade.sourceforge.net/ */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "ParserEventGeneratorKit.h" #include "libofx.h" #include "ofx_utilities.hh" #include "messages.hh" #include "ofx_containers.hh" #include "ofx_sgml.hh" using namespace std; OfxMainContainer * MainContainer = NULL; extern SGMLApplication::OpenEntityPtr entity_ptr; extern SGMLApplication::Position position; /** \brief This object is driven by OpenSP as it parses the SGML from the ofx file(s) */ class OFXApplication : public SGMLApplication { private: OfxGenericContainer *curr_container_element; /**< The currently open object from ofx_proc_rs.cpp */ OfxGenericContainer *tmp_container_element; bool is_data_element; /**< If the SGML element contains data, this flag is raised */ string incoming_data; /**< The raw data from the SGML data element */ LibofxContext * libofx_context; public: OFXApplication (LibofxContext * p_libofx_context) { MainContainer = NULL; curr_container_element = NULL; is_data_element = false; libofx_context = p_libofx_context; } ~OFXApplication() { message_out(DEBUG, "Entering the OFXApplication's destructor"); } /** \brief Callback: Start of an OFX element * An OpenSP callback, get's called when the opening tag of an OFX element appears in the file */ void startElement (const StartElementEvent & event) { string identifier; CharStringtostring (event.gi, identifier); message_out(PARSER, "startElement event received from OpenSP for element " + identifier); position = event.pos; switch (event.contentType) { case StartElementEvent::empty: message_out(ERROR, "StartElementEvent::empty\n"); break; case StartElementEvent::cdata: message_out(ERROR, "StartElementEvent::cdata\n"); break; case StartElementEvent::rcdata: message_out(ERROR, "StartElementEvent::rcdata\n"); break; case StartElementEvent::mixed: message_out(PARSER, "StartElementEvent::mixed"); is_data_element = true; break; case StartElementEvent::element: message_out(PARSER, "StartElementEvent::element"); is_data_element = false; break; default: message_out(ERROR, "Unknown SGML content type?!?!?!? OpenSP interface changed?"); } if (is_data_element == false) { /*------- The following are OFX entities ---------------*/ if (identifier == "OFX") { message_out (PARSER, "Element " + identifier + " found"); MainContainer = new OfxMainContainer (libofx_context, curr_container_element, identifier); curr_container_element = MainContainer; } else if (identifier == "STATUS") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxStatusContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "STMTRS" || identifier == "CCSTMTRS" || identifier == "INVSTMTRS") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxStatementContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "BANKTRANLIST") { message_out (PARSER, "Element " + identifier + " found"); //BANKTRANLIST ignored, we will process it's attributes directly inside the STATEMENT, if (curr_container_element->type != "STATEMENT") { message_out(ERROR, "Element " + identifier + " found while not inside a STATEMENT container"); } else { curr_container_element = new OfxPushUpContainer (libofx_context, curr_container_element, identifier); } } else if (identifier == "STMTTRN") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxBankTransactionContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "BUYDEBT" || identifier == "BUYMF" || identifier == "BUYOPT" || identifier == "BUYOTHER" || identifier == "BUYSTOCK" || identifier == "CLOSUREOPT" || identifier == "INCOME" || identifier == "INVEXPENSE" || identifier == "JRNLFUND" || identifier == "JRNLSEC" || identifier == "MARGININTEREST" || identifier == "REINVEST" || identifier == "RETOFCAP" || identifier == "SELLDEBT" || identifier == "SELLMF" || identifier == "SELLOPT" || identifier == "SELLOTHER" || identifier == "SELLSTOCK" || identifier == "SPLIT" || identifier == "TRANSFER" ) { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxInvestmentTransactionContainer (libofx_context, curr_container_element, identifier); } /*The following is a list of OFX elements whose attributes will be processed by the parent container*/ else if (identifier == "INVBUY" || identifier == "INVSELL" || identifier == "INVTRAN" || identifier == "SECID") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxPushUpContainer (libofx_context, curr_container_element, identifier); } /* The different types of accounts */ else if (identifier == "BANKACCTFROM" || identifier == "CCACCTFROM" || identifier == "INVACCTFROM") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxAccountContainer (libofx_context, curr_container_element, identifier); } else if (identifier == "SECINFO") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxSecurityContainer (libofx_context, curr_container_element, identifier); } /* The different types of balances */ else if (identifier == "LEDGERBAL" || identifier == "AVAILBAL") { message_out (PARSER, "Element " + identifier + " found"); curr_container_element = new OfxBalanceContainer (libofx_context, curr_container_element, identifier); } else { /* We dont know this OFX element, so we create a dummy container */ curr_container_element = new OfxDummyContainer(libofx_context, curr_container_element, identifier); } } else { /* The element was a data element. OpenSP will call one or several data() callback with the data */ message_out (PARSER, "Data element " + identifier + " found"); /* There is a bug in OpenSP 1.3.4, which won't send endElement Event for some elements, and will instead send an error like "document type does not allow element "MESSAGE" here". Incoming_data should be empty in such a case, but it will not be if the endElement event was skiped. So we empty it, so at least the last element has a chance of having valid data */ if (incoming_data != "") { message_out (ERROR, "startElement: incoming_data should be empty! You are probably using OpenSP <= 1.3.4. The following data was lost: " + incoming_data ); incoming_data.assign (""); } } } /** \brief Callback: End of an OFX element * An OpenSP callback, get's called at the end of an OFX element (the closing tags are not always present in OFX) in the file. */ void endElement (const EndElementEvent & event) { string identifier; bool end_element_for_data_element; CharStringtostring (event.gi, identifier); end_element_for_data_element = is_data_element; message_out(PARSER, "endElement event received from OpenSP for element " + identifier); position = event.pos; if (curr_container_element == NULL) { message_out (ERROR, "Tried to close a " + identifier + " without a open element (NULL pointer)"); incoming_data.assign (""); } else //curr_container_element != NULL { if (end_element_for_data_element == true) { incoming_data = strip_whitespace(incoming_data); curr_container_element->add_attribute (identifier, incoming_data); message_out (PARSER, "endElement: Added data '" + incoming_data + "' from " + identifier + " to " + curr_container_element->type + " container_element"); incoming_data.assign (""); is_data_element = false; } else { if (identifier == curr_container_element->tag_identifier) { if (incoming_data != "") { message_out(ERROR, "End tag for non data element " + identifier + ", incoming data should be empty but contains: " + incoming_data + " DATA HAS BEEN LOST SOMEWHERE!"); } if (identifier == "OFX") { /* The main container is a special case */ tmp_container_element = curr_container_element; curr_container_element = curr_container_element->getparent (); if (curr_container_element == NULL) { //Defensive coding, this isn't supposed to happen curr_container_element = tmp_container_element; } if (MainContainer != NULL) { MainContainer->gen_event(); delete MainContainer; MainContainer = NULL; curr_container_element = NULL; message_out (DEBUG, "Element " + identifier + " closed, MainContainer destroyed"); } else { message_out (DEBUG, "Element " + identifier + " closed, but there was no MainContainer to destroy (probably a malformed file)!"); } } else { tmp_container_element = curr_container_element; curr_container_element = curr_container_element->getparent (); if (MainContainer != NULL) { tmp_container_element->add_to_main_tree(); message_out (PARSER, "Element " + identifier + " closed, object added to MainContainer"); } else { message_out (ERROR, "MainContainer is NULL trying to add element " + identifier); } } } else { message_out (ERROR, "Tried to close a " + identifier + " but a " + curr_container_element->type + " is currently open."); } } } } /** \brief Callback: Data from an OFX element * An OpenSP callback, get's called when the raw data of an OFX element appears in the file. Is usually called more than once for a single element, so we must concatenate the data. */ void data (const DataEvent & event) { string tmp; position = event.pos; AppendCharStringtostring (event.data, incoming_data); message_out(PARSER, "data event received from OpenSP, incoming_data is now: " + incoming_data); } /** \brief Callback: SGML parse error * An OpenSP callback, get's called when a parser error has occurred. */ void error (const ErrorEvent & event) { string message; string string_buf; OfxMsgType error_type = ERROR; position = event.pos; message = message + "OpenSP parser: "; switch (event.type) { case SGMLApplication::ErrorEvent::quantity: message = message + "quantity (Exceeding a quantity limit):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::idref: message = message + "idref (An IDREF to a non-existent ID):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::capacity: message = message + "capacity (Exceeding a capacity limit):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::otherError: message = message + "otherError (misc parse error):"; error_type = ERROR; break; case SGMLApplication::ErrorEvent::warning: message = message + "warning (Not actually an error.):"; error_type = WARNING; break; case SGMLApplication::ErrorEvent::info: message = message + "info (An informationnal message. Not actually an error):"; error_type = INFO; break; default: message = message + "OpenSP sent an unknown error to LibOFX (You probably have a newer version of OpenSP):"; } message = message + "\n" + CharStringtostring (event.message, string_buf); message_out (error_type, message); } /** \brief Callback: Receive internal OpenSP state * An Internal OpenSP callback, used to be able to generate line number. */ void openEntityChange (const OpenEntityPtr & para_entity_ptr) { message_out(DEBUG, "openEntityChange()\n"); entity_ptr = para_entity_ptr; }; private: }; /** ofx_proc_sgml will take a list of files in command line format. The first file must be the DTD, and then any number of OFX files. */ int ofx_proc_sgml(LibofxContext * libofx_context, int argc, char * const* argv) { message_out(DEBUG, "Begin ofx_proc_sgml()"); assert(argc >= 3); message_out(DEBUG, argv[0]); message_out(DEBUG, argv[1]); message_out(DEBUG, argv[2]); ParserEventGeneratorKit parserKit; parserKit.setOption (ParserEventGeneratorKit::showOpenEntities); EventGenerator *egp = parserKit.makeEventGenerator (argc, argv); egp->inhibitMessages (true); /* Error output is handled by libofx not OpenSP */ OFXApplication *app = new OFXApplication(libofx_context); unsigned nErrors = egp->run (*app); /* Begin parsing */ delete egp; //Note that this is where bug is triggered return nErrors > 0; } libofx-0.9.12/lib/ofx_sgml.hh000066400000000000000000000023271315754341700160110ustar00rootroot00000000000000/*************************************************************************** ofx_sgml.h ------------------- begin : Tue Mar 19 2002 copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /** @file * \brief OFX/SGML parsing functionnality. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_SGML_H #define OFX_SGML_H #include "context.hh" ///Parses a DTD and OFX file(s) int ofx_proc_sgml(LibofxContext * libofx_context, int argc, char * const* argv); #endif libofx-0.9.12/lib/ofx_utilities.cpp000066400000000000000000000263751315754341700172560ustar00rootroot00000000000000/*************************************************************************** ofx_util.cpp ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Various simple functions for type conversion & al */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include #include #include "ParserEventGeneratorKit.h" #include "SGMLApplication.h" #include #include #include #include #include "messages.hh" #include "ofx_utilities.hh" #ifdef OS_WIN32 # define DIRSEP "\\" #else # define DIRSEP "/" #endif using namespace std; /** Convert an OpenSP CharString directly to a C++ stream, to enable the use of cout directly for debugging. */ /*ostream &operator<<(ostream &os, SGMLApplication::CharString s) { for (size_t i = 0; i < s.len; i++) { os << ((char *)(s.ptr))[i*sizeof(SGMLApplication::Char)]; } return os; }*/ /*wostream &operator<<(wostream &os, SGMLApplication::CharString s) { for (size_t i = 0; i < s.len; i++) {//cout<
* To solve this problem (since usually a time error is relatively unimportant, but date error is), and to avoid problems in Australia caused by the behaviour in libofx up to 0.6.4, it was decided starting with 0.6.5 to use the following behavior:

* -No specific time is given in the file (date only): Considering that most banks seem to be sending dates in this format represented as local time (not compliant with the specs), the transaction is assumed to have occurred 11h59 (just before noon) LOCAL TIME. This way, we should never change the date, since you'd have to travel in a timezone at least 11 hours backwards or 13 hours forward from your own to introduce mistakes. However, if you are in timezone +13 or +14, and your bank meant the data to be interpreted by the spec, you will get the wrong date. We hope that banks in those timezone will either represent in local time like most, or specify the timezone properly.

* -No timezone is specified, but exact time is, the same behavior is mostly used, as many banks just append zeros instead of using the short notation. However, the time specified is used, even if 0 (midnight).

* -When a timezone is specified, it is always used to properly convert in local time, following the spec. * */ time_t ofxdate_to_time_t(const string ofxdate) { struct tm time; double local_offset; /* in seconds */ float ofx_gmt_offset; /* in fractional hours */ char timezone[4]; /* Original timezone: the library does not expose this value*/ char exact_time_specified = false; char time_zone_specified = false; string ofxdate_whole; time_t temptime; time.tm_isdst = daylight; // initialize dst setting std::time(&temptime); local_offset = difftime(mktime(localtime(&temptime)), mktime(gmtime(&temptime))) + (3600 * daylight); if (ofxdate.size() != 0) { ofxdate_whole = ofxdate.substr(0, ofxdate.find_first_not_of("0123456789")); if (ofxdate_whole.size() >= 8) { time.tm_year = atoi(ofxdate_whole.substr(0, 4).c_str()) - 1900; time.tm_mon = atoi(ofxdate_whole.substr(4, 2).c_str()) - 1; time.tm_mday = atoi(ofxdate_whole.substr(6, 2).c_str()); if (ofxdate_whole.size() > 8) { if (ofxdate_whole.size() == 14) { /* if exact time is specified */ exact_time_specified = true; time.tm_hour = atoi(ofxdate_whole.substr(8, 2).c_str()); time.tm_min = atoi(ofxdate_whole.substr(10, 2).c_str()); time.tm_sec = atoi(ofxdate_whole.substr(12, 2).c_str()); } else { message_out(WARNING, "ofxdate_to_time_t(): Successfully parsed date part, but unable to parse time part of string " + ofxdate_whole + ". It is not in proper YYYYMMDDHHMMSS.XXX[gmt offset:tz name] format!"); } } } else { /* Catch invalid string format */ message_out(ERROR, "ofxdate_to_time_t(): Unable to convert time, string " + ofxdate + " is not in proper YYYYMMDDHHMMSS.XXX[gmt offset:tz name] format!"); return mktime(&time); } /* Check if the timezone has been specified */ string::size_type startidx = ofxdate.find("["); string::size_type endidx; if (startidx != string::npos) { /* Time zone was specified */ time_zone_specified = true; startidx++; endidx = ofxdate.find(":", startidx) - 1; ofx_gmt_offset = atof(ofxdate.substr(startidx, (endidx - startidx) + 1).c_str()); startidx = endidx + 2; strncpy(timezone, ofxdate.substr(startidx, 3).c_str(), 4); } else { /* Time zone was not specified, assume GMT (provisionnaly) in case exact time is specified */ ofx_gmt_offset = 0; strcpy(timezone, "GMT"); } if (time_zone_specified == true) { /* If the timezone is specified always correct the timezone */ /* If the timezone is not specified, but the exact time is, correct the timezone, assuming GMT following the spec */ /* Correct the time for the timezone */ time.tm_sec = time.tm_sec + (int)(local_offset - (ofx_gmt_offset * 60 * 60)); //Convert from fractionnal hours to seconds } else if (exact_time_specified == false) { /*Time zone data missing and exact time not specified, diverge from the OFX spec ans assume 11h59 local time */ time.tm_hour = 11; time.tm_min = 59; time.tm_sec = 0; } return mktime(&time); } else { message_out(ERROR, "ofxdate_to_time_t(): Unable to convert time, string is 0 length!"); return 0; // MUST RETURN ZERO here because otherwise the uninitialized &time will be returned! } return mktime(&time); } /** * Convert a C++ string containing an amount of money as specified by the OFX standard and convert it to a double float. *\note The ofx number format is the following: "." or "," as decimal separator, NO thousands separator. */ double ofxamount_to_double(const string ofxamount) { //Replace commas and decimal points for atof() string::size_type idx; string tmp = ofxamount; idx = tmp.find(','); if (idx == string::npos) { idx = tmp.find('.'); } if (idx != string::npos) { tmp.replace(idx, 1, 1, ((localeconv())->decimal_point)[0]); } return atof(tmp.c_str()); } /** Many weird caracters can be present inside a SGML element, as a result on the transfer protocol, or for any reason. This function greatly enhances the reliability of the library by zapping those gremlins (backspace,formfeed,newline,carriage return, horizontal and vertical tabs) as well as removing whitespace at the begining and end of the string. Otherwise, many problems will occur during stringmatching. */ string strip_whitespace(const string para_string) { size_t index; size_t i; string temp_string = para_string; if (temp_string.empty()) return temp_string; // so that size()-1 is allowed below const char *whitespace = " \b\f\n\r\t\v"; const char *abnormal_whitespace = "\b\f\n\r\t\v";//backspace,formfeed,newline,cariage return, horizontal and vertical tabs message_out(DEBUG4, "strip_whitespace() Before: |" + temp_string + "|"); for (i = 0; i <= temp_string.size() && temp_string.find_first_of(whitespace, i) == i && temp_string.find_first_of(whitespace, i) != string::npos; i++); temp_string.erase(0, i); //Strip leading whitespace for (i = temp_string.size() - 1; (i > 0) && (temp_string.find_last_of(whitespace, i) == i) && (temp_string.find_last_of(whitespace, i) != string::npos); i--); temp_string.erase(i + 1, temp_string.size() - (i + 1)); //Strip trailing whitespace while ((index = temp_string.find_first_of(abnormal_whitespace)) != string::npos) { temp_string.erase(index, 1); //Strip leading whitespace }; message_out(DEBUG4, "strip_whitespace() After: |" + temp_string + "|"); return temp_string; } std::string get_tmp_dir() { // Tries to mimic the behaviour of // http://developer.gnome.org/doc/API/2.0/glib/glib-Miscellaneous-Utility-Functions.html#g-get-tmp-dir char *var; var = getenv("TMPDIR"); if (var) return var; var = getenv("TMP"); if (var) return var; var = getenv("TEMP"); if (var) return var; #ifdef OS_WIN32 return "C:\\"; #else return "/tmp"; #endif } int mkTempFileName(const char *tmpl, char *buffer, unsigned int size) { std::string tmp_dir = get_tmp_dir(); strncpy(buffer, tmp_dir.c_str(), size); assert((strlen(buffer) + strlen(tmpl) + 2) < size); strcat(buffer, DIRSEP); strcat(buffer, tmpl); return 0; } libofx-0.9.12/lib/ofx_utilities.hh000066400000000000000000000043361315754341700170640ustar00rootroot00000000000000/*************************************************************************** ofx_util.h ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Various simple functions for type conversion & al */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFX_UTIL_H #define OFX_UTIL_H #include #include // for time_t #include "ParserEventGeneratorKit.h" using namespace std; /* This file contains various simple functions for type conversion & al */ /*wostream &operator<<(wostream &os, SGMLApplication::CharString s); */ ///Convert OpenSP CharString to a C++ stream ostream &operator<<(ostream &os, SGMLApplication::CharString s); ///Convert OpenSP CharString and put it in the C wchar_t string provided wchar_t* CharStringtowchar_t(SGMLApplication::CharString source, wchar_t *dest); ///Convert OpenSP CharString to a C++ STL string string CharStringtostring(const SGMLApplication::CharString source, string &dest); ///Append an OpenSP CharString to an existing C++ STL string string AppendCharStringtostring(const SGMLApplication::CharString source, string &dest); ///Convert a C++ string containing a time in OFX format to a C time_t time_t ofxdate_to_time_t(const string ofxdate); ///Convert OFX amount of money to double float double ofxamount_to_double(const string ofxamount); ///Sanitize a string coming from OpenSP string strip_whitespace(const string para_string); int mkTempFileName(const char *tmpl, char *buffer, unsigned int size); #endif libofx-0.9.12/lib/tree.hh000066400000000000000000001754041315754341700151410ustar00rootroot00000000000000/* $Id: tree.hh,v 1.6 2006-07-20 04:41:16 benoitg Exp $ STL-like templated tree class. Copyright (C) 2001-2005 Kasper Peeters . */ /** \mainpage tree.hh \author Kasper Peeters \version 2.02 \date 12-Oct-2005 \see http://www.aei.mpg.de/~peekas/tree/ \see http://www.aei.mpg.de/~peekas/tree/ChangeLog The tree.hh library for C++ provides an STL-like container class for n-ary trees, templated over the data stored at the nodes. Various types of iterators are provided (post-order, pre-order, and others). Where possible the access methods are compatible with the STL or alternative algorithms are available. */ /* 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; version 2. 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \todo - New-style move members are not completely finished yet. - Fixed depth iterators do not iterate over the entire range if there are 'holes' in the tree. - If a range uses const iter_base& as end iterator, things will inevitably go wrong, because upcast from iter_base to a non-sibling_iter is incorrect. This upcast should be removed (and then all illegal uses as previously in 'equal' will be flagged by the compiler). This requires new copy constructors though. - There's a bug in replace(sibling_iterator, ...) when the ranges sit next to each other. Turned up in append_child(iter,iter) but has been avoided now. - "std::operator<" does not work correctly on our iterators, and for some reason a globally defined template operator< did not get picked up. Using a comparison class now, but this should be investigated. */ #ifndef tree_hh_ #define tree_hh_ #include #include #include #include #include // HP-style construct/destroy have gone from the standard, // so here is a copy. namespace kp { template void constructor(T1* p, T2& val) { new ((void *) p) T1(val); } template void constructor(T1* p) { new ((void *) p) T1; } template void destructor(T1* p) { p->~T1(); } }; /// A node in the tree, combining links to other nodes as well as the actual data. template class tree_node_ // size: 5*4=20 bytes (on 32 bit arch), can be reduced by 8. { public: tree_node_ *parent; tree_node_ *first_child, *last_child; tree_node_ *prev_sibling, *next_sibling; T data; }; // __attribute__((packed)); template < class T, class tree_node_allocator = std::allocator > > class tree { protected: typedef tree_node_ tree_node; public: /// Value of the data stored at a node. typedef T value_type; class iterator_base; class pre_order_iterator; class post_order_iterator; class sibling_iterator; tree(); tree(const T&); tree(const iterator_base&); tree(const tree&); ~tree(); void operator=(const tree&); /// Base class for iterators, only pointers stored, no traversal logic. #ifdef __SGI_STL_PORT class iterator_base : public stlport::bidirectional_iterator { #else class iterator_base { #endif public: typedef T value_type; typedef T* pointer; typedef T& reference; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef std::bidirectional_iterator_tag iterator_category; iterator_base(); iterator_base(tree_node *); T& operator*() const; T* operator->() const; /// When called, the next increment/decrement skips children of this node. void skip_children(); /// Number of children of the node pointed to by the iterator. unsigned int number_of_children() const; sibling_iterator begin() const; sibling_iterator end() const; tree_node *node; protected: bool skip_current_children_; }; /// Depth-first iterator, first accessing the node, then its children. class pre_order_iterator : public iterator_base { public: pre_order_iterator(); pre_order_iterator(tree_node *); pre_order_iterator(const iterator_base&); pre_order_iterator(const sibling_iterator&); bool operator==(const pre_order_iterator&) const; bool operator!=(const pre_order_iterator&) const; pre_order_iterator& operator++(); pre_order_iterator& operator--(); pre_order_iterator operator++(int); pre_order_iterator operator--(int); pre_order_iterator& operator+=(unsigned int); pre_order_iterator& operator-=(unsigned int); }; /// Depth-first iterator, first accessing the children, then the node itself. class post_order_iterator : public iterator_base { public: post_order_iterator(); post_order_iterator(tree_node *); post_order_iterator(const iterator_base&); post_order_iterator(const sibling_iterator&); bool operator==(const post_order_iterator&) const; bool operator!=(const post_order_iterator&) const; post_order_iterator& operator++(); post_order_iterator& operator--(); post_order_iterator operator++(int); post_order_iterator operator--(int); post_order_iterator& operator+=(unsigned int); post_order_iterator& operator-=(unsigned int); /// Set iterator to the first child as deep as possible down the tree. void descend_all(); }; /// The default iterator type throughout the tree class. typedef pre_order_iterator iterator; /// Iterator which traverses only the nodes at a given depth from the root. class fixed_depth_iterator : public iterator_base { public: fixed_depth_iterator(); fixed_depth_iterator(tree_node *); fixed_depth_iterator(const iterator_base&); fixed_depth_iterator(const sibling_iterator&); fixed_depth_iterator(const fixed_depth_iterator&); bool operator==(const fixed_depth_iterator&) const; bool operator!=(const fixed_depth_iterator&) const; fixed_depth_iterator& operator++(); fixed_depth_iterator& operator--(); fixed_depth_iterator operator++(int); fixed_depth_iterator operator--(int); fixed_depth_iterator& operator+=(unsigned int); fixed_depth_iterator& operator-=(unsigned int); tree_node *first_parent_; private: void set_first_parent_(); void find_leftmost_parent_(); }; /// Iterator which traverses only the nodes which are siblings of each other. class sibling_iterator : public iterator_base { public: sibling_iterator(); sibling_iterator(tree_node *); sibling_iterator(const sibling_iterator&); sibling_iterator(const iterator_base&); bool operator==(const sibling_iterator&) const; bool operator!=(const sibling_iterator&) const; sibling_iterator& operator++(); sibling_iterator& operator--(); sibling_iterator operator++(int); sibling_iterator operator--(int); sibling_iterator& operator+=(unsigned int); sibling_iterator& operator-=(unsigned int); tree_node *range_first() const; tree_node *range_last() const; tree_node *parent_; private: void set_parent_(); }; /// Return iterator to the beginning of the tree. inline pre_order_iterator begin() const; /// Return iterator to the end of the tree. inline pre_order_iterator end() const; /// Return post-order iterator to the beginning of the tree. post_order_iterator begin_post() const; /// Return post-order iterator to the end of the tree. post_order_iterator end_post() const; /// Return fixed-depth iterator to the first node at a given depth. fixed_depth_iterator begin_fixed(const iterator_base&, unsigned int) const; /// Return fixed-depth iterator to end of the nodes at given depth. fixed_depth_iterator end_fixed(const iterator_base&, unsigned int) const; /// Return sibling iterator to the first child of given node. sibling_iterator begin(const iterator_base&) const; /// Return sibling iterator to the end of the children of a given node. sibling_iterator end(const iterator_base&) const; /// Return iterator to the parent of a node. template iter parent(iter) const; /// Return iterator to the previous sibling of a node. template iter previous_sibling(iter) const; /// Return iterator to the next sibling of a node. template iter next_sibling(iter) const; /// Return iterator to the next node at a given depth. template iter next_at_same_depth(iter) const; /// Erase all nodes of the tree. void clear(); /// Erase element at position pointed to by iterator, return incremented iterator. template iter erase(iter); /// Erase all children of the node pointed to by iterator. void erase_children(const iterator_base&); /// Insert empty node as last child of node pointed to by position. template iter append_child(iter position); /// Insert node as last child of node pointed to by position. template iter append_child(iter position, const T& x); /// Append the node (plus its children) at other_position as a child of position. template iter append_child(iter position, iter other_position); /// Append the nodes in the from-to range (plus their children) as children of position. template iter append_children(iter position, sibling_iterator from, sibling_iterator to); /// Short-hand to insert topmost node in otherwise empty tree. pre_order_iterator set_head(const T& x); /// Insert node as previous sibling of node pointed to by position. template iter insert(iter position, const T& x); /// Specialisation of previous member. sibling_iterator insert(sibling_iterator position, const T& x); /// Insert node (with children) pointed to by subtree as previous sibling of node pointed to by position. template iter insert_subtree(iter position, const iterator_base& subtree); /// Insert node as next sibling of node pointed to by position. template iter insert_after(iter position, const T& x); /// Replace node at 'position' with other node (keeping same children); 'position' becomes invalid. template iter replace(iter position, const T& x); /// Replace node at 'position' with subtree starting at 'from' (do not erase subtree at 'from'); see above. template iter replace(iter position, const iterator_base& from); /// Replace string of siblings (plus their children) with copy of a new string (with children); see above sibling_iterator replace(sibling_iterator orig_begin, sibling_iterator orig_end, sibling_iterator new_begin, sibling_iterator new_end); /// Move all children of node at 'position' to be siblings, returns position. template iter flatten(iter position); /// Move nodes in range to be children of 'position'. template iter reparent(iter position, sibling_iterator begin, sibling_iterator end); /// Move all child nodes of 'from' to be children of 'position'. template iter reparent(iter position, iter from); /// Move 'source' node (plus its children) to become the next sibling of 'target'. template iter move_after(iter target, iter source); /// Move 'source' node (plus its children) to become the previous sibling of 'target'. template iter move_before(iter target, iter source); /// Move 'source' node (plus its children) to become the node at 'target' (erasing the node at 'target'). template iter move_ontop(iter target, iter source); /// Merge with other tree, creating new branches and leaves only if they are not already present. void merge(sibling_iterator, sibling_iterator, sibling_iterator, sibling_iterator, bool duplicate_leaves = false); /// Sort (std::sort only moves values of nodes, this one moves children as well). void sort(sibling_iterator from, sibling_iterator to, bool deep = false); template void sort(sibling_iterator from, sibling_iterator to, StrictWeakOrdering comp, bool deep = false); /// Compare two ranges of nodes (compares nodes as well as tree structure). template bool equal(const iter& one, const iter& two, const iter& three) const; template bool equal(const iter& one, const iter& two, const iter& three, BinaryPredicate) const; template bool equal_subtree(const iter& one, const iter& two) const; template bool equal_subtree(const iter& one, const iter& two, BinaryPredicate) const; /// Extract a new tree formed by the range of siblings plus all their children. tree subtree(sibling_iterator from, sibling_iterator to) const; void subtree(tree&, sibling_iterator from, sibling_iterator to) const; /// Exchange the node (plus subtree) with its sibling node (do nothing if no sibling present). void swap(sibling_iterator it); /// Count the total number of nodes. int size() const; /// Check if tree is empty. bool empty() const; /// Compute the depth to the root. int depth(const iterator_base&) const; /// Count the number of children of node at position. unsigned int number_of_children(const iterator_base&) const; /// Count the number of 'next' siblings of node at iterator. unsigned int number_of_siblings(const iterator_base&) const; /// Determine whether node at position is in the subtrees with root in the range. bool is_in_subtree(const iterator_base& position, const iterator_base& begin, const iterator_base& end) const; /// Determine whether the iterator is an 'end' iterator and thus not actually pointing to a node. bool is_valid(const iterator_base&) const; /// Determine the index of a node in the range of siblings to which it belongs. unsigned int index(sibling_iterator it) const; /// Inverse of 'index': return the n-th child of the node at position. sibling_iterator child(const iterator_base& position, unsigned int) const; /// Comparator class for iterators (compares the actual node content, not pointer values). class iterator_base_less { public: bool operator()(const typename tree::iterator_base& one, const typename tree::iterator_base& two) const { return one.node < two.node; } }; tree_node *head, *feet; // head/feet are always dummy; if an iterator points to them it is invalid private: tree_node_allocator alloc_; void head_initialise_(); void copy_(const tree& other); /// Comparator class for two nodes of a tree (used for sorting and searching). template class compare_nodes { public: compare_nodes(StrictWeakOrdering comp) : comp_(comp) {}; bool operator()(const tree_node *a, const tree_node *b) { static StrictWeakOrdering comp; return comp(a->data, b->data); } private: StrictWeakOrdering comp_; }; }; //template //class iterator_base_less { // public: // bool operator()(const typename tree::iterator_base& one, // const typename tree::iterator_base& two) const // { // txtout << "operatorclass<" << one.node < two.node << std::endl; // return one.node < two.node; // } //}; //template //bool operator<(const typename tree::iterator& one, // const typename tree::iterator& two) // { // txtout << "operator< " << one.node < two.node << std::endl; // if(one.node < two.node) return true; // return false; // } template bool operator>(const typename tree::iterator_base& one, const typename tree::iterator_base& two) { if (one.node > two.node) return true; return false; } // Tree template tree::tree() { head_initialise_(); } template tree::tree(const T& x) { head_initialise_(); set_head(x); } template tree::tree(const iterator_base& other) { head_initialise_(); set_head((*other)); replace(begin(), other); } template tree::~tree() { clear(); alloc_.deallocate(head, 1); alloc_.deallocate(feet, 1); } template void tree::head_initialise_() { head = alloc_.allocate(1, 0); // MSVC does not have default second argument feet = alloc_.allocate(1, 0); head->parent = 0; head->first_child = 0; head->last_child = 0; head->prev_sibling = 0; //head; head->next_sibling = feet; //head; feet->parent = 0; feet->first_child = 0; feet->last_child = 0; feet->prev_sibling = head; feet->next_sibling = 0; } template void tree::operator=(const tree& other) { copy_(other); } template tree::tree(const tree& other) { head_initialise_(); copy_(other); } template void tree::copy_(const tree& other) { clear(); pre_order_iterator it = other.begin(), to = begin(); while (it != other.end()) { to = insert(to, (*it)); it.skip_children(); ++it; } to = begin(); it = other.begin(); while (it != other.end()) { to = replace(to, it); to.skip_children(); it.skip_children(); ++to; ++it; } } template void tree::clear() { if (head) while (head->next_sibling != feet) erase(pre_order_iterator(head->next_sibling)); } template void tree::erase_children(const iterator_base& it) { tree_node *cur = it.node->first_child; tree_node *prev = 0; while (cur != 0) { prev = cur; cur = cur->next_sibling; erase_children(pre_order_iterator(prev)); kp::destructor(&prev->data); alloc_.deallocate(prev, 1); } it.node->first_child = 0; it.node->last_child = 0; } template template iter tree::erase(iter it) { tree_node *cur = it.node; assert(cur != head); iter ret = it; ret.skip_children(); ++ret; erase_children(it); if (cur->prev_sibling == 0) { cur->parent->first_child = cur->next_sibling; } else { cur->prev_sibling->next_sibling = cur->next_sibling; } if (cur->next_sibling == 0) { cur->parent->last_child = cur->prev_sibling; } else { cur->next_sibling->prev_sibling = cur->prev_sibling; } kp::destructor(&cur->data); alloc_.deallocate(cur, 1); return ret; } template typename tree::pre_order_iterator tree::begin() const { return pre_order_iterator(head->next_sibling); } template typename tree::pre_order_iterator tree::end() const { return pre_order_iterator(feet); } template typename tree::post_order_iterator tree::begin_post() const { tree_node *tmp = head->next_sibling; if (tmp != feet) { while (tmp->first_child) tmp = tmp->first_child; } return post_order_iterator(tmp); } template typename tree::post_order_iterator tree::end_post() const { return post_order_iterator(feet); } template typename tree::fixed_depth_iterator tree::begin_fixed(const iterator_base& pos, unsigned int dp) const { tree_node *tmp = pos.node; unsigned int curdepth = 0; while (curdepth < dp) // go down one level { while (tmp->first_child == 0) { tmp = tmp->next_sibling; if (tmp == 0) throw std::range_error("tree: begin_fixed out of range"); } tmp = tmp->first_child; ++curdepth; } return tmp; } template typename tree::fixed_depth_iterator tree::end_fixed(const iterator_base& pos, unsigned int dp) const { assert(1 == 0); // FIXME: not correct yet tree_node *tmp = pos.node; unsigned int curdepth = 1; while (curdepth < dp) // go down one level { while (tmp->first_child == 0) { tmp = tmp->next_sibling; if (tmp == 0) throw std::range_error("tree: end_fixed out of range"); } tmp = tmp->first_child; ++curdepth; } return tmp; } template typename tree::sibling_iterator tree::begin(const iterator_base& pos) const { if (pos.node->first_child == 0) { return end(pos); } return pos.node->first_child; } template typename tree::sibling_iterator tree::end(const iterator_base& pos) const { sibling_iterator ret(0); ret.parent_ = pos.node; return ret; } template template iter tree::parent(iter position) const { assert(position.node != 0); return iter(position.node->parent); } template template iter tree::previous_sibling(iter position) const { assert(position.node != 0); iter ret(position); ret.node = position.node->prev_sibling; return ret; } template template iter tree::next_sibling(iter position) const { assert(position.node != 0); iter ret(position); ret.node = position.node->next_sibling; return ret; } template template iter tree::next_at_same_depth(iter position) const { assert(position.node != 0); iter ret(position); if (position.node->next_sibling) { ret.node = position.node->next_sibling; } else { int relative_depth = 0; upper: do { ret.node = ret.node->parent; if (ret.node == 0) return ret; --relative_depth; } while (ret.node->next_sibling == 0); lower: ret.node = ret.node->next_sibling; while (ret.node->first_child == 0) { if (ret.node->next_sibling == 0) goto upper; ret.node = ret.node->next_sibling; if (ret.node == 0) return ret; } while (relative_depth < 0 && ret.node->first_child != 0) { ret.node = ret.node->first_child; ++relative_depth; } if (relative_depth < 0) { if (ret.node->next_sibling == 0) goto upper; else goto lower; } } return ret; } template template iter tree::append_child(iter position) { assert(position.node != head); tree_node* tmp = alloc_.allocate(1, 0); kp::constructor(&tmp->data); tmp->first_child = 0; tmp->last_child = 0; tmp->parent = position.node; if (position.node->last_child != 0) { position.node->last_child->next_sibling = tmp; } else { position.node->first_child = tmp; } tmp->prev_sibling = position.node->last_child; position.node->last_child = tmp; tmp->next_sibling = 0; return tmp; } template template iter tree::append_child(iter position, const T& x) { // If your program fails here you probably used 'append_child' to add the top // node to an empty tree. From version 1.45 the top element should be added // using 'insert'. See the documentation for further information, and sorry about // the API change. assert(position.node != head); tree_node* tmp = alloc_.allocate(1, 0); kp::constructor(&tmp->data, x); tmp->first_child = 0; tmp->last_child = 0; tmp->parent = position.node; if (position.node->last_child != 0) { position.node->last_child->next_sibling = tmp; } else { position.node->first_child = tmp; } tmp->prev_sibling = position.node->last_child; position.node->last_child = tmp; tmp->next_sibling = 0; return tmp; } template template iter tree::append_child(iter position, iter other) { assert(position.node != head); sibling_iterator aargh = append_child(position, value_type()); return replace(aargh, other); } template template iter tree::append_children(iter position, sibling_iterator from, sibling_iterator to) { iter ret = from; while (from != to) { insert_subtree(position.end(), from); ++from; } return ret; } template typename tree::pre_order_iterator tree::set_head(const T& x) { assert(head->next_sibling == feet); return insert(iterator(feet), x); } template template iter tree::insert(iter position, const T& x) { if (position.node == 0) { position.node = feet; // Backward compatibility: when calling insert on a null node, // insert before the feet. } tree_node* tmp = alloc_.allocate(1, 0); kp::constructor(&tmp->data, x); tmp->first_child = 0; tmp->last_child = 0; tmp->parent = position.node->parent; tmp->next_sibling = position.node; tmp->prev_sibling = position.node->prev_sibling; position.node->prev_sibling = tmp; if (tmp->prev_sibling == 0) { if (tmp->parent) // when inserting nodes at the head, there is no parent tmp->parent->first_child = tmp; } else tmp->prev_sibling->next_sibling = tmp; return tmp; } template typename tree::sibling_iterator tree::insert(sibling_iterator position, const T& x) { tree_node* tmp = alloc_.allocate(1, 0); kp::constructor(&tmp->data, x); tmp->first_child = 0; tmp->last_child = 0; tmp->next_sibling = position.node; if (position.node == 0) // iterator points to end of a subtree { tmp->parent = position.parent_; tmp->prev_sibling = position.range_last(); tmp->parent->last_child = tmp; } else { tmp->parent = position.node->parent; tmp->prev_sibling = position.node->prev_sibling; position.node->prev_sibling = tmp; } if (tmp->prev_sibling == 0) { if (tmp->parent) // when inserting nodes at the head, there is no parent tmp->parent->first_child = tmp; } else tmp->prev_sibling->next_sibling = tmp; return tmp; } template template iter tree::insert_after(iter position, const T& x) { tree_node* tmp = alloc_.allocate(1, 0); kp::constructor(&tmp->data, x); tmp->first_child = 0; tmp->last_child = 0; tmp->parent = position.node->parent; tmp->prev_sibling = position.node; tmp->next_sibling = position.node->next_sibling; position.node->next_sibling = tmp; if (tmp->next_sibling == 0) { if (tmp->parent) // when inserting nodes at the head, there is no parent tmp->parent->last_child = tmp; } else { tmp->next_sibling->prev_sibling = tmp; } return tmp; } template template iter tree::insert_subtree(iter position, const iterator_base& subtree) { // insert dummy iter it = insert(position, value_type()); // replace dummy with subtree return replace(it, subtree); } // template // template // iter tree::insert_subtree(sibling_iterator position, iter subtree) // { // // insert dummy // iter it(insert(position, value_type())); // // replace dummy with subtree // return replace(it, subtree); // } template template iter tree::replace(iter position, const T& x) { kp::destructor(&position.node->data); kp::constructor(&position.node->data, x); return position; } template template iter tree::replace(iter position, const iterator_base& from) { assert(position.node != head); tree_node *current_from = from.node; tree_node *start_from = from.node; tree_node *current_to = position.node; // replace the node at position with head of the replacement tree at from erase_children(position); tree_node* tmp = alloc_.allocate(1, 0); kp::constructor(&tmp->data, (*from)); tmp->first_child = 0; tmp->last_child = 0; if (current_to->prev_sibling == 0) { current_to->parent->first_child = tmp; } else { current_to->prev_sibling->next_sibling = tmp; } tmp->prev_sibling = current_to->prev_sibling; if (current_to->next_sibling == 0) { current_to->parent->last_child = tmp; } else { current_to->next_sibling->prev_sibling = tmp; } tmp->next_sibling = current_to->next_sibling; tmp->parent = current_to->parent; kp::destructor(¤t_to->data); alloc_.deallocate(current_to, 1); current_to = tmp; // only at this stage can we fix 'last' tree_node *last = from.node->next_sibling; pre_order_iterator toit = tmp; // copy all children do { assert(current_from != 0); if (current_from->first_child != 0) { current_from = current_from->first_child; toit = append_child(toit, current_from->data); } else { while (current_from->next_sibling == 0 && current_from != start_from) { current_from = current_from->parent; toit = parent(toit); assert(current_from != 0); } current_from = current_from->next_sibling; if (current_from != last) { toit = append_child(parent(toit), current_from->data); } } } while (current_from != last); return current_to; } template typename tree::sibling_iterator tree::replace( sibling_iterator orig_begin, sibling_iterator orig_end, sibling_iterator new_begin, sibling_iterator new_end) { tree_node *orig_first = orig_begin.node; tree_node *new_first = new_begin.node; tree_node *orig_last = orig_first; while ((++orig_begin) != orig_end) orig_last = orig_last->next_sibling; tree_node *new_last = new_first; while ((++new_begin) != new_end) new_last = new_last->next_sibling; // insert all siblings in new_first..new_last before orig_first bool first = true; pre_order_iterator ret; while (1 == 1) { pre_order_iterator tt = insert_subtree(pre_order_iterator(orig_first), pre_order_iterator(new_first)); if (first) { ret = tt; first = false; } if (new_first == new_last) break; new_first = new_first->next_sibling; } // erase old range of siblings bool last = false; tree_node *next = orig_first; while (1 == 1) { if (next == orig_last) last = true; next = next->next_sibling; erase((pre_order_iterator)orig_first); if (last) break; orig_first = next; } return ret; } template template iter tree::flatten(iter position) { if (position.node->first_child == 0) return position; tree_node *tmp = position.node->first_child; while (tmp) { tmp->parent = position.node->parent; tmp = tmp->next_sibling; } if (position.node->next_sibling) { position.node->last_child->next_sibling = position.node->next_sibling; position.node->next_sibling->prev_sibling = position.node->last_child; } else { position.node->parent->last_child = position.node->last_child; } position.node->next_sibling = position.node->first_child; position.node->next_sibling->prev_sibling = position.node; position.node->first_child = 0; position.node->last_child = 0; return position; } template template iter tree::reparent(iter position, sibling_iterator begin, sibling_iterator end) { tree_node *first = begin.node; tree_node *last = first; if (begin == end) return begin; // determine last node while ((++begin) != end) { last = last->next_sibling; } // move subtree if (first->prev_sibling == 0) { first->parent->first_child = last->next_sibling; } else { first->prev_sibling->next_sibling = last->next_sibling; } if (last->next_sibling == 0) { last->parent->last_child = first->prev_sibling; } else { last->next_sibling->prev_sibling = first->prev_sibling; } if (position.node->first_child == 0) { position.node->first_child = first; position.node->last_child = last; first->prev_sibling = 0; } else { position.node->last_child->next_sibling = first; first->prev_sibling = position.node->last_child; position.node->last_child = last; } last->next_sibling = 0; tree_node *pos = first; while (1 == 1) { pos->parent = position.node; if (pos == last) break; pos = pos->next_sibling; } return first; } template template iter tree::reparent(iter position, iter from) { if (from.node->first_child == 0) return position; return reparent(position, from.node->first_child, end(from)); } template template iter tree::move_after(iter target, iter source) { tree_node *dst = target.node; tree_node *src = source.node; assert(dst); assert(src); if (dst == src) return source; // take src out of the tree if (src->prev_sibling != 0) src->prev_sibling->next_sibling = src->next_sibling; else src->parent->first_child = src->next_sibling; if (src->next_sibling != 0) src->next_sibling->prev_sibling = src->prev_sibling; else src->parent->last_child = src->prev_sibling; // connect it to the new point if (dst->next_sibling != 0) dst->next_sibling->prev_sibling = src; else dst->parent->last_child = src; src->next_sibling = dst->next_sibling; dst->next_sibling = src; src->prev_sibling = dst; src->parent = dst->parent; return src; } template template iter tree::move_before(iter target, iter source) { tree_node *dst = target.node; tree_node *src = source.node; assert(dst); assert(src); if (dst == src) return source; // take src out of the tree if (src->prev_sibling != 0) src->prev_sibling->next_sibling = src->next_sibling; else src->parent->first_child = src->next_sibling; if (src->next_sibling != 0) src->next_sibling->prev_sibling = src->prev_sibling; else src->parent->last_child = src->prev_sibling; // connect it to the new point if (dst->prev_sibling != 0) dst->prev_sibling->next_sibling = src; else dst->parent->first_child = src; src->prev_sibling = dst->prev_sibling; dst->prev_sibling = src; src->next_sibling = dst; src->parent = dst->parent; return src; } template template iter tree::move_ontop(iter target, iter source) { tree_node *dst = target.node; tree_node *src = source.node; assert(dst); assert(src); if (dst == src) return source; // remember connection points tree_node *b_prev_sibling = dst->prev_sibling; tree_node *b_next_sibling = dst->next_sibling; tree_node *b_parent = dst->parent; // remove target erase(target); // take src out of the tree if (src->prev_sibling != 0) src->prev_sibling->next_sibling = src->next_sibling; else src->parent->first_child = src->next_sibling; if (src->next_sibling != 0) src->next_sibling->prev_sibling = src->prev_sibling; else src->parent->last_child = src->prev_sibling; // connect it to the new point if (b_prev_sibling != 0) b_prev_sibling->next_sibling = src; else b_parent->first_child = src; if (b_next_sibling != 0) b_next_sibling->prev_sibling = src; else b_parent->last_child = src; src->prev_sibling = b_prev_sibling; src->next_sibling = b_next_sibling; src->parent = b_parent; return src; } template void tree::merge(sibling_iterator to1, sibling_iterator to2, sibling_iterator from1, sibling_iterator from2, bool duplicate_leaves) { sibling_iterator fnd; while (from1 != from2) { if ((fnd = std::find(to1, to2, (*from1))) != to2) // element found { if (from1.begin() == from1.end()) // full depth reached { if (duplicate_leaves) append_child(parent(to1), (*from1)); } else // descend further { merge(fnd.begin(), fnd.end(), from1.begin(), from1.end(), duplicate_leaves); } } else // element missing { insert_subtree(to2, from1); } ++from1; } } template void tree::sort(sibling_iterator from, sibling_iterator to, bool deep) { std::less comp; sort(from, to, comp, deep); } template template void tree::sort(sibling_iterator from, sibling_iterator to, StrictWeakOrdering comp, bool deep) { if (from == to) return; // make list of sorted nodes // CHECK: if multiset stores equivalent nodes in the order in which they // are inserted, then this routine should be called 'stable_sort'. std::multiset > nodes(comp); sibling_iterator it = from, it2 = to; while (it != to) { nodes.insert(it.node); ++it; } // reassemble --it2; // prev and next are the nodes before and after the sorted range tree_node *prev = from.node->prev_sibling; tree_node *next = it2.node->next_sibling; typename std::multiset >::iterator nit = nodes.begin(), eit = nodes.end(); if (prev == 0) { if ((*nit)->parent != 0) // to catch "sorting the head" situations, when there is no parent (*nit)->parent->first_child = (*nit); } else prev->next_sibling = (*nit); --eit; while (nit != eit) { (*nit)->prev_sibling = prev; if (prev) prev->next_sibling = (*nit); prev = (*nit); ++nit; } // prev now points to the last-but-one node in the sorted range if (prev) prev->next_sibling = (*eit); // eit points to the last node in the sorted range. (*eit)->next_sibling = next; (*eit)->prev_sibling = prev; // missed in the loop above if (next == 0) { if ((*eit)->parent != 0) // to catch "sorting the head" situations, when there is no parent (*eit)->parent->last_child = (*eit); } else next->prev_sibling = (*eit); if (deep) // sort the children of each node too { sibling_iterator bcs(*nodes.begin()); sibling_iterator ecs(*eit); ++ecs; while (bcs != ecs) { sort(begin(bcs), end(bcs), comp, deep); ++bcs; } } } template template bool tree::equal(const iter& one_, const iter& two, const iter& three_) const { std::equal_to comp; return equal(one_, two, three_, comp); } template template bool tree::equal_subtree(const iter& one_, const iter& two_) const { std::equal_to comp; return equal_subtree(one_, two_, comp); } template template bool tree::equal(const iter& one_, const iter& two, const iter& three_, BinaryPredicate fun) const { pre_order_iterator one(one_), three(three_); // if(one==two && is_valid(three) && three.number_of_children()!=0) // return false; while (one != two && is_valid(three)) { if (!fun(*one, *three)) return false; if (one.number_of_children() != three.number_of_children()) return false; ++one; ++three; } return true; } template template bool tree::equal_subtree(const iter& one_, const iter& two_, BinaryPredicate fun) const { pre_order_iterator one(one_), two(two_); if (!fun(*one, *two)) return false; if (number_of_children(one) != number_of_children(two)) return false; return equal(begin(one), end(one), begin(two), fun); } template tree tree::subtree(sibling_iterator from, sibling_iterator to) const { tree tmp; tmp.set_head(value_type()); tmp.replace(tmp.begin(), tmp.end(), from, to); return tmp; } template void tree::subtree(tree& tmp, sibling_iterator from, sibling_iterator to) const { tmp.set_head(value_type()); tmp.replace(tmp.begin(), tmp.end(), from, to); } template int tree::size() const { int i = 0; pre_order_iterator it = begin(), eit = end(); while (it != eit) { ++i; ++it; } return i; } template bool tree::empty() const { pre_order_iterator it = begin(), eit = end(); return (it == eit); } template int tree::depth(const iterator_base& it) const { tree_node* pos = it.node; assert(pos != 0); int ret = 0; while (pos->parent != 0) { pos = pos->parent; ++ret; } return ret; } template unsigned int tree::number_of_children(const iterator_base& it) const { tree_node *pos = it.node->first_child; if (pos == 0) return 0; unsigned int ret = 1; // while(pos!=it.node->last_child) { // ++ret; // pos=pos->next_sibling; // } while ((pos = pos->next_sibling)) ++ret; return ret; } template unsigned int tree::number_of_siblings(const iterator_base& it) const { tree_node *pos = it.node; unsigned int ret = 0; while (pos->next_sibling && pos->next_sibling != head && pos->next_sibling != feet) { ++ret; pos = pos->next_sibling; } return ret; } template void tree::swap(sibling_iterator it) { tree_node *nxt = it.node->next_sibling; if (nxt) { if (it.node->prev_sibling) it.node->prev_sibling->next_sibling = nxt; else it.node->parent->first_child = nxt; nxt->prev_sibling = it.node->prev_sibling; tree_node *nxtnxt = nxt->next_sibling; if (nxtnxt) nxtnxt->prev_sibling = it.node; else it.node->parent->last_child = it.node; nxt->next_sibling = it.node; it.node->prev_sibling = nxt; it.node->next_sibling = nxtnxt; } } // template // tree::iterator tree::find_subtree( // sibling_iterator subfrom, sibling_iterator subto, iterator from, iterator to, // BinaryPredicate fun) const // { // assert(1==0); // this routine is not finished yet. // while(from!=to) { // if(fun(*subfrom, *from)) { // // } // } // return to; // } template bool tree::is_in_subtree(const iterator_base& it, const iterator_base& begin, const iterator_base& end) const { // FIXME: this should be optimised. pre_order_iterator tmp = begin; while (tmp != end) { if (tmp == it) return true; ++tmp; } return false; } template bool tree::is_valid(const iterator_base& it) const { if (it.node == 0 || it.node == feet) return false; else return true; } template unsigned int tree::index(sibling_iterator it) const { unsigned int ind = 0; if (it.node->parent == 0) { while (it.node->prev_sibling != head) { it.node = it.node->prev_sibling; ++ind; } } else { while (it.node->prev_sibling != 0) { it.node = it.node->prev_sibling; ++ind; } } return ind; } template typename tree::sibling_iterator tree::child(const iterator_base& it, unsigned int num) const { tree_node *tmp = it.node->first_child; while (num--) { assert(tmp != 0); tmp = tmp->next_sibling; } return tmp; } // Iterator base template tree::iterator_base::iterator_base() : node(0), skip_current_children_(false) { } template tree::iterator_base::iterator_base(tree_node *tn) : node(tn), skip_current_children_(false) { } template T& tree::iterator_base::operator*() const { return node->data; } template T* tree::iterator_base::operator->() const { return &(node->data); } template bool tree::post_order_iterator::operator!=(const post_order_iterator& other) const { if (other.node != this->node) return true; else return false; } template bool tree::post_order_iterator::operator==(const post_order_iterator& other) const { if (other.node == this->node) return true; else return false; } template bool tree::pre_order_iterator::operator!=(const pre_order_iterator& other) const { if (other.node != this->node) return true; else return false; } template bool tree::pre_order_iterator::operator==(const pre_order_iterator& other) const { if (other.node == this->node) return true; else return false; } template bool tree::sibling_iterator::operator!=(const sibling_iterator& other) const { if (other.node != this->node) return true; else return false; } template bool tree::sibling_iterator::operator==(const sibling_iterator& other) const { if (other.node == this->node) return true; else return false; } template typename tree::sibling_iterator tree::iterator_base::begin() const { sibling_iterator ret(node->first_child); ret.parent_ = this->node; return ret; } template typename tree::sibling_iterator tree::iterator_base::end() const { sibling_iterator ret(0); ret.parent_ = node; return ret; } template void tree::iterator_base::skip_children() { skip_current_children_ = true; } template unsigned int tree::iterator_base::number_of_children() const { tree_node *pos = node->first_child; if (pos == 0) return 0; unsigned int ret = 1; while (pos != node->last_child) { ++ret; pos = pos->next_sibling; } return ret; } // Pre-order iterator template tree::pre_order_iterator::pre_order_iterator() : iterator_base(0) { } template tree::pre_order_iterator::pre_order_iterator(tree_node *tn) : iterator_base(tn) { } template tree::pre_order_iterator::pre_order_iterator(const iterator_base &other) : iterator_base(other.node) { } template tree::pre_order_iterator::pre_order_iterator(const sibling_iterator& other) : iterator_base(other.node) { if (this->node == 0) { if (other.range_last() != 0) this->node = other.range_last(); else this->node = other.parent_; this->skip_children(); ++(*this); } } template typename tree::pre_order_iterator& tree::pre_order_iterator::operator++() { assert(this->node != 0); if (!this->skip_current_children_ && this->node->first_child != 0) { this->node = this->node->first_child; } else { this->skip_current_children_ = false; while (this->node->next_sibling == 0) { this->node = this->node->parent; if (this->node == 0) return *this; } this->node = this->node->next_sibling; } return *this; } template typename tree::pre_order_iterator& tree::pre_order_iterator::operator--() { assert(this->node != 0); if (this->node->prev_sibling) { this->node = this->node->prev_sibling; while (this->node->last_child) this->node = this->node->last_child; } else { this->node = this->node->parent; if (this->node == 0) return *this; } return *this; } template typename tree::pre_order_iterator tree::pre_order_iterator::operator++(int n) { pre_order_iterator copy = *this; ++(*this); return copy; } template typename tree::pre_order_iterator tree::pre_order_iterator::operator--(int n) { pre_order_iterator copy = *this; --(*this); return copy; } template typename tree::pre_order_iterator& tree::pre_order_iterator::operator+=(unsigned int num) { while (num > 0) { ++(*this); --num; } return (*this); } template typename tree::pre_order_iterator& tree::pre_order_iterator::operator-=(unsigned int num) { while (num > 0) { --(*this); --num; } return (*this); } // Post-order iterator template tree::post_order_iterator::post_order_iterator() : iterator_base(0) { } template tree::post_order_iterator::post_order_iterator(tree_node *tn) : iterator_base(tn) { } template tree::post_order_iterator::post_order_iterator(const iterator_base &other) : iterator_base(other.node) { } template tree::post_order_iterator::post_order_iterator(const sibling_iterator& other) : iterator_base(other.node) { if (this->node == 0) { if (other.range_last() != 0) this->node = other.range_last(); else this->node = other.parent_; this->skip_children(); ++(*this); } } template typename tree::post_order_iterator& tree::post_order_iterator::operator++() { assert(this->node != 0); if (this->node->next_sibling == 0) { this->node = this->node->parent; this->skip_current_children_ = false; } else { this->node = this->node->next_sibling; if (this->skip_current_children_) { this->skip_current_children_ = false; } else { while (this->node->first_child) this->node = this->node->first_child; } } return *this; } template typename tree::post_order_iterator& tree::post_order_iterator::operator--() { assert(this->node != 0); if (this->skip_current_children_ || this->node->last_child == 0) { this->skip_current_children_ = false; while (this->node->prev_sibling == 0) this->node = this->node->parent; this->node = this->node->prev_sibling; } else { this->node = this->node->last_child; } return *this; } template typename tree::post_order_iterator tree::post_order_iterator::operator++(int) { post_order_iterator copy = *this; ++(*this); return copy; } template typename tree::post_order_iterator tree::post_order_iterator::operator--(int) { post_order_iterator copy = *this; --(*this); return copy; } template typename tree::post_order_iterator& tree::post_order_iterator::operator+=(unsigned int num) { while (num > 0) { ++(*this); --num; } return (*this); } template typename tree::post_order_iterator& tree::post_order_iterator::operator-=(unsigned int num) { while (num > 0) { --(*this); --num; } return (*this); } template void tree::post_order_iterator::descend_all() { assert(this->node != 0); while (this->node->first_child) this->node = this->node->first_child; } // Fixed depth iterator template tree::fixed_depth_iterator::fixed_depth_iterator() : iterator_base() { set_first_parent_(); } template tree::fixed_depth_iterator::fixed_depth_iterator(tree_node *tn) : iterator_base(tn) { set_first_parent_(); } template tree::fixed_depth_iterator::fixed_depth_iterator(const iterator_base& other) : iterator_base(other.node) { set_first_parent_(); } template tree::fixed_depth_iterator::fixed_depth_iterator(const sibling_iterator& other) : iterator_base(other.node), first_parent_(other.parent_) { find_leftmost_parent_(); } template tree::fixed_depth_iterator::fixed_depth_iterator(const fixed_depth_iterator& other) : iterator_base(other.node), first_parent_(other.first_parent_) { } template void tree::fixed_depth_iterator::set_first_parent_() { return; // FIXME: we do not use first_parent_ yet, and it actually needs some serious reworking if // it is ever to work at the 'head' level. first_parent_ = 0; if (this->node == 0) return; if (this->node->parent != 0) first_parent_ = this->node->parent; if (first_parent_) find_leftmost_parent_(); } template void tree::fixed_depth_iterator::find_leftmost_parent_() { return; // FIXME: see 'set_first_parent()' tree_node *tmppar = first_parent_; while (tmppar->prev_sibling) { tmppar = tmppar->prev_sibling; if (tmppar->first_child) first_parent_ = tmppar; } } template typename tree::fixed_depth_iterator& tree::fixed_depth_iterator::operator++() { assert(this->node != 0); if (this->node->next_sibling) { this->node = this->node->next_sibling; } else { int relative_depth = 0; upper: do { this->node = this->node->parent; if (this->node == 0) return *this; --relative_depth; } while (this->node->next_sibling == 0); lower: this->node = this->node->next_sibling; while (this->node->first_child == 0) { if (this->node->next_sibling == 0) goto upper; this->node = this->node->next_sibling; if (this->node == 0) return *this; } while (relative_depth < 0 && this->node->first_child != 0) { this->node = this->node->first_child; ++relative_depth; } if (relative_depth < 0) { if (this->node->next_sibling == 0) goto upper; else goto lower; } } return *this; // if(this->node->next_sibling!=0) { // this->node=this->node->next_sibling; // assert(this->node!=0); // if(this->node->parent==0 && this->node->next_sibling==0) // feet element // this->node=0; // } // else { // tree_node *par=this->node->parent; // do { // par=par->next_sibling; // if(par==0) { // FIXME: need to keep track of this! // this->node=0; // return *this; // } // } while(par->first_child==0); // this->node=par->first_child; // } return *this; } template typename tree::fixed_depth_iterator& tree::fixed_depth_iterator::operator--() { assert(this->node != 0); if (this->node->prev_sibling != 0) { this->node = this->node->prev_sibling; assert(this->node != 0); if (this->node->parent == 0 && this->node->prev_sibling == 0) // head element this->node = 0; } else { tree_node *par = this->node->parent; do { par = par->prev_sibling; if (par == 0) // FIXME: need to keep track of this! { this->node = 0; return *this; } } while (par->last_child == 0); this->node = par->last_child; } return *this; } template typename tree::fixed_depth_iterator tree::fixed_depth_iterator::operator++(int) { fixed_depth_iterator copy = *this; ++(*this); return copy; } template typename tree::fixed_depth_iterator tree::fixed_depth_iterator::operator--(int) { fixed_depth_iterator copy = *this; --(*this); return copy; } template typename tree::fixed_depth_iterator& tree::fixed_depth_iterator::operator-=(unsigned int num) { while (num > 0) { --(*this); --(num); } return (*this); } template typename tree::fixed_depth_iterator& tree::fixed_depth_iterator::operator+=(unsigned int num) { while (num > 0) { ++(*this); --(num); } return *this; } // FIXME: add the other members of fixed_depth_iterator. // Sibling iterator template tree::sibling_iterator::sibling_iterator() : iterator_base() { set_parent_(); } template tree::sibling_iterator::sibling_iterator(tree_node *tn) : iterator_base(tn) { set_parent_(); } template tree::sibling_iterator::sibling_iterator(const iterator_base& other) : iterator_base(other.node) { set_parent_(); } template tree::sibling_iterator::sibling_iterator(const sibling_iterator& other) : iterator_base(other), parent_(other.parent_) { } template void tree::sibling_iterator::set_parent_() { parent_ = 0; if (this->node == 0) return; if (this->node->parent != 0) parent_ = this->node->parent; } template typename tree::sibling_iterator& tree::sibling_iterator::operator++() { if (this->node) this->node = this->node->next_sibling; return *this; } template typename tree::sibling_iterator& tree::sibling_iterator::operator--() { if (this->node) this->node = this->node->prev_sibling; else { assert(parent_); this->node = parent_->last_child; } return *this; } template typename tree::sibling_iterator tree::sibling_iterator::operator++(int) { sibling_iterator copy = *this; ++(*this); return copy; } template typename tree::sibling_iterator tree::sibling_iterator::operator--(int) { sibling_iterator copy = *this; --(*this); return copy; } template typename tree::sibling_iterator& tree::sibling_iterator::operator+=(unsigned int num) { while (num > 0) { ++(*this); --num; } return (*this); } template typename tree::sibling_iterator& tree::sibling_iterator::operator-=(unsigned int num) { while (num > 0) { --(*this); --num; } return (*this); } template typename tree::tree_node *tree::sibling_iterator::range_first() const { tree_node *tmp = parent_->first_child; return tmp; } template typename tree::tree_node *tree::sibling_iterator::range_last() const { return parent_->last_child; } #endif // Local variables: // default-tab-width: 3 // End: libofx-0.9.12/lib/win32.cpp000066400000000000000000000030041315754341700153110ustar00rootroot00000000000000/*************************************************************************** $RCSfile: win32.cpp,v $ ------------------- cvs : $Id: win32.cpp,v 1.3 2007-10-27 12:15:58 aquamaniac Exp $ begin : Sat Oct 27 2007 copyright : (C) 2007 by Martin Preuss email : martin@libchipcard.de *************************************************************************** * This file is part of the project "LibOfx". * * Please see toplevel file COPYING of that project for license details. * ***************************************************************************/ #include "win32.hh" #include #include #include #include #include #include #include #include #ifdef OS_WIN32 int mkstemp(char *tmpl) { int fd = -1; int len; char *nf; int i; len = strlen(tmpl); if (len < 6) { /* bad template */ errno = EINVAL; return -1; } if (strcasecmp(tmpl + (len - 7), "XXXXXX")) { /* bad template, last 6 chars must be "X" */ errno = EINVAL; return -1; } nf = strdup(tmpl); for (i = 0; i < 10; i++) { int rnd; char numbuf[16]; rnd = rand(); snprintf(numbuf, sizeof(numbuf) - 1, "%06x", rnd); memmove(nf + (len - 7), numbuf, 6); fd = open(nf, O_RDWR | O_BINARY | O_CREAT, 0444); if (fd >= 0) { memmove(tmpl, nf, len); free(nf); return fd; } } free(nf); errno = EEXIST; return -1; } #endif libofx-0.9.12/lib/win32.hh000066400000000000000000000014111315754341700151260ustar00rootroot00000000000000/*************************************************************************** $RCSfile: win32.hh,v $ ------------------- cvs : $Id: win32.hh,v 1.3 2007-10-27 12:15:58 aquamaniac Exp $ begin : Sat Oct 27 2007 copyright : (C) 2007 by Martin Preuss email : martin@libchipcard.de *************************************************************************** * This file is part of the project "LibOfx". * * Please see toplevel file COPYING of that project for license details. * ***************************************************************************/ #ifndef LIBOFX_WIN32_HH #define LIBOFX_WIN32_HH #ifdef HAVE_CONFIG_H # include #endif #ifdef OS_WIN32 int mkstemp(char *tmpl); #endif #endif libofx-0.9.12/libcurl.m4000066400000000000000000000236521315754341700150060ustar00rootroot00000000000000# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION], # [ACTION-IF-YES], [ACTION-IF-NO]) # ---------------------------------------------------------- # David Shaw May-09-2006 # # Checks for libcurl. DEFAULT-ACTION is the string yes or no to # specify whether to default to --with-libcurl or --without-libcurl. # If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the # minimum version of libcurl to accept. Pass the version as a regular # version number like 7.10.1. If not supplied, any version is # accepted. ACTION-IF-YES is a list of shell commands to run if # libcurl was successfully found and passed the various tests. # ACTION-IF-NO is a list of shell commands that are run otherwise. # Note that using --without-libcurl does run ACTION-IF-NO. # # This macro #defines HAVE_LIBCURL if a working libcurl setup is # found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary # values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are # the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy # where yyy are the various protocols supported by libcurl. Both xxx # and yyy are capitalized. See the list of AH_TEMPLATEs at the top of # the macro for the complete list of possible defines. Shell # variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also # defined to 'yes' for those features and protocols that were found. # Note that xxx and yyy keep the same capitalization as in the # curl-config list (e.g. it's "HTTP" and not "http"). # # Users may override the detected values by doing something like: # LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure # # For the sake of sanity, this macro assumes that any libcurl that is # found is after version 7.7.2, the first version that included the # curl-config script. Note that it is very important for people # packaging binary versions of libcurl to include this script! # Without curl-config, we can only guess what protocols are available, # or use curl_version_info to figure it out at runtime. AC_DEFUN([LIBCURL_CHECK_CONFIG], [ AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL]) AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4]) AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6]) AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz]) AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS]) AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN]) AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI]) AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM]) AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP]) AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS]) AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP]) AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS]) AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE]) AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET]) AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP]) AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT]) AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP]) AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP]) AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3]) AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP]) AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP]) AC_ARG_WITH(libcurl, AC_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]), [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])]) if test "$_libcurl_with" != "no" ; then AC_PROG_AWK _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'" _libcurl_try_link=yes if test -d "$_libcurl_with" ; then LIBCURL_CPPFLAGS="-I$withval/include" _libcurl_ldflags="-L$withval/lib" AC_PATH_PROG([_libcurl_config],[curl-config],[], ["$withval/bin"]) else AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH]) fi if test x$_libcurl_config != "x" ; then AC_CACHE_CHECK([for the version of libcurl], [libcurl_cv_lib_curl_version], [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`]) _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse` if test $_libcurl_wanted -gt 0 ; then AC_CACHE_CHECK([for libcurl >= version $2], [libcurl_cv_lib_version_ok], [ if test $_libcurl_version -ge $_libcurl_wanted ; then libcurl_cv_lib_version_ok=yes else libcurl_cv_lib_version_ok=no fi ]) fi if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then if test x"$LIBCURL_CPPFLAGS" = "x" ; then LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` fi if test x"$LIBCURL" = "x" ; then LIBCURL=`$_libcurl_config --libs` # This is so silly, but Apple actually has a bug in their # curl-config script. Fixed in Tiger, but there are still # lots of Panther installs around. case "${host}" in powerpc-apple-darwin7*) LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'` ;; esac fi # All curl-config scripts support --feature _libcurl_features=`$_libcurl_config --feature` # Is it modern enough to have --protocols? (7.12.4) if test $_libcurl_version -ge 461828 ; then _libcurl_protocols=`$_libcurl_config --protocols` fi else _libcurl_try_link=no fi unset _libcurl_wanted fi if test $_libcurl_try_link = yes ; then # we didn't find curl-config, so let's see if the user-supplied # link line (or failing that, "-lcurl") is enough. LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"} AC_CACHE_CHECK([whether libcurl is usable], [libcurl_cv_lib_curl_usable], [ _libcurl_save_cppflags=$CPPFLAGS CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS" _libcurl_save_libs=$LIBS LIBS="$LIBCURL $LIBS" AC_LINK_IFELSE(AC_LANG_PROGRAM([#include ],[ /* Try and use a few common options to force a failure if we are missing symbols or can't link. */ int x; curl_easy_setopt(NULL,CURLOPT_URL,NULL); x=CURL_ERROR_SIZE; x=CURLOPT_WRITEFUNCTION; x=CURLOPT_FILE; x=CURLOPT_ERRORBUFFER; x=CURLOPT_STDERR; x=CURLOPT_VERBOSE; ]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no) CPPFLAGS=$_libcurl_save_cppflags LIBS=$_libcurl_save_libs unset _libcurl_save_cppflags unset _libcurl_save_libs ]) if test $libcurl_cv_lib_curl_usable = yes ; then # Does curl_free() exist in this version of libcurl? # If not, fake it with free() _libcurl_save_cppflags=$CPPFLAGS CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS" _libcurl_save_libs=$LIBS LIBS="$LIBS $LIBCURL" AC_CHECK_FUNC(curl_free,, AC_DEFINE(curl_free,free, [Define curl_free() as free() if our version of curl lacks curl_free.])) CPPFLAGS=$_libcurl_save_cppflags LIBS=$_libcurl_save_libs unset _libcurl_save_cppflags unset _libcurl_save_libs AC_DEFINE(HAVE_LIBCURL,1, [Define to 1 if you have a functional curl library.]) AC_SUBST(LIBCURL_CPPFLAGS) AC_SUBST(LIBCURL) for _libcurl_feature in $_libcurl_features ; do AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1]) eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes done if test "x$_libcurl_protocols" = "x" ; then # We don't have --protocols, so just assume that all # protocols are available _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" if test x$libcurl_feature_SSL = xyes ; then _libcurl_protocols="$_libcurl_protocols HTTPS" # FTPS wasn't standards-compliant until version # 7.11.0 (0x070b00 == 461568) if test $_libcurl_version -ge 461568; then _libcurl_protocols="$_libcurl_protocols FTPS" fi fi # RTSP, IMAP, POP3 and SMTP were added in # 7.20.0 (0x071400 == 463872) if test $_libcurl_version -ge 463872; then _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" fi fi for _libcurl_protocol in $_libcurl_protocols ; do AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1]) eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes done else unset LIBCURL unset LIBCURL_CPPFLAGS fi fi unset _libcurl_try_link unset _libcurl_version_parse unset _libcurl_config unset _libcurl_feature unset _libcurl_features unset _libcurl_protocol unset _libcurl_protocols unset _libcurl_version unset _libcurl_ldflags fi if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then # This is the IF-NO path ifelse([$4],,:,[$4]) else # This is the IF-YES path ifelse([$3],,:,[$3]) fi unset _libcurl_with ])dnl libofx-0.9.12/libofx.lsm.in000066400000000000000000000007341315754341700155110ustar00rootroot00000000000000Begin3 Title: LibOFX Version: @LIBOFX_VERSION_RELEASE_STRING@ Entered-date: Description: Keywords: OFX, OFX, Open Financial eXchange, Open Financial Connectivity Author: Benoit Grégoire Maintained-by: Benoit Grégoire Primary-site: Home-page: http://libofx.sourceforge.net/ Original-site: Platforms: Linux and other Unices, Windows Copying-policy: GNU Public License End libofx-0.9.12/libofx.pc.in000066400000000000000000000005771315754341700153250ustar00rootroot00000000000000# libofx pkg-config source file prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libofx Description: libofx is a library for processing Open Financial eXchange (OFX) data Version: @VERSION@ Requires: Conflicts: #Libs: -L${libdir} @OPENSPLIBS@ -lofx #Cflags: -I${includedir} -I@OPENSPINCLUDES@ Libs: -L${libdir} -lofx Cflags: -I${includedir} libofx-0.9.12/libofx.spec.in000066400000000000000000000042201315754341700156420ustar00rootroot00000000000000%define name libofx %define version @VERSION@ %define release 1 %define prefix /usr Summary: The LibOFX library is designed to allow applications to very easily support OFX command responses Name: %{name} Version: %{version} Release: %{release} Source: http://download.sourceforge.net/libofx/%{name}-%{version}.tar.gz Requires: openjade >= 1.3.1 Group: Libraries/System License: GPL Packager: Chris Lyttle BuildRoot: %{_tmppath}/%{name}-%{version}-root Prereq: /sbin/ldconfig %description This is the LibOFX library. It is a API designed to allow applications to very easily support OFX command responses, usually provided by financial institutions. See http://www.ofx.net/ofx/default.asp for details and specification. LibOFX is based on the excellent OpenSP library written by James Clark, and now part of the OpenJADE http://openjade.sourceforge.net/ project. OpenSP by itself is not widely distributed. OpenJADE 1.3.1 includes a version on OpenSP that will link, however, it has some major problems with LibOFX and isn't recommended. Since LibOFX uses the generic interface to OpenSP, it should be compatible with all recent versions of OpenSP (It has been developed with OpenSP-1.5pre5). LibOFX is written in C++, but provides a C style interface usable transparently from both C and C++ using a single include file. %prep %setup -q %build ./configure --prefix=%{_prefix} \ --libdir=%{_libdir} --datadir=%{_datadir} \ --includedir=%{_includedir} make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%{prefix} LIBRARY_PATH=$RPM_BUILD_ROOT%{_libdir} make prefix=$RPM_BUILD_ROOT%{_prefix} \ libdir=$RPM_BUILD_ROOT%{_libdir} \ datadir=$RPM_BUILD_ROOT%{_datadir} \ includedir=$RPM_BUILD_ROOT%{_includedir} install %makeinstall %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc AUTHORS COPYING ChangeLog INSTALL NEWS README %{_bindir}/* %{_libdir}/*.a %{_libdir}/*.la %{_libdir}/*.so* %{_libdir}/pkgconfig/libofx.pc %{_includedir}/* %{_datadir}/%{name}/dtd/* %{_datadir}/doc/%{name} %changelog * Sat Nov 23 2002 Chris Lyttle - Created spec file libofx-0.9.12/m4/000077500000000000000000000000001315754341700134205ustar00rootroot00000000000000libofx-0.9.12/m4/.gitignore000066400000000000000000000000331315754341700154040ustar00rootroot00000000000000Makefile.in Makefile *.m4 libofx-0.9.12/m4/Makefile.am000066400000000000000000000000241315754341700154500ustar00rootroot00000000000000 EXTRA_DIST= os.m4 libofx-0.9.12/m4/os.m4000066400000000000000000000057531315754341700143150ustar00rootroot00000000000000# $Id: os.m4,v 1.1 2007-10-27 11:28:08 aquamaniac Exp $ # (c) 2002 Martin Preuss # These functions guess your operation system AC_DEFUN([AQ_CHECK_OS],[ dnl IN: dnl - AC_CANONICAL_SYSTEM muste be called before dnl OUT: dnl Variables: dnl OSYSTEM: Short name of your system (subst) dnl OS_TYPE: either "posix" or "windows" (subst) dnl MAKE_DLL_TARGET: under windows this is set to "dll" (subst) dnl INSTALL_DLL_TARGET: under Windows this is set to "dll-install" (subst) dnl Defines: dnl OS_NAME: full name of your system dnl OS_SHORTNAME: short name of your system dnl Depending on your system one of the following is defined in addition: dnl OS_LINUX, OS_OPENBSD, OS_FREEBSD, OS_BEOS, OS_WIN32 # check for OS AC_MSG_CHECKING([host system type]) OSYSTEM="" OS_TYPE="" MAKE_DLL_TARGET="" INSTALL_DLL_TARGET="" AC_DEFINE_UNQUOTED(OS_NAME,"$host", [host system]) case "$host" in *-linux*) OSYSTEM="linux" AC_DEFINE(OS_LINUX,1,[if linux is used]) AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) OS_TYPE="posix" ;; *-solaris*) OSYSTEM="solaris" AC_DEFINE(OS_SOLARIS,1,[if Solaris is used]) AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) OS_TYPE="posix" ;; *-darwin*) OSYSTEM="osx" AC_DEFINE(OS_DARWIN,1,[if Apple Darwin is used]) AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) OS_TYPE="posix" ;; *-openbsd*) OSYSTEM="openbsd" AC_DEFINE(OS_OPENBSD,1,[if OpenBSD is used]) AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) OS_TYPE="posix" ;; *-freebsd*) OSYSTEM="freebsd" AC_DEFINE(OS_FREEBSD,1,[if FreeBSD is used]) AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) OS_TYPE="posix" ;; *-netbsd*) OSYSTEM="netbsd" AC_DEFINE(OS_NETBSD,1,[if NetBSD is used]) AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) OS_TYPE="posix" ;; *-beos*) OSYSTEM="beos" AC_DEFINE(OS_BEOS,1,[if BeOS is used]) AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) OS_TYPE="posix" ;; *-win32*) OSYSTEM="windows" AC_DEFINE(OS_WIN32,1,[if WIN32 is used]) OS_TYPE="windows" AC_DEFINE_UNQUOTED(BUILDING_DLL,1,[if DLL is to be built]) MAKE_DLL_TARGET="dll" INSTALL_DLL_TARGET="dll-install" ;; *-mingw32*) OSYSTEM="windows" AC_DEFINE(OS_WIN32,1,[if WIN32 is used]) OS_TYPE="windows" AC_DEFINE_UNQUOTED(BUILDING_DLL,1,[if DLL is to be built]) MAKE_DLL_TARGET="dll" INSTALL_DLL_TARGET="dll-install" ;; *-palmos*) OSYSTEM="palmos" AC_DEFINE(OS_PALMOS,1,[if PalmOS is used]) OS_TYPE="palmos" ;; *) AC_MSG_WARN([Sorry, but host $host is not supported. Please report if it works anyway. We will assume that your system is a posix system and continue.]) OSYSTEM="unknown" OS_TYPE="posix" AC_DEFINE(OS_POSIX,1,[if this is a POSIX system]) ;; esac AC_SUBST(OSYSTEM) AC_DEFINE_UNQUOTED(OS_SHORTNAME,"$OSYSTEM",[host system]) AC_SUBST(OS_TYPE) AC_DEFINE_UNQUOTED(OS_TYPE,"$OS_TYPE",[system type]) AC_SUBST(MAKE_DLL_TARGET) AC_SUBST(INSTALL_DLL_TARGET) AC_MSG_RESULT($OS_TYPE) ]) libofx-0.9.12/ofx2qif/000077500000000000000000000000001315754341700144565ustar00rootroot00000000000000libofx-0.9.12/ofx2qif/.gitignore000066400000000000000000000000671315754341700164510ustar00rootroot00000000000000*.la *.lo *.o .deps .libs Makefile Makefile.in ofx2qif libofx-0.9.12/ofx2qif/Makefile.am000066400000000000000000000002101315754341700165030ustar00rootroot00000000000000bin_PROGRAMS = ofx2qif ofx2qif_LDADD = $(top_builddir)/lib/libofx.la ofx2qif_SOURCES = ofx2qif.c AM_CPPFLAGS = \ -I${top_builddir}/inc libofx-0.9.12/ofx2qif/ofx2qif.c000066400000000000000000000212511315754341700162010ustar00rootroot00000000000000/*************************************************************************** ofx2qif.c ------------------- copyright : (C) 2002 by Benoit Gr�goire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Code for ofx2qif utility. C example code * * ofx2qif is a OFX "file" to QIF (Quicken Interchange Format) converter. It was written as a second code example, and as a way for LibOFX to immediately provide something usefull, and to give people a reason to try the library. It is not recommended that financial software use the output of this utility for OFX support. The QIF file format is very primitive, and much information is lost. The utility curently supports every tansaction tags of the QIF format except the address lines, and supports many of the !Account tags. It should generate QIF files that will import sucesfully in just about every software with QIF support. * * I do not plan on improving working this utility much further, however be I would be more than happy to accept contributions. If you are interested in hacking on ofx2qif, links to QIF documentation are available on the LibOFX home page. * * ofx2qif is meant to be the C code example and demo of the library. It uses many of the functions and structures of the LibOFX API. Note that unlike ofxdump, all error output is disabled by default. * * usage: ofx2qif path_to_ofx_file/ofx_filename > output_filename.qif */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include #include #include "libofx.h" #define QIF_FILE_MAX_SIZE 256000 int ofx_proc_transaction_cb(const struct OfxTransactionData data, void * transaction_data) { char dest_string[255]; char trans_buff[4096]; struct tm temp_tm; char trans_list_buff[QIF_FILE_MAX_SIZE]; trans_list_buff[0]='\0'; if(data.date_posted_valid==true){ temp_tm = *localtime(&(data.date_posted)); sprintf(trans_buff, "D%d%s%d%s%d%s", temp_tm.tm_mday, "/", temp_tm.tm_mon+1, "/", temp_tm.tm_year+1900, "\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); } if(data.amount_valid==true){ sprintf(trans_buff, "T%.2f%s",data.amount,"\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); } if(data.check_number_valid==true){ sprintf(trans_buff, "N%s%s",data.check_number,"\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); } else if(data.reference_number_valid==true){ sprintf(trans_buff, "N%s%s",data.reference_number,"\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); } if(data.name_valid==true){ sprintf(trans_buff, "P%s%s",data.name,"\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); } if(data.memo_valid==true){ sprintf(trans_buff, "M%s%s",data.memo,"\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); } /* Add PAYEE and ADRESS here once supported by the library */ if(data.transactiontype_valid==true){ switch(data.transactiontype){ case OFX_CREDIT: strncpy(dest_string, "Generic credit", sizeof(dest_string)); break; case OFX_DEBIT: strncpy(dest_string, "Generic debit", sizeof(dest_string)); break; case OFX_INT: strncpy(dest_string, "Interest earned or paid (Note: Depends on signage of amount)", sizeof(dest_string)); break; case OFX_DIV: strncpy(dest_string, "Dividend", sizeof(dest_string)); break; case OFX_FEE: strncpy(dest_string, "FI fee", sizeof(dest_string)); break; case OFX_SRVCHG: strncpy(dest_string, "Service charge", sizeof(dest_string)); break; case OFX_DEP: strncpy(dest_string, "Deposit", sizeof(dest_string)); break; case OFX_ATM: strncpy(dest_string, "ATM debit or credit (Note: Depends on signage of amount)", sizeof(dest_string)); break; case OFX_POS: strncpy(dest_string, "Point of sale debit or credit (Note: Depends on signage of amount)", sizeof(dest_string)); break; case OFX_XFER: strncpy(dest_string, "Transfer", sizeof(dest_string)); break; case OFX_CHECK: strncpy(dest_string, "Check", sizeof(dest_string)); break; case OFX_PAYMENT: strncpy(dest_string, "Electronic payment", sizeof(dest_string)); break; case OFX_CASH: strncpy(dest_string, "Cash withdrawal", sizeof(dest_string)); break; case OFX_DIRECTDEP: strncpy(dest_string, "Direct deposit", sizeof(dest_string)); break; case OFX_DIRECTDEBIT: strncpy(dest_string, "Merchant initiated debit", sizeof(dest_string)); break; case OFX_REPEATPMT: strncpy(dest_string, "Repeating payment/standing order", sizeof(dest_string)); break; case OFX_OTHER: strncpy(dest_string, "Other", sizeof(dest_string)); break; default : strncpy(dest_string, "Unknown transaction type", sizeof(dest_string)); break; } sprintf(trans_buff, "L%s%s",dest_string,"\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); } strcpy(trans_buff, "^\n"); strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff)); fputs(trans_list_buff,stdout); return 0; }/* end ofx_proc_transaction() */ int ofx_proc_statement_cb(const struct OfxStatementData data, void * statement_data) { struct tm temp_tm; printf("!Account\n"); if(data.account_id_valid==true){ /* Use the account id as the qif name of the account */ printf("N%s%s",data.account_id,"\n"); } if(data.account_ptr->account_type_valid==true) { switch(data.account_ptr->account_type){ case OFX_CHECKING : printf("TBank\n"); break; case OFX_SAVINGS : printf("TBank\n"); break; case OFX_MONEYMRKT : printf("TOth A\n"); break; case OFX_CREDITLINE : printf("TOth L\n"); break; case OFX_CMA : printf("TOth A\n"); break; case OFX_CREDITCARD : printf("TCCard\n"); break; default: perror("WRITEME: ofx_proc_account() This is an unknown account type!"); } } printf("DOFX online account\n"); if(data.ledger_balance_date_valid==true){ temp_tm = *localtime(&(data.ledger_balance_date)); printf("/%d%s%d%s%d%s", temp_tm.tm_mday, "/", temp_tm.tm_mon+1, "/", temp_tm.tm_year+1900, "\n"); } if(data.ledger_balance_valid==true){ printf("$%.2f%s",data.ledger_balance,"\n"); } printf("^\n"); /*The transactions will follow, here is the header */ if(data.account_ptr->account_type_valid==true){ switch(data.account_ptr->account_type){ case OFX_CHECKING : printf("!Type:Bank\n"); break; case OFX_SAVINGS : printf("!Type:Bank\n"); break; case OFX_MONEYMRKT : printf("!Type:Oth A\n"); break; case OFX_CREDITLINE : printf("!Type:Oth L\n"); break; case OFX_CMA : printf("!Type:Oth A\n"); break; case OFX_CREDITCARD : printf("!Type:CCard\n"); break; default: perror("WRITEME: ofx_proc_account() This is an unknown account type!"); } } return 0; }/* end ofx_proc_statement() */ int ofx_proc_account_cb(const struct OfxAccountData data, void * account_data) { char dest_string[255]=""; // strncat(trans_list_buff, dest_string, QIF_FILE_MAX_SIZE - strlen(trans_list_buff)); fputs(dest_string,stdout); return 0; }/* end ofx_proc_account() */ int main (int argc, char *argv[]) { ofx_PARSER_msg = false; ofx_DEBUG_msg = false; ofx_WARNING_msg = false; ofx_ERROR_msg = false; ofx_INFO_msg = false; ofx_STATUS_msg = false; LibofxContextPtr libofx_context = libofx_get_new_context(); ofx_set_statement_cb(libofx_context, ofx_proc_statement_cb, 0); ofx_set_account_cb(libofx_context, ofx_proc_account_cb, 0); ofx_set_transaction_cb(libofx_context, ofx_proc_transaction_cb, 0); if(argc >= 2){ libofx_proc_file(libofx_context, argv[1], OFX); } return libofx_free_context(libofx_context); } libofx-0.9.12/ofxconnect/000077500000000000000000000000001315754341700152465ustar00rootroot00000000000000libofx-0.9.12/ofxconnect/.gitignore000066400000000000000000000001221315754341700172310ustar00rootroot00000000000000*.la *.lo *.o .deps .libs Makefile Makefile.in ofxconnect cmdline.c cmdline.h *.1 libofx-0.9.12/ofxconnect/Makefile.am000066400000000000000000000016371315754341700173110ustar00rootroot00000000000000bin_PROGRAMS = ofxconnect ofxconnect_LDADD = $(top_builddir)/lib/libofx.la @LIBCURL@ @LIBXMLPP_LIBS@ ofxconnect_SOURCES = cmdline.h cmdline.c nodeparser.cpp nodeparser.h ofxpartner.cpp ofxpartner.h ofxconnect.cpp dist_man_MANS = ofxconnect.1 AM_CPPFLAGS = \ -I${top_builddir}/inc \ @LIBCURL_CPPFLAGS@ \ @LIBXMLPP_CFLAGS@ \ '-DCMDLINE_PARSER_PACKAGE="ofxconnect"' if USE_GENGETOPT CLEANFILES = cmdline.c cmdline.h cmdline.c cmdline.h: cmdline.ggo Makefile gengetopt --unamed-opts < $< endif MAINTAINERCLEANFILES = cmdline.c cmdline.h EXTRA_DIST = cmdline.ggo test-privateserver.sh # See README.privateserver for details on this server and how to get # the key needed to run this test. TESTS = test-privateserver.sh ofxconnect.1: ofxconnect.cpp $(top_srcdir)/configure.ac $(MAKE) $(AM_MAKEFLAGS) ofxconnect$(EXEEXT) help2man -n 'Create a statement request file' -N --output=ofxconnect.1 ./ofxconnect$(EXEEXT) libofx-0.9.12/ofxconnect/README000066400000000000000000000036761315754341700161420ustar00rootroot00000000000000Ofxconnect is a utility to test OFX Direct Connect. And it's a sample so you can understand how to use it in your own code. Direct Connect consists of two separate steps: First, contacting the partner server to retrieve information about your bank. Second, contacting your bank to retrieve your accounts and statements. The partner server should be contacted when the user sets up his accounts. Common mistakes with the partner server are to contact it EVERY time you contact the bank, and contacting it just once to cache the contact info for all banks. The former is overkill, the latter means users won't have up-to-date bank contact information. Step-by-step guide to using the ofxconnect utility 1. Retrieve the list of banks $ofxconnect -b 2. Find your bank in the list. Retrieve the FI partner ID's (fipid's) for that bank $ofxconnect -f "Wells Fargo" 101458 102078 5571 3. Retrieve the service capabilities of each fipid to find the one which has the services you want. Note that all the 6-digit fipids don't seem to work well with libofx right now. $ofxconnect -v 5571 Statements? Yes Billpay? Yes Investments? No 4. Retrieve and view the list of all your accounts $ofxconnect -a --fipid=5571 --user=myusername --pass=mypassword accounts.ofx $ofxdump accounts.ofx 2>/dev/null Look for entries like this: Account ID: 999888777 00 123456789 Account name: Bank account 1234567890 Account type: CHECKING Bank ID: 999888777 Branch ID: 00 Account #: 1234567890 5. Retrieve a statement for one of the accounts $ofxconnect -s --fipid=5571 --user=myusername --pass=mypassword --bank=xxx --account=xxx --type=x --past=xx statement.ofx $ofxdump statement.ofx 2>/dev/null The --bank and --account parameters should be exactly like the "Bank ID" and "Account #" results from the account request. The --type is: 1=CHECKING, 2=INVESTMENT, 3=CREDITCARD. Other types are not supported The --past is how many days previous from today you want. libofx-0.9.12/ofxconnect/README.privateserver000066400000000000000000000015131315754341700210260ustar00rootroot00000000000000There is an OFX test server which is used by the developers to ensure that the OFX connection works correctly. The providers of this server have asked us not to post the connection information publically. Therefore, the test script file which connects to this server is encrypted using a GnuPG key: OFX Test Server . You will need this private key to unlock this file. If you are an active, contributing member of the open source OFX community, please e-mail me for this key. Please do not share the key with anyone who does not fit this description. Please do not post the key on any mailing list or any other archived forum. If the key does become comprimised, please e-mail me, or the libofx-devel list and we'll cancel that key and encrypt it using a new one. Thanks Ace Jones libofx-0.9.12/ofxconnect/cmdline.ggo000066400000000000000000000036331315754341700173640ustar00rootroot00000000000000# Name of your program #package "ofxconnect" # Version of your program # don't use version if you're using automake purpose "prints to stdout the created OFX file based on the options you pass it. currently it will only create a statement request file. you can POST this to an OFX server to request a statement from that financial institution for that account." # Options # option {argtype} {typestr=""} {default=""} {required} {argoptional} {multiple} #section "Parameters" option "fipid" - "FI partner identifier (looks up fid, org & url from partner server)" string no option "fid" - "FI identifier" string no option "org" - "FI org tag" string no option "bank" - "IBAN bank identifier" string no option "broker" - "Broker identifier" string no option "user" - "User name" string no option "pass" - "Password" string no option "acct" - "Account ID" string no option "type" - "Account Type 1=checking 2=invest 3=ccard" int no option "past" - "How far back to look from today (in days)" long no option "url" - "Url to POST the data to (otherwise goes to stdout)" string no option "trid" - "Transaction id" int no #section "Commands" defgroup "command" # groupdesc="command to exectute" (Does not work properly with gengetopt 2.10) groupoption "statement-req" s "Request for a statement" group="command" groupoption "accountinfo-req" a "Request for a list of accounts" group="command" groupoption "payment-req" p "Request to make a payment" group="command" groupoption "paymentinquiry-req" i "Request to inquire about the status of a payment" group="command" groupoption "bank-list" b "List all known banks" group="command" groupoption "bank-fipid" f "List all fipids for a given bank" group="command" groupoption "bank-services" v "List supported services for a given fipid" group="command" groupoption "allsupport" - "List all banks which support online banking" group="command" libofx-0.9.12/ofxconnect/login-privateserver.asc000066400000000000000000000012141315754341700217430ustar00rootroot00000000000000-----BEGIN PGP MESSAGE----- Version: GnuPG v1.2.4 (GNU/Linux) hQEOA6R9SAPAMyo2EAP/avnvhR1v/qGWsPbX0EB9ZhFt65TcgDLWhacs+HKzYv9k EyZF2QfZkZFMcVSQhYT22s4B91Fa+Qd3B6qOjFBhVXDqiLbQ6iZIn/uHKQQLUP4+ ZEDD/uIPybrrYPo4u2Ic7GtZSGf6Xb0Es7qfLVZYaMZA0pouF2hmdEdTAgDlIDQD +gJiAQlk4inmgMxTCfXu+Tpohqz5w62bI2qdiRw4/0ANQCmqxEzPfpsGdGzeCDvG e7RHVbni1yQQrkOcSw0LQ8zpw4mrLyFBSAYnzw47Gb5qjWRFtMqXRD888I/i1Lmy Z4/s8DPRQr4fVxfJ6WP65iChqU3+SveNq6fInHE4Kx3R0ocB4hVS2l/0j0cEhSZz pgMHHs+0uo2Q8Y624tNZkvwwffJlOn1llGVEFAtUzgobGd6C3AE+sc+bFJZlmhFv fyfGhUfMh7bseiwJ1V1RsGsbOAA4zNgTQYRCQqeL3uqcTEkfvdNL+1OXI4Zd7L4/ mvDg4zeF4k4XI+LPtXsqSWXB3TWp8abG7Wc= =YLH9 -----END PGP MESSAGE----- libofx-0.9.12/ofxconnect/nodeparser.cpp000066400000000000000000000106061315754341700201170ustar00rootroot00000000000000/*************************************************************************** nodeparser.cpp ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Implementation of nodeparser object, which facilitiates searching * for nodes in an XML file using a notation similiar to XPath. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "nodeparser.h" using std::string; using std::vector; NodeParser::NodeParser(const xmlpp::Node::NodeList& list): xmlpp::Node::NodeList(list) { } NodeParser::NodeParser(const xmlpp::Node* node) { push_back(const_cast(node)); } NodeParser::NodeParser(const xmlpp::DomParser& parser) { xmlpp::Node* node = parser.get_document()->get_root_node(); push_back(const_cast(node)); } NodeParser NodeParser::Path(const xmlpp::Node* node, const std::string& path) { //std::cout << __PRETTY_FUNCTION__ << std::endl; NodeParser result; // split path string into the 1st level, and the rest std::string key = path; std::string remainder; std::string::size_type token_pos = path.find('/'); if ( token_pos != std::string::npos ) { key = path.substr(0, token_pos ); remainder = path.substr( token_pos + 1 ); } // find the first level nodes that match xmlpp::Node::NodeList list = node->get_children(); for (xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) { if ( (*iter)->get_name() == key ) { // if there is still some path left, ask for the rest of the path from those nodes. if ( remainder.length() ) { NodeParser remain_list = NodeParser(*iter).Path(remainder); result.splice(result.end(), remain_list); } // otherwise add the node to the result list. else result.push_back(*iter); } } return result; } NodeParser NodeParser::Path(const std::string& path) const { //std::cout << __PRETTY_FUNCTION__ << std::endl; NodeParser result; for (const_iterator iter = begin(); iter != end(); ++iter) { NodeParser iter_list = Path(*iter, path); result.splice(result.end(), iter_list); } return result; } NodeParser NodeParser::Select(const std::string& key, const std::string& value) const { //std::cout << __PRETTY_FUNCTION__ << std::endl; NodeParser result; for (const_iterator iter = begin(); iter != end(); ++iter) { xmlpp::Node::NodeList list = (*iter)->get_children(); for (xmlpp::Node::NodeList::const_iterator iter3 = list.begin(); iter3 != list.end(); ++iter3) { if ( (*iter3)->get_name() == key ) { xmlpp::Node::NodeList list = (*iter3)->get_children(); for (xmlpp::Node::NodeList::const_iterator iter4 = list.begin(); iter4 != list.end(); ++iter4) { const xmlpp::TextNode* nodeText = dynamic_cast(*iter4); if ( nodeText && nodeText->get_content() == value ) result.push_back(*iter); break; } } } } return result; } vector NodeParser::Text(void) const { vector result; // Go through the list of nodes for (xmlpp::Node::NodeList::const_iterator iter = begin(); iter != end(); ++iter) { // Find the text child node, and print that xmlpp::Node::NodeList list = (*iter)->get_children(); for (xmlpp::Node::NodeList::const_iterator iter2 = list.begin(); iter2 != list.end(); ++iter2) { const xmlpp::TextNode* nodeText = dynamic_cast(*iter2); if ( nodeText ) { result.push_back(nodeText->get_content()); } } } if ( result.empty() ) result.push_back(string()); return result; } // vim:cin:si:ai:et:ts=2:sw=2: libofx-0.9.12/ofxconnect/nodeparser.h000066400000000000000000000032651315754341700175670ustar00rootroot00000000000000/*************************************************************************** nodeparser.cpp ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Declaration of nodeparser object, which facilitiates searching * for nodes in an XML file using a notation similiar to XPath. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef NODEPARSER_H #define NODEPARSER_H #include #include #include class NodeParser: public xmlpp::Node::NodeList { public: NodeParser(void) {} NodeParser(const xmlpp::Node::NodeList&); NodeParser(const xmlpp::Node*); NodeParser(const xmlpp::DomParser&); NodeParser Path(const std::string& path) const; NodeParser Select(const std::string& key, const std::string& value) const; std::vector Text(void) const; protected: static NodeParser Path(const xmlpp::Node* node,const std::string& path); }; #endif // NODEPARSER_H libofx-0.9.12/ofxconnect/ofxconnect.cpp000066400000000000000000000316761315754341700201350ustar00rootroot00000000000000/*************************************************************************** ofx_connect.cpp ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Code for ofxconnect utility. C++ example code * * the purpose of the ofxconnect utility is to server as example code for * ALL functions of libOFX that have to do with creating OFX files. * * ofxconnect prints to stdout the created OFX file based on the options * you pass it * * currently it will only create the statement request file. you can POST * this to an OFX server to request a statement from that financial * institution for that account. * * In the hopefully-not-to-distant future, ofxconnect will also make the * connection to the OFX server, post the data, and call ofxdump itself. */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include #include #include "libofx.h" #include /* Include config constants, e.g., VERSION TF */ #include #include #include #include #include #include #ifdef HAVE_LIBCURL #include #endif #include "cmdline.h" /* Gengetopt generated parser */ #include "nodeparser.h" #include "ofxpartner.h" using namespace std; #ifdef HAVE_LIBCURL bool post(const char* request, const char* url, const char* filename) { CURL *curl = curl_easy_init(); if (! curl) return false; remove("tmpout"); FILE* file = fopen(filename, "wb"); if (! file ) { curl_easy_cleanup(curl); return false; } curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request); struct curl_slist *headerlist = NULL; headerlist = curl_slist_append(headerlist, "Content-type: application/x-ofx"); headerlist = curl_slist_append(headerlist, "Accept: */*, application/x-ofx"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)file); CURLcode res = curl_easy_perform(curl); curl_easy_cleanup(curl); curl_slist_free_all (headerlist); fclose(file); return true; } #else bool post(const char*, const char*, const char*) { cerr << "ERROR: libox must be configured with libcurl to post this request directly" << endl; return false; } #endif ostream& operator<<(ostream& os, const vector& strvect) { for ( vector::const_iterator it = strvect.begin(); it != strvect.end(); ++it) { os << (*it) << endl; } return os; } int main (int argc, char *argv[]) { gengetopt_args_info args_info; if (cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; if ( argc == 1 ) { cmdline_parser_print_help(); exit(1); } if ( args_info.statement_req_given || args_info.accountinfo_req_given ) { if ( (args_info.inputs_num > 0) ) { cout << "file " << args_info.inputs[0] << endl; } else { cerr << "ERROR: You must specify an output file" << endl; } } else if ( args_info.bank_fipid_given || args_info.bank_services_given ) { if ( (args_info.inputs_num > 0) ) { cout << "bank " << args_info.inputs[0] << endl; } else { cerr << "ERROR: You must specify an bank" << endl; } } OfxFiLogin fi; memset(&fi, 0, sizeof(OfxFiLogin)); bool ok = true; string url; if ( args_info.statement_req_given || args_info.accountinfo_req_given || args_info.payment_req_given || args_info.paymentinquiry_req_given ) { // Get the FI Login information // if ( args_info.fipid_given ) { cerr << "fipid " << args_info.fipid_arg << endl; cerr << "contacting partner server..." << endl; OfxFiServiceInfo svcinfo = OfxPartner::ServiceInfo(args_info.fipid_arg); cout << "fid " << svcinfo.fid << endl; strncpy(fi.fid, svcinfo.fid, OFX_FID_LENGTH - 1); cout << "org " << svcinfo.org << endl; strncpy(fi.org, svcinfo.org, OFX_ORG_LENGTH - 1); cout << "url " << svcinfo.url << endl; url = svcinfo.url; } if ( args_info.fid_given ) { cerr << "fid " << args_info.fid_arg << endl; strncpy(fi.fid, args_info.fid_arg, OFX_FID_LENGTH - 1); } else if ( ! args_info.fipid_given ) { cerr << "ERROR: --fid is required" << endl; ok = false; } if ( args_info.org_given ) { cerr << "org " << args_info.org_arg << endl; strncpy(fi.org, args_info.org_arg, OFX_ORG_LENGTH - 1); } else if ( ! args_info.fipid_given ) { cerr << "ERROR: --org is required" << endl; ok = false; } if ( args_info.user_given ) { cerr << "user " << args_info.user_arg << endl; strncpy(fi.userid, args_info.user_arg, OFX_USERID_LENGTH - 1); } else { cerr << "ERROR: --user is required" << endl; ok = false; } if ( args_info.pass_given ) { cerr << "pass " << args_info.pass_arg << endl; strncpy(fi.userpass, args_info.pass_arg, OFX_USERPASS_LENGTH - 1); } else { cerr << "ERROR: --pass is required" << endl; ok = false; } if ( args_info.url_given ) url = args_info.url_arg; } if ( args_info.statement_req_given ) { cerr << "Statement request" << endl; OfxAccountData account; memset(&account, 0, sizeof(OfxAccountData)); if ( args_info.bank_given ) { cerr << "bank " << args_info.bank_arg << endl; strncpy(account.bank_id, args_info.bank_arg, OFX_BANKID_LENGTH - 1); } else { if ( args_info.type_given && args_info.type_arg == 1 ) { cerr << "ERROR: --bank is required for a bank request" << endl; ok = false; } } if ( args_info.broker_given ) { cerr << "broker " << args_info.broker_arg << endl; strncpy(account.broker_id, args_info.broker_arg, OFX_BROKERID_LENGTH - 1); } else { if ( args_info.type_given && args_info.type_arg == 2 ) { cerr << "ERROR: --broker is required for an investment statement request" << endl; ok = false; } } if ( args_info.acct_given ) { cerr << "acct " << args_info.acct_arg << endl; strncpy(account.account_number, args_info.acct_arg, OFX_ACCTID_LENGTH - 1); } else { cerr << "ERROR: --acct is required for a statement request" << endl; ok = false; } if ( args_info.type_given ) { cerr << "type " << args_info.type_arg << endl; switch (args_info.type_arg) { case 1: account.account_type = account.OFX_CHECKING; break; case 2: account.account_type = account.OFX_INVESTMENT; break; case 3: account.account_type = account.OFX_CREDITCARD ; break; default: cerr << "ERROR: --type is not valid. Must be between 1 and 3" << endl; ok = false; } } else { cerr << "ERROR: --type is required for a statement request" << endl; ok = false; } if ( args_info.past_given ) { cerr << "past " << args_info.past_arg << endl; } else { cerr << "ERROR: --past is required for a statement request" << endl; ok = false; } if ( ok ) { char* request = libofx_request_statement( &fi, &account, time(NULL) - args_info.past_arg * 86400L ); if ( url.length() ) post(request, url.c_str(), args_info.inputs[0]); else cout << request; free(request); } } if ( args_info.paymentinquiry_req_given ) { char tridstr[33]; memset(tridstr, 0, 33); bool ok = true; if ( args_info.trid_given ) { cerr << "trid " << args_info.trid_arg << endl; snprintf(tridstr, 32, "%i", args_info.trid_arg); } else { cerr << "ERROR: --trid is required for a payment inquiry request" << endl; ok = false; } if ( ok ) { char* request = libofx_request_payment_status( &fi, tridstr ); filebuf fb; fb.open ("query", ios::out); ostream os(&fb); os << request; fb.close(); if ( url.length() ) post(request, url.c_str(), args_info.inputs[0]); else cout << request; free(request); } } if ( args_info.payment_req_given ) { OfxAccountData account; memset(&account, 0, sizeof(OfxAccountData)); OfxPayee payee; memset(&payee, 0, sizeof(OfxPayee)); OfxPayment payment; memset(&payment, 0, sizeof(OfxPayment)); strcpy(payee.name, "MARTIN PREUSS"); strcpy(payee.address1, "1 LAUREL ST"); strcpy(payee.city, "SAN CARLOS"); strcpy(payee.state, "CA"); strcpy(payee.postalcode, "94070"); strcpy(payee.phone, "866-555-1212"); strcpy(payment.amount, "200.00"); strcpy(payment.account, "1234"); strcpy(payment.datedue, "20060301"); strcpy(payment.memo, "This is a test"); bool ok = true; if ( args_info.bank_given ) { cerr << "bank " << args_info.bank_arg << endl; strncpy(account.bank_id, args_info.bank_arg, OFX_BANKID_LENGTH - 1); } else { if ( args_info.type_given && args_info.type_arg == 1 ) { cerr << "ERROR: --bank is required for a bank request" << endl; ok = false; } } if ( args_info.broker_given ) { cerr << "broker " << args_info.broker_arg << endl; strncpy(account.broker_id, args_info.broker_arg, OFX_BROKERID_LENGTH - 1); } else { if ( args_info.type_given && args_info.type_arg == 2 ) { cerr << "ERROR: --broker is required for an investment statement request" << endl; ok = false; } } if ( args_info.acct_given ) { cerr << "acct " << args_info.acct_arg << endl; strncpy(account.account_number, args_info.acct_arg, OFX_ACCTID_LENGTH - 1); } else { cerr << "ERROR: --acct is required for a statement request" << endl; ok = false; } if ( args_info.type_given ) { cerr << "type " << args_info.type_arg << endl; switch (args_info.type_arg) { case 1: account.account_type = account.OFX_CHECKING; break; case 2: account.account_type = account.OFX_INVESTMENT; break; case 3: account.account_type = account.OFX_CREDITCARD ; break; default: cerr << "ERROR: --type is not valid. Must be between 1 and 3" << endl; ok = false; } } else { cerr << "ERROR: --type is required for a statement request" << endl; ok = false; } if ( ok ) { char* request = libofx_request_payment( &fi, &account, &payee, &payment ); filebuf fb; fb.open ("query", ios::out); ostream os(&fb); os << request; fb.close(); if ( url.length() ) post(request, url.c_str(), args_info.inputs[0]); else cout << request; free(request); } } if ( args_info.accountinfo_req_given ) { if ( ok ) { char* request = libofx_request_accountinfo( &fi ); if ( url.length() ) post(request, url.c_str(), args_info.inputs[0]); else cout << request; free(request); } } if ( args_info.bank_list_given ) { cout << OfxPartner::BankNames(); } if ( args_info.bank_fipid_given ) { cout << OfxPartner::FipidForBank(args_info.inputs[0]); } if ( args_info.bank_services_given ) { OfxFiServiceInfo svcinfo = OfxPartner::ServiceInfo(args_info.inputs[0]); cout << "Account List? " << (svcinfo.accountlist ? "Yes" : "No") << endl; cout << "Statements? " << (svcinfo.statements ? "Yes" : "No") << endl; cout << "Billpay? " << (svcinfo.billpay ? "Yes" : "No") << endl; cout << "Investments? " << (svcinfo.investments ? "Yes" : "No") << endl; } if ( args_info.allsupport_given ) { vector banks = OfxPartner::BankNames(); vector::const_iterator it_bank = banks.begin(); while ( it_bank != banks.end() ) { vector fipids = OfxPartner::FipidForBank(*it_bank); vector::const_iterator it_fipid = fipids.begin(); while ( it_fipid != fipids.end() ) { if ( OfxPartner::ServiceInfo(*it_fipid).accountlist ) cout << *it_bank << endl; ++it_fipid; } ++it_bank; } } return 0; } // vim:cin:si:ai:et:ts=2:sw=2: libofx-0.9.12/ofxconnect/ofxpartner.cpp000066400000000000000000000167301315754341700201510ustar00rootroot00000000000000/*************************************************************************** ofx_partner.cpp ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Methods for connecting to the OFX partner server to retrieve * OFX server information */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include //#ifdef HAVE_LIBCURL #include //#endif #include "ofxpartner.h" #include "nodeparser.h" #include #include #include #include #include #include using std::string; using std::vector; using std::cout; using std::endl; namespace OfxPartner { bool post(const string& request, const string& url, const string& filename); const string kBankFilename = "ofx-bank-index.xml"; const string kCcFilename = "ofx-cc-index.xml"; const string kInvFilename = "ofx-inv-index.xml"; void ValidateIndexCache(void) { // TODO Check whether these files exist and are recent enough before getting them again struct stat filestats; if ( stat( kBankFilename.c_str(), &filestats ) || difftime(time(0), filestats.st_mtime) > 7.0 * 24.0 * 60.0 * 60.0 ) post("T=1&S=*&R=1&O=0&TEST=0", "http://moneycentral.msn.com/money/2005/mnynet/service/ols/filist.aspx?SKU=3&VER=6", kBankFilename); if ( stat( kCcFilename.c_str(), &filestats ) || difftime(time(0), filestats.st_mtime) > 7.0 * 24.0 * 60.0 * 60.0 ) post("T=2&S=*&R=1&O=0&TEST=0", "http://moneycentral.msn.com/money/2005/mnynet/service/ols/filist.aspx?SKU=3&VER=6", kCcFilename); if ( stat( kInvFilename.c_str(), &filestats ) || difftime(time(0), filestats.st_mtime) > 7.0 * 24.0 * 60.0 * 60.0 ) post("T=3&S=*&R=1&O=0&TEST=0", "http://moneycentral.msn.com/money/2005/mnynet/service/ols/filist.aspx?SKU=3&VER=6", kInvFilename); } vector BankNames(void) { vector result; // Make sure the index files are up to date ValidateIndexCache(); xmlpp::DomParser parser; parser.set_substitute_entities(); parser.parse_file(kBankFilename); if ( parser ) { vector names = NodeParser(parser).Path("fi/prov/name").Text(); result.insert(result.end(), names.begin(), names.end()); } parser.parse_file(kCcFilename); if ( parser ) { vector names = NodeParser(parser).Path("fi/prov/name").Text(); result.insert(result.end(), names.begin(), names.end()); } parser.parse_file(kInvFilename); if ( parser ) { vector names = NodeParser(parser).Path("fi/prov/name").Text(); result.insert(result.end(), names.begin(), names.end()); } // Add Innovision result.push_back("Innovision"); // sort the list and remove duplicates, to return one unified list of all supported banks sort(result.begin(), result.end()); result.erase(unique(result.begin(), result.end()), result.end()); return result; } vector FipidForBank(const string& bank) { vector result; xmlpp::DomParser parser; parser.set_substitute_entities(); parser.parse_file(kBankFilename); if ( parser ) { vector fipids = NodeParser(parser).Path("fi/prov").Select("name", bank).Path("guid").Text(); if ( ! fipids.back().empty() ) result.insert(result.end(), fipids.begin(), fipids.end()); } parser.parse_file(kCcFilename); if ( parser ) { vector fipids = NodeParser(parser).Path("fi/prov").Select("name", bank).Path("guid").Text(); if ( ! fipids.back().empty() ) result.insert(result.end(), fipids.begin(), fipids.end()); } parser.parse_file(kInvFilename); if ( parser ) { vector fipids = NodeParser(parser).Path("fi/prov").Select("name", bank).Path("guid").Text(); if ( ! fipids.back().empty() ) result.insert(result.end(), fipids.begin(), fipids.end()); } // the fipid for Innovision is 1. if ( bank == "Innovision" ) result.push_back("1"); sort(result.begin(), result.end()); result.erase(unique(result.begin(), result.end()), result.end()); return result; } OfxFiServiceInfo ServiceInfo(const std::string& fipid) { OfxFiServiceInfo result; memset(&result, 0, sizeof(OfxFiServiceInfo)); // Hard-coded values for Innovision test server if ( fipid == "1" ) { strncpy(result.fid, "00000", OFX_FID_LENGTH - 1); strncpy(result.org, "ReferenceFI", OFX_ORG_LENGTH - 1); strncpy(result.url, "http://ofx.innovision.com", OFX_URL_LENGTH - 1); result.accountlist = 1; result.statements = 1; result.billpay = 1; result.investments = 1; return result; } string url = "http://moneycentral.msn.com/money/2005/mnynet/service/olsvcupd/OnlSvcBrandInfo.aspx?MSNGUID=&GUID=%1&SKU=3&VER=6"; url.replace(url.find("%1"), 2, fipid); // TODO: Check whether this file exists and is recent enough before getting it again string guidfile = "fipid-%1.xml"; guidfile.replace(guidfile.find("%1"), 2, fipid); struct stat filestats; if ( stat( guidfile.c_str(), &filestats ) || difftime(time(0), filestats.st_mtime) > 7.0 * 24.0 * 60.0 * 60.0 ) post("", url.c_str(), guidfile.c_str()); // Print the FI details xmlpp::DomParser parser; parser.set_substitute_entities(); parser.parse_file(guidfile); if ( parser ) { NodeParser nodes(parser); strncpy(result.fid, nodes.Path("ProviderSettings/FID").Text().back().c_str(), OFX_FID_LENGTH - 1); strncpy(result.org, nodes.Path("ProviderSettings/Org").Text().back().c_str(), OFX_ORG_LENGTH - 1); strncpy(result.url, nodes.Path("ProviderSettings/ProviderURL").Text().back().c_str(), OFX_URL_LENGTH - 1); result.accountlist = (nodes.Path("ProviderSettings/AcctListAvail").Text().back() == "1"); result.statements = (nodes.Path("BankingCapabilities/Bank").Text().back() == "1"); result.billpay = (nodes.Path("BillPayCapabilities/Pay").Text().back() == "1"); result.investments = (nodes.Path("InvestmentCapabilities/BrkStmt").Text().back() == "1"); } return result; } bool post(const string& request, const string& url, const string& filename) { #if 1 //#ifdef HAVE_LIBCURL CURL *curl = curl_easy_init(); if (! curl) return false; remove(filename.c_str()); FILE* file = fopen(filename.c_str(), "wb"); if (! file ) { curl_easy_cleanup(curl); return false; } curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); if ( request.length() ) curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)file); /*CURLcode res =*/ curl_easy_perform(curl); curl_easy_cleanup(curl); fclose(file); return true; #else request; url; filename; cerr << "ERROR: libox must be configured with libcurl to post this request" << endl; return false; #endif } } // namespace OfxPartner // vim:cin:si:ai:et:ts=2:sw=2: libofx-0.9.12/ofxconnect/ofxpartner.h000066400000000000000000000026271315754341700176160ustar00rootroot00000000000000/*************************************************************************** ofx_partner.h ------------------- copyright : (C) 2005 by Ace Jones email : acejones@users.sourceforge.net ***************************************************************************/ /**@file * \brief Methods for connecting to the OFX partner server to retrieve * OFX server information */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef OFXPARTNER_H #define OFXPARTNER_H #include #include #include namespace OfxPartner { void ValidateIndexCache(void); OfxFiServiceInfo ServiceInfo(const std::string& fipid); std::vector BankNames(void); std::vector FipidForBank(const std::string& bank); } #endif // OFXPARTNER_H libofx-0.9.12/ofxconnect/test000077500000000000000000000012321315754341700161510ustar00rootroot00000000000000#/bin/sh # # End-to-end test # # This will use libofx to create an OFX statement request, post it to your # bank, and send the input back into libofx to display in a human readable # way. # # Ultimately, I'll make ofxconnect itself POST the file using libcurl, # but this will at least get us started. # # Parameters: # $1 org # $2 fid # $3 bank # $4 user # $5 pass # $6 acct # $7 type # $8 past # $9 url # # See the ofxconnect help for explanation of parameters 1-8. 9 is the URL of your OFX server # rm -f out ./ofxconnect -s --org=$1 --fid=$2 --bank=$3 --user=$4 --pass=$5 --acct=$6 --type=$7 --past=$8 | ./postofx.py $9 > out && ../ofxdump/ofxdump out libofx-0.9.12/ofxconnect/test-privateserver.sh000077500000000000000000000041321315754341700214630ustar00rootroot00000000000000#/bin/sh # # End-to-end test using the private server # # # Extract the login information from the encrypted file # # $serverlogin will include the --user --pass and --url options for the # private ofx server export serverlogin="`gpg -d login-privateserver.asc` --org=ReferenceFI --fid=00000 --bank=000000000 --broker=brokerdomain.com" # # Test a payment # #./ofxconnect -p $serverlogin --acct=10001010 --type=1 tmpfilex && cat tmpfilex # # Test a payment status inquiry # #./ofxconnect -i $serverlogin --trid=21384 tmpfilex && cat tmpfilex #exit # # Test the list of accounts # #./ofxconnect -a $serverlogin tmpfilex && ../ofxdump/ofxdump tmpfilex # # Test checking accounts # ./ofxconnect -s $serverlogin --acct=10001010 --type=1 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex exit ./ofxconnect -s $serverlogin --acct=10001001 --type=1 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex ./ofxconnect -s $serverlogin --acct=10001002 --type=1 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex ./ofxconnect -s $serverlogin --acct=10003001 --type=1 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex # # Test investment accounts # ./ofxconnect -s $serverlogin --acct=20001001 --type=2 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex ./ofxconnect -s $serverlogin --acct=10001010 --type=2 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex ./ofxconnect -s $serverlogin --acct=10001001 --type=2 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex ./ofxconnect -s $serverlogin --acct=10001401 --type=2 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex ./ofxconnect -s $serverlogin --acct=10001000 --type=2 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex ./ofxconnect -s $serverlogin --acct=20001001 --type=2 --past=90 tmpfilex && ../ofxdump/ofxdump tmpfilex # # These don't work yet because I mistakenly put "CHECKING" in for all "BANK" statments as the account type :-( # # --acct=10001003 --type=1 --past=90 # --acct=10001004 --type=1 --past=90 # --acct=10001005 --type=1 --past=90 # # This one throws an ofx.ValidationException. However, the other investment accounts work fine!! # # --acct=10002000 --type=2 --past=90 libofx-0.9.12/ofxdump/000077500000000000000000000000001315754341700145625ustar00rootroot00000000000000libofx-0.9.12/ofxdump/.gitignore000066400000000000000000000001171315754341700165510ustar00rootroot00000000000000*.la *.lo *.o .deps .libs Makefile Makefile.in ofxdump cmdline.c cmdline.h *.1 libofx-0.9.12/ofxdump/Makefile.am000066400000000000000000000013311315754341700166140ustar00rootroot00000000000000bin_PROGRAMS = ofxdump ofxdump_LDADD = $(top_builddir)/lib/libofx.la ofxdump_SOURCES = cmdline.h cmdline.c ofxdump.cpp dist_man_MANS = ofxdump.1 AM_CPPFLAGS = \ -I${top_builddir}/inc \ '-DCMDLINE_PARSER_PACKAGE="ofxdump"' if USE_GENGETOPT CLEANFILES = cmdline.c cmdline.h cmdline.c cmdline.h: cmdline.ggo Makefile gengetopt --unamed-opts < $< endif ofxdump.1: ofxdump.cpp $(top_srcdir)/configure.ac $(MAKE) $(AM_MAKEFLAGS) ofxdump$(EXEEXT) if HAVE_HELP2MAN $(HELP2MAN) -n 'Dump content of OFX files as human-readable text' -N --output=ofxdump.1 ./ofxdump$(EXEEXT) else echo "*** No man page available because of missing help2man tool" > $@ endif MAINTAINERCLEANFILES = cmdline.c cmdline.h EXTRA_DIST = cmdline.ggo libofx-0.9.12/ofxdump/cmdline.ggo000066400000000000000000000023511315754341700166740ustar00rootroot00000000000000# Name of your program # don't use package if you're using automake # Version of your program # don't use version if you're using automake purpose "ofxdump prints to stdout, in human readable form, everything the library understands about a particular file or response, and sends errors to stderr. To know exactly what the library understands about of a particular ofx response file, just call ofxdump on that file." # Options # option {argtype} {typestr=""} {default=""} {required} {argoptional} {multiple} #section "File options" option "import-format" f "Force the file format of the file(s) specified" string default="AUTODETECT" no option "list-import-formats" - "List available import file formats 'import-format' command" no #section "Debug output options" option "msg_parser" - "Output file parsing messages" flag off option "msg_debug" - "Output messages meant for debugging" flag off option "msg_warning" - "Output warning messages about abnormal conditions and unknown constructs" flag on option "msg_error" - "Output error messages" flag on option "msg_info" - "Output informational messages about the progress of the library" flag on option "msg_status" - "Output status messages" flag on libofx-0.9.12/ofxdump/ofxdump.cpp000066400000000000000000000457331315754341700167640ustar00rootroot00000000000000/*************************************************************************** ofxdump.cpp ------------------- copyright : (C) 2002 by Benoit Grégoire email : benoitg@coeus.ca ***************************************************************************/ /**@file * \brief Code for ofxdump utility. C++ example code * * ofxdump prints to stdout, in human readable form, everything the library understands about a particular ofx response file, and sends errors to stderr. To know exactly what the library understands about of a particular ofx response file, just call ofxdump on that file. * * ofxdump is meant as both a C++ code example and a developper/debugging tool. It uses every function and every structure of the LibOFX API. By default, WARNING, INFO, ERROR and STATUS messages are enabled. You can change these defaults at the top of ofxdump.cpp * * usage: ofxdump path_to_ofx_file/ofx_filename */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include #include #include #include #include "libofx.h" #include /* for printf() */ #include /* Include config constants, e.g., VERSION TF */ #include #include "cmdline.h" /* Gengetopt generated parser */ using namespace std; int ofx_proc_security_cb(struct OfxSecurityData data, void * security_data) { char dest_string[255]; cout << "ofx_proc_security():\n"; if (data.unique_id_valid == true) { cout << " Unique ID of the security being traded: " << data.unique_id << "\n"; } if (data.unique_id_type_valid == true) { cout << " Format of the Unique ID: " << data.unique_id_type << "\n"; } if (data.secname_valid == true) { cout << " Name of the security: " << data.secname << "\n"; } if (data.ticker_valid == true) { cout << " Ticker symbol: " << data.ticker << "\n"; } if (data.unitprice_valid == true) { cout << " Price of each unit of the security: " << data.unitprice << "\n"; } if (data.date_unitprice_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.date_unitprice))); cout << " Date as of which the unitprice is valid: " << dest_string << "\n"; } if (data.currency_valid == true) { cout << " Currency of the unitprice: " << data.currency << "\n"; } if (data.memo_valid == true) { cout << " Extra transaction information (memo): " << data.memo << "\n"; } cout << "\n"; return 0; } int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_data) { char dest_string[255]; cout << "ofx_proc_transaction():\n"; if (data.account_id_valid == true) { cout << " Account ID : " << data.account_id << "\n"; } if (data.transactiontype_valid == true) { if (data.transactiontype == OFX_CREDIT) strncpy(dest_string, "CREDIT: Generic credit", sizeof(dest_string)); else if (data.transactiontype == OFX_DEBIT) strncpy(dest_string, "DEBIT: Generic debit", sizeof(dest_string)); else if (data.transactiontype == OFX_INT) strncpy(dest_string, "INT: Interest earned or paid (Note: Depends on signage of amount)", sizeof(dest_string)); else if (data.transactiontype == OFX_DIV) strncpy(dest_string, "DIV: Dividend", sizeof(dest_string)); else if (data.transactiontype == OFX_FEE) strncpy(dest_string, "FEE: FI fee", sizeof(dest_string)); else if (data.transactiontype == OFX_SRVCHG) strncpy(dest_string, "SRVCHG: Service charge", sizeof(dest_string)); else if (data.transactiontype == OFX_DEP) strncpy(dest_string, "DEP: Deposit", sizeof(dest_string)); else if (data.transactiontype == OFX_ATM) strncpy(dest_string, "ATM: ATM debit or credit (Note: Depends on signage of amount)", sizeof(dest_string)); else if (data.transactiontype == OFX_POS) strncpy(dest_string, "POS: Point of sale debit or credit (Note: Depends on signage of amount)", sizeof(dest_string)); else if (data.transactiontype == OFX_XFER) strncpy(dest_string, "XFER: Transfer", sizeof(dest_string)); else if (data.transactiontype == OFX_CHECK) strncpy(dest_string, "CHECK: Check", sizeof(dest_string)); else if (data.transactiontype == OFX_PAYMENT) strncpy(dest_string, "PAYMENT: Electronic payment", sizeof(dest_string)); else if (data.transactiontype == OFX_CASH) strncpy(dest_string, "CASH: Cash withdrawal", sizeof(dest_string)); else if (data.transactiontype == OFX_DIRECTDEP) strncpy(dest_string, "DIRECTDEP: Direct deposit", sizeof(dest_string)); else if (data.transactiontype == OFX_DIRECTDEBIT) strncpy(dest_string, "DIRECTDEBIT: Merchant initiated debit", sizeof(dest_string)); else if (data.transactiontype == OFX_REPEATPMT) strncpy(dest_string, "REPEATPMT: Repeating payment/standing order", sizeof(dest_string)); else if (data.transactiontype == OFX_OTHER) strncpy(dest_string, "OTHER: Other", sizeof(dest_string)); else strncpy(dest_string, "Unknown transaction type", sizeof(dest_string)); cout << " Transaction type: " << dest_string << "\n"; } if (data.date_initiated_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.date_initiated))); cout << " Date initiated: " << dest_string << "\n"; } if (data.date_posted_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.date_posted))); cout << " Date posted: " << dest_string << "\n"; } if (data.date_funds_available_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.date_funds_available))); cout << " Date funds are available: " << dest_string << "\n"; } if (data.amount_valid == true) { cout << " Total money amount: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.amount << "\n"; } if (data.units_valid == true) { cout << " # of units: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.units << "\n"; } if (data.oldunits_valid == true) { cout << " # of units before split: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.oldunits << "\n"; } if (data.newunits_valid == true) { cout << " # of units after split: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.newunits << "\n"; } if (data.unitprice_valid == true) { cout << " Unit price: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.unitprice << "\n"; } if (data.fees_valid == true) { cout << " Fees: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.fees << "\n"; } if (data.commission_valid == true) { cout << " Commission: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.commission << "\n"; } if (data.fi_id_valid == true) { cout << " Financial institution's ID for this transaction: " << data.fi_id << "\n"; } if (data.fi_id_corrected_valid == true) { cout << " Financial institution ID replaced or corrected by this transaction: " << data.fi_id_corrected << "\n"; } if (data.fi_id_correction_action_valid == true) { cout << " Action to take on the corrected transaction: "; if (data.fi_id_correction_action == DELETE) cout << "DELETE\n"; else if (data.fi_id_correction_action == REPLACE) cout << "REPLACE\n"; else cout << "ofx_proc_transaction(): This should not happen!\n"; } if (data.invtransactiontype_valid == true) { cout << " Investment transaction type: "; if (data.invtransactiontype == OFX_BUYDEBT) strncpy(dest_string, "BUYDEBT (Buy debt security)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_BUYMF) strncpy(dest_string, "BUYMF (Buy mutual fund)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_BUYOPT) strncpy(dest_string, "BUYOPT (Buy option)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_BUYOTHER) strncpy(dest_string, "BUYOTHER (Buy other security type)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_BUYSTOCK) strncpy(dest_string, "BUYSTOCK (Buy stock))", sizeof(dest_string)); else if (data.invtransactiontype == OFX_CLOSUREOPT) strncpy(dest_string, "CLOSUREOPT (Close a position for an option)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_INCOME) strncpy(dest_string, "INCOME (Investment income is realized as cash into the investment account)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_INVEXPENSE) strncpy(dest_string, "INVEXPENSE (Misc investment expense that is associated with a specific security)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_JRNLFUND) strncpy(dest_string, "JRNLFUND (Journaling cash holdings between subaccounts within the same investment account)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_MARGININTEREST) strncpy(dest_string, "MARGININTEREST (Margin interest expense)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_REINVEST) strncpy(dest_string, "REINVEST (Reinvestment of income)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_RETOFCAP) strncpy(dest_string, "RETOFCAP (Return of capital)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_SELLDEBT) strncpy(dest_string, "SELLDEBT (Sell debt security. Used when debt is sold, called, or reached maturity)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_SELLMF) strncpy(dest_string, "SELLMF (Sell mutual fund)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_SELLOPT) strncpy(dest_string, "SELLOPT (Sell option)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_SELLOTHER) strncpy(dest_string, "SELLOTHER (Sell other type of security)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_SELLSTOCK) strncpy(dest_string, "SELLSTOCK (Sell stock)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_SPLIT) strncpy(dest_string, "SPLIT (Stock or mutial fund split)", sizeof(dest_string)); else if (data.invtransactiontype == OFX_TRANSFER) strncpy(dest_string, "TRANSFER (Transfer holdings in and out of the investment account)", sizeof(dest_string)); else strncpy(dest_string, "ERROR, this investment transaction type is unknown. This is a bug in ofxdump", sizeof(dest_string)); cout << dest_string << "\n"; } if (data.unique_id_valid == true) { cout << " Unique ID of the security being traded: " << data.unique_id << "\n"; } if (data.unique_id_type_valid == true) { cout << " Format of the Unique ID: " << data.unique_id_type << "\n"; } if (data.security_data_valid == true) { ofx_proc_security_cb(*(data.security_data_ptr), NULL ); } if (data.server_transaction_id_valid == true) { cout << " Server's transaction ID (confirmation number): " << data.server_transaction_id << "\n"; } if (data.check_number_valid == true) { cout << " Check number: " << data.check_number << "\n"; } if (data.reference_number_valid == true) { cout << " Reference number: " << data.reference_number << "\n"; } if (data.standard_industrial_code_valid == true) { cout << " Standard Industrial Code: " << data.standard_industrial_code << "\n"; } if (data.payee_id_valid == true) { cout << " Payee_id: " << data.payee_id << "\n"; } if (data.name_valid == true) { cout << " Name of payee or transaction description: " << data.name << "\n"; } if (data.memo_valid == true) { cout << " Extra transaction information (memo): " << data.memo << "\n"; } cout << "\n"; return 0; }//end ofx_proc_transaction() int ofx_proc_statement_cb(struct OfxStatementData data, void * statement_data) { char dest_string[255]; cout << "ofx_proc_statement():\n"; if (data.currency_valid == true) { cout << " Currency: " << data.currency << "\n"; } if (data.account_id_valid == true) { cout << " Account ID: " << data.account_id << "\n"; } if (data.date_start_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.date_start))); cout << " Start date of this statement: " << dest_string << "\n"; } if (data.date_end_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.date_end))); cout << " End date of this statement: " << dest_string << "\n"; } if (data.ledger_balance_valid == true) { cout << " Ledger balance: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.ledger_balance << "\n"; } if (data.ledger_balance_date_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.ledger_balance_date))); cout << " Ledger balance date: " << dest_string << "\n"; } if (data.available_balance_valid == true) { cout << " Available balance: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.available_balance << "\n"; } if (data.available_balance_date_valid == true) { strftime(dest_string, sizeof(dest_string), "%c %Z", localtime(&(data.available_balance_date))); cout << " Available balance date: " << dest_string << "\n"; } if (data.marketing_info_valid == true) { cout << " Marketing information: " << data.marketing_info << "\n"; } cout << "\n"; return 0; }//end ofx_proc_statement() int ofx_proc_account_cb(struct OfxAccountData data, void * account_data) { cout << "ofx_proc_account():\n"; if (data.account_id_valid == true) { cout << " Account ID: " << data.account_id << "\n"; cout << " Account name: " << data.account_name << "\n"; } if (data.account_type_valid == true) { cout << " Account type: "; switch (data.account_type) { case OfxAccountData::OFX_CHECKING : cout << "CHECKING\n"; break; case OfxAccountData::OFX_SAVINGS : cout << "SAVINGS\n"; break; case OfxAccountData::OFX_MONEYMRKT : cout << "MONEYMRKT\n"; break; case OfxAccountData::OFX_CREDITLINE : cout << "CREDITLINE\n"; break; case OfxAccountData::OFX_CMA : cout << "CMA\n"; break; case OfxAccountData::OFX_CREDITCARD : cout << "CREDITCARD\n"; break; case OfxAccountData::OFX_INVESTMENT : cout << "INVESTMENT\n"; break; default: cout << "ofx_proc_account() WRITEME: This is an unknown account type!"; } } if (data.currency_valid == true) { cout << " Currency: " << data.currency << "\n"; } if (data.bank_id_valid) cout << " Bank ID: " << data.bank_id << endl;; if (data.branch_id_valid) cout << " Branch ID: " << data.branch_id << endl; if (data.account_number_valid) cout << " Account #: " << data.account_number << endl; cout << "\n"; return 0; }//end ofx_proc_account() int ofx_proc_status_cb(struct OfxStatusData data, void * status_data) { cout << "ofx_proc_status():\n"; if (data.ofx_element_name_valid == true) { cout << " Ofx entity this status is relevant to: " << data.ofx_element_name << " \n"; } if (data.severity_valid == true) { cout << " Severity: "; switch (data.severity) { case OfxStatusData::INFO : cout << "INFO\n"; break; case OfxStatusData::WARN : cout << "WARN\n"; break; case OfxStatusData::ERROR : cout << "ERROR\n"; break; default: cout << "WRITEME: Unknown status severity!\n"; } } if (data.code_valid == true) { cout << " Code: " << data.code << ", name: " << data.name << "\n Description: " << data.description << "\n"; } if (data.server_message_valid == true) { cout << " Server Message: " << data.server_message << "\n"; } cout << "\n"; return 0; } int main (int argc, char *argv[]) { gengetopt_args_info args_info; /* let's call our cmdline parser */ if (cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; // if (args_info.msg_parser_given) // cout << "The msg_parser option was given!" << endl; // cout << "The flag is " << ( args_info.msg_parser_flag ? "on" : "off" ) << // "." << endl ; args_info.msg_parser_flag ? ofx_PARSER_msg = true : ofx_PARSER_msg = false; args_info.msg_debug_flag ? ofx_DEBUG_msg = true : ofx_DEBUG_msg = false; args_info.msg_warning_flag ? ofx_WARNING_msg = true : ofx_WARNING_msg = false; args_info.msg_error_flag ? ofx_ERROR_msg = true : ofx_ERROR_msg = false; args_info.msg_info_flag ? ofx_INFO_msg = true : ofx_INFO_msg = false; args_info.msg_status_flag ? ofx_STATUS_msg = true : ofx_STATUS_msg; bool skiphelp = false; if (args_info.list_import_formats_given) { skiphelp = true; cout << "The supported file formats for the 'input-file-format' argument are:" << endl; for (int i = 0; LibofxImportFormatList[i].format != LAST; i++) { cout << " " << LibofxImportFormatList[i].description << endl; } } LibofxContextPtr libofx_context = libofx_get_new_context(); //char **inputs ; /* unamed options */ //unsigned inputs_num ; /* unamed options number */ if (args_info.inputs_num > 0) { const char* filename = args_info.inputs[0]; ofx_set_statement_cb(libofx_context, ofx_proc_statement_cb, 0); ofx_set_account_cb(libofx_context, ofx_proc_account_cb, 0); ofx_set_transaction_cb(libofx_context, ofx_proc_transaction_cb, 0); ofx_set_security_cb(libofx_context, ofx_proc_security_cb, 0); ofx_set_status_cb(libofx_context, ofx_proc_status_cb, 0); enum LibofxFileFormat file_format = libofx_get_file_format_from_str(LibofxImportFormatList, args_info.import_format_arg); /** @todo currently, only the first file is processed as the library can't deal with more right now.*/ if (args_info.inputs_num > 1) { cout << "Sorry, currently, only the first file is processed as the library can't deal with more right now. The following files were ignored:" << endl; for ( unsigned i = 1 ; i < args_info.inputs_num ; ++i ) { cout << "file: " << args_info.inputs[i] << endl ; } } libofx_proc_file(libofx_context, args_info.inputs[0], file_format); } else { if ( !skiphelp ) cmdline_parser_print_help(); } return 0; } libofx-0.9.12/totest.txt000066400000000000000000000015541315754341700151700ustar00rootroot00000000000000This is a list of implemented but untested features OFX aggregates: inside - and - and (trivial) - (trivial) - (trivial) - and (trivial) TODO: -Write checking after tag closing that all ofx mandatory structures are present -Write currency conversion routine inside transaction lists -Stock and investment account support. This is not trivial -OFX export UNIMPLEMENTED: -In , the field , some sort of checksum. See spec 1.6, p. 179. I dont know how to use it. This fiels represents "Check digits" in Belgium, D.C. in Spain, "Clé" in France and "CIN" in Italy. Can someone from one of these country telle me how to use it? -Fully implemented structures (all mandatory and all optional information): Bank Statement Download: -