1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
/***************************************************************************
begin : Tue May 03 2005
copyright : (C) 2018 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* This file is part of the project "AqBanking". *
* Please see toplevel file COPYING of that project for license details. *
***************************************************************************/
/***************************************************************************
* This tutorial shows the list of accounts currently known to AqBanking. *
* *
* It also gives an introduction into the usage of XXX_List2's and list2 *
* iterators. *
* *
* You must either choose a GUI implementation to be used with AqBanking *
* or create one yourself by implementing the user interface callbacks of *
* LibGwenhywfar. *
* *
* However, for simplicity reasons we use the console GUI implementation *
* which implements these callbacks for you. *
* *
* There are other GUI implementations, e.g. for GTK2, QT3, QT4 and FOX16. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <aqbanking/banking.h>
#include <gwenhywfar/cgui.h>
int main(int argc, char **argv)
{
AB_BANKING *ab;
AB_ACCOUNT_SPEC_LIST *accs=NULL;
int rv;
GWEN_GUI *gui;
gui=GWEN_Gui_CGui_new();
GWEN_Gui_SetGui(gui);
ab=AB_Banking_new("tutorial2", 0, 0);
/* Initialize AqBanking */
rv=AB_Banking_Init(ab);
if (rv) {
fprintf(stderr, "Error on init (%d: %s)\n", rv, GWEN_Error_SimpleToString(rv));;
return 2;
}
fprintf(stderr, "AqBanking successfully initialized.\n");
/* Get a list of accounts which are known to AqBanking.
* We own the list returned, so in order to avoid memory
* leaks we need to free it afterwards.
*
* The rest of this tutorial shows how lists are generally used by
* AqBanking.
*/
rv=AB_Banking_GetAccountSpecList(ab, &accs);
if (rv<0) {
fprintf(stderr, "Unable to get the list of accounts (%d: %s)\n", rv, GWEN_Error_SimpleToString(rv));
return 3;
}
else {
AB_ACCOUNT_SPEC *as;
/* return the first entry of the account spec list */
as=AB_AccountSpec_List_First(accs);
while (as) {
fprintf(stderr,
"Account: %s %s (%s) [%s]\n",
AB_AccountSpec_GetBankCode(as),
AB_AccountSpec_GetAccountNumber(as),
AB_AccountSpec_GetAccountName(as),
/* every account is assigned to a backend (sometimes called provider)
* which actually performs online banking tasks. We get a pointer
* to that provider/backend with this call to show its name in our
* example.*/
AB_AccountSpec_GetBackendName(as));
/* return the next entry of the account spec list */
as=AB_AccountSpec_List_Next(as);
}
/* free the list to avoid memory leaks */
AB_AccountSpec_List_free(accs);
}
/* deinitialize AqBanking */
rv=AB_Banking_Fini(ab);
if (rv) {
fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv);
return 3;
}
/* free AqBanking object */
AB_Banking_free(ab);
return 0;
}
|