RetroArch
rxml.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2018 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (rxml.h).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #ifndef __LIBRETRO_SDK_FORMAT_RXML_H__
23 #define __LIBRETRO_SDK_FORMAT_RXML_H__
24 
25 #include <retro_common_api.h>
26 
28 
29 /* Total NIH. Very trivial "XML" implementation for use in RetroArch.
30  * Error checking is minimal. Invalid documents may lead to very
31  * buggy behavior, but memory corruption should never happen.
32  *
33  * Only parts of standard that RetroArch cares about is supported.
34  * Nothing more, nothing less. "Clever" XML documents will
35  * probably break the implementation.
36  *
37  * Do *NOT* try to use this for anything else. You have been warned.
38  */
39 
41 
43 {
44  char *attrib;
45  char *value;
47 };
48 
49 struct rxml_node
50 {
51  char *name;
52  char *data;
54 
56  struct rxml_node *next;
57 
58  /* Dummy. Used by libxml2 compat.
59  * Is always set to 0, so XML_ELEMENT_NODE check goes through. */
60  int type;
61 };
62 
65 
67 
68 /* Drop const-correctness here to avoid warnings
69  * when used as libxml2 compat.
70  * xmlGetProp() returns xmlChar*, which is supposed
71  * to be passed to xmlFree(). */
72 char *rxml_node_attrib(struct rxml_node *node, const char *attrib);
73 
74 #ifdef RXML_LIBXML2_COMPAT
75 /* Compat for part of libxml2 that RetroArch uses. */
76 #define LIBXML_TEST_VERSION ((void)0)
77 typedef char xmlChar; /* It's really unsigned char, but it doesn't matter. */
78 typedef struct rxml_node *xmlNodePtr;
79 typedef void *xmlParserCtxtPtr;
80 typedef rxml_document_t *xmlDocPtr;
81 #define XML_ELEMENT_NODE (0)
82 #define xmlNewParserCtxt() ((void*)-1)
83 #define xmlCtxtReadFile(ctx, path, a, b) rxml_load_document(path)
84 #define xmlGetProp(node, prop) rxml_node_attrib(node, prop)
85 #define xmlFree(p) ((void)0)
86 #define xmlNodeGetContent(node) (node->data)
87 #define xmlDocGetRootElement(doc) rxml_root_node(doc)
88 #define xmlFreeDoc(doc) rxml_free_document(doc)
89 #define xmlFreeParserCtxt(ctx) ((void)0)
90 #endif
91 
93 
94 #endif
95 
char * data
Definition: rxml.h:52
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
struct rxml_attrib_node * next
Definition: rxml.h:46
GLsizei const GLchar ** path
Definition: glext.h:7901
char * name
Definition: rxml.h:51
Definition: rxml.h:42
struct rxml_node * next
Definition: rxml.h:56
char * attrib
Definition: rxml.h:44
Definition: rxml.c:38
rxml_document_t * rxml_load_document(const char *path)
Definition: rxml.c:412
Definition: rxml.h:49
char * rxml_node_attrib(struct rxml_node *node, const char *attrib)
Definition: rxml.c:477
typedefRETRO_BEGIN_DECLS struct rxml_document rxml_document_t
Definition: rxml.h:40
int type
Definition: rxml.h:60
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
struct rxml_node * rxml_root_node(rxml_document_t *doc)
Definition: rxml.c:43
char * value
Definition: rxml.h:45
struct rxml_attrib_node * attrib
Definition: rxml.h:53
void rxml_free_document(rxml_document_t *doc)
Definition: rxml.c:466
struct rxml_node * children
Definition: rxml.h:55