GWEN_DIALOG *Dlg_Test1_new() { GWEN_DIALOG *dlg; int rv; const char *s; GWEN_BUFFER *tbuf; tbuf=GWEN_Buffer_new(0, 256, 0, 1); s=getenv("DIALOG_DIR"); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); else GWEN_Buffer_AppendString(tbuf, MEDIAPATH); dlg=GWEN_Dialog_new("dlg_test"); GWEN_Dialog_SetSignalHandler(dlg, _gwenGuiSignalHandler); GWEN_Dialog_AddMediaPath(dlg, GWEN_Buffer_GetStart(tbuf)); /* read dialog from dialog description file */ GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S "dlg_test.dlg"); rv=GWEN_Dialog_ReadXmlFile(dlg, GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); if (rv<0) { DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv); GWEN_Dialog_free(dlg); return NULL; } /* done */ return dlg; }
int AB_Banking_GetSharedDataDir(const AB_BANKING *ab, const char *name, GWEN_BUFFER *buf){ assert(ab); if (ab->dataDir) { GWEN_Buffer_AppendString(buf, ab->dataDir); GWEN_Buffer_AppendString(buf, DIRSEP "shared" DIRSEP); if (GWEN_Text_EscapeToBufferTolerant(name, buf)) { DBG_ERROR(AQBANKING_LOGDOMAIN, "Bad share name, aborting."); abort(); } else { char *s; s=GWEN_Buffer_GetStart(buf); while(*s) { *s=tolower(*s); s++; } } return 0; } else { DBG_ERROR(AQBANKING_LOGDOMAIN, "No data dir (not init?)"); return GWEN_ERROR_GENERIC; } }
int AH_User_AddTextWithoutTags(const char *s, GWEN_BUFFER *obuf) { while(*s) { if (*s=='<') { const char *s2; int l; s2=s; s2++; while(*s2 && *s2!='>') s2++; l=s2-s-2; if (l>0) { const char *s3; s3=s; s3++; if (l==2) { if (strncasecmp(s3, "br", 2)==0) GWEN_Buffer_AppendString(obuf, "\n"); } else if (l==3) { if (strncasecmp(s3, "br/", 3)==0) GWEN_Buffer_AppendString(obuf, "\n"); } } s=s2; /* set s to position of closing bracket */ } else GWEN_Buffer_AppendByte(obuf, *s); /* next char */ s++; } return 0; }
void AB_Value_toHumanReadableString2(const AB_VALUE *v, GWEN_BUFFER *buf, int prec, int withCurrency) { char numbuf[128]; double num; int rv; #ifdef HAVE_SETLOCALE const char *orig_locale = setlocale(LC_NUMERIC, NULL); char *currentLocale = strdup(orig_locale ? orig_locale : "C"); setlocale(LC_NUMERIC, "C"); #endif num=AB_Value_GetValueAsDouble(v); rv=snprintf(numbuf, sizeof(numbuf), "%.*f", prec, num); #ifdef HAVE_SETLOCALE setlocale(LC_NUMERIC, currentLocale); free(currentLocale); #endif if (rv<1 || rv>=sizeof(numbuf)) { assert(0); } GWEN_Buffer_AppendString(buf, numbuf); if (v->currency && withCurrency) { GWEN_Buffer_AppendString(buf, " "); GWEN_Buffer_AppendString(buf, v->currency); } }
static int AH_NewKeyFileDialog_HandleActivatedIniLetter(GWEN_DIALOG *dlg) { AH_NEWKEYFILE_DIALOG *xdlg; int rv; GWEN_BUFFER *tbuf; assert(dlg); xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_NEWKEYFILE_DIALOG, dlg); assert(xdlg); tbuf=GWEN_Buffer_new(0, 1024, 0, 1); /* add HTML version of the INI letter */ GWEN_Buffer_AppendString(tbuf, "<html>"); rv=AH_Provider_GetIniLetterHtml(AB_User_GetProvider(xdlg->user), xdlg->user, 0, 0, tbuf, 1); if (rv<0) { DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv); // TODO: show error message AB_Banking_ClearCryptTokenList(xdlg->banking); GWEN_Buffer_free(tbuf); return GWEN_DialogEvent_ResultHandled; } GWEN_Buffer_AppendString(tbuf, "</html>"); /* add ASCII version of the INI letter for frontends which don't support HTML */ rv=AH_Provider_GetIniLetterTxt(AB_User_GetProvider(xdlg->user), xdlg->user, 0, 0, tbuf, 0); if (rv<0) { DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv); // TODO: show error message AB_Banking_ClearCryptTokenList(xdlg->banking); GWEN_Buffer_free(tbuf); return GWEN_DialogEvent_ResultHandled; } rv=GWEN_Gui_Print(I18N("INI Letter"), "HBCI-INILETTER", I18N("INI Letter for HBCI"), GWEN_Buffer_GetStart(tbuf), 0); if (rv<0) { DBG_INFO(AQHBCI_LOGDOMAIN, "here (%d)", rv); // TODO: show error message GWEN_Buffer_free(tbuf); return GWEN_DialogEvent_ResultHandled; } GWEN_Buffer_free(tbuf); return GWEN_DialogEvent_ResultHandled; }
int GWEN_Directory_FindPathForFile(const GWEN_STRINGLIST *paths, const char *filePath, GWEN_BUFFER *fbuf) { GWEN_STRINGLISTENTRY *se; se=GWEN_StringList_FirstEntry(paths); while(se) { GWEN_BUFFER *tbuf; FILE *f; tbuf=GWEN_Buffer_new(0, 256, 0, 1); GWEN_Buffer_AppendString(tbuf, GWEN_StringListEntry_Data(se)); GWEN_Buffer_AppendString(tbuf, DIRSEP); GWEN_Buffer_AppendString(tbuf, filePath); DBG_VERBOUS(GWEN_LOGDOMAIN, "Trying \"%s\"", GWEN_Buffer_GetStart(tbuf)); f=fopen(GWEN_Buffer_GetStart(tbuf), "r"); if (f) { fclose(f); DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" found in folder \"%s\"", filePath, GWEN_StringListEntry_Data(se)); GWEN_Buffer_AppendString(fbuf, GWEN_StringListEntry_Data(se)); GWEN_Buffer_free(tbuf); return 0; } GWEN_Buffer_free(tbuf); se=GWEN_StringListEntry_Next(se); } DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", filePath); return GWEN_ERROR_NOT_FOUND; }
GWEN_TIME *AB_ImExporter_DateFromString(const char *p, const char *tmpl, int inUtc) { GWEN_TIME *ti; if (strchr(tmpl, 'h')==0) { GWEN_BUFFER *dbuf; GWEN_BUFFER *tbuf; dbuf=GWEN_Buffer_new(0, 32, 0, 1); GWEN_Buffer_AppendString(dbuf, p); GWEN_Buffer_AppendString(dbuf, "-12:00"); tbuf=GWEN_Buffer_new(0, 32, 0, 1); GWEN_Buffer_AppendString(tbuf, tmpl); GWEN_Buffer_AppendString(tbuf, "-hh:mm"); ti=GWEN_Time_fromUtcString(GWEN_Buffer_GetStart(dbuf), GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); GWEN_Buffer_free(dbuf); } else { if (inUtc) ti=GWEN_Time_fromUtcString(p, tmpl); else ti=GWEN_Time_fromString(p, tmpl); } return ti; }
int GWEN_Url_toCommandString(const GWEN_URL *url, GWEN_BUFFER *buf) { GWEN_DB_NODE *dbV; assert(url); if (url->path) { GWEN_Buffer_AppendString(buf, url->path); } if (url->vars) { dbV=GWEN_DB_GetFirstVar(url->vars); while(dbV) { const char *s; s=GWEN_DB_VariableName(dbV); if (s) { GWEN_DB_NODE *dbVal; GWEN_Buffer_AppendString(buf, "?"); GWEN_Buffer_AppendString(buf, s); dbVal=GWEN_DB_GetFirstValue(dbV); if (dbVal) { s=GWEN_DB_GetCharValueFromNode(dbVal); if (s) { GWEN_Buffer_AppendString(buf, "="); GWEN_Buffer_AppendString(buf, s); } } } dbV=GWEN_DB_GetNextVar(dbV); } } return 0; }
int GWEN_PathManager_FindFile(const char *destLib, const char *pathName, const char *fileName, GWEN_BUFFER *fbuf) { GWEN_DB_NODE *dbT; assert(gwen__paths); dbT=GWEN_DB_GetGroup(gwen__paths, GWEN_PATH_FLAGS_NAMEMUSTEXIST, destLib); if (dbT) { dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, pathName); if (dbT) { int i; const char *s; GWEN_DB_NODE *dbN; GWEN_BUFFER *tbuf; tbuf=GWEN_Buffer_new(0, 256, 0, 1); /* check all paths */ dbN=GWEN_DB_FindFirstGroup(dbT, "pair"); while(dbN) { for (i=0; ; i++) { s=GWEN_DB_GetCharValue(dbN, "path", i, 0); if (!s) break; else { FILE *f; GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S); GWEN_Buffer_AppendString(tbuf, fileName); DBG_DEBUG(GWEN_LOGDOMAIN, "Trying \"%s\"", GWEN_Buffer_GetStart(tbuf)); f=fopen(GWEN_Buffer_GetStart(tbuf), "r"); if (f) { fclose(f); DBG_DEBUG(GWEN_LOGDOMAIN, "File \"%s\" found in folder \"%s\"", fileName, s); GWEN_Buffer_AppendBuffer(fbuf, tbuf); GWEN_Buffer_free(tbuf); return 0; } GWEN_Buffer_Reset(tbuf); } } dbN=GWEN_DB_FindNextGroup(dbN, "pair"); } GWEN_Buffer_free(tbuf); } } DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", fileName); return GWEN_ERROR_NOT_FOUND; }
void AB_Value_toString(const AB_VALUE *v, GWEN_BUFFER *buf) { assert(v); AB_Value__toString(v, buf); if (v->currency) { GWEN_Buffer_AppendString(buf, ":"); GWEN_Buffer_AppendString(buf, v->currency); } }
int AB_Banking_GetProviderUserDataDir(const AB_BANKING *ab, const char *name, GWEN_BUFFER *buf){ int rv; rv=AB_Banking_GetUserDataDir(ab, buf); if (rv) return rv; GWEN_Buffer_AppendString(buf, DIRSEP "backends" DIRSEP); GWEN_Buffer_AppendString(buf, name); GWEN_Buffer_AppendString(buf, DIRSEP "data"); return 0; }
int LC_Client_GetReaderAndDriverType(const LC_CLIENT *cl, const char *readerName, GWEN_BUFFER *driverType, GWEN_BUFFER *readerType, uint32_t *pReaderFlags) { GWEN_DB_NODE *dbDriver; dbDriver=GWEN_DB_FindFirstGroup(lc_client__driver_db, "driver"); while(dbDriver) { const char *sDriverName; sDriverName=GWEN_DB_GetCharValue(dbDriver, "driverName", 0, NULL); if (sDriverName) { GWEN_DB_NODE *dbReader; dbReader=GWEN_DB_FindFirstGroup(dbDriver, "reader"); while(dbReader) { const char *sReaderName; const char *sTmpl; sReaderName=GWEN_DB_GetCharValue(dbReader, "readerType", 0, NULL); sTmpl=GWEN_DB_GetCharValue(dbReader, "devicePathTmpl", 0, NULL); if (sReaderName && sTmpl) { if (-1!=GWEN_Text_ComparePattern(readerName, sTmpl, 1)) { /* reader found */ GWEN_Buffer_AppendString(driverType, sDriverName); GWEN_Buffer_AppendString(readerType, sReaderName); *pReaderFlags=LC_ReaderFlags_fromDb(dbReader, "flags"); DBG_INFO(LC_LOGDOMAIN, "Reader [%s] is [%s]/[%s], %08x", readerName, sDriverName, sReaderName, *pReaderFlags); return 0; } } else { DBG_INFO(LC_LOGDOMAIN, "Either reader name or template missing"); } dbReader=GWEN_DB_FindNextGroup(dbReader, "reader"); } } else { DBG_INFO(LC_LOGDOMAIN, "Driver name is missing"); } dbDriver=GWEN_DB_FindNextGroup(dbDriver, "driver"); } return GWEN_ERROR_NOT_FOUND; }
int GWEN_PathManager_GetMatchingFilesRecursively(const char *destLib, const char *pathName, const char *subFolderName, GWEN_STRINGLIST *sl, const char *mask) { GWEN_DB_NODE *dbT; assert(gwen__paths); dbT=GWEN_DB_GetGroup(gwen__paths, GWEN_PATH_FLAGS_NAMEMUSTEXIST, destLib); if (dbT) { dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST, pathName); if (dbT) { int i; const char *s; GWEN_DB_NODE *dbN; GWEN_BUFFER *tbuf; tbuf=GWEN_Buffer_new(0, 256, 0, 1); /* check all paths */ dbN=GWEN_DB_FindFirstGroup(dbT, "pair"); while(dbN) { for (i=0; ; i++) { s=GWEN_DB_GetCharValue(dbN, "path", i, 0); if (!s) break; else { GWEN_Buffer_AppendString(tbuf, s); if (subFolderName && *subFolderName) { GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S); GWEN_Buffer_AppendString(tbuf, subFolderName); } DBG_DEBUG(GWEN_LOGDOMAIN, "Trying \"%s\"", GWEN_Buffer_GetStart(tbuf)); GWEN_Directory_GetMatchingFilesRecursively(GWEN_Buffer_GetStart(tbuf), sl, mask); GWEN_Buffer_Reset(tbuf); } } dbN=GWEN_DB_FindNextGroup(dbN, "pair"); } GWEN_Buffer_free(tbuf); } } return 0; }
int AB_Banking_GetAppUserDataDir(const AB_BANKING *ab, GWEN_BUFFER *buf){ int rv; assert(ab->appEscName); rv=AB_Banking_GetUserDataDir(ab, buf); if (rv<0) { DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv); return rv; } GWEN_Buffer_AppendString(buf, DIRSEP "apps" DIRSEP); GWEN_Buffer_AppendString(buf, ab->appEscName); GWEN_Buffer_AppendString(buf, DIRSEP "data"); return 0; }
int AHB_DTAUS__AddNum(GWEN_BUFFER *dst, unsigned int size, const char *s) { unsigned int i, j; assert(dst); assert(s); DBG_DEBUG(AQBANKING_LOGDOMAIN, "Adding num : %s", s); i=strlen(s); if (i>size) { /* Error out here because e.g. truncated BLZ will lead to failed jobs. */ DBG_ERROR(AQBANKING_LOGDOMAIN, "Number \"%s\" too long: Has length %d but must not be longer than %d characters", s, i, size); return -1; } j=size-i; if (j) { unsigned int k; for (k=0; k<j; k++) GWEN_Buffer_AppendByte(dst, '0'); } GWEN_Buffer_AppendString(dst, s); return 0; }
static int getBankUrl(AB_BANKING *ab, const char *bankId, GWEN_BUFFER *bufServer) { AB_BANKINFO *bi; bi=AB_Banking_GetBankInfo(ab, "de", 0, bankId); if (bi) { AB_BANKINFO_SERVICE_LIST *l; AB_BANKINFO_SERVICE *sv; l=AB_BankInfo_GetServices(bi); assert(l); sv=AB_BankInfoService_List_First(l); while (sv) { const char *st; st=AB_BankInfoService_GetType(sv); if (st && *st && strcasecmp(st, "ebics")==0) { const char *addr; addr=AB_BankInfoService_GetAddress(sv); if (addr && *addr) { GWEN_Buffer_Reset(bufServer); GWEN_Buffer_AppendString(bufServer, addr); return 0; } } sv=AB_BankInfoService_List_Next(sv); } AB_BankInfo_free(bi); } /* if bank info */ return -1; }
int GWEN_XML_AddNameSpace(GWEN_STRINGLIST2 *sl, const char *prefix, const char *name) { GWEN_BUFFER *nbuf; int rv; nbuf=GWEN_Buffer_new(0, 32, 0, 1); if (prefix) GWEN_Buffer_AppendString(nbuf, prefix); GWEN_Buffer_AppendByte(nbuf, ':'); GWEN_Buffer_AppendString(nbuf, name); rv=GWEN_StringList2_AppendString(sl, GWEN_Buffer_GetStart(nbuf), 0, GWEN_StringList2_IntertMode_NoDouble); GWEN_Buffer_free(nbuf); return rv; }
int GWEN_Directory_GetAbsoluteFolderPath(const char *folder, GWEN_BUFFER *tbuf) { char savedPwd[300]; char dataPwd[300]; /* get current working dir */ if (getcwd(savedPwd, sizeof(savedPwd)-1)==NULL) { DBG_ERROR(GWEN_LOGDOMAIN, "getcwd(): %s", strerror(errno)); return GWEN_ERROR_IO; } if (chdir(folder)) { DBG_ERROR(GWEN_LOGDOMAIN, "chdir(%s): %s", folder, strerror(errno)); return GWEN_ERROR_IO; } /* get new current working dir */ if (getcwd(dataPwd, sizeof(dataPwd)-1)==NULL) { DBG_ERROR(GWEN_LOGDOMAIN, "getcwd(): %s", strerror(errno)); return GWEN_ERROR_IO; } dataPwd[sizeof(dataPwd)-1]=0; /* change back to previous pwd */ if (chdir(savedPwd)) { DBG_ERROR(GWEN_LOGDOMAIN, "chdir(%s): %s", folder, strerror(errno)); return GWEN_ERROR_IO; } GWEN_Buffer_AppendString(tbuf, dataPwd); return 0; }
int GWEN_Gui_CProgress_Log(GWEN_GUI_CPROGRESS *cp, GWEN_UNUSED GWEN_LOGGER_LEVEL level, const char *text) { assert(cp); assert(text); if (!(GWEN_Gui_GetFlags(cp->gui) & GWEN_GUI_FLAGS_NONINTERACTIVE)) { GWEN_BUFFER *tbuf; const char *t; tbuf=GWEN_Buffer_new(0, 256, 0, 1); GWEN_Gui_GetRawText(cp->gui, text, tbuf); t=GWEN_Buffer_GetStart(tbuf); if (t[GWEN_Buffer_GetUsedBytes(tbuf)-1]!='\n') { GWEN_Buffer_AppendByte(tbuf, '\n'); /* Just in case the buffer has been reallocated */ t=GWEN_Buffer_GetStart(tbuf); } GWEN_Gui_StdPrintf(cp->gui, stderr, "%s", t); GWEN_Buffer_AppendString(cp->logBuf, t); GWEN_Buffer_free(tbuf); tbuf=0; if (cp->aborted) return GWEN_ERROR_USER_ABORTED; } return 0; }
void AB_Value_toHbciString(const AB_VALUE *v, GWEN_BUFFER *buf) { GWEN_BUFFER *tbuf; char *p; int l; tbuf=GWEN_Buffer_new(0, 32, 0, 1); AB_Value_toHumanReadableString2(v, tbuf, 2, 0); /* convert decimal komma */ p=GWEN_Buffer_GetStart(tbuf); while(*p) { if (*p=='.') { *p=','; break; } p++; } /* remove trailing zeroes */ p=GWEN_Buffer_GetStart(tbuf); l=strlen(GWEN_Buffer_GetStart(tbuf)); if (l>0 && strchr(p, ',')!=NULL) { l--; while(l>0 && p[l]=='0') { p[l]=0; l--; } } GWEN_Buffer_AppendString(buf, GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); }
int GWEN_Directory_GetFileEntriesWithType(const char *folder, GWEN_STRINGLIST *sl, const char *mask) { GWEN_DIRECTORY *d; int rv; char buffer[256]; GWEN_BUFFER *pbuf; uint32_t pos; d=GWEN_Directory_new(); rv=GWEN_Directory_Open(d, folder); if (rv<0) { DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv); GWEN_Directory_free(d); return rv; } pbuf=GWEN_Buffer_new(0, 256, 0, 1); GWEN_Buffer_AppendString(pbuf, folder); GWEN_Buffer_AppendString(pbuf, GWEN_DIR_SEPARATOR_S); pos=GWEN_Buffer_GetPos(pbuf); while(0==GWEN_Directory_Read(d, buffer+1, sizeof(buffer)-2)) { if (strcmp(buffer, ".")!=0 && strcmp(buffer, "..")!=0 && (mask==NULL || GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) { struct stat st; GWEN_Buffer_AppendString(pbuf, buffer+1); if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) { if (S_ISREG(st.st_mode)) buffer[0]='f'; else if (S_ISDIR(st.st_mode)) buffer[0]='d'; else buffer[0]='?'; GWEN_StringList_AppendString(sl, buffer, 0, 1); } GWEN_Buffer_Crop(pbuf, 0, pos); } } GWEN_Directory_Close(d); GWEN_Directory_free(d); return 0; }
static void createListBoxString(const AB_BANKINFO *bi, GWEN_BUFFER *tbuf) { const char *s; AB_BANKINFO_SERVICE *sv; uint32_t pos; int svsAdded=0; s=AB_BankInfo_GetBankId(bi); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); s=AB_BankInfo_GetBic(bi); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); s=AB_BankInfo_GetBankName(bi); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); s=AB_BankInfo_GetLocation(bi); if (s && *s) GWEN_Buffer_AppendString(tbuf, s); GWEN_Buffer_AppendString(tbuf, "\t"); pos=GWEN_Buffer_GetPos(tbuf); sv=AB_BankInfoService_List_First(AB_BankInfo_GetServices(bi)); while (sv) { const char *s; s=AB_BankInfoService_GetType(sv); if (s && *s) { const char *p; p=GWEN_Buffer_GetStart(tbuf)+pos; if (strstr(p, s)==NULL) { if (svsAdded) GWEN_Buffer_AppendString(tbuf, ", "); GWEN_Buffer_AppendString(tbuf, s); svsAdded++; } } sv=AB_BankInfoService_List_Next(sv); } }
static void createListBoxString(const OH_INSTITUTE_SPEC *os, GWEN_BUFFER *tbuf) { const char *s; char numbuf[32]; s=OH_InstituteSpec_GetName(os); if (s && *s) { GWEN_Buffer_AppendString(tbuf, s); snprintf(numbuf, sizeof(numbuf)-1, " (%d)", OH_InstituteSpec_GetId(os)); numbuf[sizeof(numbuf)-1]=0; GWEN_Buffer_AppendString(tbuf, numbuf); } else { snprintf(numbuf, sizeof(numbuf)-1, "%d", OH_InstituteSpec_GetId(os)); numbuf[sizeof(numbuf)-1]=0; GWEN_Buffer_AppendString(tbuf, numbuf); } }
int AO_Provider__AddAccountInfoReq(AB_PROVIDER *pro, AB_USER *u, GWEN_BUFFER *buf) { int rv; GWEN_Buffer_AppendString(buf, "<ACCTINFORQ>"); GWEN_Buffer_AppendString(buf, "<DTACCTUP>19691231"); GWEN_Buffer_AppendString(buf, "</ACCTINFORQ>"); /* wrap into request */ rv=AO_Provider__WrapRequest(pro, u, "SIGNUP", "ACCTINFO", buf); if (rv<0) { DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "here (%d)", rv); return rv; } return 0; }
int AB_ImExporterContext_ReadDb(AB_IMEXPORTER_CONTEXT *iec, GWEN_DB_NODE *db) { GWEN_DB_NODE *dbT; int i; dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "accountInfoList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "accountInfo"); while(dbT) { AB_IMEXPORTER_ACCOUNTINFO *iea; iea=AB_ImExporterAccountInfo_fromDb(dbT); assert(iea); AB_ImExporterAccountInfo_List_Add(iea, iec->accountInfoList); dbT=GWEN_DB_FindNextGroup(dbT, "accountInfo"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "securityList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "security"); while(dbT) { AB_SECURITY *sec; sec=AB_Security_fromDb(dbT); assert(sec); AB_Security_List_Add(sec, iec->securityList); dbT=GWEN_DB_FindNextGroup(dbT, "security"); } } dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "messageList"); if (dbT) { dbT=GWEN_DB_FindFirstGroup(dbT, "message"); while(dbT) { AB_MESSAGE *msg; msg=AB_Message_fromDb(dbT); assert(msg); AB_Message_List_Add(msg, iec->messageList); dbT=GWEN_DB_FindNextGroup(dbT, "message"); } } for (i=0; ; i++) { const char *s; s=GWEN_DB_GetCharValue(db, "logs", i, NULL); if (!s) break; GWEN_Buffer_AppendString(iec->logs, s); } return 0; }
int AB_Banking_GetUserDataDir(const AB_BANKING *ab, GWEN_BUFFER *buf){ if (ab->dataDir) { GWEN_Buffer_AppendString(buf, ab->dataDir); return 0; } else { DBG_ERROR(AQBANKING_LOGDOMAIN, "No data dir (not init?)"); return GWEN_ERROR_GENERIC; } }
int EBC_Provider_GenerateTimeStamp(GWEN_UNUSED AB_PROVIDER *pro, AB_USER *u, GWEN_BUFFER *buf) { char timestamp[40]; time_t ti; struct tm *t; ti=time(0); /* if (EBC_User_GetFlags(u) & EBC_USER_FLAGS_TIMESTAMP_FIX1) { */ t=gmtime(&ti); snprintf(timestamp, sizeof(timestamp)-1, "%04d-%02d-%02dT%02d:%02d:%02d.000Z", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); timestamp[sizeof(timestamp)-1]=0; DBG_DEBUG(AQEBICS_LOGDOMAIN, "Generated timestamp [%s]", timestamp); GWEN_Buffer_AppendString(buf, timestamp); /* } else { int thzone; t=localtime(&ti); thzone=-timezone/60; if (t->tm_isdst>0) thzone+=60; snprintf(timestamp, sizeof(timestamp)-1, "%04d-%02d-%02dT%02d:%02d:%02d.000%+03d:%02d", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, (int)(thzone/60), abs(thzone%60)); timestamp[sizeof(timestamp)-1]=0; DBG_DEBUG(AQEBICS_LOGDOMAIN, "Generated timestamp [%s] (tz=%d, daylight=%d)", timestamp, (int)timezone, t->tm_isdst); GWEN_Buffer_AppendString(buf, timestamp); } */ return 0; }
int AO_Provider__WrapMessage(AB_PROVIDER *pro, AB_USER *u, GWEN_BUFFER *buf) { GWEN_BUFFER *tbuf; int rv; tbuf=GWEN_Buffer_new(0, 1024, 0, 1); /* add headers and "<OFX>" */ rv=AO_Provider__AddHeaders(pro, u, tbuf); if (rv<0) { DBG_ERROR(AQOFXCONNECT_LOGDOMAIN, "Error adding headers (%d)", rv); GWEN_Buffer_free(tbuf); return rv; } GWEN_Buffer_AppendString(tbuf, "<OFX>"); rv=AO_Provider__AddSignOn(pro, u, tbuf); if (rv<0) { DBG_ERROR(AQOFXCONNECT_LOGDOMAIN, "Error adding signon element (%d)", rv); GWEN_Buffer_free(tbuf); return rv; } /* append end of OFX element to original buffer */ GWEN_Buffer_AppendString(buf, "</OFX>"); /* go to start of buffer and insert leading elements there */ GWEN_Buffer_SetPos(buf, 0); GWEN_Buffer_InsertBuffer(buf, tbuf); /* point to end of buffer */ GWEN_Buffer_SetPos(buf, GWEN_Buffer_GetUsedBytes(buf)); /* cleanup */ GWEN_Buffer_free(tbuf); return 0; }
GWEN_DB_NODE *AH_User_GetUpdForAccountIdAndSuffix(const AB_USER *u, const char *sAccountNumber, const char *sAccountSuffix) { AH_USER *ue; GWEN_DB_NODE *db; GWEN_BUFFER *tbuf; assert(u); ue=GWEN_INHERIT_GETDATA(AB_USER, AH_USER, u); assert(ue); db=AH_User_GetUpd(u); if (db==NULL) { DBG_INFO(AQHBCI_LOGDOMAIN, "No upd"); return NULL; } tbuf=GWEN_Buffer_new(0, 64, 0, 1); GWEN_Buffer_AppendString(tbuf, sAccountNumber); GWEN_Buffer_AppendString(tbuf, "-"); /* take into account the "Unterkontomerkmal", don't rely solely on account id */ if (sAccountSuffix && *sAccountSuffix) GWEN_Buffer_AppendString(tbuf, sAccountSuffix); else GWEN_Buffer_AppendString(tbuf, "none"); DBG_INFO(AQHBCI_LOGDOMAIN, "Checking upd for account \"%s\"", GWEN_Buffer_GetStart(tbuf)); db=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); if (db==NULL) { DBG_INFO(AQHBCI_LOGDOMAIN, "Falling back to old storage of UPD for account \"%s\"", sAccountNumber); db=AH_User_GetUpd(u); db=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, sAccountNumber); } return db; }
int GWEN_FSLock__UnifyLockFileName(GWEN_BUFFER *nbuf) { char buffer[256]; GWEN_Buffer_AppendString(nbuf, "."); buffer[0]=0; if (gethostname(buffer, sizeof(buffer)-1)) { DBG_ERROR(GWEN_LOGDOMAIN, "gethostname: %s", strerror(errno)); return -1; } buffer[sizeof(buffer)-1]=0; GWEN_Buffer_AppendString(nbuf, buffer); GWEN_Buffer_AppendString(nbuf, "-"); buffer[0]=0; snprintf(buffer, sizeof(buffer)-1, "%i", getpid()); buffer[sizeof(buffer)-1]=0; GWEN_Buffer_AppendString(nbuf, buffer); return 0; }