summaryrefslogtreecommitdiffstats
path: root/src/xml.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml.c')
-rw-r--r--src/xml.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/xml.c b/src/xml.c
index 267b25e..b10b4c7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
+#include <inttypes.h>
#include <expat.h>
+#include <SDL_stdinc.h>
#include "xml.h"
#include "logging.h"
@@ -35,6 +37,26 @@ xml_unexpected_end_tag(XML_Parser p, const char *found, const char *expected)
}
void
+xml_get_uint32_attr(XML_Parser p, const char **attr, const char *name,
+ Uint32 *dest, int req)
+{
+ for (; attr[0] != NULL; attr += 2) {
+ if (strcmp(attr[0], name) == 0) {
+ if (sscanf(attr[1], "%" PRIu32, dest) == 1) {
+ return;
+ } else if (req) {
+ warn("Invalid \"%s\" attribute value", name);
+ XML_StopParser(p, XML_FALSE);
+ }
+ }
+ }
+ if (req) {
+ warn("Required attribute \"%s\" not found", name);
+ XML_StopParser(p, XML_FALSE);
+ }
+}
+
+void
xml_get_int_attr(XML_Parser p, const char **attr, const char *name,
int *dest, int req)
{