Initial Commit
[apps/agl-service-unicens.git] / ucs2-interface / ucs-xml / UcsXml.h
1 /*
2  * Unicens XML Parser
3  *
4  * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  * You may also obtain this software under a propriety license from Microchip.
20  * Please contact Microchip for further information.
21  *
22  */
23 #ifndef UCSXML_H_
24 #define UCSXML_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include <stdbool.h>
31 #include <stdint.h>
32 #include "ucs_api.h"
33
34 /** Structure holding informations to startup Unicens (UCS).
35  *  Pass all these variables to the UCS manager structure, but not pInternal.
36  *  */
37 typedef struct
38 {
39     /** The amount of bytes assigned to the async channel*/
40     uint16_t packetBw;
41     /** Array of routes */
42     Ucs_Rm_Route_t *pRoutes;
43     /** Route array size */
44     uint16_t routesSize;
45     /** Array of nodes */
46     Ucs_Rm_Node_t *pNod;
47     /** Node array size */
48     uint16_t nodSize;
49     /** Internal data, to be ignored */
50     void *pInternal;
51 } UcsXmlVal_t;
52
53 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
54 /*                            Public API                                */
55 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
56
57 /**
58  * \brief Initializes Unicens XML parser module, parses the given string and 
59  *        generate the data needed to run Unicens (UCS) library.
60  *
61  * \note In case of errors the callback UcsXml_CB_OnError will be raised.
62  * \param xmlString - Zero terminated XML string. The string will not be used
63  *                    after this function call.
64  * \return Structure holding the needed data for UCS. NULL, if there was an error.
65  *         The structure will be created dynamically, to free the data call UcsXml_FreeVal.
66  */
67 UcsXmlVal_t *UcsXml_Parse(const char *xmlString);
68
69 /**
70  * \brief Frees the given structure, generated by UcsXml_Parse. 
71  *
72  * \note In case of errors the callback UcsXml_CB_OnError will be raised.
73  * \param val - The structure to be freed.
74  */
75 void UcsXml_FreeVal(UcsXmlVal_t *val);
76
77 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
78 /*                        CALLBACK SECTION                              */
79 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
80
81 /**
82  * \brief Callback whenever a parser error occurs. The message is human readable.
83  * \note This function must be implemented by the integrator.
84  *
85  * \param format - Zero terminated format string (following printf rules)
86  * \param vargsCnt - Amount of parameters stored in "..."
87  */
88 extern void UcsXml_CB_OnError(const char format[], uint16_t vargsCnt, ...);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* UCSXML_H_ */