gwenhywfar  5.10.1
xmlcmd_gxml_todb.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Sat Apr 18 2018
3  copyright : (C) 2020 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * Lesser General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU Lesser General Public *
19  * License along with this library; if not, write to the Free Software *
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21  * MA 02111-1307 USA *
22  * *
23  ***************************************************************************/
24 
25 
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
30 
31 
32 #include "xmlcmd_gxml_todb.h"
33 #include "xmlcmd_gxml.h"
34 
35 #include <gwenhywfar/debug.h>
36 #include <gwenhywfar/text.h>
37 #include <gwenhywfar/gwendate.h>
38 
39 
40 #include <ctype.h>
41 
42 
43 
44 
45 /* ------------------------------------------------------------------------------------------------
46  * forward declarations
47  * ------------------------------------------------------------------------------------------------
48  */
49 
50 static int _handleChildren_toDb(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode);
51 
52 static const char *_getCharValueByPath(GWEN_XMLNODE *xmlNode, const char *path, const char *defValue);
53 static int _convertAndSetCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode, GWEN_DB_NODE *dbCurrent,
54  const char *value);
55 
56 static int _handleDbSetCharValue_internal(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode, GWEN_DB_NODE *dbCurrent);
57 
58 
59 static int _handleXmlEnter(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode);
60 static int _handleXmlForEvery(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode);
63 static int _handleDbSetCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode);
67 static int _handleXmlIfHasCharData(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode);
69 static int _handleXmlIfPathExists(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode);
71 
72 
73 
74 
75 
76 /* ------------------------------------------------------------------------------------------------
77  * implementations
78  * ------------------------------------------------------------------------------------------------
79  */
80 
81 
82 
84  GWEN_DB_NODE *dbDestination)
85 {
86  GWEN_XMLCOMMANDER *cmd;
87 
88  cmd=GWEN_XmlCommanderGwenXml_new(xmlNodeDocument, dbDestination);
90 
91  return cmd;
92 }
93 
94 
95 
97 {
98  GWEN_XMLNODE *n;
99 
100  n=GWEN_XMLNode_GetFirstTag(xmlNode);
101  while (n) {
102  const char *name;
103 
104  name=GWEN_XMLNode_GetData(n);
105  if (name && *name) {
106  int rv;
107 
108  DBG_INFO(GWEN_LOGDOMAIN, "Handling element \"%s\"", name);
109  if (strcasecmp(name, "XmlEnter")==0)
110  rv=_handleXmlEnter(cmd, n);
111  else if (strcasecmp(name, "XmlForEvery")==0)
112  rv=_handleXmlForEvery(cmd, n);
113  else if (strcasecmp(name, "DbCreateAndEnterGroup")==0)
114  rv=_handleDbCreateAndEnterGroup(cmd, n);
115  else if (strcasecmp(name, "DbCreateAndEnterTempGroup")==0)
117  else if (strcasecmp(name, "DbSetCharValue")==0)
118  rv=_handleDbSetCharValue(cmd, n);
119  else if (strcasecmp(name, "DbSetTempCharValue")==0)
120  rv=_handleDbSetTempCharValue(cmd, n);
121  else if (strcasecmp(name, "XmlIfCharDataMatches")==0)
122  rv=_handleXmlIfCharDataMatches(cmd, n);
123  else if (strcasecmp(name, "XmlIfNotCharDataMatches")==0)
125  else if (strcasecmp(name, "XmlIfHasCharData")==0)
126  rv=_handleXmlIfHasCharData(cmd, n);
127  else if (strcasecmp(name, "XmlIfNotHasCharData")==0)
128  rv=_handleXmlIfNotHasCharData(cmd, n);
129  else if (strcasecmp(name, "XmlIfPathExists")==0)
130  rv=_handleXmlIfPathExists(cmd, n);
131  else if (strcasecmp(name, "XmlIfNotPathExists")==0)
132  rv=_handleXmlIfNotPathExists(cmd, n);
133  else {
134  DBG_ERROR(GWEN_LOGDOMAIN, "Unknown element \"%s\", aborting", name);
135  return GWEN_ERROR_INVALID;
136  }
137  if (rv<0) {
138  DBG_ERROR(GWEN_LOGDOMAIN, "Error in element \"%s\", aborting", name);
139  return rv;
140  }
141  }
142 
144  }
145 
146  return 0;
147 }
148 
149 
150 
151 
152 const char *_getCharValueByPath(GWEN_XMLNODE *xmlNode, const char *path, const char *defValue)
153 {
154  const char *s;
155 
156  s=strchr(path, '@');
157  if (s) {
158  int idx;
159  char *cpyOfPath;
160  char *property;
161  GWEN_XMLNODE *n;
162 
163 
164  idx=s-path;
165  cpyOfPath=strdup(path);
166  assert(cpyOfPath);
167  cpyOfPath[idx]=0;
168  property=cpyOfPath+idx+1;
169 
170  if (*cpyOfPath) {
172  }
173  else
174  n=xmlNode;
175 
176  if (n) {
177  const char *result;
178 
179  result=GWEN_XMLNode_GetProperty(n, property, defValue);
180  DBG_INFO(GWEN_LOGDOMAIN, "Got XML property: %s = %s (%s)", property, result, path);
181  free(cpyOfPath);
182  return result;
183  }
184  free(cpyOfPath);
185  return defValue;
186  }
187  else
188  return GWEN_XMLNode_GetCharValueByPath(xmlNode, path, defValue);
189 }
190 
191 
192 /* TODO: optimize later */
194  GWEN_DB_NODE *dbCurrent,
195  const char *value)
196 {
197  if (value && *value) {
198  const char *name;
199  const char *typ;
200  const char *mode;
201  int doTrim=0;
202  GWEN_BUFFER *vbuf;
203  GWEN_BUFFER *resultBuf;
204 
205  doTrim=GWEN_XMLNode_GetIntProperty(xmlNode, "trim", 0);
206  vbuf=GWEN_Buffer_new(0, 256, 0, 1);
207  resultBuf=GWEN_Buffer_new(0, 256, 0, 1);
208 
209  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
210  if (!(name && *name)) {
211  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"SetCharValue\"");
212  GWEN_Buffer_free(resultBuf);
213  GWEN_Buffer_free(vbuf);
214  return GWEN_ERROR_INVALID;
215  }
216 
217  typ=GWEN_XMLNode_GetProperty(xmlNode, "type", "string");
218  if (!(typ && *typ)) {
219  DBG_ERROR(GWEN_LOGDOMAIN, "Empty type in \"SetCharValue\"");
220  GWEN_Buffer_free(resultBuf);
221  GWEN_Buffer_free(vbuf);
222  return GWEN_ERROR_INVALID;
223  }
224 
225  mode=GWEN_XMLNode_GetProperty(xmlNode, "mode", "add");
226 
227  if (strcasecmp(typ, "string")==0) {
228  GWEN_Buffer_AppendString(vbuf, value);
229  if (doTrim)
231  }
232  else if (strcasecmp(typ, "date")==0) {
233  const char *tmpl;
234  GWEN_DATE *dt=NULL;
235 
236  tmpl=GWEN_XMLNode_GetProperty(xmlNode, "template", "YYYYMMDD");
237  if (!(tmpl && *tmpl)) {
238  DBG_ERROR(GWEN_LOGDOMAIN, "Empty date template in \"SetCharValue\"");
239  GWEN_Buffer_free(resultBuf);
240  GWEN_Buffer_free(vbuf);
241  return GWEN_ERROR_INVALID;
242  }
243 
244  dt=GWEN_Date_fromStringWithTemplate(value, tmpl);
245  if (dt) {
247  GWEN_Date_free(dt);
248  }
249  }
250  else if (strcasecmp(typ, "time")==0) {
251  const char *tmpl;
252  GWEN_TIME *ti=NULL;
253 
254  tmpl=GWEN_XMLNode_GetProperty(xmlNode, "template", "YYYYMMDDhhmmss");
255  if (!(tmpl && *tmpl)) {
256  DBG_ERROR(GWEN_LOGDOMAIN, "Empty time template in \"SetCharValue\"");
257  GWEN_Buffer_free(resultBuf);
258  GWEN_Buffer_free(vbuf);
259  return GWEN_ERROR_INVALID;
260  }
261 
262  ti=GWEN_Time_fromString(value, tmpl);
263  if (ti) {
264  GWEN_Time_toString(ti, "YYYYMMDDhhmmss", vbuf);
265  GWEN_Time_free(ti);
266  }
267  else {
268  DBG_INFO(GWEN_LOGDOMAIN, "Invalid timespec \"%s\" according to template \"%s\"",
269  value?value:"<empty>", tmpl);
270  return GWEN_ERROR_INVALID;
271  }
272  }
273 
274  if (strcasecmp(mode, "add")==0) {
275  /* just exchange the buffer */
276  GWEN_Buffer_free(resultBuf);
277  resultBuf=vbuf;
278  vbuf=NULL;
279  }
280  else if (strcasecmp(mode, "append")==0) {
281  const char *s;
282 
283  s=GWEN_DB_GetCharValue(dbCurrent, name, 0, NULL);
284  if (s && *s) {
285  const char *delimiter;
286 
287  /* write previous data into resultBuffer */
288  GWEN_Buffer_AppendString(resultBuf, s);
289 
290  /* possibly write delimiter into resultBuffer */
291  delimiter=GWEN_XMLNode_GetProperty(xmlNode, "delimiter", NULL);
292  if (delimiter && *delimiter) {
293  if (strcasecmp(delimiter, "\\n")==0)
294  GWEN_Buffer_AppendByte(resultBuf, '\n');
295  else if (strcasecmp(delimiter, "\\t")==0)
296  GWEN_Buffer_AppendByte(resultBuf, '\t');
297  else
298  GWEN_Buffer_AppendString(resultBuf, delimiter);
299  }
300  } /* if previous value */
301  /* write value into resultBuffer */
303 
304  GWEN_DB_DeleteVar(dbCurrent, name);
305  }
306  else if (strcasecmp(mode, "replace")==0) {
307  /* just exchange the buffer */
308  GWEN_Buffer_free(resultBuf);
309  resultBuf=vbuf;
310  vbuf=NULL;
311  GWEN_DB_DeleteVar(dbCurrent, name);
312  }
313 
314  DBG_INFO(GWEN_LOGDOMAIN, "Setting value: %s = %s", name, GWEN_Buffer_GetStart(resultBuf));
315 
317  GWEN_Buffer_free(resultBuf);
318  GWEN_Buffer_free(vbuf);
319  }
320  return 0;
321 }
322 
323 
324 
325 
326 
327 
328 
330 {
331  const char *path;
332  GWEN_XMLNODE *n;
333  int rv;
334 
335  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
336  if (path==NULL) {
337  DBG_ERROR(GWEN_LOGDOMAIN, "Missing path in \"EnterPath\"");
338  return GWEN_ERROR_INVALID;
339  }
340 
342  if (n==NULL) {
343  DBG_ERROR(GWEN_LOGDOMAIN, "XmlEnter: Path \"%s\" does not exist", path);
344  return GWEN_ERROR_INVALID;
345  }
346 
347  /* enter given document node */
349 
350  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
351  if (rv<0) {
352  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
353  return rv;
354  }
355 
356  /* leave given document node, re-select previously active one, thus restoring status from the beginning */
358  return 0;
359 }
360 
361 
362 
364 {
365  const char *path;
366  GWEN_XMLNODE *n;
367  int rv;
368 
369  path=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
370  if (path==NULL) {
371  DBG_ERROR(GWEN_LOGDOMAIN, "Missing name in \"ForEvery\"");
372  return GWEN_ERROR_INVALID;
373  }
374 
376  if (n==NULL) {
377  DBG_INFO(GWEN_LOGDOMAIN, "XmlForEvery: Path \"%s\" not found, not entering", path);
378  /* GWEN_XMLNode_Dump(cmd->currentDocNode, 2); */
379  }
380  while (n) {
381  DBG_INFO(GWEN_LOGDOMAIN, "XmlForEvery: Entering path \"%s\"", path);
382 
383  /* enter given document node */
385 
386  /* handle all children of this parser XML node with the current document node */
387  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
388 
389  /* leave given document node, re-select previously active one, thus restoring status from the beginning */
391 
392  if (rv<0) {
393  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
394  return rv;
395  }
396 
397  n=GWEN_XMLNode_FindNextTag(n, path, NULL, NULL);
398  }
399 
400  return 0;
401 }
402 
403 
404 
406 {
407  const char *name;
408  GWEN_DB_NODE *dbLast;
409  int rv;
410 
411  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
412  if (!(name && *name)) {
413  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"CreateAnEnterDbGroup\"");
414  return GWEN_ERROR_INVALID;
415  }
416 
417  /* push group */
419 
420  /* create group */
422 
423  /* handle children (nothing special here) */
424  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
425 
426  /* pop group */
428 
429  if (rv<0) {
430  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
431  return rv;
432  }
433 
434  return 0;
435 }
436 
437 
438 
440 {
441  const char *name;
442  GWEN_DB_NODE *dbLast;
443  GWEN_DB_NODE *dbCurrent;
444  int rv;
445 
446  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
447  if (!(name && *name)) {
448  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"CreateAnEnterTempDbGroup\"");
449  return GWEN_ERROR_INVALID;
450  }
451 
452  /* push group */
454 
455  /* create group */
456  dbCurrent=GWEN_DB_GetGroup(dbLast, GWEN_PATH_FLAGS_CREATE_GROUP, name);
458 
459  /* handle children (nothing special here) */
460  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
461 
462  /* delete temp group */
463  GWEN_DB_UnlinkGroup(dbCurrent);
464  GWEN_DB_Group_free(dbCurrent);
465 
466  /* pop group */
468 
469  if (rv<0) {
470  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
471  return rv;
472  }
473 
474  return 0;
475 }
476 
477 
478 
480  GWEN_DB_NODE *dbCurrent)
481 {
482  const char *name;
483  const char *value;
484 
485  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
486  if (!(name && *name)) {
487  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"SetCharValue\"");
488  return GWEN_ERROR_INVALID;
489  }
490 
491  value=GWEN_XMLNode_GetProperty(xmlNode, "value", NULL);
492  if (value) {
493  GWEN_BUFFER *dbuf;
494  int rv;
495 
496  dbuf=GWEN_Buffer_new(0, 256, 0, 1);
498  if (rv<0) {
499  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
500  GWEN_Buffer_free(dbuf);
501  return rv;
502  }
503  _convertAndSetCharValue(cmd, xmlNode, dbCurrent, GWEN_Buffer_GetStart(dbuf));
504  GWEN_Buffer_free(dbuf);
505  }
506  else {
507  const char *path;
508 
509  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
510  if (!(path && *path)) {
511  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"SetCharValue\"");
512  return GWEN_ERROR_INVALID;
513  }
514 
516  if (value && *value) {
517  _convertAndSetCharValue(cmd, xmlNode, dbCurrent, value);
518  }
519 #if 0
520  else {
521  GWEN_BUFFER *tbuf;
522 
523  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
524 
526 
527  DBG_ERROR(GWEN_LOGDOMAIN, "No value in path \"%s\" (%s)", path, GWEN_Buffer_GetStart(tbuf));
528  GWEN_Buffer_free(tbuf);
529 
530  /* GWEN_XMLNode_Dump(cmd->currentDocNode, 2); */
531  }
532 #endif
533  }
534 
535  return 0;
536 }
537 
538 
539 
541 {
543 }
544 
545 
546 
548 {
550 }
551 
552 
553 
555 {
556  const char *pattern;
557  const char *path;
558  const char *value;
559 
560  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
561  if (!(path && *path)) {
562  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfCharDataMatches\"");
563  return GWEN_ERROR_INVALID;
564  }
565 
566  pattern=GWEN_XMLNode_GetProperty(xmlNode, "pattern", NULL);
567  if (!(pattern && *pattern)) {
568  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty pattern in \"IfCharDataMatches\"");
569  return GWEN_ERROR_INVALID;
570  }
571 
573  if (value) {
574  if (-1!=GWEN_Text_ComparePattern(value, pattern, 0)) {
575  int rv;
576 
577  /* pattern matches, handle children */
578  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
579  if (rv<0) {
580  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
581  return rv;
582  }
583  }
584  }
585 
586  return 0;
587 }
588 
589 
590 
592 {
593  const char *pattern;
594  const char *path;
595  const char *value;
596 
597  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
598  if (!(path && *path)) {
599  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotCharDataMatches\"");
600  return GWEN_ERROR_INVALID;
601  }
602 
603  pattern=GWEN_XMLNode_GetProperty(xmlNode, "pattern", NULL);
604  if (!(pattern && *pattern)) {
605  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty pattern in \"IfNotCharDataMatches\"");
606  return GWEN_ERROR_INVALID;
607  }
608 
610  if (value) {
611  if (-1==GWEN_Text_ComparePattern(value, pattern, 0)) {
612  int rv;
613 
614  /* pattern doesnt match, handle children */
615  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
616  if (rv<0) {
617  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
618  return rv;
619  }
620  }
621  }
622 
623  return 0;
624 }
625 
626 
627 
629 {
630  const char *path;
631  const char *value;
632 
633  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
634  if (!(path && *path)) {
635  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfCharDataMatches\"");
636  return GWEN_ERROR_INVALID;
637  }
638 
640  if (value && *value) {
641  int rv;
642 
643  /* there is a value, handle children */
644  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
645  if (rv<0) {
646  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
647  return rv;
648  }
649  }
650  else {
651  DBG_INFO(GWEN_LOGDOMAIN, "XmlIfHasCharData: No value for path \"%s\"", path);
652  }
653 
654  return 0;
655 }
656 
657 
658 
660 {
661  const char *path;
662  const char *value;
663 
664  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
665  if (!(path && *path)) {
666  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotCharDataMatches\"");
667  return GWEN_ERROR_INVALID;
668  }
669 
671  if (!(value && *value)) {
672  int rv;
673 
674  /* there is a value, handle children */
675  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
676  if (rv<0) {
677  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
678  return rv;
679  }
680  }
681 
682  return 0;
683 }
684 
685 
686 
688 {
689  const char *path;
690 
691  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
692  if (!(path && *path)) {
693  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfPathExists\"");
694  return GWEN_ERROR_INVALID;
695  }
696 
698  int rv;
699 
700  /* path exists, handle children */
701  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
702  if (rv<0) {
703  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
704  return rv;
705  }
706  }
707  else {
708  DBG_INFO(GWEN_LOGDOMAIN, "XmlIfPathExists: Path \"%s\" does not exist", path);
709  }
710 
711  return 0;
712 }
713 
714 
715 
717 {
718  const char *path;
719 
720  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
721  if (!(path && *path)) {
722  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotPathExists\"");
723  return GWEN_ERROR_INVALID;
724  }
725 
727  int rv;
728 
729  /* path does not exist, handle children */
730  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
731  if (rv<0) {
732  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
733  return rv;
734  }
735  }
736  else {
737  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" exists", path);
738  }
739 
740  return 0;
741 }
742 
743 
int GWEN_DB_ReplaceVars(GWEN_DB_NODE *db, const char *s, GWEN_BUFFER *dbuf)
Definition: db.c:1951
void GWEN_XmlCommanderGwenXml_EnterDocNode(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
Definition: xmlcmd_gxml.c:207
struct GWEN_TIME GWEN_TIME
Definition: gwentime.h:43
static int _handleXmlIfNotHasCharData(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:235
void GWEN_Text_CondenseBuffer(GWEN_BUFFER *buf)
Definition: text.c:1620
GWEN_XMLCMD_HANDLECHILDREN_FN GWEN_XmlCommander_SetHandleChildrenFn(GWEN_XMLCOMMANDER *cmd, GWEN_XMLCMD_HANDLECHILDREN_FN f)
Definition: xmlcmd.c:69
static int _handleChildren_toDb(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
GWEN_DATE * GWEN_Date_fromStringWithTemplate(const char *s, const char *tmpl)
Definition: gwendate.c:479
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
Definition: db.c:421
#define GWEN_ERROR_INVALID
Definition: error.h:67
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:239
GWEN_XMLNODE * GWEN_XMLNode_FindNextTag(const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue)
Definition: xml.c:794
static int _handleXmlIfNotPathExists(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
#define NULL
Definition: binreloc.c:300
#define GWEN_PATH_FLAGS_CREATE_GROUP
Definition: path.h:96
#define GWEN_LOGDOMAIN
Definition: logger.h:35
GWEN_XMLCOMMANDER * GWEN_XmlCommanderGwenXml_new(GWEN_XMLNODE *documentRoot, GWEN_DB_NODE *dbRoot)
Definition: xmlcmd_gxml.c:52
static int _handleXmlIfHasCharData(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:42
static int _handleDbCreateAndEnterTempGroup(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
void GWEN_XmlCommanderGwenXml_LeaveDocNode(GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_gxml.c:223
GWEN_XMLNODE * GWEN_XMLNode_FindFirstTag(const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue)
Definition: xml.c:776
int GWEN_XMLNode_GetIntProperty(const GWEN_XMLNODE *n, const char *name, int defaultValue)
Definition: xml.c:263
void GWEN_XmlCommanderGwenXml_SetCurrentDbGroup(GWEN_XMLCOMMANDER *cmd, GWEN_DB_NODE *db)
Definition: xmlcmd_gxml.c:155
GWENHYWFAR_API int GWEN_Time_toString(const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf)
Definition: gwentime_all.c:830
static int _convertAndSetCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode, GWEN_DB_NODE *dbCurrent, const char *value)
GWEN_XMLNODE * GWEN_XMLNode_GetNextTag(const GWEN_XMLNODE *n)
Definition: xml.c:712
void GWEN_Date_free(GWEN_DATE *gd)
Definition: gwendate.c:330
static int _handleDbSetCharValue_internal(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode, GWEN_DB_NODE *dbCurrent)
GWEN_XMLNODE * GWEN_XMLNode_GetNodeByXPath(GWEN_XMLNODE *n, const char *path, uint32_t flags)
Definition: xml.c:1311
int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c)
Definition: buffer.c:394
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition: db.c:971
static int _handleXmlIfNotCharDataMatches(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
Definition: db.c:1381
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:89
int GWEN_DB_DeleteVar(GWEN_DB_NODE *n, const char *path)
Definition: db.c:899
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:38
GWENHYWFAR_API void GWEN_Time_free(GWEN_TIME *t)
Definition: gwentime_all.c:462
const char * GWEN_Date_GetString(const GWEN_DATE *gd)
Definition: gwendate.c:425
int GWEN_XMLNode_GetXPath(const GWEN_XMLNODE *n1, const GWEN_XMLNODE *n2, GWEN_BUFFER *nbuf)
Definition: xml.c:1097
GWEN_DB_NODE * GWEN_XmlCommanderGwenXml_GetCurrentDbGroup(const GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_gxml.c:142
static int _handleXmlIfPathExists(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
GWEN_XMLNODE * GWEN_XmlCommanderGwenXml_GetCurrentDocNode(const GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_gxml.c:103
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
GWEN_XMLNODE * GWEN_XMLNode_GetFirstTag(const GWEN_XMLNODE *n)
Definition: xml.c:705
GWENHYWFAR_API GWEN_TIME * GWEN_Time_fromString(const char *s, const char *tmpl)
Definition: gwentime_all.c:345
static int _handleXmlEnter(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
const char * GWEN_XMLNode_GetData(const GWEN_XMLNODE *n)
Definition: xml.c:370
int GWEN_Text_ComparePattern(const char *w, const char *p, int sensecase)
Definition: text.c:1208
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
Definition: db.c:997
GWEN_DB_NODE * GWEN_XmlCommanderGwenXml_GetCurrentTempDbGroup(const GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_gxml.c:181
static int _handleXmlIfCharDataMatches(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
#define GWEN_PATH_FLAGS_PATHMUSTEXIST
Definition: path.h:66
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:181
void GWEN_DB_UnlinkGroup(GWEN_DB_NODE *n)
Definition: db.c:1554
const char * GWEN_XMLNode_GetCharValueByPath(GWEN_XMLNODE *n, const char *name, const char *defValue)
Definition: xml.c:981
int GWEN_XmlCommander_HandleChildren(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
Definition: xmlcmd.c:80
static const char * _getCharValueByPath(GWEN_XMLNODE *xmlNode, const char *path, const char *defValue)
static int _handleXmlForEvery(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
static int _handleDbSetCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
static int _handleDbSetTempCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:156
void GWEN_XmlCommanderGwenXml_SetCurrentTempDbGroup(GWEN_XMLCOMMANDER *cmd, GWEN_DB_NODE *db)
Definition: xmlcmd_gxml.c:194
#define GWEN_UNUSED
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition: buffer.c:989
#define GWEN_DB_FLAGS_DEFAULT
Definition: db.h:168
GWEN_XMLCOMMANDER * GWEN_XmlCommanderGwenXml_toDb_new(GWEN_XMLNODE *xmlNodeDocument, GWEN_DB_NODE *dbDestination)
static int _handleDbCreateAndEnterGroup(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
struct GWEN_XMLCOMMANDER GWEN_XMLCOMMANDER
Definition: xmlcmd.h:39
struct GWEN_DATE GWEN_DATE
Definition: gwendate.h:34