int GWEN_Logger_ModuleInit(void) { const char *s; GWEN_LOGGER_LEVEL ll=GWEN_LoggerLevel_Warning; GWEN_Logger_Open(GWEN_LOGDOMAIN, "gwen", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); s=getenv("GWEN_LOGLEVEL"); if (s) { ll=GWEN_Logger_Name2Level(s); if (ll==GWEN_LoggerLevel_Unknown) ll=GWEN_LoggerLevel_Warning; } GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, ll); return 0; }
int EBC_Provider_Init(AB_PROVIDER *pro, GWEN_DB_NODE *dbData) { EBC_PROVIDER *dp; const char *logLevelName; assert(pro); dp=GWEN_INHERIT_GETDATA(AB_PROVIDER, EBC_PROVIDER, pro); assert(dp); if (!GWEN_Logger_IsOpen(AQEBICS_LOGDOMAIN)) { GWEN_Logger_Open(AQEBICS_LOGDOMAIN, "aqebics", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); } logLevelName=getenv("AQEBICS_LOGLEVEL"); if (logLevelName) { GWEN_LOGGER_LEVEL ll; ll=GWEN_Logger_Name2Level(logLevelName); if (ll!=GWEN_LoggerLevel_Unknown) { GWEN_Logger_SetLevel(AQEBICS_LOGDOMAIN, ll); DBG_WARN(AQEBICS_LOGDOMAIN, "Overriding loglevel for AqEBICS with \"%s\"", logLevelName); } else { DBG_ERROR(AQEBICS_LOGDOMAIN, "Unknown loglevel \"%s\"", logLevelName); } } DBG_INFO(AQEBICS_LOGDOMAIN, "Please remember to purchase a license if you want to use the EBICS backend."); if (1) { GWEN_STRINGLIST *sl=GWEN_PathManager_GetPaths(AB_PM_LIBNAME, AB_PM_LOCALEDIR); const char *localedir=GWEN_StringList_FirstString(sl); int rv; rv=GWEN_I18N_BindTextDomain_Dir(PACKAGE, localedir); if (rv) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Could not bind textdomain (%d)", rv); } else { rv=GWEN_I18N_BindTextDomain_Codeset(PACKAGE, "UTF-8"); if (rv) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Could not set codeset (%d)", rv); } } GWEN_StringList_free(sl); } DBG_NOTICE(AQEBICS_LOGDOMAIN, "Initializing AqEBICS backend"); dp->connectTimeout=GWEN_DB_GetIntValue(dbData, "connectTimeout", 0, EBC_DEFAULT_CONNECT_TIMEOUT); dp->transferTimeout=GWEN_DB_GetIntValue(dbData, "transferTimeout", 0, EBC_DEFAULT_TRANSFER_TIMEOUT); return 0; }
int LC_Client_InitCommon() { if (lc_client__initcounter==0) { int rv; GWEN_STRINGLIST *paths; rv=GWEN_Init(); if (rv) { DBG_ERROR_ERR(LC_LOGDOMAIN, rv); return rv; } if (!GWEN_Logger_IsOpen(LC_LOGDOMAIN)) { const char *s; /* only set our logger if it not already has been */ GWEN_Logger_Open(LC_LOGDOMAIN, "chipcard3-client", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); GWEN_Logger_SetLevel(LC_LOGDOMAIN, GWEN_LoggerLevel_Warning); s=getenv("LC_LOGLEVEL"); if (s) { GWEN_LOGGER_LEVEL ll; ll=GWEN_Logger_Name2Level(s); if (ll!=GWEN_LoggerLevel_Unknown) { GWEN_Logger_SetLevel(LC_LOGDOMAIN, ll); DBG_WARN(LC_LOGDOMAIN, "Overriding loglevel for Libchipcard-Client with \"%s\"", s); } else { DBG_ERROR(0, "Unknown loglevel \"%s\"", s); } } else { GWEN_Logger_SetLevel(LC_LOGDOMAIN, GWEN_LoggerLevel_Warning); } } /* define sysconf path */ GWEN_PathManager_DefinePath(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PathManager_AddRelPath(LCC_PM_LIBNAME, LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR, LC_CLIENT_CONFIG_DIR, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PathManager_AddPath(LCC_PM_LIBNAME, LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR, LC_CLIENT_CONFIG_DIR); #endif /* define data path */ GWEN_PathManager_DefinePath(LCC_PM_LIBNAME, LCC_PM_DATADIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PathManager_AddRelPath(LCC_PM_LIBNAME, LCC_PM_LIBNAME, LCC_PM_DATADIR, LC_CLIENT_XML_DIR, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PathManager_AddPath(LCC_PM_LIBNAME, LCC_PM_LIBNAME, LCC_PM_DATADIR, LC_CLIENT_XML_DIR); #endif /* load configuration file */ #if 0 paths=GWEN_PathManager_GetPaths(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); if (paths) { GWEN_DB_NODE *db; GWEN_BUFFER *fbuf; db=GWEN_DB_Group_new("config"); fbuf=GWEN_Buffer_new(0, 256, 0, 1); rv=GWEN_Directory_FindFileInPaths(paths, LC_CLIENT_CONFIG_FILE, fbuf); if (rv) { DBG_INFO(LC_LOGDOMAIN, "Trying config file with suffix \".default\""); rv=GWEN_Directory_FindFileInPaths(paths, LC_CLIENT_CONFIG_FILE".default", fbuf); } GWEN_StringList_free(paths); if (rv) { DBG_WARN(LC_LOGDOMAIN, "No configuration file found, using defaults"); } else { DBG_INFO(LC_LOGDOMAIN, "Reading configuration file \"%s\"", GWEN_Buffer_GetStart(fbuf)); rv=GWEN_DB_ReadFile(db, GWEN_Buffer_GetStart(fbuf), GWEN_DB_FLAGS_DEFAULT | GWEN_PATH_FLAGS_CREATE_GROUP); if (rv<0) { DBG_ERROR(LC_LOGDOMAIN, "Error in configuration file \"%s\" (%d)", GWEN_Buffer_GetStart(fbuf), rv); GWEN_Buffer_free(fbuf); /* undo all init stuff so far */ GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_DATADIR); GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); return rv; } } GWEN_Buffer_free(fbuf); lc_client__config=db; } else { DBG_ERROR(LC_LOGDOMAIN, "Internal error: Paths not found"); return GWEN_ERROR_INTERNAL; } #else lc_client__config=GWEN_DB_Group_new("config"); #endif /* load XML files */ paths=GWEN_PathManager_GetPaths(LCC_PM_LIBNAME, LCC_PM_DATADIR); if (paths) { GWEN_XMLNODE *n; GWEN_DB_NODE *db; GWEN_BUFFER *fbuf; uint32_t bpos; fbuf=GWEN_Buffer_new(0, 256, 0, 1); rv=GWEN_Directory_FindPathForFile(paths, "cards/README", fbuf); GWEN_StringList_free(paths); if (rv) { DBG_ERROR(LC_LOGDOMAIN, "Data files not found (%d)", rv); /* undo all init stuff so far */ GWEN_Buffer_free(fbuf); GWEN_DB_Group_free(lc_client__config); lc_client__config=NULL; GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_DATADIR); GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); return rv; } /* load card files */ n=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "cards"); if (LC_Client_ReadXmlFiles(n, GWEN_Buffer_GetStart(fbuf), "cards", "card")) { DBG_ERROR(LC_LOGDOMAIN, "Could not read card files"); GWEN_XMLNode_free(n); /* undo all init stuff so far */ GWEN_Buffer_free(fbuf); GWEN_DB_Group_free(lc_client__config); lc_client__config=NULL; GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_DATADIR); GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); return GWEN_ERROR_GENERIC; } lc_client__card_nodes=n; /* load app files */ n=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "apps"); if (LC_Client_ReadXmlFiles(n, GWEN_Buffer_GetStart(fbuf), "apps", "app")) { DBG_ERROR(LC_LOGDOMAIN, "Could not read app files"); GWEN_XMLNode_free(n); /* undo all init stuff so far */ GWEN_XMLNode_free(lc_client__card_nodes); lc_client__card_nodes=NULL; GWEN_Buffer_free(fbuf); GWEN_DB_Group_free(lc_client__config); lc_client__config=NULL; GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_DATADIR); GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); return GWEN_ERROR_GENERIC; } lc_client__app_nodes=n; /*GWEN_XMLNode_WriteFile(n, "/tmp/apps", GWEN_XML_FLAGS_DEFAULT);*/ /* load driver files (if any) */ bpos=GWEN_Buffer_GetPos(fbuf); GWEN_Buffer_AppendString(fbuf, DIRSEP "drivers"); db=GWEN_DB_Group_new("drivers"); rv=LC_DriverInfo_ReadDrivers(GWEN_Buffer_GetStart(fbuf), db, 0, 1); if (rv) { DBG_INFO(LC_LOGDOMAIN, "here (%d)", rv); GWEN_DB_Group_free(db); /* undo all init stuff so far */ GWEN_XMLNode_free(lc_client__app_nodes); lc_client__app_nodes=NULL; GWEN_XMLNode_free(lc_client__card_nodes); lc_client__card_nodes=NULL; GWEN_Buffer_free(fbuf); GWEN_DB_Group_free(lc_client__config); lc_client__config=NULL; GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_DATADIR); GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); return rv; } lc_client__driver_db=db; GWEN_Buffer_Crop(fbuf, 0, bpos); /* insert more loading here */ GWEN_Buffer_free(fbuf); } else { DBG_ERROR(LC_LOGDOMAIN, "No data files found."); /* undo all init stuff so far */ GWEN_DB_Group_free(lc_client__config); lc_client__config=NULL; GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_DATADIR); GWEN_PathManager_UndefinePath(LCC_PM_LIBNAME, LCC_PM_SYSCONFDIR); return GWEN_ERROR_GENERIC; } } lc_client__initcounter++; 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 APY_Provider_Init(AB_PROVIDER *pro, GWEN_DB_NODE *dbData) { APY_PROVIDER *dp; const char *logLevelName; uint32_t currentVersion; uint32_t lastVersion; assert(pro); dp=GWEN_INHERIT_GETDATA(AB_PROVIDER, APY_PROVIDER, pro); assert(dp); if (!GWEN_Logger_IsOpen(AQPAYPAL_LOGDOMAIN)) { GWEN_Logger_Open(AQPAYPAL_LOGDOMAIN, "aqpaypal", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); } logLevelName=getenv("AQPAYPAL_LOGLEVEL"); if (logLevelName) { GWEN_LOGGER_LEVEL ll; ll=GWEN_Logger_Name2Level(logLevelName); if (ll!=GWEN_LoggerLevel_Unknown) { GWEN_Logger_SetLevel(AQPAYPAL_LOGDOMAIN, ll); DBG_WARN(AQPAYPAL_LOGDOMAIN, "Overriding loglevel for AqPAYPAL with \"%s\"", logLevelName); } else { DBG_ERROR(AQPAYPAL_LOGDOMAIN, "Unknown loglevel \"%s\"", logLevelName); } } /* check whether we need to update */ currentVersion= (AQBANKING_VERSION_MAJOR<<24) | (AQBANKING_VERSION_MINOR<<16) | (AQBANKING_VERSION_PATCHLEVEL<<8) | AQBANKING_VERSION_BUILD; lastVersion=GWEN_DB_GetIntValue(dbData, "lastVersion", 0, 0); if (lastVersion<currentVersion) { int rv; DBG_WARN(AQPAYPAL_LOGDOMAIN, "Updating configuration for AqPaypal (before init)"); rv=APY_Provider_UpdatePreInit(pro, lastVersion, currentVersion); if (rv<0) { DBG_INFO(AQPAYPAL_LOGDOMAIN, "here (%d)", rv); return rv; } } /* do some init (currently: none needed) */ /* update post-init */ if (lastVersion<currentVersion) { int rv; DBG_WARN(AQPAYPAL_LOGDOMAIN, "Updating configuration for AqPaypal (after init)"); rv=APY_Provider_UpdatePostInit(pro, lastVersion, currentVersion); if (rv<0) { DBG_INFO(AQPAYPAL_LOGDOMAIN, "here (%d)", rv); return rv; } } if (1) { GWEN_STRINGLIST *sl; const char *localedir; int rv; sl=GWEN_PathManager_GetPaths(AB_PM_LIBNAME, AB_PM_LOCALEDIR); localedir=GWEN_StringList_FirstString(sl); rv=GWEN_I18N_BindTextDomain_Dir(PACKAGE, localedir); if (rv) { DBG_ERROR(AQPAYPAL_LOGDOMAIN, "Could not bind textdomain (%d)", rv); } else { rv=GWEN_I18N_BindTextDomain_Codeset(PACKAGE, "UTF-8"); if (rv) { DBG_ERROR(AQPAYPAL_LOGDOMAIN, "Could not set codeset (%d)", rv); } } GWEN_StringList_free(sl); } DBG_NOTICE(AQPAYPAL_LOGDOMAIN, "Initializing AqPaypal backend"); 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) { 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; }
int AB_Banking_PluginSystemInit(void) { if (ab_plugin_init_count==0) { const char *s; GWEN_PLUGIN_MANAGER *pm; int rv; rv=GWEN_Init(); if (rv) { DBG_ERROR_ERR(AQBANKING_LOGDOMAIN, rv); return rv; } if (!GWEN_Logger_IsOpen(AQBANKING_LOGDOMAIN)) { GWEN_Logger_Open(AQBANKING_LOGDOMAIN, "aqbanking", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User); GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Notice); } s=getenv("AQBANKING_LOGLEVEL"); if (s && *s) { GWEN_LOGGER_LEVEL ll; ll=GWEN_Logger_Name2Level(s); GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, ll); } DBG_INFO(AQBANKING_LOGDOMAIN, "AqBanking v" AQBANKING_VERSION_FULL_STRING " (compiled at " COMPILE_DATETIME "): initialising"); /* define locale paths */ GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_LOCALEDIR); GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_LOCALEDIR, AB_BANKING_REGKEY_PATHS, AB_BANKING_REGKEY_LOCALEDIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PathManager_AddRelPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_LOCALEDIR, LOCALEDIR, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PathManager_AddPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_LOCALEDIR, LOCALEDIR); #endif if (1) { GWEN_STRINGLIST *sl=GWEN_PathManager_GetPaths(AB_PM_LIBNAME, AB_PM_LOCALEDIR); const char *localedir=GWEN_StringList_FirstString(sl); rv=GWEN_I18N_BindTextDomain_Dir(PACKAGE, localedir); if (rv) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not bind textdomain (%d)", rv); } else { rv=GWEN_I18N_BindTextDomain_Codeset(PACKAGE, "UTF-8"); if (rv) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not set codeset (%d)", rv); } } GWEN_StringList_free(sl); } /* define sysconf paths */ GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_SYSCONFDIR); GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_SYSCONFDIR, AB_BANKING_REGKEY_PATHS, AB_BANKING_REGKEY_SYSCONFDIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PathManager_AddRelPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_SYSCONFDIR, AQBANKING_SYSCONF_DIR, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PathManager_AddPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_SYSCONFDIR, AQBANKING_SYSCONF_DIR); #endif /* define data paths */ GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_DATADIR); GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_DATADIR, AB_BANKING_REGKEY_PATHS, AB_BANKING_REGKEY_DATADIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PathManager_AddRelPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_DATADIR, AQBANKING_DATA_DIR, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PathManager_AddPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_DATADIR, AQBANKING_DATA_DIR); #endif /* define wizard paths */ GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_WIZARDDIR); GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_WIZARDDIR, AB_BANKING_REGKEY_PATHS, AB_BANKING_REGKEY_WIZARDDIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PathManager_AddRelPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_WIZARDDIR, AQBANKING_PLUGINS DIRSEP AB_WIZARD_FOLDER, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PathManager_AddPath(AB_PM_LIBNAME, AB_PM_LIBNAME, AB_PM_WIZARDDIR, AQBANKING_PLUGINS DIRSEP AB_WIZARD_FOLDER); #endif /* create bankinfo plugin manager */ DBG_INFO(AQBANKING_LOGDOMAIN, "Registering bankinfo plugin manager"); pm=GWEN_PluginManager_new("bankinfo", AB_PM_LIBNAME); if (GWEN_PluginManager_Register(pm)) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not register bankinfo plugin manager"); return GWEN_ERROR_GENERIC; } GWEN_PluginManager_AddPathFromWinReg(pm, AB_PM_LIBNAME, AB_BANKING_REGKEY_PATHS, AB_BANKING_REGKEY_BANKINFODIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PluginManager_AddRelPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_BANKINFO_PLUGIN_FOLDER, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PluginManager_AddPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_BANKINFO_PLUGIN_FOLDER); #endif ab_pluginManagerBankInfo=pm; /* create provider plugin manager */ DBG_INFO(AQBANKING_LOGDOMAIN, "Registering provider plugin manager"); pm=GWEN_PluginManager_new("provider", AB_PM_LIBNAME); if (GWEN_PluginManager_Register(pm)) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not register provider plugin manager"); return GWEN_ERROR_GENERIC; } GWEN_PluginManager_AddPathFromWinReg(pm, AB_PM_LIBNAME, AB_BANKING_REGKEY_PATHS, AB_BANKING_REGKEY_PROVIDERDIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PluginManager_AddRelPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_PROVIDER_FOLDER, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PluginManager_AddPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_PROVIDER_FOLDER); #endif ab_pluginManagerProvider=pm; /* create imexporters plugin manager */ DBG_INFO(AQBANKING_LOGDOMAIN, "Registering imexporters plugin manager"); pm=GWEN_PluginManager_new("imexporter", AB_PM_LIBNAME); if (GWEN_PluginManager_Register(pm)) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not register imexporters plugin manager"); return GWEN_ERROR_GENERIC; } GWEN_PluginManager_AddPathFromWinReg(pm, AB_PM_LIBNAME, AB_BANKING_REGKEY_PATHS, AB_BANKING_REGKEY_IMPORTERDIR); #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* add folder relative to EXE */ GWEN_PluginManager_AddRelPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_IMEXPORTER_FOLDER, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PluginManager_AddPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_IMEXPORTER_FOLDER); #endif ab_pluginManagerImExporter=pm; /* insert DBIO plugin folder */ pm=GWEN_PluginManager_FindPluginManager("dbio"); if (pm) { #if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL) /* insert folder relative to EXE */ GWEN_PluginManager_InsertRelPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_DBIO_FOLDER, GWEN_PathManager_RelModeExe); #else /* add absolute folder */ GWEN_PluginManager_InsertPath(pm, AB_PM_LIBNAME, AQBANKING_PLUGINS DIRSEP AB_DBIO_FOLDER); #endif } else { DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not find DBIO plugin manager, maybe GWEN_Init() was not called?"); return GWEN_ERROR_GENERIC; } ab_imexporters=AB_ImExporter_List_new(); ab_bankInfoPlugins=AB_BankInfoPlugin_List_new(); } ab_plugin_init_count++; 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; 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; }