AB_IMEXPORTER_ACCOUNTINFO* AB_ImExporterContext_FindAccountInfo(AB_IMEXPORTER_CONTEXT *iec, const char *bankCode, const char *accountNumber){ AB_IMEXPORTER_ACCOUNTINFO *iea; if (!bankCode) bankCode=""; if (!accountNumber) accountNumber=""; assert(iec); iea=AB_ImExporterAccountInfo_List_First(iec->accountInfoList); while(iea) { const char *sBankCode; const char *sAccountNumber; sBankCode=AB_ImExporterAccountInfo_GetBankCode(iea); if (sBankCode==0) sBankCode=""; sAccountNumber=AB_ImExporterAccountInfo_GetAccountNumber(iea); if (sAccountNumber==0) sAccountNumber=""; if (strcasecmp(sBankCode, bankCode)==0 && strcasecmp(sAccountNumber, accountNumber)==0) { return iea; } iea=AB_ImExporterAccountInfo_List_Next(iea); } return 0; }
/** * Call gnc_import_select_account() on the online id constructed using * the information in @a acc_info. * * @param acc_info AB_IMEXPORTER_ACCOUNTINFO * @return A GnuCash account, or NULL otherwise */ static Account * gnc_ab_accinfo_to_gnc_acc(AB_IMEXPORTER_ACCOUNTINFO *acc_info) { const gchar *bankcode, *accountnumber; gchar *online_id; Account *gnc_acc; g_return_val_if_fail(acc_info, NULL); bankcode = AB_ImExporterAccountInfo_GetBankCode(acc_info); accountnumber = AB_ImExporterAccountInfo_GetAccountNumber(acc_info); online_id = g_strconcat(bankcode ? bankcode : "", accountnumber ? accountnumber : "", (gchar*)NULL); gnc_acc = gnc_import_select_account( NULL, online_id, 1, AB_ImExporterAccountInfo_GetAccountName(acc_info), NULL, ACCT_TYPE_NONE, NULL, NULL); if (!gnc_acc) { g_warning("gnc_ab_accinfo_to_gnc_acc: Could not determine source account" " for online_id %s", online_id); } g_free(online_id); return gnc_acc; }
AB_IMEXPORTER_ACCOUNTINFO *AB_ImExporterContext__GetAccountInfoForTransaction(AB_IMEXPORTER_CONTEXT *iec, const AB_TRANSACTION *t){ AB_IMEXPORTER_ACCOUNTINFO *iea; const char *tIban; const char *tBankCode; const char *tAccountNumber; tBankCode=AB_Transaction_GetLocalBankCode(t); if (!tBankCode) tBankCode=""; tAccountNumber=AB_Transaction_GetLocalAccountNumber(t); if (!tAccountNumber) tAccountNumber=""; tIban=AB_Transaction_GetLocalIban(t); if (!tIban) tIban=""; iea=AB_ImExporterAccountInfo_List_First(iec->accountInfoList); while(iea) { const char *sBankCode; const char *sAccountNumber; const char *sIban; sBankCode=AB_ImExporterAccountInfo_GetBankCode(iea); if (!sBankCode) sBankCode=""; sAccountNumber=AB_ImExporterAccountInfo_GetAccountNumber(iea); if (!sAccountNumber) sAccountNumber=""; sIban=AB_ImExporterAccountInfo_GetIban(iea); if (!sIban) sIban=""; if (strcasecmp(sIban, tIban)==0) return iea; if ((strcasecmp(sBankCode, tBankCode)==0) && (strcasecmp(sAccountNumber, tAccountNumber)==0)) return iea; iea=AB_ImExporterAccountInfo_List_Next(iea); } /* not found, append it */ iea=AB_ImExporterAccountInfo_new(); if (tIban && *tIban) AB_ImExporterAccountInfo_SetIban(iea, tIban); if (tBankCode && *tBankCode) AB_ImExporterAccountInfo_SetBankCode(iea, tBankCode); if (tAccountNumber && *tAccountNumber) AB_ImExporterAccountInfo_SetAccountNumber(iea, tAccountNumber); AB_ImExporterAccountInfo_List_Add(iea, iec->accountInfoList); return iea; }
static AB_IMEXPORTER_ACCOUNTINFO * accountinfolist_cb(AB_IMEXPORTER_ACCOUNTINFO *accinfo, void *user_data) { Account *gnc_acc; struct import_data *data = user_data; const char *bank_code = AB_ImExporterAccountInfo_GetBankCode(accinfo); const char *account_number = AB_ImExporterAccountInfo_GetAccountNumber(accinfo); const char *account_name = AB_ImExporterAccountInfo_GetAccountName(accinfo); gchar *online_id = g_strconcat (bank_code, account_number, NULL); gnc_acc = gnc_import_select_account(NULL, online_id, 1, account_name, NULL, ACCT_TYPE_NONE, NULL, NULL); g_free(online_id); if (gnc_acc) { /* Store chosen gnucash account in callback data */ data->gnc_acc = gnc_acc; if (data->execute_transactions) { /* Retrieve the aqbanking account that belongs to this gnucash account */ data->hbci_account = gnc_hbci_get_hbci_acc (data->ab, gnc_acc); if (data->hbci_account == NULL) { gnc_error_dialog (NULL, _("No Online Banking account found for this gnucash account. These transactions will not be executed by Online Banking.")); } } else { data->hbci_account = NULL; } /* Iterate through all transactions. */ AB_ImExporterAccountInfo_TransactionsForEach (accinfo, translist_cb, data); /* all transactions finished. */ } return NULL; }
int AB_ImExporterYN__ReadTransactions(AB_IMEXPORTER *ie, AB_IMEXPORTER_ACCOUNTINFO *ai, GWEN_XMLNODE *doc) { GWEN_XMLNODE *n; n=GWEN_XMLNode_FindFirstTag(doc, "SG4", 0, 0); while (n) { GWEN_XMLNODE *nn; nn=GWEN_XMLNode_GetNodeByXPath(n, "LIN/PF:D_0805", GWEN_PATH_FLAGS_NAMEMUSTEXIST); if (nn) { const char *s; s=GWEN_XMLNode_GetProperty(nn, "Value", 0); if (s && (strcasecmp(s, "LNE")==0 || strcasecmp(s, "LNS")==0) ) { nn = GWEN_XMLNode_FindFirstTag(n, "SG6", 0, 0); while (nn) { AB_TRANSACTION *t; const char *s; t=AB_ImExporterYN__ReadLNE_LNS(ie, ai, nn); s=AB_ImExporterAccountInfo_GetAccountNumber(ai); AB_Transaction_SetLocalAccountNumber(t, s); s=AB_ImExporterAccountInfo_GetIban(ai); AB_Transaction_SetLocalIban(t, s); AB_ImExporterAccountInfo_AddTransaction(ai, t); nn=GWEN_XMLNode_FindNextTag(nn, "SG6", 0, 0); } } } n=GWEN_XMLNode_FindNextTag(n, "SG4", 0, 0); } return 0; }
static int listBal(AB_BANKING *ab, GWEN_DB_NODE *dbArgs, int argc, char **argv) { GWEN_DB_NODE *db; int rv; const char *ctxFile; const char *outFile; AB_IMEXPORTER_CONTEXT *ctx=0; AB_IMEXPORTER_ACCOUNTINFO *iea=0; const char *bankId; const char *accountId; const char *bankName; const char *accountName; FILE *f; const GWEN_ARGS args[]={ { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "bankId", /* name */ 0, /* minnum */ 1, /* maxnum */ "b", /* short option */ "bank", /* long option */ "Specify the bank code", /* short description */ "Specify the bank code" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "accountId", /* name */ 0, /* minnum */ 1, /* maxnum */ "a", /* short option */ "account", /* long option */ "Specify the account number", /* short description */ "Specify the account number" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "bankName", /* name */ 0, /* minnum */ 1, /* maxnum */ "N", /* short option */ "bankname", /* long option */ "Specify the bank name", /* short description */ "Specify the bank name" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "accountName", /* name */ 0, /* minnum */ 1, /* maxnum */ "n", /* short option */ "accountname", /* long option */ "Specify the account name", /* short description */ "Specify the account name" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "ctxFile", /* name */ 0, /* minnum */ 1, /* maxnum */ "c", /* short option */ "ctxfile", /* long option */ "Specify the file to store the context in", /* short description */ "Specify the file to store the context in" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "outFile", /* name */ 0, /* minnum */ 1, /* maxnum */ "o", /* short option */ "outfile", /* long option */ "Specify the file to store the data in", /* short description */ "Specify the file to store the data in" /* long description */ }, { GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */ GWEN_ArgsType_Int, /* type */ "help", /* name */ 0, /* minnum */ 0, /* maxnum */ "h", /* short option */ "help", /* long option */ "Show this help screen", /* short description */ "Show this help screen" /* long description */ } }; db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local"); rv=GWEN_Args_Check(argc, argv, 1, 0 /*GWEN_ARGS_MODE_ALLOW_FREEPARAM*/, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments\n"); return 1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); return 1; } fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } bankId=GWEN_DB_GetCharValue(db, "bankId", 0, 0); bankName=GWEN_DB_GetCharValue(db, "bankName", 0, 0); accountId=GWEN_DB_GetCharValue(db, "accountId", 0, 0); accountName=GWEN_DB_GetCharValue(db, "accountName", 0, 0); rv=AB_Banking_Init(ab); if (rv) { DBG_ERROR(0, "Error on init (%d)", rv); return 2; } ctxFile=GWEN_DB_GetCharValue(db, "ctxfile", 0, 0); rv=readContext(ctxFile, &ctx, 1); if (rv<0) { DBG_ERROR(0, "Error reading context (%d)", rv); return 4; } /* open output stream */ outFile=GWEN_DB_GetCharValue(db, "outFile", 0, 0); if (outFile==0) f=stdout; else f=fopen(outFile, "w+"); if (f==0) { DBG_ERROR(0, "Error selecting output file: %s", strerror(errno)); return 4; } iea=AB_ImExporterContext_GetFirstAccountInfo(ctx); while(iea) { int matches=1; const char *s; if (matches && bankId) { s=AB_ImExporterAccountInfo_GetBankCode(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, bankId, 0)) matches=0; } if (matches && bankName) { s=AB_ImExporterAccountInfo_GetBankName(iea); if (!s || !*s) s=AB_ImExporterAccountInfo_GetBankName(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, bankName, 0)) matches=0; } if (matches && accountId) { s=AB_ImExporterAccountInfo_GetAccountNumber(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, accountId, 0)) matches=0; } if (matches && accountName) { s=AB_ImExporterAccountInfo_GetAccountName(iea); if (!s || !*s) s=AB_ImExporterAccountInfo_GetAccountName(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, accountName, 0)) matches=0; } if (matches) { AB_ACCOUNT_STATUS *ast; ast=_getLastAccountStatus(iea); if (ast) { const GWEN_TIME *ti; const char *s; fprintf(f, "Account\t"); s=AB_ImExporterAccountInfo_GetBankCode(iea); if (!s) s=""; fprintf(f, "%s\t", s); s=AB_ImExporterAccountInfo_GetAccountNumber(iea); if (!s) s=""; fprintf(f, "%s\t", s); s=AB_ImExporterAccountInfo_GetBankName(iea); if (!s) s=""; fprintf(f, "%s\t", s); s=AB_ImExporterAccountInfo_GetAccountName(iea); if (!s) s=""; fprintf(f, "%s\t", s); ti=AB_AccountStatus_GetTime(ast); _dumpBal(AB_AccountStatus_GetBookedBalance(ast), ti, f); _dumpBal(AB_AccountStatus_GetNotedBalance(ast), ti, f); fprintf(f, "\n"); } } /* if matches */ iea=AB_ImExporterContext_GetNextAccountInfo(ctx); } /* while */ if (outFile) { if (fclose(f)) { DBG_ERROR(0, "Error closing output file: %s", strerror(errno)); return 4; } } rv=AB_Banking_Fini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 5; } return 0; }
int listBal(AB_BANKING *ab, GWEN_DB_NODE *dbArgs, int argc, char **argv) { GWEN_DB_NODE *db; int rv; const char *ctxFile; AB_IMEXPORTER_CONTEXT *ctx=0; AB_IMEXPORTER_ACCOUNTINFO *iea=0; uint32_t aid; const char *bankId; const char *accountId; const char *subAccountId; const char *iban; const char *tmplString; const char *s; AB_BALANCE_TYPE bt=AB_Balance_TypeBooked; /* parse command line arguments */ db=_readCommandLine(dbArgs, argc, argv); if (db==NULL) { /* error in command line */ return 1; } /* read command line arguments */ aid=(uint32_t)GWEN_DB_GetIntValue(db, "uniqueAccountId", 0, 0); bankId=GWEN_DB_GetCharValue(db, "bankId", 0, 0); accountId=GWEN_DB_GetCharValue(db, "accountId", 0, 0); subAccountId=GWEN_DB_GetCharValue(db, "subAccountId", 0, 0); iban=GWEN_DB_GetCharValue(db, "iban", 0, 0); tmplString=GWEN_DB_GetCharValue(db, "template", 0, "$(dateAsString)\t" "$(valueAsString)\t" "$(iban)"); /* determine balance type */ s=GWEN_DB_GetCharValue(db, "balanceType", 0, "noted"); if (s && *s) { AB_BALANCE_TYPE tempBalanceType; tempBalanceType=AB_Balance_Type_fromString(s); if (tempBalanceType==AB_Balance_TypeUnknown) { DBG_ERROR(0, "Invalid balance type given (%s)", s); return 1; } bt=tempBalanceType; } /* init AqBanking */ rv=AB_Banking_Init(ab); if (rv) { DBG_ERROR(0, "Error on init (%d)", rv); return 2; } /* load ctx file */ ctxFile=GWEN_DB_GetCharValue(db, "ctxfile", 0, 0); rv=readContext(ctxFile, &ctx, 1); if (rv<0) { DBG_ERROR(0, "Error reading context (%d)", rv); AB_ImExporterContext_free(ctx); return 4; } /* copy context, but only keep wanted accounts and transactions */ iea=AB_ImExporterContext_GetFirstAccountInfo(ctx); while (iea) { if (AB_ImExporterAccountInfo_Matches(iea, aid, /* unique account id */ "*", bankId, accountId, subAccountId, iban, "*", /* currency */ AB_AccountType_Unknown)) { AB_BALANCE *bal; GWEN_DB_NODE *dbAccount; const char *s; dbAccount=GWEN_DB_Group_new("dbAccount"); s=AB_ImExporterAccountInfo_GetBankCode(iea); if (s && *s) GWEN_DB_SetCharValue(dbAccount, GWEN_DB_FLAGS_OVERWRITE_VARS, "bankCode", s); s=AB_ImExporterAccountInfo_GetAccountNumber(iea); if (s && *s) GWEN_DB_SetCharValue(dbAccount, GWEN_DB_FLAGS_OVERWRITE_VARS, "accountNumber", s); s=AB_ImExporterAccountInfo_GetBic(iea); if (s && *s) GWEN_DB_SetCharValue(dbAccount, GWEN_DB_FLAGS_OVERWRITE_VARS, "bic", s); s=AB_ImExporterAccountInfo_GetIban(iea); if (s && *s) GWEN_DB_SetCharValue(dbAccount, GWEN_DB_FLAGS_OVERWRITE_VARS, "iban", s); bal=AB_Balance_List_GetLatestByType(AB_ImExporterAccountInfo_GetBalanceList(iea), bt); if (bal) { GWEN_DB_NODE *dbElement; const AB_VALUE *v; const GWEN_DATE *dt; GWEN_BUFFER *dbuf; dbElement=GWEN_DB_Group_dup(dbAccount); AB_Balance_toDb(bal, dbElement); /* translate value */ dbuf=GWEN_Buffer_new(0, 256, 0, 1); v=AB_Balance_GetValue(bal); if (v) { AB_Value_toHumanReadableString(v, dbuf, 2, 0); GWEN_DB_SetCharValue(dbElement, GWEN_DB_FLAGS_OVERWRITE_VARS, "valueAsString", GWEN_Buffer_GetStart(dbuf)); GWEN_Buffer_Reset(dbuf); } /* translate date */ dt=AB_Balance_GetDate(bal); if (dt) { rv=GWEN_Date_toStringWithTemplate(dt, I18N("DD.MM.YYYY"), dbuf); if (rv>=0) { GWEN_DB_SetCharValue(dbElement, GWEN_DB_FLAGS_OVERWRITE_VARS, "dateAsString", GWEN_Buffer_GetStart(dbuf)); } GWEN_Buffer_Reset(dbuf); } GWEN_DB_ReplaceVars(dbElement, tmplString, dbuf); fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(dbuf)); GWEN_Buffer_free(dbuf); GWEN_DB_Group_free(dbElement); } /* if bal */ GWEN_DB_Group_free(dbAccount); } /* if account matches */ iea=AB_ImExporterAccountInfo_List_Next(iea); } /* while */ AB_ImExporterContext_free(ctx); /* deinit */ rv=AB_Banking_Fini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 5; } return 0; }
static int listTrans(AB_BANKING *ab, GWEN_DB_NODE *dbArgs, int argc, char **argv) { GWEN_DB_NODE *db; int rv; const char *ctxFile; const char *outFile; const char *exporterName; const char *profileName; const char *profileFile; AB_IMEXPORTER_CONTEXT *ctx=0; AB_IMEXPORTER_CONTEXT *nctx=0; AB_IMEXPORTER_ACCOUNTINFO *iea=0; const char *bankId; const char *accountId; const char *bankName; const char *accountName; const GWEN_ARGS args[]={ { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "bankId", /* name */ 0, /* minnum */ 1, /* maxnum */ "b", /* short option */ "bank", /* long option */ "Specify the bank code", /* short description */ "Specify the bank code" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "accountId", /* name */ 0, /* minnum */ 1, /* maxnum */ "a", /* short option */ "account", /* long option */ "Specify the account number", /* short description */ "Specify the account number" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "bankName", /* name */ 0, /* minnum */ 1, /* maxnum */ "N", /* short option */ "bankname", /* long option */ "Specify the bank name", /* short description */ "Specify the bank name" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "accountName", /* name */ 0, /* minnum */ 1, /* maxnum */ "n", /* short option */ "accountname", /* long option */ "Specify the account name", /* short description */ "Specify the account name" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "ctxFile", /* name */ 0, /* minnum */ 1, /* maxnum */ "c", /* short option */ "ctxfile", /* long option */ "Specify the file to store the context in", /* short description */ "Specify the file to store the context in" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "outFile", /* name */ 0, /* minnum */ 1, /* maxnum */ "o", /* short option */ "outfile", /* long option */ "Specify the file to store the data in", /* short description */ "Specify the file to store the data in" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "exporterName", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "exporter", /* long option */ "Specify the exporter to use", /* short description */ "Specify the exporter to use" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "profileName", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "profile", /* long option */ "Specify the export profile to use", /* short description */ "Specify the export profile to use" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "profileFile", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "profile-file", /* long option */ "Specify the file to load the export profile from",/* short description */ "Specify the file to load the export profile from" /* long description */ }, { GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */ GWEN_ArgsType_Int, /* type */ "help", /* name */ 0, /* minnum */ 0, /* maxnum */ "h", /* short option */ "help", /* long option */ "Show this help screen", /* short description */ "Show this help screen" /* long description */ } }; db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local"); rv=GWEN_Args_Check(argc, argv, 1, 0 /*GWEN_ARGS_MODE_ALLOW_FREEPARAM*/, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments\n"); return 1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); return 1; } fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } exporterName=GWEN_DB_GetCharValue(db, "exporterName", 0, "csv"); profileName=GWEN_DB_GetCharValue(db, "profileName", 0, "default"); profileFile=GWEN_DB_GetCharValue(db, "profileFile", 0, NULL); bankId=GWEN_DB_GetCharValue(db, "bankId", 0, 0); bankName=GWEN_DB_GetCharValue(db, "bankName", 0, 0); accountId=GWEN_DB_GetCharValue(db, "accountId", 0, 0); accountName=GWEN_DB_GetCharValue(db, "accountName", 0, 0); outFile=GWEN_DB_GetCharValue(db, "outFile", 0, 0); rv=AB_Banking_Init(ab); if (rv) { DBG_ERROR(0, "Error on init (%d)", rv); return 2; } /* load ctx file */ ctxFile=GWEN_DB_GetCharValue(db, "ctxfile", 0, 0); rv=readContext(ctxFile, &ctx, 1); if (rv<0) { DBG_ERROR(0, "Error reading context (%d)", rv); AB_ImExporterContext_free(ctx); return 4; } nctx=AB_ImExporterContext_new(); iea=AB_ImExporterContext_GetFirstAccountInfo(ctx); while(iea) { int matches=1; const char *s; if (matches && bankId) { s=AB_ImExporterAccountInfo_GetBankCode(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, bankId, 0)) matches=0; } if (matches && bankName) { s=AB_ImExporterAccountInfo_GetBankName(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, bankName, 0)) matches=0; } if (matches && accountId) { s=AB_ImExporterAccountInfo_GetAccountNumber(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, accountId, 0)) matches=0; } if (matches && accountName) { s=AB_ImExporterAccountInfo_GetAccountName(iea); if (!s || !*s || -1==GWEN_Text_ComparePattern(s, accountName, 0)) matches=0; } if (matches) { AB_IMEXPORTER_ACCOUNTINFO *nai; nai=AB_ImExporterAccountInfo_dup(iea); AB_ImExporterContext_AddAccountInfo(nctx, nai); } /* if matches */ iea=AB_ImExporterContext_GetNextAccountInfo(ctx); } /* while */ AB_ImExporterContext_free(ctx); /* export new context */ rv=AB_Banking_ExportToFileWithProfile(ab, exporterName, nctx, profileName, profileFile, outFile); if (rv<0) { DBG_ERROR(0, "Error exporting (%d).", rv); AB_ImExporterContext_free(nctx); return 4; } AB_ImExporterContext_free(nctx); rv=AB_Banking_Fini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 5; } return 0; }