gwenhywfar  5.4.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 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 
251  if (strcasecmp(mode, "add")==0) {
252  /* just exchange the buffer */
253  GWEN_Buffer_free(resultBuf);
254  resultBuf=vbuf;
255  vbuf=NULL;
256  }
257  else if (strcasecmp(mode, "append")==0) {
258  const char *s;
259 
260  s=GWEN_DB_GetCharValue(dbCurrent, name, 0, NULL);
261  if (s && *s) {
262  const char *delimiter;
263 
264  /* write previous data into resultBuffer */
265  GWEN_Buffer_AppendString(resultBuf, s);
266 
267  /* possibly write delimiter into resultBuffer */
268  delimiter=GWEN_XMLNode_GetProperty(xmlNode, "delimiter", NULL);
269  if (delimiter && *delimiter) {
270  if (strcasecmp(delimiter, "\\n")==0)
271  GWEN_Buffer_AppendByte(resultBuf, '\n');
272  else if (strcasecmp(delimiter, "\\t")==0)
273  GWEN_Buffer_AppendByte(resultBuf, '\t');
274  else
275  GWEN_Buffer_AppendString(resultBuf, delimiter);
276  }
277  } /* if previous value */
278  /* write value into resultBuffer */
280 
281  GWEN_DB_DeleteVar(dbCurrent, name);
282  }
283  else if (strcasecmp(mode, "replace")==0) {
284  /* just exchange the buffer */
285  GWEN_Buffer_free(resultBuf);
286  resultBuf=vbuf;
287  vbuf=NULL;
288  GWEN_DB_DeleteVar(dbCurrent, name);
289  }
290 
291  DBG_INFO(GWEN_LOGDOMAIN, "Setting value: %s = %s", name, GWEN_Buffer_GetStart(resultBuf));
292 
294  GWEN_Buffer_free(resultBuf);
295  GWEN_Buffer_free(vbuf);
296  }
297  return 0;
298 }
299 
300 
301 
302 
303 
304 
305 
307 {
308  const char *path;
309  GWEN_XMLNODE *n;
310  int rv;
311 
312  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
313  if (path==NULL) {
314  DBG_ERROR(GWEN_LOGDOMAIN, "Missing path in \"EnterPath\"");
315  return GWEN_ERROR_INVALID;
316  }
317 
319  if (n==NULL) {
320  DBG_ERROR(GWEN_LOGDOMAIN, "Path \"%s\" does not exist", path);
321  return GWEN_ERROR_INVALID;
322  }
323 
324  /* enter given document node */
326 
327  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
328  if (rv<0) {
329  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
330  return rv;
331  }
332 
333  /* leave given document node, re-select previously active one, thus restoring status from the beginning */
335  return 0;
336 }
337 
338 
339 
341 {
342  const char *path;
343  GWEN_XMLNODE *n;
344  int rv;
345 
346  path=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
347  if (path==NULL) {
348  DBG_ERROR(GWEN_LOGDOMAIN, "Missing name in \"ForEvery\"");
349  return GWEN_ERROR_INVALID;
350  }
351 
353  if (n==NULL) {
354  DBG_ERROR(GWEN_LOGDOMAIN, "Path \"%s\" not found", path);
355  /* GWEN_XMLNode_Dump(cmd->currentDocNode, 2); */
356  }
357  while (n) {
358 
359  /* enter given document node */
361 
362  /* handle all children of this parser XML node with the current document node */
363  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
364 
365  /* leave given document node, re-select previously active one, thus restoring status from the beginning */
367 
368  if (rv<0) {
369  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
370  return rv;
371  }
372 
373  n=GWEN_XMLNode_FindNextTag(n, path, NULL, NULL);
374  }
375 
376  return 0;
377 }
378 
379 
380 
382 {
383  const char *name;
384  GWEN_DB_NODE *dbLast;
385  int rv;
386 
387  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
388  if (!(name && *name)) {
389  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"CreateAnEnterDbGroup\"");
390  return GWEN_ERROR_INVALID;
391  }
392 
393  /* push group */
395 
396  /* create group */
398 
399  /* handle children (nothing special here) */
400  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
401 
402  /* pop group */
404 
405  if (rv<0) {
406  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
407  return rv;
408  }
409 
410  return 0;
411 }
412 
413 
414 
416 {
417  const char *name;
418  GWEN_DB_NODE *dbLast;
419  GWEN_DB_NODE *dbCurrent;
420  int rv;
421 
422  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
423  if (!(name && *name)) {
424  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"CreateAnEnterTempDbGroup\"");
425  return GWEN_ERROR_INVALID;
426  }
427 
428  /* push group */
430 
431  /* create group */
432  dbCurrent=GWEN_DB_GetGroup(dbLast, GWEN_PATH_FLAGS_CREATE_GROUP, name);
434 
435  /* handle children (nothing special here) */
436  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
437 
438  /* delete temp group */
439  GWEN_DB_UnlinkGroup(dbCurrent);
440  GWEN_DB_Group_free(dbCurrent);
441 
442  /* pop group */
444 
445  if (rv<0) {
446  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
447  return rv;
448  }
449 
450  return 0;
451 }
452 
453 
454 
456  GWEN_DB_NODE *dbCurrent)
457 {
458  const char *name;
459  const char *value;
460 
461  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
462  if (!(name && *name)) {
463  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"SetCharValue\"");
464  return GWEN_ERROR_INVALID;
465  }
466 
467  value=GWEN_XMLNode_GetProperty(xmlNode, "value", NULL);
468  if (value) {
469  GWEN_BUFFER *dbuf;
470  int rv;
471 
472  dbuf=GWEN_Buffer_new(0, 256, 0, 1);
474  if (rv<0) {
475  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
476  GWEN_Buffer_free(dbuf);
477  return rv;
478  }
479  _convertAndSetCharValue(cmd, xmlNode, dbCurrent, GWEN_Buffer_GetStart(dbuf));
480  GWEN_Buffer_free(dbuf);
481  }
482  else {
483  const char *path;
484 
485  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
486  if (!(path && *path)) {
487  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"SetCharValue\"");
488  return GWEN_ERROR_INVALID;
489  }
490 
492  if (value && *value) {
493  _convertAndSetCharValue(cmd, xmlNode, dbCurrent, value);
494  }
495 #if 0
496  else {
497  GWEN_BUFFER *tbuf;
498 
499  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
500 
502 
503  DBG_ERROR(GWEN_LOGDOMAIN, "No value in path \"%s\" (%s)", path, GWEN_Buffer_GetStart(tbuf));
504  GWEN_Buffer_free(tbuf);
505 
506  /* GWEN_XMLNode_Dump(cmd->currentDocNode, 2); */
507  }
508 #endif
509  }
510 
511  return 0;
512 }
513 
514 
515 
517 {
519 }
520 
521 
522 
524 {
526 }
527 
528 
529 
531 {
532  const char *pattern;
533  const char *path;
534  const char *value;
535 
536  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
537  if (!(path && *path)) {
538  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfCharDataMatches\"");
539  return GWEN_ERROR_INVALID;
540  }
541 
542  pattern=GWEN_XMLNode_GetProperty(xmlNode, "pattern", NULL);
543  if (!(pattern && *pattern)) {
544  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty pattern in \"IfCharDataMatches\"");
545  return GWEN_ERROR_INVALID;
546  }
547 
549  if (value) {
550  if (-1!=GWEN_Text_ComparePattern(value, pattern, 0)) {
551  int rv;
552 
553  /* pattern matches, handle children */
554  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
555  if (rv<0) {
556  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
557  return rv;
558  }
559  }
560  }
561 
562  return 0;
563 }
564 
565 
566 
568 {
569  const char *pattern;
570  const char *path;
571  const char *value;
572 
573  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
574  if (!(path && *path)) {
575  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotCharDataMatches\"");
576  return GWEN_ERROR_INVALID;
577  }
578 
579  pattern=GWEN_XMLNode_GetProperty(xmlNode, "pattern", NULL);
580  if (!(pattern && *pattern)) {
581  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty pattern in \"IfNotCharDataMatches\"");
582  return GWEN_ERROR_INVALID;
583  }
584 
586  if (value) {
587  if (-1==GWEN_Text_ComparePattern(value, pattern, 0)) {
588  int rv;
589 
590  /* pattern doesnt match, handle children */
591  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
592  if (rv<0) {
593  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
594  return rv;
595  }
596  }
597  }
598 
599  return 0;
600 }
601 
602 
603 
605 {
606  const char *path;
607  const char *value;
608 
609  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
610  if (!(path && *path)) {
611  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfCharDataMatches\"");
612  return GWEN_ERROR_INVALID;
613  }
614 
616  if (value && *value) {
617  int rv;
618 
619  /* there is a value, handle children */
620  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
621  if (rv<0) {
622  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
623  return rv;
624  }
625  }
626  else {
627  DBG_INFO(GWEN_LOGDOMAIN, "No value for path \"%s\"", path);
628  }
629 
630  return 0;
631 }
632 
633 
634 
636 {
637  const char *path;
638  const char *value;
639 
640  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
641  if (!(path && *path)) {
642  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotCharDataMatches\"");
643  return GWEN_ERROR_INVALID;
644  }
645 
647  if (!(value && *value)) {
648  int rv;
649 
650  /* there is a value, handle children */
651  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
652  if (rv<0) {
653  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
654  return rv;
655  }
656  }
657 
658  return 0;
659 }
660 
661 
662 
664 {
665  const char *path;
666 
667  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
668  if (!(path && *path)) {
669  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfPathExists\"");
670  return GWEN_ERROR_INVALID;
671  }
672 
674  int rv;
675 
676  /* path exists, handle children */
677  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
678  if (rv<0) {
679  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
680  return rv;
681  }
682  }
683  else {
684  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" does not exist", path);
685  }
686 
687  return 0;
688 }
689 
690 
691 
693 {
694  const char *path;
695 
696  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
697  if (!(path && *path)) {
698  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotPathExists\"");
699  return GWEN_ERROR_INVALID;
700  }
701 
703  int rv;
704 
705  /* path does not exist, handle children */
706  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
707  if (rv<0) {
708  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
709  return rv;
710  }
711  }
712  else {
713  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" exists", path);
714  }
715 
716  return 0;
717 }
718 
719 
int GWEN_DB_ReplaceVars(GWEN_DB_NODE *db, const char *s, GWEN_BUFFER *dbuf)
Definition: db.c:1949
void GWEN_XmlCommanderGwenXml_EnterDocNode(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
Definition: xmlcmd_gxml.c:207
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:377
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
Definition: db.c:419
#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:754
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:736
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
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:672
void GWEN_Date_free(GWEN_DATE *gd)
Definition: gwendate.c:237
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:1271
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:969
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:1379
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:897
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:38
const char * GWEN_Date_GetString(const GWEN_DATE *gd)
Definition: gwendate.c:323
int GWEN_XMLNode_GetXPath(const GWEN_XMLNODE *n1, const GWEN_XMLNODE *n2, GWEN_BUFFER *nbuf)
Definition: xml.c:1057
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:665
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:995
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:178
void GWEN_DB_UnlinkGroup(GWEN_DB_NODE *n)
Definition: db.c:1552
const char * GWEN_XMLNode_GetCharValueByPath(GWEN_XMLNODE *n, const char *name, const char *defValue)
Definition: xml.c:941
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:149
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