00001
00002
00003
00004
00005
00006
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <iostream>
00031 #include <iomanip>
00032 #include <string>
00033 #include "libofx.h"
00034 using namespace std;
00035
00036
00037 int main (int argc, char *argv[])
00038 {
00040 extern int ofx_PARSER_msg;
00041 extern int ofx_DEBUG_msg;
00042 extern int ofx_WARNING_msg;
00043 extern int ofx_ERROR_msg;
00044 extern int ofx_INFO_msg;
00045 extern int ofx_STATUS_msg;
00046
00047 ofx_PARSER_msg = false;
00048 ofx_DEBUG_msg = false;
00049 ofx_WARNING_msg = true;
00050 ofx_ERROR_msg = true;
00051 ofx_INFO_msg = true;
00052 ofx_STATUS_msg = true;
00053
00054 ofx_proc_file(argc, argv);
00055 }
00056
00057 int ofx_proc_status_cb(struct OfxStatusData data)
00058 {
00059 cout<<"ofx_proc_status():\n";
00060 if(data.ofx_element_name_valid==true){
00061 cout<<" Ofx entity this status is relevent to: "<< data.ofx_element_name<<" \n";
00062 }
00063 if(data.severity_valid==true){
00064 cout<<" Severity: ";
00065 switch(data.severity){
00066 case OfxStatusData::INFO : cout<<"INFO\n";
00067 break;
00068 case OfxStatusData::WARN : cout<<"WARN\n";
00069 break;
00070 case OfxStatusData::ERROR : cout<<"ERROR\n";
00071 break;
00072 default: cout<<"WRITEME: Unknown status severity!\n";
00073 }
00074 }
00075 if(data.code_valid==true){
00076 cout<<" Code: "<<data.code<<", name: "<<data.name<<"\n Description: "<<data.description<<"\n";
00077 }
00078 if(data.server_message_valid==true){
00079 cout<<" Server Message: "<<data.server_message<<"\n";
00080 }
00081 cout<<"\n";
00082 return 0;
00083 }
00084
00085 int ofx_proc_security_cb(struct OfxSecurityData data)
00086 {
00087 char dest_string[255];
00088 cout<<"ofx_proc_security():\n";
00089 if(data.unique_id_valid==true){
00090 cout<<" Unique ID of the security being traded: "<<data.unique_id<<"\n";
00091 }
00092 if(data.unique_id_type_valid==true){
00093 cout<<" Format of the Unique ID: "<<data.unique_id_type<<"\n";
00094 }
00095 if(data.secname_valid==true){
00096 cout<<" Name of the security: "<<data.secname<<"\n";
00097 }
00098 if(data.ticker_valid==true){
00099 cout<<" Ticker symbol: "<<data.ticker<<"\n";
00100 }
00101 if(data.unitprice_valid==true){
00102 cout<<" Price of each unit of the security: "<<data.unitprice<<"\n";
00103 }
00104 if(data.date_unitprice_valid==true){
00105 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_unitprice)));
00106 cout<<" Date as of which the unitprice is valid: "<<dest_string<<"\n";
00107 }
00108 if(data.currency_valid==true){
00109 cout<<" Currency of the unitprice: "<<data.currency<<"\n";
00110 }
00111 if(data.memo_valid==true){
00112 cout<<" Extra transaction information (memo): "<<data.memo<<"\n";
00113 }
00114 cout<<"\n";
00115 return 0;
00116 }
00117
00118 int ofx_proc_transaction_cb(struct OfxTransactionData data)
00119 {
00120 char dest_string[255];
00121 cout<<"ofx_proc_transaction():\n";
00122
00123 if(data.account_id_valid==true){
00124 cout<<" Account ID : "<<data.account_id<<"\n";
00125 }
00126
00127 if(data.transactiontype_valid==true){
00128 switch(data.transactiontype){
00129 case data.OFX_CREDIT: strncpy(dest_string, "CREDIT: Generic credit", sizeof(dest_string));
00130 break;
00131 case data.OFX_DEBIT: strncpy(dest_string, "DEBIT: Generic debit", sizeof(dest_string));
00132 break;
00133 case data.OFX_INT: strncpy(dest_string, "INT: Interest earned or paid (Note: Depends on signage of amount)", sizeof(dest_string));
00134 break;
00135 case data.OFX_DIV: strncpy(dest_string, "DIV: Dividend", sizeof(dest_string));
00136 break;
00137 case data.OFX_FEE: strncpy(dest_string, "FEE: FI fee", sizeof(dest_string));
00138 break;
00139 case data.OFX_SRVCHG: strncpy(dest_string, "SRVCHG: Service charge", sizeof(dest_string));
00140 break;
00141 case data.OFX_DEP: strncpy(dest_string, "DEP: Deposit", sizeof(dest_string));
00142 break;
00143 case data.OFX_ATM: strncpy(dest_string, "ATM: ATM debit or credit (Note: Depends on signage of amount)", sizeof(dest_string));
00144 break;
00145 case data.OFX_POS: strncpy(dest_string, "POS: Point of sale debit or credit (Note: Depends on signage of amount)", sizeof(dest_string));
00146 break;
00147 case data.OFX_XFER: strncpy(dest_string, "XFER: Transfer", sizeof(dest_string));
00148 break;
00149 case data.OFX_CHECK: strncpy(dest_string, "CHECK: Check", sizeof(dest_string));
00150 break;
00151 case data.OFX_PAYMENT: strncpy(dest_string, "PAYMENT: Electronic payment", sizeof(dest_string));
00152 break;
00153 case data.OFX_CASH: strncpy(dest_string, "CASH: Cash withdrawal", sizeof(dest_string));
00154 break;
00155 case data.OFX_DIRECTDEP: strncpy(dest_string, "DIRECTDEP: Direct deposit", sizeof(dest_string));
00156 break;
00157 case data.OFX_DIRECTDEBIT: strncpy(dest_string, "DIRECTDEBIT: Merchant initiated debit", sizeof(dest_string));
00158 break;
00159 case data.OFX_REPEATPMT: strncpy(dest_string, "REPEATPMT: Repeating payment/standing order", sizeof(dest_string));
00160 break;
00161 case data.OFX_OTHER: strncpy(dest_string, "OTHER: Other", sizeof(dest_string));
00162 break;
00163 default : strncpy(dest_string, "Unknown transaction type", sizeof(dest_string));
00164 break;
00165 }
00166 cout<<" Transaction type: "<<dest_string<<"\n";
00167 }
00168 if(data.date_initiated_valid==true){
00169 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_initiated)));
00170 cout<<" Date initiated: "<<dest_string<<"\n";
00171 }
00172 if(data.date_posted_valid==true){
00173 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_posted)));
00174 cout<<" Date posted: "<<dest_string<<"\n";
00175 }
00176 if(data.date_funds_available_valid==true){
00177 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_funds_available)));
00178 cout<<" Date funds are available: "<<dest_string<<"\n";
00179 }
00180 if(data.amount_valid==true){
00181 cout<<" Total money amount: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.amount<<"\n";
00182 }
00183 if(data.units_valid==true){
00184 cout<<" # of units: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.units<<"\n";
00185 }
00186 if(data.unitprice_valid==true){
00187 cout<<" Unit price: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.unitprice<<"\n";
00188 }
00189 if(data.fi_id_valid==true){
00190 cout<<" Financial institution's ID for this transaction: "<<data.fi_id<<"\n";
00191 }
00192 if(data.fi_id_corrected_valid==true){
00193 cout<<" Financial institution ID replaced or corrected by this transaction: "<<data.fi_id_corrected<<"\n";
00194 }
00195 if(data.fi_id_correction_action_valid==true){
00196 cout<<" Action to take on the corrected transaction: ";
00197 switch(data.fi_id_correction_action){
00198 case data.DELETE : cout<<"DELETE\n";
00199 break;
00200 case data.REPLACE : cout<<"REPLACE\n";
00201 break;
00202 default:
00203 cout<<"ofx_proc_transaction(): This should not happen!\n";
00204 }
00205 }
00206 if(data.invtransactiontype_valid==true){
00207 cout<<" Investment transaction type: ";
00208 switch(data.invtransactiontype){
00209 case data.OFX_BUYDEBT: strncpy(dest_string, "BUYDEBT (Buy debt security)", sizeof(dest_string));
00210 break;
00211 case data.OFX_BUYMF: strncpy(dest_string, "BUYMF (Buy mutual fund)", sizeof(dest_string));
00212 break;
00213 case data.OFX_BUYOPT: strncpy(dest_string, "BUYOPT (Buy option)", sizeof(dest_string));
00214 break;
00215 case data.OFX_BUYOTHER: strncpy(dest_string, "BUYOTHER (Buy other security type)", sizeof(dest_string));
00216 break;
00217 case data.OFX_BUYSTOCK: strncpy(dest_string, "BUYSTOCK (Buy stock))", sizeof(dest_string));
00218 break;
00219 case data.OFX_CLOSUREOPT: strncpy(dest_string, "CLOSUREOPT (Close a position for an option)", sizeof(dest_string));
00220 break;
00221 case data.OFX_INCOME: strncpy(dest_string, "INCOME (Investment income is realized as cash into the investment account)", sizeof(dest_string));
00222 break;
00223 case data.OFX_INVEXPENSE: strncpy(dest_string, "INVEXPENSE (Misc investment expense that is associated with a specific security)", sizeof(dest_string));
00224 break;
00225 case data.OFX_JRNLFUND: strncpy(dest_string, "JRNLFUND (Journaling cash holdings between subaccounts within the same investment account)", sizeof(dest_string));
00226 break;
00227 case data.OFX_MARGININTEREST: strncpy(dest_string, "MARGININTEREST (Margin interest expense)", sizeof(dest_string));
00228 break;
00229 case data.OFX_REINVEST: strncpy(dest_string, "REINVEST (Reinvestment of income)", sizeof(dest_string));
00230 break;
00231 case data.OFX_RETOFCAP: strncpy(dest_string, "RETOFCAP (Return of capital)", sizeof(dest_string));
00232 break;
00233 case data.OFX_SELLDEBT: strncpy(dest_string, "SELLDEBT (Sell debt security. Used when debt is sold, called, or reached maturity)", sizeof(dest_string));
00234 break;
00235 case data.OFX_SELLMF: strncpy(dest_string, "SELLMF (Sell mutual fund)", sizeof(dest_string));
00236 break;
00237 case data.OFX_SELLOPT: strncpy(dest_string, "SELLOPT (Sell option)", sizeof(dest_string));
00238 break;
00239 case data.OFX_SELLOTHER: strncpy(dest_string, "SELLOTHER (Sell other type of security)", sizeof(dest_string));
00240 break;
00241 case data.OFX_SELLSTOCK: strncpy(dest_string, "SELLSTOCK (Sell stock)", sizeof(dest_string));
00242 break;
00243 case data.OFX_SPLIT: strncpy(dest_string, "SPLIT (Stock or mutial fund split)", sizeof(dest_string));
00244 break;
00245 case data.OFX_TRANSFER: strncpy(dest_string, "TRANSFER (Transfer holdings in and out of the investment account)", sizeof(dest_string));
00246 break;
00247 default: strncpy(dest_string, "ERROR, this investment transaction type is unknown. This is a bug in ofxdump", sizeof(dest_string));
00248 break;
00249 }
00250 cout<<dest_string<<"\n";
00251 }
00252 if(data.unique_id_valid==true){
00253 cout<<" Unique ID of the security being traded: "<<data.unique_id<<"\n";
00254 }
00255 if(data.unique_id_type_valid==true){
00256 cout<<" Format of the Unique ID: "<<data.unique_id_type<<"\n";
00257 }
00258 if(data.security_data_valid==true){
00259 cout<<" Security data is available:\n START security_data content----------\n";
00260 ofx_proc_security_cb(*(data.security_data_ptr));
00261 cout<<" END security_data content----------\n";
00262
00263 }
00264
00265 if(data.server_transaction_id_valid==true){
00266 cout<<" Server's transaction ID (confirmation number): "<<data.server_transaction_id<<"\n";
00267 }
00268 if(data.check_number_valid==true){
00269 cout<<" Check number: "<<data.check_number<<"\n";
00270 }
00271 if(data.reference_number_valid==true){
00272 cout<<" Reference number: "<<data.reference_number<<"\n";
00273 }
00274 if(data.standard_industrial_code_valid==true){
00275 cout<<" Standard Industrial Code: "<<data.standard_industrial_code<<"\n";
00276 }
00277 if(data.payee_id_valid==true){
00278 cout<<" Payee_id: "<<data.payee_id<<"\n";
00279 }
00280 if(data.name_valid==true){
00281 cout<<" Name of payee or transaction description: "<<data.name<<"\n";
00282 }
00283 if(data.memo_valid==true){
00284 cout<<" Extra transaction information (memo): "<<data.memo<<"\n";
00285 }
00286 cout<<"\n";
00287 return 0;
00288 }
00289
00290 int ofx_proc_statement_cb(struct OfxStatementData data)
00291 {
00292 char dest_string[255];
00293 cout<<"ofx_proc_statement():\n";
00294 if(data.currency_valid==true){
00295 cout<<" Currency: "<<data.currency<<"\n";
00296 }
00297 if(data.account_id_valid==true){
00298 cout<<" Account ID: "<<data.account_id<<"\n";
00299 }
00300 if(data.date_start_valid==true){
00301 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_start)));
00302 cout<<" Start date of this statement: "<<dest_string<<"\n";
00303 }
00304 if(data.date_end_valid==true){
00305 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_end)));
00306 cout<<" End date of this statement: "<<dest_string<<"\n";
00307 }
00308 if(data.ledger_balance_valid==true){
00309 cout<<" Ledger balance: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.ledger_balance<<"\n";
00310 }
00311 if(data.ledger_balance_date_valid==true){
00312 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.ledger_balance_date)));
00313 cout<<" Ledger balance date: "<<dest_string<<"\n";
00314 }
00315 if(data.available_balance_valid==true){
00316 cout<<" Available balance: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.available_balance<<"\n";
00317 }
00318 if(data.available_balance_date_valid==true){
00319 strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.available_balance_date)));
00320 cout<<" Ledger balance date: "<<dest_string<<"\n";
00321 }
00322 if(data.marketing_info_valid==true){
00323 cout<<" Marketing information: "<<data.marketing_info<<"\n";
00324 }
00325 cout<<"\n";
00326 return 0;
00327 }
00328
00329 int ofx_proc_account_cb(struct OfxAccountData data)
00330 {
00331 cout<<"ofx_proc_account():\n";
00332 if(data.account_id_valid==true){
00333 cout<<" Account ID: "<<data.account_id<<"\n";
00334 cout<<" Account name: "<<data.account_name<<"\n";
00335 }
00336 if(data.account_type_valid==true){
00337 cout<<" Account type: ";
00338 switch(data.account_type){
00339 case OfxAccountData::OFX_CHECKING : cout<<"CHECKING\n";
00340 break;
00341 case OfxAccountData::OFX_SAVINGS : cout<<"SAVINGS\n";
00342 break;
00343 case OfxAccountData::OFX_MONEYMRKT : cout<<"MONEYMRKT\n";
00344 break;
00345 case OfxAccountData::OFX_CREDITLINE : cout<<"CREDITLINE\n";
00346 break;
00347 case OfxAccountData::OFX_CMA : cout<<"CMA\n";
00348 break;
00349 case OfxAccountData::OFX_CREDITCARD : cout<<"CREDITCARD\n";
00350 break;
00351 case OfxAccountData::OFX_INVESTMENT : cout<<"INVESTMENT\n";
00352 break;
00353 default: cout<<"ofx_proc_account() WRITEME: This is an unknown account type!";
00354 }
00355 }
00356 if(data.currency_valid==true){
00357 cout<<" Currency: "<<data.currency<<"\n";
00358 }
00359
00360 cout<<"\n";
00361 return 0;
00362 }