Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 218782
Collapse All | Expand All

(-)libofx-0.9.0.orig/lib/ofx_container_transaction.cpp (+1 lines)
Lines 19-28 Link Here
19
19
20
#ifdef HAVE_CONFIG_H
20
#ifdef HAVE_CONFIG_H
21
#include <config.h>
21
#include <config.h>
22
#endif
22
#endif
23
23
24
#include <cstdlib>
24
#include <string>
25
#include <string>
25
#include "messages.hh"
26
#include "messages.hh"
26
#include "libofx.h"
27
#include "libofx.h"
27
#include "ofx_containers.hh"
28
#include "ofx_containers.hh"
28
#include "ofx_utilities.hh"
29
#include "ofx_utilities.hh"
(-)libofx-0.9.0.orig/lib/ofx_request_accountinfo.cpp (+1 lines)
Lines 19-28 Link Here
19
19
20
#ifdef HAVE_CONFIG_H
20
#ifdef HAVE_CONFIG_H
21
#include <config.h>
21
#include <config.h>
22
#endif
22
#endif
23
23
24
#include <cstdlib>
24
#include <string>
25
#include <string>
25
#include "libofx.h"
26
#include "libofx.h"
26
#include "ofx_request_accountinfo.hh"
27
#include "ofx_request_accountinfo.hh"
27
28
28
using namespace std;
29
using namespace std;
(-)libofx-0.9.0.orig/lib/ofx_request.cpp (+1 lines)
Lines 19-28 Link Here
19
19
20
#ifdef HAVE_CONFIG_H
20
#ifdef HAVE_CONFIG_H
21
#include <config.h>
21
#include <config.h>
22
#endif
22
#endif
23
23
24
#include <cstring>
24
#include <string>
25
#include <string>
25
#include "messages.hh"
26
#include "messages.hh"
26
#include "libofx.h"
27
#include "libofx.h"
27
#include "ofx_request.hh"
28
#include "ofx_request.hh"
28
29
(-)libofx-0.9.0.orig/lib/ofx_request_statement.cpp (+1 lines)
Lines 19-28 Link Here
19
19
20
#ifdef HAVE_CONFIG_H
20
#ifdef HAVE_CONFIG_H
21
#include <config.h>
21
#include <config.h>
22
#endif
22
#endif
23
23
24
#include <cstdlib>
24
#include <string>
25
#include <string>
25
#include "libofx.h"
26
#include "libofx.h"
26
#include "ofx_utilities.hh"
27
#include "ofx_utilities.hh"
27
#include "ofx_request_statement.hh"
28
#include "ofx_request_statement.hh"
28
29
(-)libofx-0.9.0.orig/lib/ofx_utilities.cpp (-1 / +2 lines)
Lines 19-29 Link Here
19
#include <iostream>
19
#include <iostream>
20
#include <assert.h>
20
#include <assert.h>
21
21
22
#include "ParserEventGeneratorKit.h"
22
#include "ParserEventGeneratorKit.h"
23
#include "SGMLApplication.h"
23
#include "SGMLApplication.h"
24
#include <time.h>
24
#include <ctime>
25
#include <cstdlib>
25
#include <string>
26
#include <string>
26
#include <locale.h>
27
#include <locale.h>
27
#include "messages.hh"
28
#include "messages.hh"
28
#include "ofx_utilities.hh"
29
#include "ofx_utilities.hh"
29
30
(-)libofx-0.9.0.orig/lib/ofx_utilities.cpp.orig (+245 lines)
Line 0 Link Here
1
/***************************************************************************
2
                          ofx_util.cpp
3
                             -------------------
4
    copyright            : (C) 2002 by Benoit Grégoire
5
    email                : bock@step.polymtl.ca
6
 ***************************************************************************/
7
/**@file
8
 * \brief Various simple functions for type conversion & al
9
 */
10
/***************************************************************************
11
 *                                                                         *
12
 *   This program is free software; you can redistribute it and/or modify  *
13
 *   it under the terms of the GNU General Public License as published by  *
14
 *   the Free Software Foundation; either version 2 of the License, or     *
15
 *   (at your option) any later version.                                   *
16
 *                                                                         *
17
 ***************************************************************************/
18
#include <config.h>
19
#include <iostream>
20
#include <assert.h>
21
22
#include "ParserEventGeneratorKit.h"
23
#include "SGMLApplication.h"
24
#include <time.h>
25
#include <string>
26
#include <locale.h>
27
#include "messages.hh"
28
#include "ofx_utilities.hh"
29
30
#ifdef OS_WIN32
31
# define DIRSEP "\\"
32
#else
33
# define DIRSEP "/"
34
#endif
35
36
37
using namespace std;
38
/**
39
   Convert an OpenSP CharString directly to a C++ stream, to enable the use of cout directly for debugging.
40
*/ 
41
/*ostream &operator<<(ostream &os, SGMLApplication::CharString s)
42
  {
43
  for (size_t i = 0; i < s.len; i++)
44
  {
45
  os << ((char *)(s.ptr))[i*sizeof(SGMLApplication::Char)];
46
  }
47
  return os;
48
  }*/
49
50
/*wostream &operator<<(wostream &os, SGMLApplication::CharString s)
51
  {
52
  for (size_t i = 0; i < s.len; i++)
53
  {//cout<<i;
54
  os << wchar_t(s.ptr[i*MULTIPLY4]);  
55
  }
56
  return os;
57
  }            */
58
59
/*wchar_t* CharStringtowchar_t(SGMLApplication::CharString source, wchar_t *dest)
60
  {
61
  size_t i;
62
  for (i = 0; i < source.len; i++)
63
  {
64
  dest[i]+=wchar_t(source.ptr[i*sizeof(SGMLApplication::Char)*(sizeof(char)/sizeof(wchar_t))]);
65
  }
66
  return dest;
67
  }*/
68
69
string CharStringtostring(const SGMLApplication::CharString source, string &dest)
70
{
71
  size_t i;
72
  dest.assign("");//Empty the provided string
73
  //  cout<<"Length: "<<source.len<<"sizeof(Char)"<<sizeof(SGMLApplication::Char)<<endl;
74
  for (i = 0; i < source.len; i++){
75
    dest+=(char)(((source.ptr)[i]));  
76
    //    cout<<i<<" "<<(char)(((source.ptr)[i]))<<endl; 
77
  }
78
  return dest;
79
}
80
81
string AppendCharStringtostring(const SGMLApplication::CharString source, string &dest)
82
{
83
  size_t i;
84
  for (i = 0; i < source.len; i++)
85
    {
86
      dest+=(char)(((source.ptr)[i]));
87
    }
88
  return dest;
89
}
90
91
/** 
92
 * Converts a date from the YYYYMMDDHHMMSS.XXX[gmt offset:tz name] OFX format (see OFX 2.01 spec p.66) to a C time_t.
93
 * @param ofxdate date from the YYYYMMDDHHMMSS.XXX[gmt offset:tz name] OFX format
94
 * @return C time_t in the local time zone
95
 * @note
96
 * @li The library always returns the time in the systems local time
97
 * @li OFX defines the date up to the millisecond.  The library ignores those milliseconds, since ANSI C does not handle such precision cleanly.  The date provided by LibOFX is precise to the second, assuming that information this precise was provided in the ofx file.  So you wont know the millisecond you were ruined...
98
 
99
 * @note DEVIATION FROM THE SPECS : The OFX specifications (both version 1.6 and 2.02) state that a client should assume that if the server returns a date without à specific time, we assume it means 0h00 GMT.  As such, when we apply the local timezone and for example you are in the EST timezone, we will remove 5h, and the transaction will have occurred on the prior day!  This is probably not what the bank intended (and will lead to systematic errors), but the spec is quite explicit in this respect (Ref:  OFX 2.01 spec pp. 66-68)<BR><BR>
100
 * 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:<BR><BR>
101
 * -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.<BR><BR>
102
 * -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).<BR><BR>
103
 * -When a timezone is specified, it is always used to properly convert in local time, following the spec.
104
 *
105
 */
106
time_t ofxdate_to_time_t(const string ofxdate)
107
{
108
  struct tm time;
109
  double local_offset; /* in seconds */
110
  float ofx_gmt_offset; /* in fractionnal hours */
111
  char timezone[4]; /* Original timezone: the library does not expose this value*/
112
  char exact_time_specified = false;
113
  char time_zone_specified = false;
114
115
  time_t temptime;
116
  std::time(&temptime);
117
  local_offset = difftime(mktime(localtime(&temptime)), mktime(gmtime(&temptime)));
118
  
119
  if(ofxdate.size()!=0){
120
    time.tm_year=atoi(ofxdate.substr(0,4).c_str())-1900;
121
    time.tm_mon=atoi(ofxdate.substr(4,2).c_str())-1;
122
    time.tm_mday=atoi(ofxdate.substr(6,2).c_str());
123
    if(ofxdate.size()>8) {
124
    /* if exact time is specified */
125
exact_time_specified = true;
126
      time.tm_hour=atoi(ofxdate.substr(8,2).c_str());
127
      time.tm_min=atoi(ofxdate.substr(10,2).c_str());
128
      time.tm_sec=atoi(ofxdate.substr(12,2).c_str());
129
    }
130
    
131
    /* Check if the timezone has been specified */
132
    string::size_type startidx = ofxdate.find("[");
133
    string::size_type endidx;
134
    if(startidx!=string::npos){
135
      /* Time zone was specified */
136
      time_zone_specified = true;
137
      startidx++;
138
      endidx = ofxdate.find(":", startidx)-1;
139
      ofx_gmt_offset=atof(ofxdate.substr(startidx,(endidx-startidx)+1).c_str());
140
      startidx = endidx+2;
141
      strncpy(timezone,ofxdate.substr(startidx,3).c_str(),4);
142
    }
143
    else{
144
      /* Time zone was not specified, assume GMT (provisionnaly) in case exact time is specified */
145
      ofx_gmt_offset=0;
146
      strcpy(timezone, "GMT");
147
    }
148
149
    if(time_zone_specified == true)
150
      {
151
	/* If the timezone is specified always correct the timezone */
152
	/* If the timezone is not specified, but the exact time is, correct the timezone, assuming GMT following the spec */
153
	/* Correct the time for the timezone */
154
	time.tm_sec = time.tm_sec + (int)(local_offset - (ofx_gmt_offset*60*60));//Convert from fractionnal hours to seconds
155
      }
156
    else if (exact_time_specified == false)
157
      {
158
	/*Time zone data missing and exact time not specified, diverge from the OFX spec ans assume 11h59 local time */
159
       time.tm_hour=11;
160
       time.tm_min=59;
161
       time.tm_sec=0;
162
      }
163
  }
164
  else{
165
    message_out(ERROR, "ofxdate_to_time_t():  Unable to convert time, string is 0 length!");
166
  }
167
  return mktime(&time);
168
}
169
170
/**
171
 * Convert a C++ string containing an amount of money as specified by the OFX standard and convert it to a double float.
172
 *\note The ofx number format is the following:  "." or "," as decimal separator, NO thousands separator.
173
 */ 
174
double ofxamount_to_double(const string ofxamount)
175
{
176
  //Replace commas and decimal points for atof()
177
  string::size_type idx;
178
  string tmp = ofxamount;
179
180
  idx = tmp.find(',');
181
  if(idx==string::npos){
182
    idx = tmp.find('.');
183
  }
184
  
185
  if(idx!=string::npos){
186
    tmp.replace(idx,1,1,((localeconv())->decimal_point)[0]);
187
  }
188
189
  return atof(tmp.c_str());
190
}
191
192
/**
193
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.
194
*/
195
string strip_whitespace(const string para_string)
196
{
197
  size_t index;
198
  size_t i;
199
  string temp_string = para_string;
200
  const char *whitespace = " \b\f\n\r\t\v";
201
  const char *abnormal_whitespace = "\b\f\n\r\t\v";//backspace,formfeed,newline,cariage return, horizontal and vertical tabs
202
  message_out(DEBUG4,"strip_whitespace() Before: |"+temp_string+"|");
203
  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++);
204
  temp_string.erase(0,i);//Strip leading whitespace
205
  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--);
206
  temp_string.erase(i+1,temp_string.size()-(i+1));//Strip trailing whitespace
207
  
208
while ((index = temp_string.find_first_of(abnormal_whitespace))!=string::npos)
209
  {
210
    temp_string.erase(index,1);//Strip leading whitespace
211
  };
212
 
213
 message_out(DEBUG4,"strip_whitespace() After:  |"+temp_string+"|");
214
 
215
 return temp_string;
216
}
217
218
219
int mkTempFileName(const char *tmpl, char *buffer, unsigned int size) {
220
  const char *tmp_dir;
221
222
  tmp_dir = getenv ("TMPDIR");
223
  if (!tmp_dir)
224
    tmp_dir = getenv ("TMP");
225
  if (!tmp_dir)
226
    tmp_dir = getenv ("TEMP");
227
228
  if (!tmp_dir)
229
    {
230
#ifdef OS_WIN32
231
      tmp_dir = "C:\\";
232
#else  
233
      tmp_dir = "/tmp";
234
#endif	/* !OS_WIN32 */
235
    }
236
237
  strncpy(buffer, tmp_dir, size);
238
  assert((strlen(buffer)+strlen(tmpl)+2)<size);
239
  strcat(buffer, DIRSEP);
240
  strcat(buffer, tmpl);
241
  return 0;
242
}
243
244
245
(-)libofx-0.9.0.orig/ofxconnect/ofxconnect.cpp (+1 lines)
Lines 34-43 Link Here
34
#include "libofx.h"
34
#include "libofx.h"
35
#include <config.h>		/* Include config constants, e.g., VERSION TF */
35
#include <config.h>		/* Include config constants, e.g., VERSION TF */
36
#include <stdio.h>
36
#include <stdio.h>
37
#include <stdlib.h>
37
#include <stdlib.h>
38
#include <unistd.h>
38
#include <unistd.h>
39
#include <cstring>
39
40
40
#ifdef HAVE_LIBCURL
41
#ifdef HAVE_LIBCURL
41
#include <curl/curl.h>
42
#include <curl/curl.h>
42
#endif
43
#endif
43
44
(-)libofx-0.9.0.orig/ofxconnect/ofxpartner.cpp (+3 lines)
Lines 33-42 Link Here
33
#include <sys/stat.h>
33
#include <sys/stat.h>
34
34
35
#include <iostream>
35
#include <iostream>
36
#include <string>
36
#include <string>
37
#include <vector>
37
#include <vector>
38
#include <algorithm>
39
#include <cstring>
40
38
41
39
using std::string;
42
using std::string;
40
using std::vector;
43
using std::vector;
41
using std::cout;
44
using std::cout;
42
using std::endl;
45
using std::endl;
(-)libofx-0.9.0.orig/ofxdump/ofxdump.cpp (+2 lines)
Lines 27-36 Link Here
27
 *   (at your option) any later version.                                   *
27
 *   (at your option) any later version.                                   *
28
 *                                                                         *
28
 *                                                                         *
29
 ***************************************************************************/
29
 ***************************************************************************/
30
#include <iostream>
30
#include <iostream>
31
#include <iomanip>
31
#include <iomanip>
32
#include <cstdlib>
33
#include <cstring>
32
#include <string>
34
#include <string>
33
#include "libofx.h"
35
#include "libofx.h"
34
#include <stdio.h>		/* for printf() */
36
#include <stdio.h>		/* for printf() */
35
#include <config.h>		/* Include config constants, e.g., VERSION TF */
37
#include <config.h>		/* Include config constants, e.g., VERSION TF */
36
#include <errno.h>
38
#include <errno.h>

Return to bug 218782