1 /***************************************************************************
2     begin       : Sun Dec 16 2018
3     copyright   : (C) 2018 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 "xml2db.h"
33 
34 #include <gwenhywfar/debug.h>
35 #include <gwenhywfar/text.h>
36 #include <gwenhywfar/gwendate.h>
37 #include <gwenhywfar/xmlcmd_gxml_fromdb.h>
38 #include <gwenhywfar/xmlcmd_gxml_todb.h>
39 
40 
41 #include <ctype.h>
42 
43 
44 
45 
GWEN_Xml2Db(GWEN_XMLNODE * xmlNodeDocument,GWEN_XMLNODE * xmlNodeSchema,GWEN_DB_NODE * dbDestination)46 int GWEN_Xml2Db(GWEN_XMLNODE *xmlNodeDocument,
47                 GWEN_XMLNODE *xmlNodeSchema,
48                 GWEN_DB_NODE *dbDestination)
49 {
50   GWEN_XMLCOMMANDER *cmd;
51   int rv;
52 
53   cmd=GWEN_XmlCommanderGwenXml_toDb_new(xmlNodeDocument, dbDestination);
54 
55   rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNodeSchema);
56   GWEN_XmlCommander_free(cmd);
57 
58   if (rv<0) {
59     DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
60     return rv;
61   }
62 
63   return 0;
64 }
65 
66 
67 
GWEN_XmlFromDb(GWEN_XMLNODE * xmlNodeDestination,GWEN_XMLNODE * xmlNodeSchema,GWEN_DB_NODE * dbSource)68 int GWEN_XmlFromDb(GWEN_XMLNODE *xmlNodeDestination,
69 		   GWEN_XMLNODE *xmlNodeSchema,
70 		   GWEN_DB_NODE *dbSource)
71 {
72   GWEN_XMLCOMMANDER *cmd;
73   int rv;
74 
75   cmd=GWEN_XmlCommanderGwenXml_fromDb_new(xmlNodeDestination, dbSource);
76 
77   rv=GWEN_XmlCommander_HandleChildren(cmd, xmlNodeSchema);
78   GWEN_XmlCommander_free(cmd);
79 
80   if (rv<0) {
81     DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
82     return rv;
83   }
84 
85   return 0;
86 }
87 
88 
89