int test2(int argc, char **argv) { OFXHOME *oh; const OH_INSTITUTE_DATA *d; GWEN_GUI *gui; int rv; rv=GWEN_Init(); if (rv) { fprintf(stderr, "ERROR: Unable to init Gwen.\n"); exit(2); } GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Info); GWEN_Logger_SetLevel(AQOFXCONNECT_LOGDOMAIN, GWEN_LoggerLevel_Info); GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug); gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); oh=OfxHome_new("/tmp/ofx"); d=OfxHome_GetData(oh, 542); if (d==NULL) { fprintf(stderr, "No data...\n"); return 2; } OfxHome_free(oh); return 0; }
int main(int argc, char **argv) { int errs=0; GWEN_GUI *gui; gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetCheckCertFn(gui, checkCert); GWEN_Gui_SetGui(gui); if (check_db()) errs++; #ifdef GWENHYWFAR_SKIP_NETWORK_CHECKS fprintf(stderr, "Skipping all checks that assume available network connectivity\n" "Run ./configure without --disable-network-checks to enable the skipped checks\n"); #else if (check_syncio_tls()) errs++; if (check_syncio_http()) errs++; if (check_syncio_https()) errs++; #endif if (errs) return 2; return 0; }
int test1(int argc, char **argv) { GWEN_GUI *gui; int rv; GWEN_DIALOG *dlg; rv=GWEN_Init(); if (rv) { DBG_ERROR_ERR(0, rv); return 2; } GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info); gtk_set_locale (); gtk_init (&argc, &argv); /* create GUI */ gui=Gtk2_Gui_new(); GWEN_Gui_SetGui(gui); dlg=Dlg_Test1_new(); if (dlg==NULL) { fprintf(stderr, "Could not create dialog.\n"); return 2; } rv=GWEN_Gui_ExecDialog(dlg, 0); fprintf(stderr, "Result: %d\n", rv); return 0; }
static void register_callbacks(GncGWENGui *gui) { GWEN_GUI *gwen_gui; g_return_if_fail(gui && !gui->gwen_gui); ENTER("gui=%p", gui); gui->gwen_gui = gwen_gui = GWEN_Gui_new(); GWEN_Gui_SetMessageBoxFn(gwen_gui, messagebox_cb); GWEN_Gui_SetInputBoxFn(gwen_gui, inputbox_cb); GWEN_Gui_SetShowBoxFn(gwen_gui, showbox_cb); GWEN_Gui_SetHideBoxFn(gwen_gui, hidebox_cb); GWEN_Gui_SetProgressStartFn(gwen_gui, progress_start_cb); GWEN_Gui_SetProgressAdvanceFn(gwen_gui, progress_advance_cb); GWEN_Gui_SetProgressLogFn(gwen_gui, progress_log_cb); GWEN_Gui_SetProgressEndFn(gwen_gui, progress_end_cb); GWEN_Gui_SetGetPasswordFn(gwen_gui, getpassword_cb); GWEN_Gui_SetSetPasswordStatusFn(gwen_gui, setpasswordstatus_cb); GWEN_Gui_SetLogHookFn(gwen_gui, loghook_cb); gui->builtin_checkcert = GWEN_Gui_SetCheckCertFn(gwen_gui, checkcert_cb); GWEN_Gui_SetGui(gwen_gui); SETDATA_GUI(gwen_gui, gui); LEAVE(" "); }
void gnc_GWEN_Gui_shutdown(void) { GncGWENGui *gui = full_gui; ENTER(" "); if (log_gwen_gui) { GWEN_Gui_free(log_gwen_gui); log_gwen_gui = NULL; } GWEN_Gui_SetGui(NULL); if (!gui) return; gui->parent = NULL; reset_dialog(gui); if (gui->passwords) g_hash_table_destroy(gui->passwords); if (gui->showbox_hash) g_hash_table_destroy(gui->showbox_hash); if (gui->permanently_accepted_certs) GWEN_DB_Group_free(gui->permanently_accepted_certs); if (gui->accepted_certs) g_hash_table_destroy(gui->accepted_certs); gtk_widget_destroy(gui->dialog); g_free(gui); full_gui = NULL; LEAVE(" "); }
int test2(int argc, char **argv) { int rv; uint32_t id1; uint32_t id2; uint64_t i1; uint64_t i2; GWEN_GUI *gui; gtk_set_locale (); gtk_init (&argc, &argv); gui=Gtk2_Gui_new(); GWEN_Gui_SetGui(gui); id1=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_LOG | GWEN_GUI_PROGRESS_SHOW_ABORT | GWEN_GUI_PROGRESS_KEEP_OPEN, "Progress-Title", "<html>" "<p><b>This</b> is an example <i>text</i>..</p>" "<p>As you can see <font color=red>colors</font> can " "be used.</p>" "</html>", 10, 0); for (i1=1; i1<=10; i1++) { char numbuf[128]; snprintf(numbuf, sizeof(numbuf)-1, "Step %d\n", (int)i1); GWEN_Gui_ProgressLog(id1, GWEN_LoggerLevel_Notice, numbuf); id2=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_LOG | GWEN_GUI_PROGRESS_DELAY | GWEN_GUI_PROGRESS_SHOW_ABORT, "2nd progress", "Starting 2nd progress...", 10, id1); for (i2=1; i2<=10; i2++) { sleep(1); fprintf(stderr, "Advancing %d/%d\n", (int)i1, (int)i2); rv=GWEN_Gui_ProgressAdvance(id2, i2); if (rv==GWEN_ERROR_USER_ABORTED) { fprintf(stderr, "Aborted by user (2)\n"); break; } } GWEN_Gui_ProgressEnd(id2); rv=GWEN_Gui_ProgressAdvance(id1, i1); if (rv==GWEN_ERROR_USER_ABORTED) { fprintf(stderr, "Aborted by user (1)\n"); break; } } GWEN_Gui_ProgressEnd(id1); return 0; }
void gnc_GWEN_Gui_log_init(void) { if (!gwen_gui) { gwen_gui = Gtk2_Gui_new(); GWEN_Gui_SetGui(gwen_gui); } }
void gnc_GWEN_Gui_shutdown(void) { if (gwen_gui) { GWEN_Gui_free(gwen_gui); gwen_gui = NULL; GWEN_Gui_SetGui(NULL); } }
int AB_create(aqbanking_Account *acct = NULL) { int rv = 0; //Initialisierungen GWEN if (acct == NULL) { GWEN_Gui_SetGui(aqh->getCInterface()); } else { GWEN_Gui_SetGui(acct->aqh->getCInterface()); } // Initialisierungen AB if (acct == NULL) { ab = AB_Banking_new("python-aqbanking", 0, AB_BANKING_EXTENSION_NONE); rv = AB_Banking_Init(ab); } else { acct->ab = AB_Banking_new("python-aqbanking", 0, AB_BANKING_EXTENSION_NONE); rv = AB_Banking_Init(acct->ab); } if (rv) { PyErr_SetObject(AqBankingInitializeError, PyUnicode_FromFormat("Could not initialize (%d).", rv)); return 2; } if (acct == NULL) { rv = AB_Banking_OnlineInit(ab); } else { rv = AB_Banking_OnlineInit(acct->ab); } if (rv) { PyErr_SetObject(AqBankingInitializeError, PyUnicode_FromFormat("Could not do online initialize (%d).", rv)); return 2; } //Setzen der Call-backs /*GWEN_Gui_SetProgressLogFn(this->gui, zProgressLog); GWEN_Gui_SetCheckCertFn(this->gui, zCheckCert); GWEN_Gui_SetMessageBoxFn(this->gui, zMessageBox); GWEN_Gui_SetGetPasswordFn(this->gui, zPasswordFn);*/ return 0; }
void gnc_GWEN_Gui_log_init(void) { if (!log_gwen_gui) { log_gwen_gui = GWEN_Gui_new(); /* Always use our own logging */ GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb); /* Keep a reference so that the GWEN_GUI survives a GUI switch */ GWEN_Gui_Attach(log_gwen_gui); } GWEN_Gui_SetGui(log_gwen_gui); }
void gnc_GWEN_Gui_log_init(void) { if (!log_gwen_gui) { log_gwen_gui = #ifdef USING_GWENHYWFAR_GTK2_GUI Gtk2_Gui_new() #else GWEN_Gui_new() #endif ; /* Always use our own logging */ GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb); /* Keep a reference so that the GWEN_GUI survives a GUI switch */ GWEN_Gui_Attach(log_gwen_gui); } GWEN_Gui_SetGui(log_gwen_gui); }
int main(int argc, char **argv) { GWEN_DB_NODE *db; const char *cmd; int rv; AB_BANKING *ab; GWEN_GUI *gui; int nonInteractive=0; int acceptValidCerts=0; const char *pinFile; const char *cfgDir; const char *s; const GWEN_ARGS args[]={ { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "cfgdir", /* name */ 0, /* minnum */ 1, /* maxnum */ "D", /* short option */ "cfgdir", /* long option */ I18S("Specify the configuration folder"), I18S("Specify the configuration folder") }, { 0, /* flags */ GWEN_ArgsType_Int, /* type */ "nonInteractive", /* name */ 0, /* minnum */ 1, /* maxnum */ "n", /* short option */ "noninteractive", /* long option */ "Select non-interactive mode",/* short description */ "Select non-interactive mode.\n" /* long description */ "This automatically returns a confirmative answer to any non-critical\n" "message." }, { 0, /* flags */ GWEN_ArgsType_Int, /* type */ "acceptValidCerts", /* name */ 0, /* minnum */ 1, /* maxnum */ "A", /* short option */ "acceptvalidcerts", /* long option */ "Automatically accept all valid TLS certificate", "Automatically accept all valid TLS certificate" }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "charset", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "charset", /* long option */ "Specify the output character set", /* short description */ "Specify the output character set" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "pinfile", /* name */ 0, /* minnum */ 1, /* maxnum */ "P", /* short option */ "pinfile", /* long option */ "Specify the PIN file", /* short description */ "Specify the PIN file" /* 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", I18S("Show this help screen. For help on commands, " "run aqbanking-cli <COMMAND> --help."), I18S("Show this help screen. For help on commands, run aqbanking-cli <COMMAND> --help.") } }; rv=GWEN_Init(); if (rv) { fprintf(stderr, "ERROR: Unable to init Gwen.\n"); exit(2); } GWEN_Logger_Open(0, "aqbanking-cli", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Warning); rv=GWEN_I18N_BindTextDomain_Dir(PACKAGE, LOCALEDIR); if (rv) { DBG_ERROR(0, "Could not bind textdomain (%d)", rv); } else { rv=GWEN_I18N_BindTextDomain_Codeset(PACKAGE, "UTF-8"); if (rv) { DBG_ERROR(0, "Could not set codeset (%d)", rv); } } db=GWEN_DB_Group_new("arguments"); rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM | GWEN_ARGS_MODE_STOP_AT_FREEPARAM, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments main\n"); GWEN_DB_Group_free(db); return 1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); GWEN_Buffer_AppendString(ubuf, I18N("This is version ")); GWEN_Buffer_AppendString(ubuf, AQHBCI_VERSION_STRING "\n"); GWEN_Buffer_AppendString(ubuf, I18N("Usage: ")); GWEN_Buffer_AppendString(ubuf, argv[0]); GWEN_Buffer_AppendString(ubuf, I18N(" [GLOBAL OPTIONS] COMMAND " "[LOCAL OPTIONS]\n")); GWEN_Buffer_AppendString(ubuf, I18N("\nGlobal Options:\n")); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); GWEN_DB_Group_free(db); return 1; } GWEN_Buffer_AppendString(ubuf, I18N("\nCommands:\n")); cmdAddHelpStr(ubuf, "senddtazv", I18N("Sends a DTAZV file to the bank")); cmdAddHelpStr(ubuf, "listaccs", I18N("Prints the list of accounts")); cmdAddHelpStr(ubuf, "listbal", I18N("Export balances from a context file.")); cmdAddHelpStr(ubuf, "listtrans", I18N("Export transactions from a context file.")); cmdAddHelpStr(ubuf, "listtransfers", I18N("Export transactions from a context file which match certain status.")); cmdAddHelpStr(ubuf, "request", I18N("Requests transactions, balances, standing orders etc.")); cmdAddHelpStr(ubuf, "chkacc", I18N("Check a combination of bank id and account number")); cmdAddHelpStr(ubuf, "chkiban", I18N("Check an IBAN")); cmdAddHelpStr(ubuf, "import", I18N("Import a file into an import context file")); cmdAddHelpStr(ubuf, "transfer", I18N("Issue a single transfer (data from command line)")); cmdAddHelpStr(ubuf, "transfers", I18N("Issue a number of transfers (data from a file)")); cmdAddHelpStr(ubuf, "sepatransfer", I18N("Issue a single SEPA transfer (data from command line)")); cmdAddHelpStr(ubuf, "sepatransfers", I18N("Issue a number of SEPA transfers (data from a file)")); cmdAddHelpStr(ubuf, "debitnote", I18N("Issue a single debit note (data from command line)")); cmdAddHelpStr(ubuf, "debitnotes", I18N("Issue a number of debit notes (data from a file)")); cmdAddHelpStr(ubuf, "sepadebitnote", I18N("Issue a single SEPA debit note (data from command line)")); cmdAddHelpStr(ubuf, "sepaflashdebitnote", I18N("Issue a single flash SEPA debit note COR1 (data from command line)")); cmdAddHelpStr(ubuf, "sepadebitnotes", I18N("Issue a number of SEPA debit notes (data from a file)")); cmdAddHelpStr(ubuf, "addtrans", I18N("Add a transfer to an existing import context file")); cmdAddHelpStr(ubuf, "addsepadebitnote", I18N("Add a SEPA debit note to an existing import context file")); cmdAddHelpStr(ubuf, "sepasto", I18N("Manage SEPA standing orders")); cmdAddHelpStr(ubuf, "fillgaps", I18N("Fill gaps in an import context file from configuration settings")); cmdAddHelpStr(ubuf, "updateconf", I18N("Update configuration from previous AqBanking versions")); cmdAddHelpStr(ubuf, "listprofiles", I18N("Print existing profiles")); cmdAddHelpStr(ubuf, "versions", I18N("Print the program and library versions")); GWEN_Buffer_AppendString(ubuf, "\n"); fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); GWEN_DB_Group_free(db); return 0; } if (rv) { argc-=rv-1; argv+=rv-1; } nonInteractive=GWEN_DB_GetIntValue(db, "nonInteractive", 0, 0); acceptValidCerts=GWEN_DB_GetIntValue(db, "acceptValidCerts", 0, 0); cfgDir=GWEN_DB_GetCharValue(db, "cfgdir", 0, 0); cmd=GWEN_DB_GetCharValue(db, "params", 0, 0); if (!cmd) { fprintf(stderr, "ERROR: Command needed.\n"); GWEN_DB_Group_free(db); return 1; } gui=GWEN_Gui_CGui_new(); s=GWEN_DB_GetCharValue(db, "charset", 0, NULL); if (s && *s) GWEN_Gui_SetCharSet(gui, s); if (nonInteractive) GWEN_Gui_AddFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE); else GWEN_Gui_SubFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE); if (acceptValidCerts) GWEN_Gui_AddFlags(gui, GWEN_GUI_FLAGS_ACCEPTVALIDCERTS); else GWEN_Gui_SubFlags(gui, GWEN_GUI_FLAGS_ACCEPTVALIDCERTS); pinFile=GWEN_DB_GetCharValue(db, "pinFile", 0, NULL); if (pinFile) { GWEN_DB_NODE *dbPins; dbPins=GWEN_DB_Group_new("pins"); if (GWEN_DB_ReadFile(dbPins, pinFile, GWEN_DB_FLAGS_DEFAULT | GWEN_PATH_FLAGS_CREATE_GROUP)) { fprintf(stderr, "Error reading pinfile \"%s\"\n", pinFile); GWEN_DB_Group_free(dbPins); GWEN_DB_Group_free(db); return 2; } GWEN_Gui_SetPasswordDb(gui, dbPins, 1); } GWEN_Gui_SetGui(gui); ab=AB_Banking_new("aqbanking-cli", cfgDir, 0); AB_Gui_Extend(gui, ab); if (strcasecmp(cmd, "senddtazv")==0) { rv=sendDtazv(ab, db, argc, argv); } else if (strcasecmp(cmd, "listaccs")==0) { rv=listAccs(ab, db, argc, argv); } else if (strcasecmp(cmd, "listbal")==0) { rv=listBal(ab, db, argc, argv); } else if (strcasecmp(cmd, "listtrans")==0) { rv=listTrans(ab, db, argc, argv); } else if (strcasecmp(cmd, "listtransfers")==0) { rv=listTransfers(ab, db, argc, argv); } else if (strcasecmp(cmd, "request")==0) { rv=request(ab, db, argc, argv); } else if (strcasecmp(cmd, "chkacc")==0) { rv=chkAcc(ab, db, argc, argv); } else if (strcasecmp(cmd, "chkiban")==0) { rv=chkIban(ab, db, argc, argv); } else if (strcasecmp(cmd, "import")==0) { rv=import(ab, db, argc, argv); } else if (strcasecmp(cmd, "transfer")==0) { rv=transfer(ab, db, argc, argv); } else if (strcasecmp(cmd, "transfers")==0) { rv=transfers(ab, db, argc, argv); } else if (strcasecmp(cmd, "sepatransfer")==0) { rv=sepaTransfer(ab, db, argc, argv); } else if (strcasecmp(cmd, "sepatransfers")==0) { rv=sepaMultiJobs(ab, db, argc, argv, AQBANKING_TOOL_SEPA_TRANSFERS); } else if (strcasecmp(cmd, "debitnote")==0) { rv=debitNote(ab, db, argc, argv); } else if (strcasecmp(cmd, "debitnotes")==0) { rv=debitNotes(ab, db, argc, argv); } else if (strcasecmp(cmd, "sepadebitnote")==0) { rv=sepaDebitNote(ab, db, argc, argv, 0); } else if (strcasecmp(cmd, "sepaFlashDebitNote")==0) { rv=sepaDebitNote(ab, db, argc, argv, 1); } else if (strcasecmp(cmd, "sepadebitnotes")==0) { rv=sepaMultiJobs(ab, db, argc, argv, AQBANKING_TOOL_SEPA_DEBITNOTES); } else if (strcasecmp(cmd, "addtrans")==0) { rv=addTransaction(ab, db, argc, argv); } else if (strcasecmp(cmd, "addsepadebitnote")==0) { rv=addSepaDebitNote(ab, db, argc, argv); } else if (strcasecmp(cmd, "sepasto")==0) { rv=sepaRecurTransfer(ab, db, argc, argv); } else if (strcasecmp(cmd, "fillgaps")==0) { rv=fillGaps(ab, db, argc, argv); } else if (strcasecmp(cmd, "updateconf")==0) { rv=updateConf(ab, db, argc, argv); } else if (strcasecmp(cmd, "listprofiles")==0) { rv=listProfiles(ab, db, argc, argv); } else if (strcasecmp(cmd, "versions")==0) { rv=versions(ab, db, argc, argv); } else { fprintf(stderr, "ERROR: Unknown command \"%s\".\n", cmd); rv=1; } GWEN_DB_Group_free(db); return rv; }
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; }
int main(int argc, char **argv) { GWEN_GUI *gui; AB_BANKING *ab; AB_ACCOUNT_SPEC_LIST *accs=NULL; AB_ACCOUNT_SPEC *as; AB_IMEXPORTER_ACCOUNTINFO *ai; gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); ab=AB_Banking_new("tutorial3", 0, 0); AB_Banking_Init(ab); fprintf(stderr, "AqBanking successfully initialized.\n"); /* get the list of known accounts */ AB_Banking_GetAccountSpecList(ab, &accs); /* find a matching account within the given list */ as=AB_AccountSpec_List_FindFirst(accs, "aqhbci", /* backendName */ "de", /* country */ "28*", /* bankId bank */ "*", /* accountNumber */ "*", /* subAccountId */ "*", /* iban */ "*", /* currency */ AB_AccountType_Unknown); /* ty */ if (as) { AB_TRANSACTION_LIST2 *cmdList; AB_TRANSACTION *t; AB_IMEXPORTER_CONTEXT *ctx; cmdList=AB_Transaction_List2_new(); t=AB_Transaction_new(); AB_Transaction_SetCommand(t, AB_Transaction_CommandGetTransactions); AB_Transaction_SetUniqueAccountId(t, AB_AccountSpec_GetUniqueId(as)); AB_Transaction_List2_PushBack(cmdList, t); ctx=AB_ImExporterContext_new(); AB_Banking_SendCommands(ab, cmdList, ctx); ai=AB_ImExporterContext_GetFirstAccountInfo(ctx); while (ai) { const AB_TRANSACTION *t; t=AB_ImExporterAccountInfo_GetFirstTransaction(ai, 0, 0); while (t) { const AB_VALUE *v; v=AB_Transaction_GetValue(t); if (v) { const char *purpose; purpose=AB_Transaction_GetPurpose(t); fprintf(stderr, " %-32s (%.2f %s)\n", purpose, AB_Value_GetValueAsDouble(v), AB_Value_GetCurrency(v)); } t=AB_Transaction_List_Next(t); } /* while transactions */ ai=AB_ImExporterAccountInfo_List_Next(ai); } /* while ai */ AB_ImExporterContext_free(ctx); } /* if (as) */ AB_Banking_Fini(ab); AB_Banking_free(ab); return 0; }
int main(int argc, char **argv) { int rv; GWEN_DB_NODE *db; const char *s; LC_CLIENT *cl; LC_CLIENT_RESULT res; GWEN_GUI *gui; int v; gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); db=GWEN_DB_Group_new("arguments"); rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM, prg_args, db); if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 256, 0, 1); if (GWEN_Args_Usage(prg_args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "Could not generate usage string.\n"); GWEN_Buffer_free(ubuf); return RETURNVALUE_PARAM; } usage(argv[0], GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } if (rv<1) { fprintf(stderr, "ERROR: Error in argument list (%d)\n", rv); return RETURNVALUE_PARAM; } v=GWEN_DB_GetIntValue(db, "verbosity", 0, 0); if (v<2) GWEN_Gui_AddFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE); /* get command */ s=GWEN_DB_GetCharValue(db, "params", 0, 0); if (!s) { fprintf(stderr, "No command given.\n"); GWEN_DB_Group_free(db); return RETURNVALUE_PARAM; } cl=LC_Client_new("kvkcard", PROGRAM_VERSION); res=LC_Client_Init(cl); if (res!=LC_Client_ResultOk) { showError(0, res, "Init"); return RETURNVALUE_SETUP; } /* handle command */ if (strcasecmp(s, "read")==0) { rv=kvkRead(cl, db); } else if (strcasecmp(s, "daemon")==0) { fprintf(stderr, "KVK daemon no longer supported.\n"); return RETURNVALUE_SETUP; } else if (strcasecmp(s, "rdvd")==0) { rv=rdvd(cl, db); } else if (strcasecmp(s, "rdpd")==0) { rv=rdpd(cl, db); } else if (strcasecmp(s, "psvd")==0) { rv=psvd(cl, db); } else { fprintf(stderr, "Unknown command \"%s\"", s); rv=RETURNVALUE_PARAM; } LC_Client_free(cl); GWEN_DB_Group_free(db); return 0; }
int main(int argc, char **argv) { GWEN_DB_NODE *db; const char *cmd; const char *pinFile; int nonInteractive=0; const char *s; int rv; AB_BANKING *ab; GWEN_GUI *gui; const GWEN_ARGS args[]={ { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "cfgfile", /* name */ 0, /* minnum */ 1, /* maxnum */ "C", /* short option */ "cfgfile", /* long option */ "Specify the configuration file", /* short description */ "Specify the configuration file" /* long description */ }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "pinfile", /* name */ 0, /* minnum */ 1, /* maxnum */ "P", /* short option */ "pinfile", /* long option */ "Specify the PIN file", /* short description */ "Specify the PIN file" /* long description */ }, { 0, /* flags */ GWEN_ArgsType_Int, /* type */ "nonInteractive", /* name */ 0, /* minnum */ 1, /* maxnum */ "n", /* short option */ "noninteractive", /* long option */ "Select non-interactive mode",/* short description */ "Select non-interactive mode.\n" /* long description */ "This automatically returns a confirmative answer to any non-critical\n" "message." }, { 0, GWEN_ArgsType_Int, "verbosity", 0, 10, "v", 0, "Increase the verbosity level", "Increase the verbosity level" }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "charset", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "charset", /* long option */ "Specify the output character set", /* short description */ "Specify the output character set" /* 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 */ } }; rv=GWEN_Init(); if (rv<0) { fprintf(stderr, "ERROR: Unable to init GWEN (%d).\n", rv); return 2; } GWEN_Logger_Open("aqpaypal-tool", "aqpaypal-tool", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); GWEN_Logger_SetLevel("aqpaypal-tool", GWEN_LoggerLevel_Warning); GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Warning); db=GWEN_DB_Group_new("arguments"); rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM | GWEN_ARGS_MODE_STOP_AT_FREEPARAM, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments main\n"); return -1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); GWEN_Buffer_AppendString(ubuf, I18N("Usage: ")); GWEN_Buffer_AppendString(ubuf, argv[0]); GWEN_Buffer_AppendString(ubuf, I18N(" [GLOBAL OPTIONS] COMMAND " "[LOCAL OPTIONS]\n")); GWEN_Buffer_AppendString(ubuf, I18N("\nGlobal Options:\n")); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); return 1; } GWEN_Buffer_AppendString(ubuf, I18N("\nCommands:\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" listusers:\n" " blurb " "file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" listaccounts:\n" " blurb " "file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" adduser:\n" " blurb " "file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" addaccount:\n" " blurb " "file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" setsecret:\n" " blurb " "file\n\n")); fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } if (rv) { argc-=rv-1; argv+=rv-1; } cmd=GWEN_DB_GetCharValue(db, "params", 0, 0); if (!cmd) { fprintf(stderr, "ERROR: Command needed.\n"); return 1; } gui=GWEN_Gui_CGui_new(); s=GWEN_DB_GetCharValue(db, "charset", 0, "ISO-8859-15"); GWEN_Gui_SetCharSet(gui, s); nonInteractive=GWEN_DB_GetIntValue(db, "nonInteractive", 0, 0); if (nonInteractive) GWEN_Gui_AddFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE); else GWEN_Gui_SubFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE); pinFile=GWEN_DB_GetCharValue(db, "pinFile", 0, NULL); if (pinFile) { GWEN_DB_NODE *dbPins; dbPins=GWEN_DB_Group_new("pins"); if (GWEN_DB_ReadFile(dbPins, pinFile, GWEN_DB_FLAGS_DEFAULT | GWEN_PATH_FLAGS_CREATE_GROUP)) { fprintf(stderr, "Error reading pinfile \"%s\"\n", pinFile); return 2; } /* set argument "persistent" to one in non-interactive mode */ GWEN_Gui_CGui_SetPasswordDb(gui, dbPins, nonInteractive); } GWEN_Gui_SetGui(gui); ab=AB_Banking_new("aqpaypal-tool", GWEN_DB_GetCharValue(db, "cfgfile", 0, 0), 0); AB_Gui_Extend(gui, ab); if (strcasecmp(cmd, "listusers")==0) { rv=listUsers(ab, db, argc, argv); } else if (strcasecmp(cmd, "listaccounts")==0) { rv=listAccounts(ab, db, argc, argv); } else if (strcasecmp(cmd, "adduser")==0) { rv=addUser(ab, db, argc, argv); } else if (strcasecmp(cmd, "addaccount")==0) { rv=addAccount(ab, db, argc, argv); } else if (strcasecmp(cmd, "setsecrets")==0) { rv=setSecrets(ab, db, argc, argv); } else { fprintf(stderr, "ERROR: Unknown command \"%s\".\n", cmd); rv=1; } return rv; }
int main(int argc, char **argv) { AB_BANKING *ab; int rv; GWEN_GUI *gui; gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); /* The first argument is the name of the application. This is needed for * AqBanking to internally store some application-specific settings. * This name may contain whatever characters you like, it is escaped * internally before creating file paths or DB groups from it. * * The second argument is the folder in which the AqBanking settings are * stored. You should in most cases provide NULL here which makes AqBanking * choose the default path ($HOME/.aqbanking). * If this folder doesn't exist it will be created as soon as AqBanking has * something to store (in most cases when closing the application). */ ab=AB_Banking_new("tutorial1", 0, 0); /* This function initializes AqBanking. It is only after successfull return * from this function that any other AqBanking function may be used. */ rv=AB_Banking_Init(ab); if (rv) { fprintf(stderr, "Error on init (%d)\n", rv); return 2; } /* Initialize the only banking part of AqBanking. This is needed to * actually perform online banking actions (like retrieving account * statements etc). */ rv=AB_Banking_OnlineInit(ab); if (rv) { fprintf(stderr, "Error on onlineinit (%d)\n", rv); return 2; } fprintf(stderr, "AqBanking successfully initialized.\n"); /* deinit the online banking part of AqBanking */ rv=AB_Banking_OnlineFini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 3; } /* You must always call this function before exiting, because only then * AqBanking's settings are written. * After this function has been called no other function except * AB_Banking_free() or AB_Banking_Init() may be called. */ rv=AB_Banking_Fini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 3; } /* The AqBanking instance you created at the beginning must always be * destroyed using this function to avoid memory leaks. */ AB_Banking_free(ab); return 0; }
int main(int argc, char **argv) { GWEN_DB_NODE *db; const char *cmd; int rv; int err; GWEN_GUI *gui; const GWEN_ARGS args[]={ { 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 */ } }; err=GWEN_Init(); if (err) { fprintf(stderr, "Could not initialize Gwenhywfar.\n"); return 2; } gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); GWEN_Logger_Open(GSA_LOGDOMAIN, "gsa", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); GWEN_Logger_SetLevel(GSA_LOGDOMAIN, GWEN_LoggerLevel_Warning); GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Warning); #ifdef GSA_IS_EXPERIMENTAL fprintf(stderr, "\n"); fprintf(stderr, "\n"); fprintf(stderr, "=================== WARNING ===================\n"); fprintf(stderr, "This tool is still EXPERIMENTAL !!!\n"); fprintf(stderr, "Please DON'T USE it with your data files !\n"); fprintf(stderr, "===============================================\n"); fprintf(stderr, "\n"); fprintf(stderr, "\n"); #endif db=GWEN_DB_Group_new("arguments"); rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM | GWEN_ARGS_MODE_STOP_AT_FREEPARAM, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments main\n"); return -1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); GWEN_Buffer_AppendString(ubuf, I18N("GWEN's Simple Archiver")); GWEN_Buffer_AppendString(ubuf, " (Gwenhywfar v" GWENHYWFAR_VERSION_FULL_STRING ")\n"); GWEN_Buffer_AppendString(ubuf, I18N("Usage: ")); GWEN_Buffer_AppendString(ubuf, argv[0]); GWEN_Buffer_AppendString(ubuf, I18N(" [GLOBAL OPTIONS] COMMAND " "[LOCAL OPTIONS]\n")); GWEN_Buffer_AppendString(ubuf, I18N("\nGlobal Options:\n")); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); return 1; } GWEN_Buffer_AppendString(ubuf, I18N("\nCommands:\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" create:\n" " This command creates an archive file" "\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" add:\n" " Add files and folders to an archive file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" list:\n" " List files and folders in an archive file\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" check:\n" " Check integrity of files and folders in an archive file\n\n")); fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } if (rv) { argc-=rv-1; argv+=rv-1; } cmd=GWEN_DB_GetCharValue(db, "params", 0, 0); if (!cmd) { fprintf(stderr, "ERROR: Command needed.\n"); return 1; } if (strcasecmp(cmd, "create")==0) { rv=createArchive(db, argc, argv); } else if (strcasecmp(cmd, "add")==0) { rv=add2Archive(db, argc, argv); } else if (strcasecmp(cmd, "list")==0) { rv=listArchive(db, argc, argv); } else if (strcasecmp(cmd, "check")==0) { rv=checkArchive(db, argc, argv); } else if (strcasecmp(cmd, "extract")==0) { rv=extractArchive(db, argc, argv); } else if (strcasecmp(cmd, "sign")==0) { rv=signArchive(db, argc, argv); } else if (strcasecmp(cmd, "verify")==0) { rv=verifyArchive(db, argc, argv); } else if (strcasecmp(cmd, "mkkey")==0) { rv=mkArchiveKey(db, argc, argv); } else if (strcasecmp(cmd, "rfi")==0) { rv=releaseFillIn(db, argc, argv); } else { fprintf(stderr, "ERROR: Unknown command \"%s\".\n", cmd); rv=1; } err=GWEN_Fini(); if (err) { fprintf(stderr, "WARNING: Could not deinitialize Gwenhywfar.\n"); } return rv; }
int main(int argc, char **argv) { AB_BANKING *ab; AB_ACCOUNT_LIST2 *accs; int rv; GWEN_GUI *gui; gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); ab=AB_Banking_new("tutorial2", 0, 0); rv=AB_Banking_Init(ab); if (rv) { fprintf(stderr, "Error on init (%d)\n", rv); return 2; } rv=AB_Banking_OnlineInit(ab); if (rv) { fprintf(stderr, "Error on onlineinit (%d)\n", rv); return 2; } fprintf(stderr, "AqBanking successfully initialized.\n"); /* Get a list of accounts which are known to AqBanking. * There are some pecularities about the list returned: * The list itself is owned by the caller (who must call * AB_Account_List2_free() as we do below), but the elements of that * list (->the accounts) are still owned by AqBanking. * Therefore you MUST NOT free any of the accounts within the list returned. * This also rules out calling AB_Account_List2_freeAll() which not only * frees the list itself but also frees all its elements. * * The rest of this tutorial shows how lists are generally used by * AqBanking. */ accs=AB_Banking_GetAccounts(ab); if (accs) { AB_ACCOUNT_LIST2_ITERATOR *it; /* List2's are traversed using iterators. An iterator is an object * which points to a single element of a list. * If the list is empty NULL is returned. */ it=AB_Account_List2_First(accs); if (it) { AB_ACCOUNT *a; /* this function returns a pointer to the element of the list to * which the iterator currently points to */ a=AB_Account_List2Iterator_Data(it); while(a) { AB_PROVIDER *pro; /* 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.*/ pro=AB_Account_GetProvider(a); fprintf(stderr, "Account: %s (%s) %s (%s) [%s]\n", AB_Account_GetBankCode(a), AB_Account_GetBankName(a), AB_Account_GetAccountNumber(a), AB_Account_GetAccountName(a), /* the name of the provider/backend as decribed above */ AB_Provider_GetName(pro)); /* this function lets the iterator advance to the next element in * the list, so a following call to AB_Account_List2Iterator_Data() * would return a pointer to the next element. * This function also returns a pointer to the next element of the * list. If there is no next element then NULL is returned. */ a=AB_Account_List2Iterator_Next(it); } /* the iterator must be freed after using it */ AB_Account_List2Iterator_free(it); } /* as discussed the list itself is only a container which has to be freed * after use. This explicitly does not free any of the elements in that * list, and it shouldn't because AqBanking still is the owner of the * accounts */ AB_Account_List2_free(accs); } rv=AB_Banking_OnlineFini(ab); if (rv) { fprintf(stderr, "ERROR: Error on online deinit (%d)\n", rv); return 3; } rv=AB_Banking_Fini(ab); if (rv) { fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv); return 3; } AB_Banking_free(ab); return 0; }
int test3(int argc, char **argv) { #ifdef USE_GWENGUI_GTK2 GWEN_GUI *gui; GWEN_DIALOG *dlg; int rv; AB_BANKING *ab; rv=GWEN_Init(); if (rv) { fprintf(stderr, "ERROR: Unable to init Gwen.\n"); exit(2); } GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Info); GWEN_Logger_SetLevel(AQOFXCONNECT_LOGDOMAIN, GWEN_LoggerLevel_Info); GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug); gtk_init(&argc, &argv); gui=Gtk2_Gui_new(); GWEN_Gui_SetGui(gui); ab=AB_Banking_new("test-ofxhome", NULL, 0); rv=AB_Banking_Init(ab); if (rv<0){ fprintf(stderr, "Error on banking init: %d\n", rv); exit(2); } AB_Gui_Extend(gui, ab); dlg=OH_GetInstituteDialog_new("/tmp/ofx", NULL); if (dlg==NULL) { fprintf(stderr, "Could not create dialog\n"); exit(2); } rv=GWEN_Gui_ExecDialog(dlg, 0); if (rv<=0){ fprintf(stderr, "Dialog was aborted/rejected\n"); } else { const OH_INSTITUTE_DATA *od; fprintf(stderr, "Dialog accepted, all fine\n"); od=OH_GetInstituteDialog_GetSelectedInstitute(dlg); if (od) { fprintf(stderr, "- Id : %d\n", OH_InstituteData_GetId(od)); fprintf(stderr, "- Name: %s\n", OH_InstituteData_GetName(od)); fprintf(stderr, "- FID : %s\n", OH_InstituteData_GetFid(od)); fprintf(stderr, "- ORG : %s\n", OH_InstituteData_GetOrg(od)); fprintf(stderr, "- URL : %s\n", OH_InstituteData_GetUrl(od)); } } GWEN_Dialog_free(dlg); AB_Gui_Unextend(gui); rv=AB_Banking_Fini(ab); if (rv<0){ fprintf(stderr, "Error on banking fini: %d\n", rv); exit(2); } AB_Banking_free(ab); GWEN_Gui_free(gui); #endif return 0; }
int main(int argc, char **argv) { int rv; GWEN_DB_NODE *db; const char *s; LC_CLIENT *cl; GWEN_LOGGER_LOGTYPE logType; GWEN_LOGGER_LEVEL logLevel; GWEN_GUI *gui; gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); db=GWEN_DB_Group_new("arguments"); rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM, prg_args, db); if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 256, 0, 1); if (GWEN_Args_Usage(prg_args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "Could not generate usage string.\n"); GWEN_Buffer_free(ubuf); return RETURNVALUE_PARAM; } fprintf(stdout, I18N("General usage: %s COMMAND [OPTIONS]\n" "Allowed Commands:\n" " This tool accepts the following commands:\n" " loaded\n" " show the amount of money stored on the card\n" " maxload\n" " show the maximum amount to be stored on the card\n" " maxxfer\n" " show the maximum amount which can be transferred " "in one session.\n" "\n" "Allowed Options:\n"), argv[0]); fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } if (rv<1) { fprintf(stderr, "ERROR: Error in argument list (%d)\n", rv); return RETURNVALUE_PARAM; } /* setup logging */ s=GWEN_DB_GetCharValue(db, "loglevel", 0, "warning"); logLevel=GWEN_Logger_Name2Level(s); if (logLevel==GWEN_LoggerLevel_Unknown) { fprintf(stderr, "ERROR: Unknown log level (%s)\n", s); return RETURNVALUE_PARAM; } s=GWEN_DB_GetCharValue(db, "logtype", 0, "console"); logType=GWEN_Logger_Name2Logtype(s); if (logType==GWEN_LoggerType_Unknown) { fprintf(stderr, "ERROR: Unknown log type (%s)\n", s); return RETURNVALUE_PARAM; } rv=GWEN_Logger_Open(LC_LOGDOMAIN, "geldkarte3", GWEN_DB_GetCharValue(db, "logfile", 0, "geldkarte3.log"), logType, GWEN_LoggerFacility_User); if (rv) { fprintf(stderr, "ERROR: Could not setup logging (%d).\n", rv); return RETURNVALUE_SETUP; } GWEN_Logger_SetLevel(LC_LOGDOMAIN, logLevel); /* get command */ s=GWEN_DB_GetCharValue(db, "params", 0, 0); if (!s) { fprintf(stderr, "No command given.\n"); GWEN_DB_Group_free(db); return RETURNVALUE_PARAM; } cl=LC_Client_new("geldkarte", PROGRAM_VERSION); if (LC_Client_Init(cl)) { fprintf(stderr, "ERROR: Could not init libchipcard3.\n"); LC_Client_free(cl); GWEN_DB_Group_free(db); return RETURNVALUE_SETUP; } /* handle command */ if (strcasecmp(s, "loaded")==0) { rv=loaded(cl, db); } else if (strcasecmp(s, "maxload")==0) { rv=maxload(cl, db); } else if (strcasecmp(s, "maxxfer")==0) { rv=maxxfer(cl, db); } else if (strcasecmp(s, "blogs")==0) { rv=b_logs(cl, db); } else { fprintf(stderr, "Unknown command \"%s\"", s); rv=RETURNVALUE_PARAM; } LC_Client_free(cl); GWEN_DB_Group_free(db); return 0; }
int main(int argc, char **argv) { GWEN_DB_NODE *db; const char *cmd; int rv; int err; GWEN_GUI *gui; const char *localedir; GWEN_STRINGLIST *slist; const GWEN_ARGS args[]={ { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ "cfgfile", /* name */ 0, /* minnum */ 1, /* maxnum */ "C", /* short option */ "cfgfile", /* long option */ "Specify the configuration file", /* short description */ "Specify the configuration file" /* long description */ }, { 0, /* flags */ GWEN_ArgsType_Int, /* type */ "forcePin", /* name */ 0, /* minnum */ 1, /* maxnum */ 0, /* short option */ "forcepin", /* long option */ "force pin entry", /* short description */ "force pin entry even if the error counter is not zero" }, { 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 */ } }; err=GWEN_Init(); if (err) { fprintf(stderr, "Could not initialize Gwenhywfar.\n"); return 2; } gui=GWEN_Gui_CGui_new(); GWEN_Gui_SetGui(gui); slist = GWEN_PathManager_GetPaths(GWEN_PM_LIBNAME, GWEN_PM_LOCALEDIR); assert(GWEN_StringList_Count(slist) > 0); localedir = GWEN_StringList_FirstString(slist); #ifdef HAVE_I18N setlocale(LC_ALL,""); if (bindtextdomain(PACKAGE, localedir)==0) fprintf(stderr, "Error binding locale\n"); #endif GWEN_StringList_free(slist); GWEN_Logger_Open(GCT_LOGDOMAIN, "gct-tool", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); #ifdef DEBUG_GCT_TOOL GWEN_Logger_SetLevel(GCT_LOGDOMAIN, GWEN_LoggerLevel_Info); GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug); GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info); #else GWEN_Logger_SetLevel(GCT_LOGDOMAIN, GWEN_LoggerLevel_Warning); GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Warning); GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Warning); #endif #ifdef GCT_IS_EXPERIMENTAL fprintf(stderr, "\n"); fprintf(stderr, "\n"); fprintf(stderr, "=================== WARNING ===================\n"); fprintf(stderr, "This tool is still EXPERIMENTAL !!!\n"); fprintf(stderr, "Please DON'T USE it with your daily key files !\n"); fprintf(stderr, "===============================================\n"); fprintf(stderr, "\n"); fprintf(stderr, "\n"); #endif db=GWEN_DB_Group_new("arguments"); rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM | GWEN_ARGS_MODE_STOP_AT_FREEPARAM, args, db); if (rv==GWEN_ARGS_RESULT_ERROR) { fprintf(stderr, "ERROR: Could not parse arguments main\n"); return -1; } else if (rv==GWEN_ARGS_RESULT_HELP) { GWEN_BUFFER *ubuf; ubuf=GWEN_Buffer_new(0, 1024, 0, 1); GWEN_Buffer_AppendString(ubuf, I18N("Usage: ")); GWEN_Buffer_AppendString(ubuf, argv[0]); GWEN_Buffer_AppendString(ubuf, I18N(" [GLOBAL OPTIONS] COMMAND " "[LOCAL OPTIONS]\n")); GWEN_Buffer_AppendString(ubuf, I18N("\nGlobal Options:\n")); if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { fprintf(stderr, "ERROR: Could not create help string\n"); return 1; } GWEN_Buffer_AppendString(ubuf, I18N("\nCommands:\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" create:\n" " This command creates a crypt token" "\n\n")); GWEN_Buffer_AppendString(ubuf, I18N(" showuser:\n" " Display user data stored on the " "token\n\n")); fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); GWEN_Buffer_free(ubuf); return 0; } if (rv) { argc-=rv-1; argv+=rv-1; } cmd=GWEN_DB_GetCharValue(db, "params", 0, 0); if (!cmd) { fprintf(stderr, "ERROR: Command needed.\n"); return 1; } if (strcasecmp(cmd, "sign1")==0) { rv=signWithOld(db, argc, argv); } else if (strcasecmp(cmd, "sign2")==0) { rv=signWithNew(db, argc, argv); } else if (strcasecmp(cmd, "crypt1")==0) { rv=cryptWithOld(db, argc, argv); } else if (strcasecmp(cmd, "crypt2")==0) { rv=cryptWithNew(db, argc, argv); } else if (strcasecmp(cmd, "crypt3")==0) { rv=cryptWithNew2(db, argc, argv); } else { fprintf(stderr, "ERROR: Unknown command \"%s\".\n", cmd); rv=1; } err=GWEN_Fini(); if (err) { fprintf(stderr, "WARNING: Could not deinitialize Gwenhywfar.\n"); } return rv; }