Index: ChangeLog =================================================================== RCS file: /cvsroot/libofx/libofx/ChangeLog,v retrieving revision 1.96 diff -u -r1.96 ChangeLog --- ChangeLog 15 May 2009 14:11:41 -0000 1.96 +++ ChangeLog 22 Sep 2009 20:28:40 -0000 @@ -1,3 +1,8 @@ +2009-09-22 Christian Stimming + + * lib/ofx_preproc.cpp: Win32: Add gnucash patch that looks up the + dtd installation directory from the current executable's location. + 2009-05-09 Benoit Grégoire * Various C++ include fixes for building with recent compilers. Patch by Bill Nottingham Index: lib/ofx_preproc.cpp =================================================================== RCS file: /cvsroot/libofx/libofx/lib/ofx_preproc.cpp,v retrieving revision 1.24 diff -u -r1.24 ofx_preproc.cpp --- lib/ofx_preproc.cpp 6 Dec 2008 22:28:39 -0000 1.24 +++ lib/ofx_preproc.cpp 22 Sep 2009 20:28:41 -0000 @@ -36,6 +36,9 @@ #ifdef OS_WIN32 # include "win32.hh" +# include // for GetModuleFileName() +# undef ERROR +# undef DELETE #endif #define LIBOFX_DEFAULT_INPUT_ENCODING "CP1252" @@ -505,6 +508,31 @@ } +#ifdef OS_WIN32 +static std::string get_dtd_installation_directory() +{ + // Partial implementation of + // http://developer.gnome.org/doc/API/2.0/glib/glib-Windows-Compatibility-Functions.html#g-win32-get-package-installation-directory + char ch_fn[MAX_PATH], *p; + std::string str_fn; + + if (!GetModuleFileName(NULL, ch_fn, MAX_PATH)) return ""; + + if ((p = strrchr(ch_fn, '\\')) != NULL) + *p = '\0'; + + p = strrchr(ch_fn, '\\'); + if (p && (_stricmp(p+1, "bin") == 0 || + _stricmp(p+1, "lib") == 0)) + *p = '\0'; + + str_fn = ch_fn; + str_fn += "\\share\\libofx\\dtd\\"; + + return str_fn; +} +#endif + /** This function will try to find a DTD matching the requested_version and return the full path of the DTD found (or an empty string if unsuccessfull) @@ -513,45 +541,45 @@ */ string find_dtd(LibofxContextPtr ctx, string dtd_filename) { - int i; - ifstream dtd_file; string dtd_path_filename; - bool dtd_found=false; - dtd_path_filename=((LibofxContext*)ctx)->dtdDir(); + dtd_path_filename = reinterpret_cast(ctx)->dtdDir(); if (!dtd_path_filename.empty()) { dtd_path_filename.append(dtd_filename); - dtd_file.clear(); - dtd_file.open(dtd_path_filename.c_str()); + ifstream dtd_file(dtd_path_filename.c_str()); if(dtd_file){ message_out(STATUS,"find_dtd():DTD found: "+dtd_path_filename); - dtd_file.close(); - dtd_found=true; + return dtd_path_filename; } } - if (!dtd_found) { - for(i=0;i