45 int ofx_proc_security_cb(
struct OfxSecurityData data,
void * security_data)
47 char dest_string[255];
48 cout <<
"ofx_proc_security():\n";
49 if (data.unique_id_valid ==
true)
51 cout <<
" Unique ID of the security being traded: " << data.
unique_id <<
"\n";
53 if (data.unique_id_type_valid ==
true)
55 cout <<
" Format of the Unique ID: " << data.
unique_id_type <<
"\n";
57 if (data.secname_valid ==
true)
59 cout <<
" Name of the security: " << data.
secname <<
"\n";
61 if (data.ticker_valid ==
true)
63 cout <<
" Ticker symbol: " << data.
ticker <<
"\n";
65 if (data.unitprice_valid ==
true)
67 cout <<
" Price of each unit of the security: " << data.
unitprice <<
"\n";
69 if (data.date_unitprice_valid ==
true)
71 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.
date_unitprice)));
72 cout <<
" Date as of which the unitprice is valid: " << dest_string <<
"\n";
74 if (data.currency_valid ==
true)
76 cout <<
" Currency of the unitprice: " << data.
currency <<
"\n";
78 if (data.memo_valid ==
true)
80 cout <<
" Extra transaction information (memo): " << data.
memo <<
"\n";
88 char dest_string[255];
89 cout <<
"ofx_proc_transaction():\n";
91 if (data.account_id_valid ==
true)
93 cout <<
" Account ID : " << data.
account_id <<
"\n";
99 strncpy(dest_string,
"CREDIT: Generic credit",
sizeof(dest_string));
100 else if (data.transactiontype ==
OFX_DEBIT)
101 strncpy(dest_string,
"DEBIT: Generic debit",
sizeof(dest_string));
102 else if (data.transactiontype ==
OFX_INT)
103 strncpy(dest_string,
"INT: Interest earned or paid (Note: Depends on signage of amount)",
sizeof(dest_string));
104 else if (data.transactiontype ==
OFX_DIV)
105 strncpy(dest_string,
"DIV: Dividend",
sizeof(dest_string));
106 else if (data.transactiontype ==
OFX_FEE)
107 strncpy(dest_string,
"FEE: FI fee",
sizeof(dest_string));
109 strncpy(dest_string,
"SRVCHG: Service charge",
sizeof(dest_string));
110 else if (data.transactiontype ==
OFX_DEP)
111 strncpy(dest_string,
"DEP: Deposit",
sizeof(dest_string));
112 else if (data.transactiontype ==
OFX_ATM)
113 strncpy(dest_string,
"ATM: ATM debit or credit (Note: Depends on signage of amount)",
sizeof(dest_string));
114 else if (data.transactiontype ==
OFX_POS)
115 strncpy(dest_string,
"POS: Point of sale debit or credit (Note: Depends on signage of amount)",
sizeof(dest_string));
116 else if (data.transactiontype ==
OFX_XFER)
117 strncpy(dest_string,
"XFER: Transfer",
sizeof(dest_string));
118 else if (data.transactiontype ==
OFX_CHECK)
119 strncpy(dest_string,
"CHECK: Check",
sizeof(dest_string));
121 strncpy(dest_string,
"PAYMENT: Electronic payment",
sizeof(dest_string));
122 else if (data.transactiontype ==
OFX_CASH)
123 strncpy(dest_string,
"CASH: Cash withdrawal",
sizeof(dest_string));
125 strncpy(dest_string,
"DIRECTDEP: Direct deposit",
sizeof(dest_string));
127 strncpy(dest_string,
"DIRECTDEBIT: Merchant initiated debit",
sizeof(dest_string));
129 strncpy(dest_string,
"REPEATPMT: Repeating payment/standing order",
sizeof(dest_string));
130 else if (data.transactiontype ==
OFX_OTHER)
131 strncpy(dest_string,
"OTHER: Other",
sizeof(dest_string));
133 strncpy(dest_string,
"Unknown transaction type",
sizeof(dest_string));
134 cout <<
" Transaction type: " << dest_string <<
"\n";
138 if (data.date_initiated_valid ==
true)
140 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.
date_initiated)));
141 cout <<
" Date initiated: " << dest_string <<
"\n";
143 if (data.date_posted_valid ==
true)
145 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.
date_posted)));
146 cout <<
" Date posted: " << dest_string <<
"\n";
148 if (data.date_funds_available_valid ==
true)
151 cout <<
" Date funds are available: " << dest_string <<
"\n";
153 if (data.amount_valid ==
true)
155 cout <<
" Total money amount: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.
amount <<
"\n";
157 if (data.units_valid ==
true)
159 cout <<
" # of units: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.
units <<
"\n";
161 if (data.oldunits_valid ==
true)
163 cout <<
" # of units before split: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.oldunits <<
"\n";
165 if (data.newunits_valid ==
true)
167 cout <<
" # of units after split: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.newunits <<
"\n";
169 if (data.unitprice_valid ==
true)
171 cout <<
" Unit price: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.
unitprice <<
"\n";
173 if (data.fees_valid ==
true)
175 cout <<
" Fees: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.
fees <<
"\n";
177 if (data.commission_valid ==
true)
179 cout <<
" Commission: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.
commission <<
"\n";
181 if (data.fi_id_valid ==
true)
183 cout <<
" Financial institution's ID for this transaction: " << data.
fi_id <<
"\n";
185 if (data.fi_id_corrected_valid ==
true)
187 cout <<
" Financial institution ID replaced or corrected by this transaction: " << data.
fi_id_corrected <<
"\n";
189 if (data.fi_id_correction_action_valid ==
true)
191 cout <<
" Action to take on the corrected transaction: ";
197 cout <<
"ofx_proc_transaction(): This should not happen!\n";
199 if (data.invtransactiontype_valid ==
true)
201 cout <<
" Investment transaction type: ";
203 strncpy(dest_string,
"BUYDEBT (Buy debt security)",
sizeof(dest_string));
204 else if (data.invtransactiontype ==
OFX_BUYMF)
205 strncpy(dest_string,
"BUYMF (Buy mutual fund)",
sizeof(dest_string));
206 else if (data.invtransactiontype ==
OFX_BUYOPT)
207 strncpy(dest_string,
"BUYOPT (Buy option)",
sizeof(dest_string));
209 strncpy(dest_string,
"BUYOTHER (Buy other security type)",
sizeof(dest_string));
211 strncpy(dest_string,
"BUYSTOCK (Buy stock))",
sizeof(dest_string));
213 strncpy(dest_string,
"CLOSUREOPT (Close a position for an option)",
sizeof(dest_string));
214 else if (data.invtransactiontype ==
OFX_INCOME)
215 strncpy(dest_string,
"INCOME (Investment income is realized as cash into the investment account)",
sizeof(dest_string));
217 strncpy(dest_string,
"INVEXPENSE (Misc investment expense that is associated with a specific security)",
sizeof(dest_string));
219 strncpy(dest_string,
"JRNLFUND (Journaling cash holdings between subaccounts within the same investment account)",
sizeof(dest_string));
221 strncpy(dest_string,
"MARGININTEREST (Margin interest expense)",
sizeof(dest_string));
223 strncpy(dest_string,
"REINVEST (Reinvestment of income)",
sizeof(dest_string));
225 strncpy(dest_string,
"RETOFCAP (Return of capital)",
sizeof(dest_string));
227 strncpy(dest_string,
"SELLDEBT (Sell debt security. Used when debt is sold, called, or reached maturity)",
sizeof(dest_string));
228 else if (data.invtransactiontype ==
OFX_SELLMF)
229 strncpy(dest_string,
"SELLMF (Sell mutual fund)",
sizeof(dest_string));
231 strncpy(dest_string,
"SELLOPT (Sell option)",
sizeof(dest_string));
233 strncpy(dest_string,
"SELLOTHER (Sell other type of security)",
sizeof(dest_string));
235 strncpy(dest_string,
"SELLSTOCK (Sell stock)",
sizeof(dest_string));
236 else if (data.invtransactiontype ==
OFX_SPLIT)
237 strncpy(dest_string,
"SPLIT (Stock or mutial fund split)",
sizeof(dest_string));
239 strncpy(dest_string,
"TRANSFER (Transfer holdings in and out of the investment account)",
sizeof(dest_string));
241 strncpy(dest_string,
"ERROR, this investment transaction type is unknown. This is a bug in ofxdump",
sizeof(dest_string));
243 cout << dest_string <<
"\n";
245 if (data.unique_id_valid ==
true)
247 cout <<
" Unique ID of the security being traded: " << data.
unique_id <<
"\n";
249 if (data.unique_id_type_valid ==
true)
251 cout <<
" Format of the Unique ID: " << data.
unique_id_type <<
"\n";
255 ofx_proc_security_cb(*(data.security_data_ptr), NULL );
258 if (data.server_transaction_id_valid ==
true)
262 if (data.check_number_valid ==
true)
266 if (data.reference_number_valid ==
true)
270 if (data.standard_industrial_code_valid ==
true)
274 if (data.payee_id_valid ==
true)
276 cout <<
" Payee_id: " << data.
payee_id <<
"\n";
278 if (data.name_valid ==
true)
280 cout <<
" Name of payee or transaction description: " << data.
name <<
"\n";
282 if (data.memo_valid ==
true)
284 cout <<
" Extra transaction information (memo): " << data.
memo <<
"\n";
290 int ofx_proc_statement_cb(
struct OfxStatementData data,
void * statement_data)
292 char dest_string[255];
293 cout <<
"ofx_proc_statement():\n";
294 if (data.currency_valid ==
true)
296 cout <<
" Currency: " << data.
currency <<
"\n";
298 if (data.account_id_valid ==
true)
300 cout <<
" Account ID: " << data.
account_id <<
"\n";
302 if (data.date_start_valid ==
true)
304 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.
date_start)));
305 cout <<
" Start date of this statement: " << dest_string <<
"\n";
307 if (data.date_end_valid ==
true)
309 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.
date_end)));
310 cout <<
" End date of this statement: " << dest_string <<
"\n";
312 if (data.ledger_balance_valid ==
true)
314 cout <<
" Ledger balance: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.
ledger_balance <<
"\n";
316 if (data.ledger_balance_date_valid ==
true)
318 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.
ledger_balance_date)));
319 cout <<
" Ledger balance date: " << dest_string <<
"\n";
321 if (data.available_balance_valid ==
true)
323 cout <<
" Available balance: " << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2) << data.
available_balance <<
"\n";
327 strftime(dest_string,
sizeof(dest_string),
"%c %Z", localtime(&(data.available_balance_date)));
328 cout <<
" Ledger balance date: " << dest_string <<
"\n";
330 if (data.marketing_info_valid ==
true)
332 cout <<
" Marketing information: " << data.
marketing_info <<
"\n";
338 int ofx_proc_account_cb(
struct OfxAccountData data,
void * account_data)
340 cout <<
"ofx_proc_account():\n";
341 if (data.account_id_valid ==
true)
343 cout <<
" Account ID: " << data.
account_id <<
"\n";
346 if (data.account_type_valid ==
true)
348 cout <<
" Account type: ";
349 switch (data.account_type)
352 cout <<
"CHECKING\n";
358 cout <<
"MONEYMRKT\n";
361 cout <<
"CREDITLINE\n";
367 cout <<
"CREDITCARD\n";
370 cout <<
"INVESTMENT\n";
373 cout <<
"ofx_proc_account() WRITEME: This is an unknown account type!";
376 if (data.currency_valid ==
true)
378 cout <<
" Currency: " << data.
currency <<
"\n";
381 if (data.bank_id_valid)
382 cout <<
" Bank ID: " << data.
bank_id << endl;;
384 if (data.branch_id_valid)
385 cout <<
" Branch ID: " << data.branch_id << endl;
387 if (data.account_number_valid)
396 int ofx_proc_status_cb(
struct OfxStatusData data,
void * status_data)
398 cout <<
"ofx_proc_status():\n";
401 cout <<
" Ofx entity this status is relevent to: " << data.ofx_element_name <<
" \n";
403 if (data.severity_valid ==
true)
405 cout <<
" Severity: ";
406 switch (data.severity)
418 cout <<
"WRITEME: Unknown status severity!\n";
423 cout <<
" Code: " << data.
code <<
", name: " << data.
name <<
"\n Description: " << data.
description <<
"\n";
425 if (data.server_message_valid ==
true)
434 int main (
int argc,
char *argv[])
454 bool skiphelp =
false;
459 cout <<
"The supported file formats for the 'input-file-format' argument are:" << endl;
460 for (
int i = 0; LibofxImportFormatList[i].
format !=
LAST; i++)
462 cout <<
" " << LibofxImportFormatList[i].
description << endl;
472 const char* filename = args_info.
inputs[0];
485 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;
486 for (
unsigned i = 1 ; i < args_info.
inputs_num ; ++i )
488 cout <<
"file: " << args_info.
inputs[i] << endl ;
time_t ledger_balance_date
int msg_info_flag
Output informational messages about the progress of the library (default=on).
An abstraction of an account.
enum LibofxFileFormat libofx_get_file_format_from_str(const struct LibofxFileFormatInfo format_list[], const char *file_type_string)
libofx_get_file_type returns a proper enum from a file type string.
int msg_warning_flag
Output warning messages about abnormal conditions and unknown constructs (default=on).
char * import_format_arg
Force the file format of the file(s) specified (default='AUTODETECT').
Where the command line options are stored.
char reference_number[OFX_REFERENCE_NUMBER_LENGTH]
char unique_id[OFX_UNIQUE_ID_LENGTH]
char account_id[OFX_ACCOUNT_ID_LENGTH]
char fi_id_corrected[256]
char currency[OFX_CURRENCY_LENGTH]
char check_number[OFX_CHECK_NUMBER_LENGTH]
int transactiontype_valid
char name[OFX_TRANSACTION_NAME_LENGTH]
char marketing_info[OFX_MARKETING_INFO_LENGTH]
char memo[OFX_MEMO2_LENGTH]
FiIdCorrectionAction fi_id_correction_action
int msg_debug_flag
Output messages meant for debuging (default=off).
unsigned int list_import_formats_given
Whether list-import-formats was given.
char currency[OFX_CURRENCY_LENGTH]
LibofxContextPtr libofx_get_new_context()
Initialise the library and return a new context.
long int standard_industrial_code
char account_id[OFX_ACCOUNT_ID_LENGTH]
char memo[OFX_MEMO2_LENGTH]
void ofx_set_statement_cb(LibofxContextPtr ctx, LibofxProcStatementCallback cb, void *user_data)
void ofx_set_status_cb(LibofxContextPtr ctx, LibofxProcStatusCallback cb, void *user_data)
void ofx_set_account_cb(LibofxContextPtr ctx, LibofxProcAccountCallback cb, void *user_data)
char account_id[OFX_ACCOUNT_ID_LENGTH]
char unique_id[OFX_UNIQUE_ID_LENGTH]
char account_name[OFX_ACCOUNT_NAME_LENGTH]
char server_transaction_id[OFX_SVRTID2_LENGTH]
char bank_id[OFX_BANKID_LENGTH]
int msg_error_flag
Output error messages (default=on).
An abstraction of an OFX STATUS element.
int cmdline_parser(int argc, char **argv, struct gengetopt_args_info *args_info)
void ofx_set_security_cb(LibofxContextPtr ctx, LibofxProcSecurityCallback cb, void *user_data)
void cmdline_parser_print_help(void)
unsigned inputs_num
unamed options number
char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]
int msg_status_flag
Output status messages (default=on).
int msg_parser_flag
Output file parsing messages (default=off).
int available_balance_date_valid
char ticker[OFX_TICKER_LENGTH]
char payee_id[OFX_SVRTID2_LENGTH]
An abstraction of a security, such as a stock, mutual fund, etc.
int ofx_element_name_valid
void ofx_set_transaction_cb(LibofxContextPtr ctx, LibofxProcTransactionCallback cb, void *user_data)
int main(int argc, char *argv[])
An abstraction of a transaction in an account.
time_t date_funds_available
The header file for the command line option parser generated by GNU Gengetopt version 2...
int libofx_proc_file(LibofxContextPtr libofx_context, const char *p_filename, enum LibofxFileFormat ftype)
libofx_proc_file is the entry point of the library.
char account_number[OFX_ACCTID_LENGTH]
char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]
char currency[OFX_CURRENCY_LENGTH]
char ** inputs
unamed options (options without names)
An abstraction of an account statement.
char secname[OFX_SECNAME_LENGTH]