1 /***************************************************************************
2  begin       : Sat Sep 27 2008
3  copyright   : (C) 2018 by Martin Preuss
4  email       : martin@libchipcard.de
5 
6  ***************************************************************************
7  * This file is part of the project "AqBanking".                           *
8  * Please see toplevel file COPYING of that project for license details.   *
9  ***************************************************************************/
10 
11 
12 
AB_Banking__GetConfigManager(AB_BANKING * ab,const char * dname)13 int AB_Banking__GetConfigManager(AB_BANKING *ab, const char *dname)
14 {
15   GWEN_BUFFER *buf;
16   char home[256];
17 
18   if (GWEN_Directory_GetHomeDirectory(home, sizeof(home))) {
19     DBG_ERROR(AQBANKING_LOGDOMAIN,
20               "Could not determine home directory, aborting.");
21     abort();
22   }
23 
24   buf=GWEN_Buffer_new(0, 256, 0, 1);
25 
26   if (dname) {
27     /* setup data dir */
28     ab->dataDir=strdup(dname);
29 
30     /* determine config manager URL */
31     GWEN_Buffer_AppendString(buf, "dir://");
32     GWEN_Buffer_AppendString(buf, dname);
33     GWEN_Buffer_AppendString(buf, DIRSEP);
34     GWEN_Buffer_AppendString(buf, AB_BANKING_SETTINGS_DIR);
35   }
36   else {
37     const char *s;
38     uint32_t pos;
39 
40 
41     GWEN_Buffer_AppendString(buf, "dir://");
42     pos=GWEN_Buffer_GetPos(buf);
43 
44     /* determine config directory */
45     s=getenv("AQBANKING_HOME");
46     if (s && !*s)
47       s=0;
48     if (s)
49       GWEN_Buffer_AppendString(buf, s);
50     else {
51       /* use default */
52       GWEN_Buffer_AppendString(buf, home);
53       GWEN_Buffer_AppendString(buf, DIRSEP);
54       GWEN_Buffer_AppendString(buf, AB_BANKING_USERDATADIR);
55     }
56 
57     /* as we are at it: store default data dir */
58     ab->dataDir=strdup(GWEN_Buffer_GetStart(buf)+pos);
59 
60     /* continue with settings folder */
61     GWEN_Buffer_AppendString(buf, DIRSEP);
62     GWEN_Buffer_AppendString(buf, AB_BANKING_SETTINGS_DIR);
63 
64   }
65 
66   DBG_INFO(AQBANKING_LOGDOMAIN,
67            "Using data folder [%s]",
68            ab->dataDir);
69   DBG_INFO(AQBANKING_LOGDOMAIN,
70            "Using ConfigManager [%s]",
71            GWEN_Buffer_GetStart(buf));
72 
73   ab->configMgr=GWEN_ConfigMgr_Factory(GWEN_Buffer_GetStart(buf));
74   if (ab->configMgr==NULL) {
75     DBG_ERROR(AQBANKING_LOGDOMAIN,
76               "Could not create ConfigMgr[%s]. "
77               "Maybe the gwenhywfar plugins are not installed?",
78               GWEN_Buffer_GetStart(buf));
79     GWEN_Buffer_free(buf);
80     return GWEN_ERROR_GENERIC;
81   }
82 
83   /* done */
84   GWEN_Buffer_free(buf);
85   return 0;
86 }
87 
88 
89 
AB_Banking_LoadSharedConfig(AB_BANKING * ab,const char * name,GWEN_DB_NODE ** pDb)90 int AB_Banking_LoadSharedConfig(AB_BANKING *ab, const char *name, GWEN_DB_NODE **pDb)
91 {
92   assert(ab);
93   assert(name);
94   if (name) {
95     int rv;
96 
97     rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, AB_CFG_GROUP_SHARED, name, pDb);
98     if (rv<0) {
99       DBG_ERROR(AQBANKING_LOGDOMAIN,
100                 "Could not load shared group [%s] (%d)",
101                 name, rv);
102       return rv;
103     }
104     return 0;
105   }
106   else {
107     DBG_INFO(AQBANKING_LOGDOMAIN, "Name of shared group missing");
108     return GWEN_ERROR_GENERIC;
109   }
110 }
111 
112 
113 
AB_Banking_SaveSharedConfig(AB_BANKING * ab,const char * name,GWEN_DB_NODE * db)114 int AB_Banking_SaveSharedConfig(AB_BANKING *ab, const char *name, GWEN_DB_NODE *db)
115 {
116   assert(ab);
117   assert(name);
118   if (name) {
119     int rv;
120 
121     rv=GWEN_ConfigMgr_SetGroup(ab->configMgr, AB_CFG_GROUP_SHARED, name, db);
122     if (rv<0) {
123       DBG_ERROR(AQBANKING_LOGDOMAIN,
124                 "Could not save shared group [%s] (%d)",
125                 name, rv);
126       return rv;
127     }
128     return 0;
129   }
130   else {
131     DBG_INFO(AQBANKING_LOGDOMAIN, "Name of shared group missing");
132     return GWEN_ERROR_GENERIC;
133   }
134 }
135 
136 
137 
AB_Banking_LockSharedConfig(AB_BANKING * ab,const char * name)138 int AB_Banking_LockSharedConfig(AB_BANKING *ab, const char *name)
139 {
140   assert(ab);
141   assert(name);
142   if (name) {
143     int rv;
144 
145     rv=GWEN_ConfigMgr_LockGroup(ab->configMgr, AB_CFG_GROUP_SHARED, name);
146     if (rv<0) {
147       DBG_ERROR(AQBANKING_LOGDOMAIN,
148                 "Could not lock shared group [%s] (%d)",
149                 name, rv);
150       return rv;
151     }
152     return 0;
153   }
154   else {
155     DBG_INFO(AQBANKING_LOGDOMAIN, "Name of shared group missing");
156     return GWEN_ERROR_GENERIC;
157   }
158 }
159 
160 
161 
AB_Banking_UnlockSharedConfig(AB_BANKING * ab,const char * name)162 int AB_Banking_UnlockSharedConfig(AB_BANKING *ab, const char *name)
163 {
164   assert(ab);
165   assert(name);
166   if (name) {
167     int rv;
168 
169     rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr, AB_CFG_GROUP_SHARED, name);
170     if (rv<0) {
171       DBG_ERROR(AQBANKING_LOGDOMAIN,
172                 "Could not unlock shared group [%s] (%d)",
173                 name, rv);
174       return rv;
175     }
176     return 0;
177   }
178   else {
179     DBG_INFO(AQBANKING_LOGDOMAIN, "Name of shared group missing");
180     return GWEN_ERROR_GENERIC;
181   }
182 }
183 
184 
185 
AB_Banking_GetUserDataDir(const AB_BANKING * ab,GWEN_BUFFER * buf)186 int AB_Banking_GetUserDataDir(const AB_BANKING *ab, GWEN_BUFFER *buf)
187 {
188   if (ab->dataDir) {
189     GWEN_Buffer_AppendString(buf, ab->dataDir);
190     return 0;
191   }
192   else {
193     DBG_ERROR(AQBANKING_LOGDOMAIN, "No data dir (not init?)");
194     return GWEN_ERROR_GENERIC;
195   }
196 }
197 
198 
199 
AB_Banking_GetSharedDataDir(const AB_BANKING * ab,const char * name,GWEN_BUFFER * buf)200 int AB_Banking_GetSharedDataDir(const AB_BANKING *ab,
201                                 const char *name,
202                                 GWEN_BUFFER *buf)
203 {
204   assert(ab);
205   if (ab->dataDir) {
206     GWEN_Buffer_AppendString(buf, ab->dataDir);
207     GWEN_Buffer_AppendString(buf, DIRSEP "shared" DIRSEP);
208     if (GWEN_Text_EscapeToBufferTolerant(name, buf)) {
209       DBG_ERROR(AQBANKING_LOGDOMAIN,
210                 "Bad share name, aborting.");
211       abort();
212     }
213     else {
214       char *s;
215 
216       s=GWEN_Buffer_GetStart(buf);
217       while (*s) {
218         *s=tolower(*s);
219         s++;
220       }
221     }
222     return 0;
223   }
224   else {
225     DBG_ERROR(AQBANKING_LOGDOMAIN, "No data dir (not init?)");
226     return GWEN_ERROR_GENERIC;
227   }
228 }
229 
230 
231 
AB_Banking_GetAppUserDataDir(const AB_BANKING * ab,GWEN_BUFFER * buf)232 int AB_Banking_GetAppUserDataDir(const AB_BANKING *ab, GWEN_BUFFER *buf)
233 {
234   int rv;
235 
236   assert(ab->appEscName);
237   rv=AB_Banking_GetUserDataDir(ab, buf);
238   if (rv<0) {
239     DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
240     return rv;
241   }
242   GWEN_Buffer_AppendString(buf, DIRSEP "apps" DIRSEP);
243   GWEN_Buffer_AppendString(buf, ab->appEscName);
244   GWEN_Buffer_AppendString(buf, DIRSEP "data");
245 
246   return 0;
247 }
248 
249 
250 
AB_Banking_GetProviderUserDataDir(const AB_BANKING * ab,const char * name,GWEN_BUFFER * buf)251 int AB_Banking_GetProviderUserDataDir(const AB_BANKING *ab,
252                                       const char *name,
253                                       GWEN_BUFFER *buf)
254 {
255   int rv;
256 
257   rv=AB_Banking_GetUserDataDir(ab, buf);
258   if (rv)
259     return rv;
260   GWEN_Buffer_AppendString(buf, DIRSEP "backends" DIRSEP);
261   GWEN_Buffer_AppendString(buf, name);
262   GWEN_Buffer_AppendString(buf, DIRSEP "data");
263   return 0;
264 }
265 
266 
267 
AB_Banking_GetGlobalDataDirs(void)268 GWEN_STRINGLIST *AB_Banking_GetGlobalDataDirs(void)
269 {
270   GWEN_STRINGLIST *sl;
271 
272   sl=GWEN_PathManager_GetPaths(AB_PM_LIBNAME, AB_PM_DATADIR);
273   return sl;
274 }
275 
276 
277 
AB_Banking_GetGlobalSysconfDirs(void)278 GWEN_STRINGLIST *AB_Banking_GetGlobalSysconfDirs(void)
279 {
280   GWEN_STRINGLIST *sl;
281 
282   sl=GWEN_PathManager_GetPaths(AB_PM_LIBNAME, AB_PM_SYSCONFDIR);
283   return sl;
284 }
285 
286 
287 
AB_Banking_ReadNamedConfigGroup(const AB_BANKING * ab,const char * groupName,const char * subGroupName,int doLock,int doUnlock,GWEN_DB_NODE ** pDb)288 int AB_Banking_ReadNamedConfigGroup(const AB_BANKING *ab,
289                                     const char *groupName,
290                                     const char *subGroupName,
291                                     int doLock,
292                                     int doUnlock,
293                                     GWEN_DB_NODE **pDb)
294 {
295   GWEN_DB_NODE *db=NULL;
296   int rv;
297 
298   assert(ab);
299 
300   /* check for config manager (created by AB_Banking_Init) */
301   if (ab->configMgr==NULL) {
302     DBG_ERROR(AQBANKING_LOGDOMAIN,
303               "No config manager (maybe the gwenhywfar plugins are not installed?");
304     return GWEN_ERROR_GENERIC;
305   }
306 
307 
308   /* lock group if requested */
309   if (doLock) {
310     rv=GWEN_ConfigMgr_LockGroup(ab->configMgr, groupName, subGroupName);
311     if (rv<0) {
312       DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to lock config group (%d)", rv);
313       return rv;
314     }
315   }
316 
317   /* load group */
318   rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, groupName, subGroupName, &db);
319   if (rv<0) {
320     DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not load config group (%d)", rv);
321     if (doLock)
322       GWEN_ConfigMgr_UnlockGroup(ab->configMgr, groupName, subGroupName);
323     return rv;
324   }
325 
326   /* unlock group */
327   if (doUnlock) {
328     rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr, groupName, subGroupName);
329     if (rv<0) {
330       DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to unlock config group (%d)", rv);
331       GWEN_DB_Group_free(db);
332       return rv;
333     }
334   }
335 
336   *pDb=db;
337   return 0;
338 }
339 
340 
341 
AB_Banking_WriteNamedConfigGroup(AB_BANKING * ab,const char * groupName,const char * subGroupName,int doLock,int doUnlock,GWEN_DB_NODE * db)342 int AB_Banking_WriteNamedConfigGroup(AB_BANKING *ab,
343                                      const char *groupName,
344                                      const char *subGroupName,
345                                      int doLock,
346                                      int doUnlock,
347                                      GWEN_DB_NODE *db)
348 {
349   int rv;
350 
351   assert(ab);
352   assert(db);
353 
354   /* check for config manager (created by AB_Banking_Init) */
355   if (ab->configMgr==NULL) {
356     DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?");
357     return GWEN_ERROR_GENERIC;
358   }
359 
360 
361   /* lock group */
362   if (doLock) {
363     rv=GWEN_ConfigMgr_LockGroup(ab->configMgr, groupName, subGroupName);
364     if (rv<0) {
365       DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to lock config group (%d)", rv);
366       return rv;
367     }
368   }
369 
370   /* store group (is locked now) */
371   rv=GWEN_ConfigMgr_SetGroup(ab->configMgr, groupName, subGroupName, db);
372   if (rv<0) {
373     DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not load config group (%d)", rv);
374     if (doLock)
375       GWEN_ConfigMgr_UnlockGroup(ab->configMgr, groupName, subGroupName);
376     return rv;
377   }
378 
379   /* unlock group */
380   if (doUnlock) {
381     rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr, groupName, subGroupName);
382     if (rv<0) {
383       DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to unlock config group (%d)", rv);
384       return rv;
385     }
386   }
387 
388   return 0;
389 }
390 
391 
392 
AB_Banking_ReadConfigGroup(const AB_BANKING * ab,const char * groupName,uint32_t uniqueId,int doLock,int doUnlock,GWEN_DB_NODE ** pDb)393 int AB_Banking_ReadConfigGroup(const AB_BANKING *ab,
394                                const char *groupName,
395                                uint32_t uniqueId,
396                                int doLock,
397                                int doUnlock,
398                                GWEN_DB_NODE **pDb)
399 {
400   int rv;
401   char idBuf[256];
402 
403   assert(ab);
404 
405   /* check for config manager (created by AB_Banking_Init) */
406   if (ab->configMgr==NULL) {
407     DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?");
408     return GWEN_ERROR_GENERIC;
409   }
410 
411 
412   /* make config manager id from given unique id */
413   rv=GWEN_ConfigMgr_MkUniqueIdFromId(ab->configMgr, groupName, uniqueId, 0, idBuf, sizeof(idBuf)-1);
414   if (rv<0) {
415     DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to create a unique id for config group (%d)", rv);
416     return rv;
417   }
418   idBuf[sizeof(idBuf)-1]=0;
419 
420   rv=AB_Banking_ReadNamedConfigGroup(ab, groupName, idBuf, doLock, doUnlock, pDb);
421   if (rv<0) {
422     DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
423     return rv;
424   }
425 
426   return rv;
427 }
428 
429 
430 
AB_Banking_HasConfigGroup(const AB_BANKING * ab,const char * groupName,uint32_t uniqueId)431 int AB_Banking_HasConfigGroup(const AB_BANKING *ab,
432                               const char *groupName,
433                               uint32_t uniqueId)
434 {
435   int rv;
436   char idBuf[256];
437 
438   assert(ab);
439 
440   /* check for config manager (created by AB_Banking_Init) */
441   if (ab->configMgr==NULL) {
442     DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?");
443     return GWEN_ERROR_GENERIC;
444   }
445 
446 
447   /* make config manager id from given unique id */
448   rv=GWEN_ConfigMgr_MkUniqueIdFromId(ab->configMgr, groupName, uniqueId, 0, idBuf, sizeof(idBuf)-1);
449   if (rv<0) {
450     DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to create a unique id for config group (%d)", rv);
451     return rv;
452   }
453   idBuf[sizeof(idBuf)-1]=0;
454 
455   rv=GWEN_ConfigMgr_HasGroup(ab->configMgr, groupName, idBuf);
456   if (rv<0) {
457     DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
458     return rv;
459   }
460 
461   return rv;
462 }
463 
464 
465 
AB_Banking_WriteConfigGroup(AB_BANKING * ab,const char * groupName,uint32_t uniqueId,int doLock,int doUnlock,GWEN_DB_NODE * db)466 int AB_Banking_WriteConfigGroup(AB_BANKING *ab,
467                                 const char *groupName,
468                                 uint32_t uniqueId,
469                                 int doLock,
470                                 int doUnlock,
471                                 GWEN_DB_NODE *db)
472 {
473   int rv;
474   char idBuf[256];
475 
476   assert(ab);
477   assert(db);
478 
479   /* check for config manager (created by AB_Banking_Init) */
480   if (ab->configMgr==NULL) {
481     DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?");
482     return GWEN_ERROR_GENERIC;
483   }
484 
485 
486   /* make config manager id from given unique id */
487   rv=GWEN_ConfigMgr_MkUniqueIdFromId(ab->configMgr, groupName, uniqueId, 0, idBuf, sizeof(idBuf)-1);
488   if (rv<0) {
489     DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to create a unique id for config group (%d)", rv);
490     return rv;
491   }
492   idBuf[sizeof(idBuf)-1]=0;
493 
494   rv=AB_Banking_WriteNamedConfigGroup(ab, groupName, idBuf, doLock, doUnlock, db);
495   if (rv<0) {
496     DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
497     return rv;
498   }
499 
500   return rv;
501 }
502 
503 
504 
AB_Banking_DeleteConfigGroup(AB_BANKING * ab,const char * groupName,uint32_t uniqueId)505 int AB_Banking_DeleteConfigGroup(AB_BANKING *ab, const char *groupName, uint32_t uniqueId)
506 {
507   int rv;
508   char idBuf[256];
509 
510   assert(ab);
511 
512   /* check for config manager (created by AB_Banking_Init) */
513   if (ab->configMgr==NULL) {
514     DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?");
515     return GWEN_ERROR_GENERIC;
516   }
517 
518   /* make config manager id from given unique id */
519   rv=GWEN_ConfigMgr_MkUniqueIdFromId(ab->configMgr, groupName, uniqueId, 0, idBuf, sizeof(idBuf)-1);
520   if (rv<0) {
521     DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to create a unique id for config group (%d)", rv);
522     return rv;
523   }
524   idBuf[sizeof(idBuf)-1]=0;
525 
526   /* unlock group */
527   rv=GWEN_ConfigMgr_DeleteGroup(ab->configMgr, groupName, idBuf);
528   if (rv<0) {
529     DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to delete config group (%d)", rv);
530     return rv;
531   }
532 
533   return 0;
534 }
535 
536 
537 
AB_Banking_UnlockConfigGroup(AB_BANKING * ab,const char * groupName,uint32_t uniqueId)538 int AB_Banking_UnlockConfigGroup(AB_BANKING *ab, const char *groupName, uint32_t uniqueId)
539 {
540   int rv;
541   char idBuf[256];
542 
543   assert(ab);
544 
545   /* check for config manager (created by AB_Banking_Init) */
546   if (ab->configMgr==NULL) {
547     DBG_ERROR(AQBANKING_LOGDOMAIN, "No config manager (maybe the gwenhywfar plugins are not installed?");
548     return GWEN_ERROR_GENERIC;
549   }
550 
551   /* make config manager id from given unique id */
552   rv=GWEN_ConfigMgr_MkUniqueIdFromId(ab->configMgr, groupName, uniqueId, 0, idBuf, sizeof(idBuf)-1);
553   if (rv<0) {
554     DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to create a unique id for config group (%d)", rv);
555     return rv;
556   }
557   idBuf[sizeof(idBuf)-1]=0;
558 
559   /* unlock group */
560   rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr, groupName, idBuf);
561   if (rv<0) {
562     DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to unlock config group (%d)", rv);
563     return rv;
564   }
565 
566   return 0;
567 }
568 
569 
570 
AB_Banking_ReadConfigGroups(const AB_BANKING * ab,const char * groupName,const char * uidField,const char * matchVar,const char * matchVal,GWEN_DB_NODE ** pDb)571 int AB_Banking_ReadConfigGroups(const AB_BANKING *ab,
572                                 const char *groupName,
573                                 const char *uidField,
574                                 const char *matchVar,
575                                 const char *matchVal,
576                                 GWEN_DB_NODE **pDb)
577 {
578   GWEN_STRINGLIST *sl;
579   int rv;
580 
581   sl=GWEN_StringList_new();
582   rv=GWEN_ConfigMgr_ListSubGroups(ab->configMgr, groupName, sl);
583   if (rv<0) {
584     DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
585     GWEN_StringList_free(sl);
586     return rv;
587   }
588   if (GWEN_StringList_Count(sl)) {
589     GWEN_DB_NODE *dbAll;
590     GWEN_STRINGLISTENTRY *se;
591     int ignoredGroups=0;
592 
593     dbAll=GWEN_DB_Group_new("all");
594 
595     se=GWEN_StringList_FirstEntry(sl);
596     while (se) {
597       const char *t;
598       GWEN_DB_NODE *db=NULL;
599 
600       t=GWEN_StringListEntry_Data(se);
601       assert(t);
602 
603       /* lock before reading */
604       rv=GWEN_ConfigMgr_LockGroup(ab->configMgr, groupName, t);
605       if (rv<0) {
606         DBG_ERROR(AQBANKING_LOGDOMAIN, "Unable to lock config group \"%s\" (%d), ignoring", t, rv);
607         ignoredGroups++;
608       }
609       else {
610         rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, groupName, t, &db);
611         if (rv<0) {
612           DBG_WARN(AQBANKING_LOGDOMAIN, "Could not load group [%s] (%d), ignoring", t, rv);
613           GWEN_ConfigMgr_UnlockGroup(ab->configMgr, groupName, t);
614           ignoredGroups++;
615         }
616         else {
617           int doAdd=1;
618 
619           /* unlock after reading */
620           rv=GWEN_ConfigMgr_UnlockGroup(ab->configMgr, groupName, t);
621           if (rv<0) {
622             DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not unlock group [%s] (%d)", t, rv);
623           }
624 
625           assert(db);
626           GWEN_DB_GroupRename(db, t);
627           if (doAdd && uidField && *uidField) {
628             int v;
629 
630             v=GWEN_DB_GetIntValue(db, uidField, 0, 0);
631             if (v==0)
632               doAdd=0;
633           }
634 
635           if (doAdd && matchVar && *matchVar) {
636             const char *s;
637 
638             s=GWEN_DB_GetCharValue(db, matchVar, 0, NULL);
639             if (s && *s) {
640               if (strcasecmp(s, matchVal)!=0)
641                 doAdd=0;
642             }
643             else {
644               if (matchVal && *matchVal)
645                 doAdd=0;
646             }
647           }
648 
649           if (doAdd)
650             GWEN_DB_AddGroup(dbAll, db);
651           else
652             GWEN_DB_Group_free(db);
653         } /* if getGroup ok */
654       } /* if locking ok */
655       se=GWEN_StringListEntry_Next(se);
656     } /* while se */
657 
658     if (GWEN_DB_Groups_Count(dbAll)) {
659       *pDb=dbAll;
660       if (ignoredGroups) {
661         GWEN_StringList_free(sl);
662         return GWEN_ERROR_PARTIAL;
663       }
664       GWEN_StringList_free(sl);
665       return 0;
666     }
667     else {
668       DBG_WARN(AQBANKING_LOGDOMAIN, "No matching config groups found");
669       GWEN_DB_Group_free(dbAll);
670       GWEN_StringList_free(sl);
671       return GWEN_ERROR_NOT_FOUND;
672     }
673   }
674   GWEN_StringList_free(sl);
675 
676   DBG_INFO(AQBANKING_LOGDOMAIN, "No account specs found");
677   return GWEN_ERROR_NOT_FOUND;
678 }
679 
680 
681 
682 
683 
684