gwenhywfar  5.10.1
xmlcmd_lxml_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_lxml_todb.h"
33 #include "xmlcmd_lxml.h"
34 
35 #include <gwenhywfar/debug.h>
36 #include <gwenhywfar/text.h>
37 #include <gwenhywfar/gwendate.h>
38 #include <gwenhywfar/path.h>
39 
40 
41 #include <ctype.h>
42 
43 
44 
45 
46 /* ------------------------------------------------------------------------------------------------
47  * forward declarations
48  * ------------------------------------------------------------------------------------------------
49  */
50 
51 static int _handleChildren_toDb(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode);
52 
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  * implementations
77  * ------------------------------------------------------------------------------------------------
78  */
79 
80 
81 
82 GWEN_XMLCOMMANDER *GWEN_XmlCommanderLibXml_toDb_new(xmlNodePtr xmlNodeDocument, GWEN_DB_NODE *dbDestination)
83 {
84  GWEN_XMLCOMMANDER *cmd;
85 
86  cmd=GWEN_XmlCommanderLibXml_new(xmlNodeDocument, dbDestination);
88 
89  return cmd;
90 }
91 
92 
93 
95 {
96  GWEN_XMLNODE *n;
97 
98  n=GWEN_XMLNode_GetFirstTag(xmlNode);
99  while (n) {
100  const char *name;
101 
102  name=GWEN_XMLNode_GetData(n);
103  if (name && *name) {
104  int rv;
105 
106  DBG_INFO(GWEN_LOGDOMAIN, "Handling element \"%s\"", name);
107  if (strcasecmp(name, "XmlEnter")==0)
108  rv=_handleXmlEnter(cmd, n);
109  else if (strcasecmp(name, "XmlForEvery")==0)
110  rv=_handleXmlForEvery(cmd, n);
111  else if (strcasecmp(name, "DbCreateAndEnterGroup")==0)
112  rv=_handleDbCreateAndEnterGroup(cmd, n);
113  else if (strcasecmp(name, "DbCreateAndEnterTempGroup")==0)
115  else if (strcasecmp(name, "DbSetCharValue")==0)
116  rv=_handleDbSetCharValue(cmd, n);
117  else if (strcasecmp(name, "DbSetTempCharValue")==0)
118  rv=_handleDbSetTempCharValue(cmd, n);
119  else if (strcasecmp(name, "XmlIfCharDataMatches")==0)
120  rv=_handleXmlIfCharDataMatches(cmd, n);
121  else if (strcasecmp(name, "XmlIfNotCharDataMatches")==0)
123  else if (strcasecmp(name, "XmlIfHasCharData")==0)
124  rv=_handleXmlIfHasCharData(cmd, n);
125  else if (strcasecmp(name, "XmlIfNotHasCharData")==0)
126  rv=_handleXmlIfNotHasCharData(cmd, n);
127  else if (strcasecmp(name, "XmlIfPathExists")==0)
128  rv=_handleXmlIfPathExists(cmd, n);
129  else if (strcasecmp(name, "XmlIfNotPathExists")==0)
130  rv=_handleXmlIfNotPathExists(cmd, n);
131  else {
132  DBG_ERROR(GWEN_LOGDOMAIN, "Unknown element \"%s\", aborting", name);
133  return GWEN_ERROR_INVALID;
134  }
135  if (rv<0) {
136  DBG_ERROR(GWEN_LOGDOMAIN, "Error in element \"%s\", aborting", name);
137  return rv;
138  }
139  }
140 
142  }
143 
144  return 0;
145 }
146 
147 
148 
149 
150 /* TODO: optimize later */
152  GWEN_DB_NODE *dbCurrent,
153  const char *value)
154 {
155  if (value && *value) {
156  const char *name;
157  const char *typ;
158  const char *mode;
159  int doTrim=0;
160  GWEN_BUFFER *vbuf;
161  GWEN_BUFFER *resultBuf;
162 
163  doTrim=GWEN_XMLNode_GetIntProperty(xmlNode, "trim", 0);
164  vbuf=GWEN_Buffer_new(0, 256, 0, 1);
165  resultBuf=GWEN_Buffer_new(0, 256, 0, 1);
166 
167  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
168  if (!(name && *name)) {
169  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"SetCharValue\"");
170  GWEN_Buffer_free(resultBuf);
171  GWEN_Buffer_free(vbuf);
172  return GWEN_ERROR_INVALID;
173  }
174 
175  typ=GWEN_XMLNode_GetProperty(xmlNode, "type", "string");
176  if (!(typ && *typ)) {
177  DBG_ERROR(GWEN_LOGDOMAIN, "Empty type in \"SetCharValue\"");
178  GWEN_Buffer_free(resultBuf);
179  GWEN_Buffer_free(vbuf);
180  return GWEN_ERROR_INVALID;
181  }
182 
183  mode=GWEN_XMLNode_GetProperty(xmlNode, "mode", "add");
184 
185  if (strcasecmp(typ, "string")==0) {
186  GWEN_Buffer_AppendString(vbuf, value);
187  if (doTrim)
189  }
190  else if (strcasecmp(typ, "date")==0) {
191  const char *tmpl;
192  GWEN_DATE *dt=NULL;
193 
194  tmpl=GWEN_XMLNode_GetProperty(xmlNode, "template", "YYYYMMDD");
195  if (!(tmpl && *tmpl)) {
196  DBG_ERROR(GWEN_LOGDOMAIN, "Empty template in \"SetCharValue\"");
197  GWEN_Buffer_free(resultBuf);
198  GWEN_Buffer_free(vbuf);
199  return GWEN_ERROR_INVALID;
200  }
201 
202  dt=GWEN_Date_fromStringWithTemplate(value, tmpl);
203  if (dt) {
205  GWEN_Date_free(dt);
206  }
207  }
208 
209  if (strcasecmp(mode, "add")==0) {
210  /* just exchange the buffer */
211  GWEN_Buffer_free(resultBuf);
212  resultBuf=vbuf;
213  vbuf=NULL;
214  }
215  else if (strcasecmp(mode, "append")==0) {
216  const char *s;
217 
218  s=GWEN_DB_GetCharValue(dbCurrent, name, 0, NULL);
219  if (s && *s) {
220  const char *delimiter;
221 
222  /* write previous data into resultBuffer */
223  GWEN_Buffer_AppendString(resultBuf, s);
224 
225  /* possibly write delimiter into resultBuffer */
226  delimiter=GWEN_XMLNode_GetProperty(xmlNode, "delimiter", NULL);
227  if (delimiter && *delimiter) {
228  if (strcasecmp(delimiter, "\\n")==0)
229  GWEN_Buffer_AppendByte(resultBuf, '\n');
230  else if (strcasecmp(delimiter, "\\t")==0)
231  GWEN_Buffer_AppendByte(resultBuf, '\t');
232  else
233  GWEN_Buffer_AppendString(resultBuf, delimiter);
234  }
235  } /* if previous value */
236  /* write value into resultBuffer */
238 
239  GWEN_DB_DeleteVar(dbCurrent, name);
240  }
241  else if (strcasecmp(mode, "replace")==0) {
242  /* just exchange the buffer */
243  GWEN_Buffer_free(resultBuf);
244  resultBuf=vbuf;
245  vbuf=NULL;
246  GWEN_DB_DeleteVar(dbCurrent, name);
247  }
248 
249  DBG_INFO(GWEN_LOGDOMAIN, "Setting value: %s = %s", name, GWEN_Buffer_GetStart(resultBuf));
250 
252  GWEN_Buffer_free(resultBuf);
253  GWEN_Buffer_free(vbuf);
254  }
255  return 0;
256 }
257 
258 
259 
260 
261 
262 
263 
265 {
266  const char *path;
267  xmlNodePtr n;
268  int rv;
269 
270  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
271  if (path==NULL) {
272  DBG_ERROR(GWEN_LOGDOMAIN, "Missing path in \"EnterPath\"");
273  return GWEN_ERROR_INVALID;
274  }
275 
277  if (n==NULL) {
278  DBG_ERROR(GWEN_LOGDOMAIN, "Path \"%s\" does not exist", path);
279  return GWEN_ERROR_INVALID;
280  }
281 
282  /* enter given document node */
284 
285  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
286  if (rv<0) {
287  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
288  return rv;
289  }
290 
291  /* leave given document node, re-select previously active one, thus restoring status from the beginning */
293  return 0;
294 }
295 
296 
297 
299 {
300  const char *path;
301  xmlNodePtr n;
302  int rv;
303 
304  path=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
305  if (path==NULL) {
306  DBG_ERROR(GWEN_LOGDOMAIN, "Missing name in \"ForEvery\"");
307  return GWEN_ERROR_INVALID;
308  }
309 
311  if (n==NULL) {
312  DBG_ERROR(GWEN_LOGDOMAIN, "Path \"%s\" not found", path);
313  /* GWEN_XMLNode_Dump(cmd->currentDocNode, 2); */
314  }
315  while (n) {
316  /* enter given document node */
318 
319  /* handle all children of this parser XML node with the current document node */
320  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
321 
322  /* leave given document node, re-select previously active one, thus restoring status from the beginning */
324 
325  if (rv<0) {
326  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
327  return rv;
328  }
329 
331  }
332 
333  return 0;
334 }
335 
336 
337 
339 {
340  const char *name;
341  GWEN_DB_NODE *dbLast;
342  int rv;
343 
344  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
345  if (!(name && *name)) {
346  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"CreateAnEnterDbGroup\"");
347  return GWEN_ERROR_INVALID;
348  }
349 
350  /* push group */
352 
353  /* create group */
355 
356  /* handle children (nothing special here) */
357  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
358 
359  /* pop group */
361 
362  if (rv<0) {
363  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
364  return rv;
365  }
366 
367  return 0;
368 }
369 
370 
371 
373 {
374  const char *name;
375  GWEN_DB_NODE *dbLast;
376  GWEN_DB_NODE *dbCurrent;
377  int rv;
378 
379  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
380  if (!(name && *name)) {
381  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"CreateAnEnterTempDbGroup\"");
382  return GWEN_ERROR_INVALID;
383  }
384 
385  /* push group */
387 
388  /* create group */
389  dbCurrent=GWEN_DB_GetGroup(dbLast, GWEN_PATH_FLAGS_CREATE_GROUP, name);
391 
392  /* handle children (nothing special here) */
393  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
394 
395  /* delete temp group */
396  GWEN_DB_UnlinkGroup(dbCurrent);
397  GWEN_DB_Group_free(dbCurrent);
398 
399  /* pop group */
401 
402  if (rv<0) {
403  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
404  return rv;
405  }
406 
407  return 0;
408 }
409 
410 
411 
413 {
414  const char *name;
415  const char *value;
416 
417  name=GWEN_XMLNode_GetProperty(xmlNode, "name", NULL);
418  if (!(name && *name)) {
419  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty name in \"SetCharValue\"");
420  return GWEN_ERROR_INVALID;
421  }
422 
423  value=GWEN_XMLNode_GetProperty(xmlNode, "value", NULL);
424  if (value) {
425  GWEN_BUFFER *dbuf;
426  int rv;
427 
428  dbuf=GWEN_Buffer_new(0, 256, 0, 1);
430  if (rv<0) {
431  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
432  GWEN_Buffer_free(dbuf);
433  return rv;
434  }
435  _convertAndSetCharValue(cmd, xmlNode, dbCurrent, GWEN_Buffer_GetStart(dbuf));
436  GWEN_Buffer_free(dbuf);
437  }
438  else {
439  const char *path;
440 
441  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
442  if (!(path && *path)) {
443  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"SetCharValue\"");
444  return GWEN_ERROR_INVALID;
445  }
446 
448  if (value && *value) {
449  _convertAndSetCharValue(cmd, xmlNode, dbCurrent, value);
450  }
451  }
452 
453  return 0;
454 }
455 
456 
457 
459 {
461 }
462 
463 
464 
466 {
468 }
469 
470 
471 
473 {
474  const char *pattern;
475  const char *path;
476  const char *value;
477 
478  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
479  if (!(path && *path)) {
480  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfCharDataMatches\"");
481  return GWEN_ERROR_INVALID;
482  }
483 
484  pattern=GWEN_XMLNode_GetProperty(xmlNode, "pattern", NULL);
485  if (!(pattern && *pattern)) {
486  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty pattern in \"IfCharDataMatches\"");
487  return GWEN_ERROR_INVALID;
488  }
489 
491  if (value) {
492  if (-1!=GWEN_Text_ComparePattern(value, pattern, 0)) {
493  int rv;
494 
495  /* pattern matches, handle children */
496  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
497  if (rv<0) {
498  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
499  return rv;
500  }
501  }
502  }
503 
504  return 0;
505 }
506 
507 
508 
510 {
511  const char *pattern;
512  const char *path;
513  const char *value;
514 
515  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
516  if (!(path && *path)) {
517  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotCharDataMatches\"");
518  return GWEN_ERROR_INVALID;
519  }
520 
521  pattern=GWEN_XMLNode_GetProperty(xmlNode, "pattern", NULL);
522  if (!(pattern && *pattern)) {
523  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty pattern in \"IfNotCharDataMatches\"");
524  return GWEN_ERROR_INVALID;
525  }
526 
528  if (value) {
529  if (-1==GWEN_Text_ComparePattern(value, pattern, 0)) {
530  int rv;
531 
532  /* pattern doesnt match, handle children */
533  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
534  if (rv<0) {
535  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
536  return rv;
537  }
538  }
539  }
540 
541  return 0;
542 }
543 
544 
545 
547 {
548  const char *path;
549  const char *value;
550 
551  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
552  if (!(path && *path)) {
553  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfCharDataMatches\"");
554  return GWEN_ERROR_INVALID;
555  }
556 
558  if (value && *value) {
559  int rv;
560 
561  /* there is a value, handle children */
562  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
563  if (rv<0) {
564  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
565  return rv;
566  }
567  }
568  else {
569  DBG_INFO(GWEN_LOGDOMAIN, "No value for path \"%s\"", path);
570  }
571 
572  return 0;
573 }
574 
575 
576 
578 {
579  const char *path;
580  const char *value;
581 
582  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
583  if (!(path && *path)) {
584  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotCharDataMatches\"");
585  return GWEN_ERROR_INVALID;
586  }
587 
589  if (!(value && *value)) {
590  int rv;
591 
592  /* there is a value, handle children */
593  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
594  if (rv<0) {
595  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
596  return rv;
597  }
598  }
599 
600  return 0;
601 }
602 
603 
604 
606 {
607  const char *path;
608 
609  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
610  if (!(path && *path)) {
611  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfPathExists\"");
612  return GWEN_ERROR_INVALID;
613  }
614 
616  int rv;
617 
618  /* path exists, handle children */
619  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
620  if (rv<0) {
621  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
622  return rv;
623  }
624  }
625  else {
626  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" does not exist", path);
627  }
628 
629  return 0;
630 }
631 
632 
633 
635 {
636  const char *path;
637 
638  path=GWEN_XMLNode_GetProperty(xmlNode, "path", NULL);
639  if (!(path && *path)) {
640  DBG_ERROR(GWEN_LOGDOMAIN, "Missing or empty path in \"IfNotPathExists\"");
641  return GWEN_ERROR_INVALID;
642  }
643 
645  int rv;
646 
647  /* path does not exist, handle children */
648  rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNode);
649  if (rv<0) {
650  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
651  return rv;
652  }
653  }
654  else {
655  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" exists", path);
656  }
657 
658  return 0;
659 }
660 
661 
662 
663 
int GWEN_DB_ReplaceVars(GWEN_DB_NODE *db, const char *s, GWEN_BUFFER *dbuf)
Definition: db.c:1951
static int _handleChildren_toDb(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
GWEN_DATE * GWEN_Date_fromStringWithTemplate(const char *s, const char *tmpl)
Definition: gwendate.c:479
static int _handleDbCreateAndEnterTempGroup(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
xmlNodePtr GWEN_XmlCommanderLibXml_FindNextElement(xmlNodePtr elem, const char *elemName)
Definition: xmlcmd_lxml.c:289
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
Definition: db.c:421
#define GWEN_ERROR_INVALID
Definition: error.h:67
GWEN_DB_NODE * GWEN_XmlCommanderLibXml_GetCurrentTempDbGroup(const GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_lxml.c:190
GWEN_XMLCOMMANDER * GWEN_XmlCommanderLibXml_new(xmlNodePtr documentRoot, GWEN_DB_NODE *dbRoot)
Definition: xmlcmd_lxml.c:65
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:239
static int _handleXmlForEvery(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
void GWEN_XmlCommanderLibXml_SetCurrentTempDbGroup(GWEN_XMLCOMMANDER *cmd, GWEN_DB_NODE *db)
Definition: xmlcmd_lxml.c:203
#define NULL
Definition: binreloc.c:300
#define GWEN_PATH_FLAGS_CREATE_GROUP
Definition: path.h:96
void GWEN_XmlCommanderLibXml_LeaveDocNode(GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_lxml.c:239
xmlNodePtr GWEN_XmlCommanderLibXml_GetXmlNode(xmlNodePtr n, const char *path, uint32_t flags)
Definition: xmlcmd_lxml.c:263
xmlNodePtr GWEN_XmlCommanderLibXml_GetCurrentDocNode(const GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_lxml.c:112
#define GWEN_LOGDOMAIN
Definition: logger.h:35
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:42
void GWEN_XmlCommanderLibXml_SetCurrentDbGroup(GWEN_XMLCOMMANDER *cmd, GWEN_DB_NODE *db)
Definition: xmlcmd_lxml.c:164
static int _handleXmlIfHasCharData(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
static int _handleXmlIfNotPathExists(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
static int _convertAndSetCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode, GWEN_DB_NODE *dbCurrent, const char *value)
int GWEN_XMLNode_GetIntProperty(const GWEN_XMLNODE *n, const char *name, int defaultValue)
Definition: xml.c:263
static int _handleXmlIfPathExists(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
GWEN_XMLNODE * GWEN_XMLNode_GetNextTag(const GWEN_XMLNODE *n)
Definition: xml.c:712
void GWEN_Date_free(GWEN_DATE *gd)
Definition: gwendate.c:330
GWEN_DB_NODE * GWEN_XmlCommanderLibXml_GetCurrentDbGroup(const GWEN_XMLCOMMANDER *cmd)
Definition: xmlcmd_lxml.c:151
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
void GWEN_XmlCommanderLibXml_EnterDocNode(GWEN_XMLCOMMANDER *cmd, xmlNodePtr xNode)
Definition: xmlcmd_lxml.c:216
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
const char * GWEN_Date_GetString(const GWEN_DATE *gd)
Definition: gwendate.c:425
static int _handleXmlEnter(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
GWEN_XMLNODE * GWEN_XMLNode_GetFirstTag(const GWEN_XMLNODE *n)
Definition: xml.c:705
const char * GWEN_XMLNode_GetData(const GWEN_XMLNODE *n)
Definition: xml.c:370
static int _handleXmlIfCharDataMatches(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
static int _handleDbSetTempCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
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
static int _handleDbSetCharValue_internal(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode, GWEN_DB_NODE *dbCurrent)
#define GWEN_PATH_FLAGS_PATHMUSTEXIST
Definition: path.h:66
const char * GWEN_XmlCommanderLibXml_GetXmlCharValueByPath(xmlNodePtr elem, const char *path, const char *defValue)
Definition: xmlcmd_lxml.c:377
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:181
void GWEN_DB_UnlinkGroup(GWEN_DB_NODE *n)
Definition: db.c:1554
static int _handleXmlIfNotCharDataMatches(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
static int _handleXmlIfNotHasCharData(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
xmlNodePtr GWEN_XmlCommanderLibXml_FindFirstElement(xmlNodePtr parent, const char *elemName)
Definition: xmlcmd_lxml.c:270
int GWEN_XmlCommander_HandleChildren(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
Definition: xmlcmd.c:80
GWEN_XMLCOMMANDER * GWEN_XmlCommanderLibXml_toDb_new(xmlNodePtr xmlNodeDocument, GWEN_DB_NODE *dbDestination)
static int _handleDbCreateAndEnterGroup(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:156
static int _handleDbSetCharValue(GWEN_XMLCOMMANDER *cmd, GWEN_XMLNODE *xmlNode)
#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
struct GWEN_XMLCOMMANDER GWEN_XMLCOMMANDER
Definition: xmlcmd.h:39
struct GWEN_DATE GWEN_DATE
Definition: gwendate.h:34