Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

libofx.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 libofx.h - Main header file for the libofx API 00003 ------------------- 00004 copyright : (C) 2002 by Benoit Grégoire 00005 email : bock@step.polymtl.ca 00006 ***************************************************************************/ 00026 /*************************************************************************** 00027 * * 00028 * This program is free software; you can redistribute it and/or modify * 00029 * it under the terms of the GNU General Public License as published by * 00030 * the Free Software Foundation; either version 2 of the License, or * 00031 * (at your option) any later version. * 00032 * * 00033 ***************************************************************************/ 00034 00035 #ifndef LIBOFX_H 00036 #define LIBOFX_H 00037 #include <time.h> 00038 00039 #ifdef __cplusplus 00040 #define CFCT extern "C" 00041 #else 00042 #define CFCT 00043 #define true 1 00044 #define false 0 00045 #endif 00046 00047 #define OFX_ELEMENT_NAME_LENGTH 100 00048 #define OFX_SVRTID2_LENGTH 36 + 1 00049 #define OFX_CHECK_NUMBER_LENGTH 12 + 1 00050 #define OFX_REFERENCE_NUMBER_LENGTH 32 + 1 00051 #define OFX_FITID_LENGTH 255 + 1 00052 #define OFX_TOKEN2_LENGTH 36 + 1 00053 #define OFX_MEMO2_LENGTH 390 + 1 00054 #define OFX_BALANCE_NAME_LENGTH 32 + 1 00055 #define OFX_BALANCE_DESCRIPTION_LENGTH 80 + 1 00056 #define OFX_CURRENCY_LENGTH 3 + 1 /* In ISO-4217 format */ 00057 #define OFX_BANKID_LENGTH 9 00058 #define OFX_BRANCHID_LENGTH 22 + 1 00059 #define OFX_ACCTID_LENGTH 22 + 1 00060 #define OFX_ACCTKEY_LENGTH 22 + 1 00061 #define OFX_BROKERID_LENGTH 22 + 1 00062 /* Must be MAX of <BANKID>+<BRANCHID>+<ACCTID>, <ACCTID>+<ACCTKEY> and <ACCTID>+<BROKERID> */ 00063 #define OFX_ACCOUNT_ID_LENGTH OFX_BANKID_LENGTH + OFX_BRANCHID_LENGTH + OFX_ACCTID_LENGTH + 1 00064 #define OFX_ACCOUNT_NAME_LENGTH 255 00065 #define OFX_MARKETING_INFO_LENGTH 360 + 1 00066 #define OFX_TRANSACTION_NAME_LENGTH 32 + 1 00067 #define OFX_UNIQUE_ID_LENGTH 32 + 1 00068 #define OFX_UNIQUE_ID_TYPE_LENGTH 10 + 1 00069 #define OFX_SECNAME_LENGTH 32 + 1 00070 #define OFX_TICKER_LENGTH 32 + 1 00071 00072 /* 00073 #define OFX_STATEMENT_CB 0; 00074 #define OFX_ACCOUNT_CB 1; 00075 #define OFX_TRACSACTION_CB 2; 00076 #define OFX_SECURITY_CB 3; 00077 #define OFX_STATUS_CB 4; 00078 */ 00079 00080 typedef void * LibofxContextPtr; 00086 CFCT LibofxContextPtr libofx_get_new_context(); 00092 CFCT int libofx_free_context( LibofxContextPtr ); 00093 00095 enum LibofxFileFormat{ AUTODETECT, 00096 OFX, 00097 OFC, 00098 QIF, 00099 UNKNOWN, 00100 LAST 00101 }; 00102 00103 struct LibofxFileFormatInfo{ 00104 enum LibofxFileFormat format; 00105 const char * format_name; 00106 const char * description; 00107 }; 00108 00109 const struct LibofxFileFormatInfo LibofxImportFormatList[] = 00110 { 00111 {AUTODETECT, "AUTODETECT", "AUTODETECT (File format will be automatically detected later)"}, 00112 {OFX, "OFX", "OFX (Open Financial eXchange (OFX or QFX))"}, 00113 {OFC, "OFC", "OFC (Microsoft Open Financial Connectivity)"}, 00114 {QIF, "QIF", "QIF (Intuit Quicken Interchange Format) NOT IMPLEMENTED"}, 00115 {LAST, "LAST", "Not a file format, meant as a loop breaking condition"} 00116 }; 00117 00118 const struct LibofxFileFormatInfo LibofxExportFormatList[] = 00119 { 00120 {QIF, "QIF", "QIF (Intuit Quicken Interchange Format) NOT IMPLEMENTED"}, 00121 {LAST, "LAST", "Not a file format, meant as a loop breaking condition"} 00122 }; 00123 00131 CFCT enum LibofxFileFormat libofx_get_file_format_from_str(const struct LibofxFileFormatInfo format_list[], const char * file_type_string); 00132 00140 CFCT const char * libofx_get_file_format_description(const struct LibofxFileFormatInfo format_list[], enum LibofxFileFormat file_format); 00141 00148 CFCT int libofx_proc_file(LibofxContextPtr libofx_context, 00149 const char * p_filename, 00150 enum LibofxFileFormat ftype); 00151 00152 00165 struct OfxStatusData{ 00170 char ofx_element_name[OFX_ELEMENT_NAME_LENGTH]; 00172 int ofx_element_name_valid; 00173 00178 int code; 00179 char* name; 00180 char* description; 00181 int code_valid; 00184 enum Severity{INFO, 00185 WARN, 00186 ERROR 00187 } severity; 00188 int severity_valid; 00189 00195 char* server_message; 00197 int server_message_valid; 00199 }; 00200 00201 00210 CFCT typedef int (*LibofxProcStatusCallback)(const struct OfxStatusData data, void * status_data); 00211 00218 struct OfxAccountData{ 00219 00230 char account_id[OFX_ACCOUNT_ID_LENGTH]; 00236 char account_name[OFX_ACCOUNT_NAME_LENGTH]; 00237 int account_id_valid;/* Use for both account_id and account_name */ 00238 00240 enum AccountType{ 00241 OFX_CHECKING, 00242 OFX_SAVINGS, 00243 OFX_MONEYMRKT, 00244 OFX_CREDITLINE, 00245 OFX_CMA, 00246 OFX_CREDITCARD, 00247 OFX_INVESTMENT 00248 } account_type; 00249 int account_type_valid; 00250 char currency[OFX_CURRENCY_LENGTH]; 00251 int currency_valid; 00252 00253 }; 00254 00267 CFCT typedef int (*LibofxProcAccountCallback)(const struct OfxAccountData data, void * account_data); 00268 00275 struct OfxSecurityData{ 00281 char unique_id[OFX_UNIQUE_ID_LENGTH]; 00282 int unique_id_valid; 00283 char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]; 00285 int unique_id_type_valid; 00286 char secname[OFX_SECNAME_LENGTH]; 00287 int secname_valid; 00288 00294 char ticker[OFX_TICKER_LENGTH]; 00295 int ticker_valid; 00296 00297 double unitprice; 00299 int unitprice_valid; 00300 00301 time_t date_unitprice; 00302 int date_unitprice_valid; 00303 00304 char currency[OFX_CURRENCY_LENGTH]; 00307 int currency_valid; 00308 char memo[OFX_MEMO2_LENGTH]; 00309 int memo_valid; 00310 };/* end struct OfxSecurityData */ 00311 00323 CFCT typedef int (*LibofxProcSecurityCallback)(const struct OfxSecurityData data, void * security_data); 00324 00325 typedef enum { 00326 OFX_CREDIT, 00327 OFX_DEBIT, 00328 OFX_INT, 00329 OFX_DIV, 00330 OFX_FEE, 00331 OFX_SRVCHG, 00332 OFX_DEP, 00333 OFX_ATM, 00334 OFX_POS, 00335 OFX_XFER, 00336 OFX_CHECK, 00337 OFX_PAYMENT, 00338 OFX_CASH, 00339 OFX_DIRECTDEP, 00340 OFX_DIRECTDEBIT, 00341 OFX_REPEATPMT, 00342 OFX_OTHER 00343 } TransactionType; 00344 00345 typedef enum{ 00346 OFX_BUYDEBT, 00347 OFX_BUYMF, 00348 OFX_BUYOPT, 00349 OFX_BUYOTHER, 00350 OFX_BUYSTOCK, 00351 OFX_CLOSUREOPT, 00352 OFX_INCOME, 00353 OFX_INVEXPENSE, 00354 OFX_JRNLFUND, 00355 OFX_JRNLSEC, 00356 OFX_MARGININTEREST, 00357 OFX_REINVEST, 00358 OFX_RETOFCAP, 00359 OFX_SELLDEBT, 00360 OFX_SELLMF, 00361 OFX_SELLOPT, 00362 OFX_SELLOTHER, 00363 OFX_SELLSTOCK, 00364 OFX_SPLIT, 00365 OFX_TRANSFER 00366 } InvTransactionType; 00367 typedef enum { 00368 DELETE, 00370 REPLACE 00372 } FiIdCorrectionAction; 00373 00380 struct OfxTransactionData{ 00381 00387 char account_id[OFX_ACCOUNT_ID_LENGTH]; 00390 struct OfxAccountData * account_ptr; 00392 int account_id_valid; 00393 00394 TransactionType transactiontype; 00395 int transactiontype_valid; 00396 00400 InvTransactionType invtransactiontype; 00401 int invtransactiontype_valid; 00402 00403 double units; 00409 int units_valid; 00410 double unitprice; 00412 int unitprice_valid; 00413 double amount; 00417 int amount_valid; 00418 char fi_id[256]; 00421 int fi_id_valid; 00422 00430 char unique_id[OFX_UNIQUE_ID_LENGTH]; 00431 int unique_id_valid; 00432 char unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]; 00434 int unique_id_type_valid; 00435 struct OfxSecurityData *security_data_ptr; 00436 int security_data_valid; 00437 00438 time_t date_posted; 00443 int date_posted_valid; 00444 00445 time_t date_initiated; 00451 int date_initiated_valid; 00452 time_t date_funds_available; 00455 int date_funds_available_valid; 00459 char fi_id_corrected[256]; 00460 int fi_id_corrected_valid; 00463 FiIdCorrectionAction fi_id_correction_action; 00464 int fi_id_correction_action_valid; 00465 00468 char server_transaction_id[OFX_SVRTID2_LENGTH]; 00469 int server_transaction_id_valid; 00473 char check_number[OFX_CHECK_NUMBER_LENGTH]; 00474 int check_number_valid; 00477 char reference_number[OFX_REFERENCE_NUMBER_LENGTH]; 00478 int reference_number_valid; 00479 long int standard_industrial_code; 00481 int standard_industrial_code_valid; 00482 char payee_id[OFX_SVRTID2_LENGTH]; 00483 int payee_id_valid; 00484 char name[OFX_TRANSACTION_NAME_LENGTH]; 00486 int name_valid; 00487 char memo[OFX_MEMO2_LENGTH]; 00488 int memo_valid; 00489 00490 /*********** NOT YET COMPLETE!!! *********************/ 00491 }; 00492 00501 CFCT typedef int (*LibofxProcTransactionCallback)(const struct OfxTransactionData data, void * transaction_data); 00502 00511 struct OfxStatementData{ 00512 00520 char currency[OFX_CURRENCY_LENGTH]; 00521 int currency_valid; 00522 char account_id[OFX_ACCOUNT_ID_LENGTH]; 00524 struct OfxAccountData * account_ptr; 00526 int account_id_valid; 00529 double ledger_balance; 00530 int ledger_balance_valid; 00531 time_t ledger_balance_date; 00532 int ledger_balance_date_valid; 00533 00539 double available_balance; 00542 int available_balance_valid; 00543 time_t available_balance_date; 00544 int available_balance_date_valid; 00549 time_t date_start; 00550 int date_start_valid; 00555 time_t date_end; 00556 int date_end_valid; 00559 char marketing_info[OFX_MARKETING_INFO_LENGTH]; 00560 int marketing_info_valid; 00561 }; 00562 00570 CFCT typedef int (*LibofxProcStatementCallback)(const struct OfxStatementData data, void * statement_data); 00571 00575 struct OfxCurrency{ 00576 char currency[OFX_CURRENCY_LENGTH]; 00577 double exchange_rate; 00578 int must_convert; 00579 }; 00580 00581 00588 CFCT void ofx_set_status_cb(LibofxContextPtr ctx, 00589 LibofxProcStatusCallback cb, 00590 void *user_data); 00597 CFCT void ofx_set_account_cb(LibofxContextPtr ctx, 00598 LibofxProcAccountCallback cb, 00599 void *user_data); 00606 CFCT void ofx_set_security_cb(LibofxContextPtr ctx, 00607 LibofxProcSecurityCallback cb, 00608 void *user_data); 00615 CFCT void ofx_set_transaction_cb(LibofxContextPtr ctx, 00616 LibofxProcTransactionCallback cb, 00617 void *user_data); 00618 00625 CFCT void ofx_set_statement_cb(LibofxContextPtr ctx, 00626 LibofxProcStatementCallback cb, 00627 void *user_data); 00628 00629 00633 CFCT int libofx_proc_buffer(LibofxContextPtr ctx, 00634 const char *s, unsigned int size); 00635 00636 00637 00638 #endif 00639

Generated on Fri Oct 8 20:34:47 2004 for LibOFX by doxygen 1.3.7