7#ifdef __MINGW64_VERSION_MAJOR
15#define LIBXML_ATTR_FORMAT( fmt, args )
18#include "libxml/parser.h"
19#include "libxml/xmlwriter.h"
22#include "attributes.h"
25#include "opengl_tex.h"
27#define XML_NODE_START 1
28#define XML_NODE_TEXT 3
33#define xml_onlyNodes( n ) \
34 if ( ( ( n ) == NULL ) || ( ( n )->type != XML_NODE_START ) ) \
38#define xml_isNode( n, s ) \
39 ( ( n != NULL ) && ( ( n )->type == XML_NODE_START ) && \
40 ( strcmp( (char *)( n )->name, s ) == 0 ) )
43#define xml_nextNode( n ) ( ( n != NULL ) && ( ( n = n->next ) != NULL ) )
46#define xml_raw( n ) ( (char *)( n )->children->content )
48 ( ( ( n )->children == NULL ) ? NULL : (char *)( n )->children->content )
49#define xml_getInt( n ) \
50 ( ( xml_get( n ) == NULL ) ? 0 : strtol( xml_raw( n ), NULL, 10 ) )
51#define xml_getUInt( n ) \
52 ( ( xml_get( n ) == NULL ) ? 0 : strtoul( xml_raw( n ), NULL, 10 ) )
53#define xml_getLong( n ) \
54 ( ( xml_get( n ) == NULL ) ? 0 : strtoll( xml_raw( n ), NULL, 10 ) )
55#define xml_getULong( n ) \
56 ( ( xml_get( n ) == NULL ) ? 0 : strtoull( xml_raw( n ), NULL, 10 ) )
57#define xml_getFloat( n ) \
58 ( ( xml_get( n ) == NULL ) ? 0. : strtod( xml_raw( n ), NULL ) )
59#define xml_getStrd( n ) \
60 ( ( xml_get( n ) == NULL ) ? NULL : strdup( xml_raw( n ) ) )
65#define xmlr_int( n, s, i ) \
67 if ( xml_isNode( n, s ) ) { \
68 i = xml_getInt( n ); \
72#define xmlr_uint( n, s, i ) \
74 if ( xml_isNode( n, s ) ) { \
75 i = xml_getUInt( n ); \
79#define xmlr_long( n, s, l ) \
81 if ( xml_isNode( n, s ) ) { \
82 l = xml_getLong( n ); \
86#define xmlr_ulong( n, s, l ) \
88 if ( xml_isNode( n, s ) ) { \
89 l = xml_getULong( n ); \
93#define xmlr_float( n, s, f ) \
95 if ( xml_isNode( n, s ) ) { \
96 f = xml_getFloat( n ); \
100#define xmlr_str( n, s, str ) \
102 if ( xml_isNode( n, s ) ) { \
103 str = xml_get( n ); \
107#define xmlr_strd( n, s, str ) \
109 if ( xml_isNode( n, s ) ) { \
110 if ( str != NULL ) { \
111 WARN( "Node '%s' already loaded and being replaced from '%s' to " \
113 s, str, xml_raw( n ) ); \
116 str = ( ( xml_get( n ) == NULL ) ? NULL : strdup( xml_raw( n ) ) ); \
120#define xmlr_strd_free( n, s, str ) \
122 if ( xml_isNode( n, s ) ) { \
125 str = ( ( xml_get( n ) == NULL ) ? NULL : strdup( xml_raw( n ) ) ); \
134static inline char *nxml_trace_strdup(
void *ptr )
136 void *pointer_from_libxml2 = ptr;
137 char *ret = ( ptr == NULL ) ? NULL : strdup( ptr );
138 free( pointer_from_libxml2 );
142#define nxml_trace_strdup( ptr ) ( (char *)( ptr ) )
146#define xmlr_attr_strd( n, s, a ) \
147 a = nxml_trace_strdup( xmlGetProp( n, (xmlChar *)s ) )
148#define xmlr_attr_strd_free( n, s, a ) \
152 a = nxml_trace_strdup( xmlGetProp( n, (xmlChar *)s ) ); \
156#define xmlr_attr_int_def( n, s, a, def ) \
158 xmlr_attr_strd( n, s, char *T ); \
159 a = T == NULL ? def : strtol( T, NULL, 10 ); \
162#define xmlr_attr_uint_def( n, s, a, def ) \
164 xmlr_attr_strd( n, s, char *T ); \
165 a = T == NULL ? def : strtoul( T, NULL, 10 ); \
168#define xmlr_attr_long_def( n, s, a, def ) \
170 xmlr_attr_strd( n, s, char *T ); \
171 a = T == NULL ? def : strtoll( T, NULL, 10 ); \
174#define xmlr_attr_ulong_def( n, s, a, def ) \
176 xmlr_attr_strd( n, s, char *T ); \
177 a = T == NULL ? def : strtoull( T, NULL, 10 ); \
180#define xmlr_attr_float_def( n, s, a, def ) \
182 xmlr_attr_strd( n, s, char *T ); \
183 a = T == NULL ? def : strtod( T, NULL ); \
187#define xmlr_attr_int( n, s, a ) xmlr_attr_int_def( n, s, a, 0 )
188#define xmlr_attr_uint( n, s, a ) xmlr_attr_uint_def( n, s, a, 0 )
189#define xmlr_attr_long( n, s, a ) xmlr_attr_long_def( n, s, a, 0 )
190#define xmlr_attr_ulong( n, s, a ) xmlr_attr_ulong_def( n, s, a, 0 )
191#define xmlr_attr_float( n, s, a ) xmlr_attr_float_def( n, s, a, 0. )
193#define xmlr_attr_int_opt( n, s, a ) xmlr_attr_int_def( n, s, a, a )
194#define xmlr_attr_uint_opt( n, s, a ) xmlr_attr_uint_def( n, s, a, a )
195#define xmlr_attr_long_opt( n, s, a ) xmlr_attr_long_def( n, s, a, a )
196#define xmlr_attr_ulong_opt( n, s, a ) xmlr_attr_ulong_def( n, s, a, a )
197#define xmlr_attr_float_opt( n, s, a ) xmlr_attr_float_def( n, s, a, a )
203#define xmlw_startElem( w, str ) \
205 if ( xmlTextWriterStartElement( w, (xmlChar *)str ) < 0 ) { \
206 WARN( "xmlw: unable to create start element" ); \
210#define xmlw_endElem( w ) \
212 if ( xmlTextWriterEndElement( w ) < 0 ) { \
213 WARN( "xmlw: unable to create end element" ); \
218#define xmlw_elemEmpty( w, n ) \
220 xmlw_startElem( w, n ); \
223#define xmlw_elem( w, n, str, ... ) \
225 if ( xmlTextWriterWriteFormatElement( w, (xmlChar *)n, str, \
226 ##__VA_ARGS__ ) < 0 ) { \
227 WARN( "xmlw: unable to write format element" ); \
231#define xmlw_raw( w, b, l ) \
233 if ( xmlTextWriterWriteRawLen( w, (xmlChar *)b, l ) < 0 ) { \
234 WARN( "xmlw: unable to write raw element" ); \
238#define xmlw_attr_raw( w, str, val ) \
240 if ( xmlTextWriterWriteAttribute( w, (xmlChar *)str, (xmlChar *)val ) < \
242 WARN( "xmlw: unable to write element attribute" ); \
246#define xmlw_attr( w, str, ... ) \
248 if ( xmlTextWriterWriteFormatAttribute( w, (xmlChar *)str, \
249 ##__VA_ARGS__ ) < 0 ) { \
250 WARN( "xmlw: unable to write element attribute" ); \
254#define xmlw_str( w, str, ... ) \
256 if ( xmlTextWriterWriteFormatString( w, str, ##__VA_ARGS__ ) < 0 ) { \
257 WARN( "xmlw: unable to write element data" ); \
262#define xmlw_start( w ) \
264 if ( xmlTextWriterStartDocument( writer, NULL, "UTF-8", NULL ) < 0 ) { \
265 WARN( "xmlw: unable to start document" ); \
269#define xmlw_done( w ) \
271 if ( xmlTextWriterEndDocument( w ) < 0 ) { \
272 WARN( "xmlw: unable to end document" ); \
282 int defsx,
int defsy,
283 const unsigned int flags );
284int xml_parseTime( xmlNodePtr node, time_t *t );
285int xml_parseNTime( xmlNodePtr node, ntime_t *t );
291int xmlw_saveTime( xmlTextWriterPtr writer,
const char *name, time_t t );
292int xmlw_saveNTime( xmlTextWriterPtr writer,
const char *name, ntime_t t );
glTexture * xml_parseTexture(xmlNodePtr node, const char *path, int defsx, int defsy, const unsigned int flags)
Parses a texture handling the sx and sy elements.
void xmlw_setParams(xmlTextWriterPtr writer)
Sets up the standard xml write parameters.
xmlDocPtr xml_parsePhysFS(const char *filename)
Analogous to xmlParseMemory/xmlParseFile.
Abstraction for rendering sprite sheets.