46 #define QIF_FILE_MAX_SIZE 256000 
   48 int ofx_proc_transaction_cb(
const struct OfxTransactionData data, 
void * transaction_data)
 
   50   char dest_string[255];
 
   51   char trans_buff[4096];
 
   53   char trans_list_buff[QIF_FILE_MAX_SIZE];
 
   55   trans_list_buff[0]=
'\0';
 
   57   if(data.date_posted_valid==
true){
 
   59     sprintf(trans_buff, 
"D%d%s%d%s%d%s", temp_tm.tm_mday, 
"/", temp_tm.tm_mon+1, 
"/", temp_tm.tm_year+1900, 
"\n");
 
   60     strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
   62   if(data.amount_valid==
true){
 
   63     sprintf(trans_buff, 
"T%.2f%s",data.
amount,
"\n");
 
   64     strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
   66   if(data.check_number_valid==
true){
 
   68     strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
   70   else if(data.reference_number_valid==
true){
 
   72       strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
   74 if(data.name_valid==
true){
 
   75     sprintf(trans_buff, 
"P%s%s",data.
name,
"\n");
 
   76         strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
   78 if(data.memo_valid==
true){
 
   79     sprintf(trans_buff, 
"M%s%s",data.
memo,
"\n");
 
   80         strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
   86     switch(data.transactiontype){
 
   87         case OFX_CREDIT: strncpy(dest_string, 
"Generic credit", 
sizeof(dest_string));
 
   89         case OFX_DEBIT: strncpy(dest_string, 
"Generic debit", 
sizeof(dest_string));
 
   91         case OFX_INT: strncpy(dest_string, 
"Interest earned or paid (Note: Depends on signage of amount)", 
sizeof(dest_string));
 
   93         case OFX_DIV: strncpy(dest_string, 
"Dividend", 
sizeof(dest_string));
 
   95         case OFX_FEE: strncpy(dest_string, 
"FI fee", 
sizeof(dest_string));
 
   97         case OFX_SRVCHG: strncpy(dest_string, 
"Service charge", 
sizeof(dest_string));
 
   99         case OFX_DEP: strncpy(dest_string, 
"Deposit", 
sizeof(dest_string));
 
  101         case OFX_ATM: strncpy(dest_string, 
"ATM debit or credit (Note: Depends on signage of amount)", 
sizeof(dest_string));
 
  103         case OFX_POS: strncpy(dest_string, 
"Point of sale debit or credit (Note: Depends on signage of amount)", 
sizeof(dest_string));
 
  105         case OFX_XFER: strncpy(dest_string, 
"Transfer", 
sizeof(dest_string));
 
  107         case OFX_CHECK: strncpy(dest_string, 
"Check", 
sizeof(dest_string));
 
  109         case OFX_PAYMENT: strncpy(dest_string, 
"Electronic payment", 
sizeof(dest_string));
 
  111         case OFX_CASH: strncpy(dest_string, 
"Cash withdrawal", 
sizeof(dest_string));
 
  113         case OFX_DIRECTDEP: strncpy(dest_string, 
"Direct deposit", 
sizeof(dest_string));
 
  115         case OFX_DIRECTDEBIT: strncpy(dest_string, 
"Merchant initiated debit", 
sizeof(dest_string));
 
  117         case OFX_REPEATPMT: strncpy(dest_string, 
"Repeating payment/standing order", 
sizeof(dest_string));
 
  119         case OFX_OTHER: strncpy(dest_string, 
"Other", 
sizeof(dest_string));
 
  121         default : strncpy(dest_string, 
"Unknown transaction type", 
sizeof(dest_string));
 
  124     sprintf(trans_buff, 
"L%s%s",dest_string,
"\n");
 
  125     strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
  127  strcpy(trans_buff, 
"^\n");
 
  128  strncat(trans_list_buff, trans_buff, 
sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
 
  129  fputs(trans_list_buff,stdout);
 
  133 int ofx_proc_statement_cb(
const struct OfxStatementData data, 
void * statement_data)
 
  137   printf(
"!Account\n");
 
  138   if(data.account_id_valid==
true){
 
  145       case OFX_CHECKING : printf(
"TBank\n");
 
  147       case OFX_SAVINGS :  printf(
"TBank\n");
 
  149       case OFX_MONEYMRKT :  printf(
"TOth A\n");
 
  151       case OFX_CREDITLINE :  printf(
"TOth L\n");
 
  153       case OFX_CMA :  printf(
"TOth A\n");
 
  155       case OFX_CREDITCARD :   printf(
"TCCard\n");
 
  157       default: perror(
"WRITEME: ofx_proc_account() This is an unknown account type!");
 
  160   printf(
"DOFX online account\n");
 
  162   if(data.ledger_balance_date_valid==
true){
 
  164     printf(
"/%d%s%d%s%d%s", temp_tm.tm_mday, 
"/", temp_tm.tm_mon+1, 
"/", temp_tm.tm_year+1900, 
"\n");
 
  166   if(data.ledger_balance_valid==
true){
 
  173     case OFX_CHECKING : printf(
"!Type:Bank\n");
 
  175     case OFX_SAVINGS : printf(
"!Type:Bank\n");
 
  177     case OFX_MONEYMRKT : printf(
"!Type:Oth A\n");
 
  179     case OFX_CREDITLINE : printf(
"!Type:Oth L\n");
 
  181     case OFX_CMA : printf(
"!Type:Oth A\n");
 
  183     case OFX_CREDITCARD : printf(
"!Type:CCard\n");
 
  185     default: perror(
"WRITEME: ofx_proc_account() This is an unknown account type!");
 
  192 int ofx_proc_account_cb(
const struct OfxAccountData data, 
void * account_data)
 
  194   char dest_string[255]=
"";
 
  198   fputs(dest_string,stdout);
 
  202 int main (
int argc, 
char *argv[])
 
time_t ledger_balance_date
An abstraction of an account. 
char reference_number[OFX_REFERENCE_NUMBER_LENGTH]
char check_number[OFX_CHECK_NUMBER_LENGTH]
int transactiontype_valid
char name[OFX_TRANSACTION_NAME_LENGTH]
char memo[OFX_MEMO2_LENGTH]
LibofxContextPtr libofx_get_new_context()
Initialise the library and return a new context. 
char account_id[OFX_ACCOUNT_ID_LENGTH]
void ofx_set_statement_cb(LibofxContextPtr ctx, LibofxProcStatementCallback cb, void *user_data)
void ofx_set_account_cb(LibofxContextPtr ctx, LibofxProcAccountCallback cb, void *user_data)
struct OfxAccountData * account_ptr
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. 
int libofx_proc_file(LibofxContextPtr libofx_context, const char *p_filename, enum LibofxFileFormat ftype)
libofx_proc_file is the entry point of the library. 
int libofx_free_context(LibofxContextPtr)
Free all ressources used by this context. 
An abstraction of an account statement.