mirror of https://github.com/Gnucash/gnucash
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
6.4 KiB
226 lines
6.4 KiB
diff -ur libofx-0.8.3/lib/ofx_preproc.cpp win32-libofx-0.8.3/lib/ofx_preproc.cpp
|
|
--- libofx-0.8.3/lib/ofx_preproc.cpp Tue Jan 9 02:38:33 2007
|
|
+++ win32-libofx-0.8.3/lib/ofx_preproc.cpp Thu Feb 8 13:53:59 2007
|
|
@@ -20,8 +20,14 @@
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <stdlib.h>
|
|
+#include <io.h> // for mktemp() on win32/mingw
|
|
#include <stdio.h>
|
|
#include <string>
|
|
+#ifdef OS_WIN32
|
|
+#include <windows.h> // for GetModuleFileName()
|
|
+#undef ERROR
|
|
+#undef DELETE
|
|
+#endif
|
|
#include "ParserEventGeneratorKit.h"
|
|
#include "libofx.h"
|
|
#include "messages.hh"
|
|
@@ -51,6 +57,57 @@
|
|
"~/"};
|
|
const unsigned int READ_BUFFER_SIZE = 1024;
|
|
|
|
+#ifdef OS_WIN32
|
|
+# define DIR_SEPARATOR_S "\\"
|
|
+#else
|
|
+# define DIR_SEPARATOR_S "/"
|
|
+#endif
|
|
+// The filenames can get quite long on windows.
|
|
+#define TMPFILEBUFSIZE 120
|
|
+
|
|
+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
|
|
+#ifdef OS_WIN32
|
|
+ char *var;
|
|
+ var = getenv("TMPDIR");
|
|
+ if (var) return var;
|
|
+ var = getenv("TMP");
|
|
+ if (var) return var;
|
|
+ var = getenv("TEMP");
|
|
+ if (var) return var;
|
|
+ return "C:\\";
|
|
+#else
|
|
+ return "/tmp";
|
|
+#endif
|
|
+}
|
|
+
|
|
+#ifdef OS_WIN32
|
|
+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
|
|
+
|
|
/** @brief File pre-processing of OFX AND for OFC files
|
|
*
|
|
* Takes care of comment striping, dtd locating, etc.
|
|
@@ -66,7 +123,7 @@
|
|
char buffer[READ_BUFFER_SIZE];
|
|
string s_buffer;
|
|
char *filenames[3];
|
|
- char tmp_filename[50];
|
|
+ char tmp_filename[TMPFILEBUFSIZE];
|
|
|
|
libofx_context=(LibofxContext*)ctx;
|
|
|
|
@@ -75,8 +132,10 @@
|
|
message_out(DEBUG, string("ofx_proc_file():Opening file: ")+ p_filename);
|
|
|
|
input_file.open(p_filename);
|
|
- strncpy(tmp_filename,"/tmp/libofxtmpXXXXXX",50);
|
|
- mkstemp(tmp_filename);
|
|
+ std::string tmpdir = get_tmp_dir();
|
|
+ std::string tmpfiletemplate = tmpdir + DIR_SEPARATOR_S "libofxtmpXXXXXX";
|
|
+ strncpy(tmp_filename,tmpfiletemplate.c_str(),TMPFILEBUFSIZE);
|
|
+ mktemp(tmp_filename);
|
|
tmp_file.open(tmp_filename);
|
|
|
|
message_out(DEBUG,"ofx_proc_file(): Creating temp file: "+string(tmp_filename));
|
|
@@ -203,7 +262,7 @@
|
|
ofstream tmp_file;
|
|
string s_buffer;
|
|
char *filenames[3];
|
|
- char tmp_filename[50];
|
|
+ char tmp_filename[TMPFILEBUFSIZE];
|
|
int pos;
|
|
LibofxContext *libofx_context;
|
|
|
|
@@ -216,8 +275,10 @@
|
|
}
|
|
s_buffer=string(s, size);
|
|
|
|
- strncpy(tmp_filename,"/tmp/libofxtmpXXXXXX",50);
|
|
- mkstemp(tmp_filename);
|
|
+ std::string tmpdir = get_tmp_dir();
|
|
+ std::string tmpfiletemplate = tmpdir + DIR_SEPARATOR_S "libofxtmpXXXXXX";
|
|
+ strncpy(tmp_filename,tmpfiletemplate.c_str(),TMPFILEBUFSIZE);
|
|
+ mktemp(tmp_filename);
|
|
tmp_file.open(tmp_filename);
|
|
|
|
message_out(DEBUG,"ofx_proc_file(): Creating temp file: "+string(tmp_filename));
|
|
@@ -439,8 +500,16 @@
|
|
string dtd_path_filename;
|
|
bool dtd_found=false;
|
|
|
|
- for(i=0;i<DTD_SEARCH_PATH_NUM&&dtd_found==false;i++){
|
|
- dtd_path_filename=DTD_SEARCH_PATH[i];
|
|
+ for(i=-1;i<DTD_SEARCH_PATH_NUM&&dtd_found==false;i++){
|
|
+ if (i==-1) {
|
|
+#ifdef OS_WIN32
|
|
+ dtd_path_filename=get_dtd_installation_directory();
|
|
+#else
|
|
+ continue;
|
|
+#endif
|
|
+ } else {
|
|
+ dtd_path_filename=DTD_SEARCH_PATH[i];
|
|
+ }
|
|
dtd_path_filename.append(dtd_filename);
|
|
dtd_file.clear();
|
|
dtd_file.open(dtd_path_filename.c_str());
|
|
--- libofx-0.8.3/lib/ofx_utilities.cpp-org 2010-05-22 12:57:31 +0000
|
|
+++ libofx-0.8.3/lib/ofx_utilities.cpp 2010-05-22 13:31:13 +0000
|
|
@@ -19,7 +19,8 @@
|
|
#include <iostream>
|
|
#include "ParserEventGeneratorKit.h"
|
|
#include "SGMLApplication.h"
|
|
-#include <time.h>
|
|
+#include <ctime>
|
|
+#include <cstdlib>
|
|
#include <string>
|
|
#include <locale.h>
|
|
#include "messages.hh"
|
|
--- libofx-0.8.3/lib/ofx_container_transaction.cpp-org 2010-05-22 14:08:02 +0000
|
|
+++ libofx-0.8.3/lib/ofx_container_transaction.cpp 2010-05-22 14:07:09 +0000
|
|
@@ -21,6 +21,7 @@
|
|
#include <config.h>
|
|
#endif
|
|
|
|
+#include <cstdlib>
|
|
#include <string>
|
|
#include "messages.hh"
|
|
#include "libofx.h"
|
|
--- libofx-0.8.3/lib/ofx_request_accountinfo.cpp-org 2010-05-22 14:17:26 +0000
|
|
+++ libofx-0.8.3/lib/ofx_request_accountinfo.cpp 2010-05-22 14:17:55 +0000
|
|
@@ -21,6 +21,7 @@
|
|
#include <config.h>
|
|
#endif
|
|
|
|
+#include <cstdlib>
|
|
#include <string>
|
|
#include "libofx.h"
|
|
#include "ofx_request_accountinfo.hh"
|
|
--- libofx-0.8.3/lib/ofx_request.cpp-org 2010-05-22 14:19:52 +0000
|
|
+++ libofx-0.8.3/lib/ofx_request.cpp 2010-05-22 14:20:12 +0000
|
|
@@ -21,6 +21,7 @@
|
|
#include <config.h>
|
|
#endif
|
|
|
|
+#include <cstring>
|
|
#include <string>
|
|
#include "messages.hh"
|
|
#include "libofx.h"
|
|
--- libofx-0.8.3/lib/ofx_request_statement.cpp-org 2010-05-22 14:21:19 +0000
|
|
+++ libofx-0.8.3/lib/ofx_request_statement.cpp 2010-05-22 14:21:34 +0000
|
|
@@ -21,6 +21,7 @@
|
|
#include <config.h>
|
|
#endif
|
|
|
|
+#include <cstdlib>
|
|
#include <string>
|
|
#include "libofx.h"
|
|
#include "ofx_utilities.hh"
|
|
--- libofx-0.8.3/ofxdump/ofxdump.cpp-org 2010-05-22 14:54:40 +0000
|
|
+++ libofx-0.8.3/ofxdump/ofxdump.cpp 2010-05-22 14:55:20 +0000
|
|
@@ -29,6 +29,8 @@
|
|
***************************************************************************/
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
+#include <cstdlib>
|
|
+#include <cstring>
|
|
#include <string>
|
|
#include "libofx.h"
|
|
#include <stdio.h> /* for printf() */
|
|
--- libofx-0.8.3/ofxconnect/ofxconnect.cpp-org 2010-05-22 14:57:35 +0000
|
|
+++ libofx-0.8.3/ofxconnect/ofxconnect.cpp 2010-05-22 14:58:24 +0000
|
|
@@ -30,6 +30,7 @@
|
|
***************************************************************************/
|
|
#include <iostream>
|
|
#include <fstream>
|
|
+#include <cstring>
|
|
#include <string>
|
|
#include "libofx.h"
|
|
#include <config.h> /* Include config constants, e.g., VERSION TF */
|
|
--- libofx-0.8.3/ofxconnect/ofxpartner.cpp-org 2010-05-22 14:59:39 +0000
|
|
+++ libofx-0.8.3/ofxconnect/ofxpartner.cpp 2010-05-22 15:00:46 +0000
|
|
@@ -33,8 +33,10 @@
|
|
#include <sys/stat.h>
|
|
|
|
#include <iostream>
|
|
+#include <cstring>
|
|
#include <string>
|
|
#include <vector>
|
|
+#include <algorithm>
|
|
|
|
using std::string;
|
|
using std::vector;
|