00001
00002
00003
00004
00005
00006
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #include <string.h>
00043 #include <time.h>
00044 #include "libofx.h"
00045
00046 #define QIF_FILE_MAX_SIZE 256000
00047
00048 int main (int argc, char *argv[])
00049 {
00050 extern int ofx_PARSER_msg;
00051 extern int ofx_DEBUG_msg;
00052 extern int ofx_WARNING_msg;
00053 extern int ofx_ERROR_msg;
00054 extern int ofx_INFO_msg;
00055 extern int ofx_STATUS_msg;
00056 ofx_PARSER_msg = false;
00057 ofx_DEBUG_msg = false;
00058 ofx_WARNING_msg = false;
00059 ofx_ERROR_msg = false;
00060 ofx_INFO_msg = false;
00061 ofx_STATUS_msg = false;
00062
00063 ofx_proc_file(argc, argv);
00064 return 0;
00065 }
00066
00067 int ofx_proc_status_cb(struct OfxStatusData data)
00068 {
00069 return 0;
00070 }
00071 int ofx_proc_security_cb(struct OfxSecurityData data)
00072 {
00073 return 0;
00074 }
00075
00076
00077 int ofx_proc_transaction_cb(struct OfxTransactionData data)
00078 {
00079 char dest_string[255];
00080 char trans_buff[4096];
00081 struct tm temp_tm;
00082 char trans_list_buff[QIF_FILE_MAX_SIZE];
00083
00084 trans_list_buff[0]='\0';
00085
00086 if(data.date_posted_valid==true){
00087 temp_tm = *localtime(&(data.date_posted));
00088 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");
00089 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00090 }
00091 if(data.amount_valid==true){
00092 sprintf(trans_buff, "T%.2f%s",data.amount,"\n");
00093 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00094 }
00095 if(data.check_number_valid==true){
00096 sprintf(trans_buff, "N%s%s",data.check_number,"\n");
00097 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00098 }
00099 else if(data.reference_number_valid==true){
00100 sprintf(trans_buff, "N%s%s",data.reference_number,"\n");
00101 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00102 }
00103 if(data.name_valid==true){
00104 sprintf(trans_buff, "P%s%s",data.name,"\n");
00105 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00106 }
00107 if(data.memo_valid==true){
00108 sprintf(trans_buff, "M%s%s",data.memo,"\n");
00109 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00110 }
00111
00112
00113
00114 if(data.transactiontype_valid==true){
00115 switch(data.transactiontype){
00116 case OFX_CREDIT: strncpy(dest_string, "Generic credit", sizeof(dest_string));
00117 break;
00118 case OFX_DEBIT: strncpy(dest_string, "Generic debit", sizeof(dest_string));
00119 break;
00120 case OFX_INT: strncpy(dest_string, "Interest earned or paid (Note: Depends on signage of amount)", sizeof(dest_string));
00121 break;
00122 case OFX_DIV: strncpy(dest_string, "Dividend", sizeof(dest_string));
00123 break;
00124 case OFX_FEE: strncpy(dest_string, "FI fee", sizeof(dest_string));
00125 break;
00126 case OFX_SRVCHG: strncpy(dest_string, "Service charge", sizeof(dest_string));
00127 break;
00128 case OFX_DEP: strncpy(dest_string, "Deposit", sizeof(dest_string));
00129 break;
00130 case OFX_ATM: strncpy(dest_string, "ATM debit or credit (Note: Depends on signage of amount)", sizeof(dest_string));
00131 break;
00132 case OFX_POS: strncpy(dest_string, "Point of sale debit or credit (Note: Depends on signage of amount)", sizeof(dest_string));
00133 break;
00134 case OFX_XFER: strncpy(dest_string, "Transfer", sizeof(dest_string));
00135 break;
00136 case OFX_CHECK: strncpy(dest_string, "Check", sizeof(dest_string));
00137 break;
00138 case OFX_PAYMENT: strncpy(dest_string, "Electronic payment", sizeof(dest_string));
00139 break;
00140 case OFX_CASH: strncpy(dest_string, "Cash withdrawal", sizeof(dest_string));
00141 break;
00142 case OFX_DIRECTDEP: strncpy(dest_string, "Direct deposit", sizeof(dest_string));
00143 break;
00144 case OFX_DIRECTDEBIT: strncpy(dest_string, "Merchant initiated debit", sizeof(dest_string));
00145 break;
00146 case OFX_REPEATPMT: strncpy(dest_string, "Repeating payment/standing order", sizeof(dest_string));
00147 break;
00148 case OFX_OTHER: strncpy(dest_string, "Other", sizeof(dest_string));
00149 break;
00150 default : strncpy(dest_string, "Unknown transaction type", sizeof(dest_string));
00151 break;
00152 }
00153 sprintf(trans_buff, "L%s%s",dest_string,"\n");
00154 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00155 }
00156 strcpy(trans_buff, "^\n");
00157 strncat(trans_list_buff, trans_buff, sizeof(trans_list_buff)-1 - strlen(trans_list_buff));
00158 fputs(trans_list_buff,stdout);
00159 return 0;
00160 }
00161
00162 int ofx_proc_statement_cb(struct OfxStatementData data)
00163 {
00164 struct tm temp_tm;
00165
00166 printf("!Account\n");
00167 if(data.account_id_valid==true){
00168
00169 printf("N%s%s",data.account_id,"\n");
00170 }
00171 if(data.account_ptr->account_type_valid==true)
00172 {
00173 switch(data.account_ptr->account_type){
00174 case OFX_CHECKING : printf("TBank\n");
00175 break;
00176 case OFX_SAVINGS : printf("TBank\n");
00177 break;
00178 case OFX_MONEYMRKT : printf("TOth A\n");
00179 break;
00180 case OFX_CREDITLINE : printf("TOth L\n");
00181 break;
00182 case OFX_CMA : printf("TOth A\n");
00183 break;
00184 case OFX_CREDITCARD : printf("TCCard\n");
00185 break;
00186 default: perror("WRITEME: ofx_proc_account() This is an unknown account type!");
00187 }
00188 }
00189 printf("DOFX online account\n");
00190
00191 if(data.ledger_balance_date_valid==true){
00192 temp_tm = *localtime(&(data.ledger_balance_date));
00193 printf("/%d%s%d%s%d%s", temp_tm.tm_mday, "/", temp_tm.tm_mon+1, "/", temp_tm.tm_year+1900, "\n");
00194 }
00195 if(data.ledger_balance_valid==true){
00196 printf("$%.2f%s",data.ledger_balance,"\n");
00197 }
00198 printf("^\n");
00199
00200 if(data.account_ptr->account_type_valid==true){
00201 switch(data.account_ptr->account_type){
00202 case OFX_CHECKING : printf("!Type:Bank\n");
00203 break;
00204 case OFX_SAVINGS : printf("!Type:Bank\n");
00205 break;
00206 case OFX_MONEYMRKT : printf("!Type:Oth A\n");
00207 break;
00208 case OFX_CREDITLINE : printf("!Type:Oth L\n");
00209 break;
00210 case OFX_CMA : printf("!Type:Oth A\n");
00211 break;
00212 case OFX_CREDITCARD : printf("!Type:CCard\n");
00213 break;
00214 default: perror("WRITEME: ofx_proc_account() This is an unknown account type!");
00215 }
00216 }
00217
00218 return 0;
00219 }
00220
00221 int ofx_proc_account_cb(struct OfxAccountData data)
00222 {
00223 char dest_string[255]="";
00224
00225
00226
00227 fputs(dest_string,stdout);
00228 return 0;
00229 }