int GWEN_Error_ToString(int c, char *buffer, int bsize) { const char *s; assert(buffer); assert(bsize); s=GWEN_Error_SimpleToString(c); snprintf(buffer, bsize-1, "Error %d [%s]", c, s?s:"none"); /* make sure the string is NULL terminated */ buffer[bsize-1]=0; /* finished */ return 1; }
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; }