summaryrefslogtreecommitdiff
path: root/src/xml/xml.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml/xml.c')
-rw-r--r--src/xml/xml.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/xml/xml.c b/src/xml/xml.c
index 33782c4..24d544c 100644
--- a/src/xml/xml.c
+++ b/src/xml/xml.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include "xml.h"
/* parse a string into a document */
@@ -31,3 +32,21 @@ char * kai_tag_get_attr(struct kai_tag_t *t, const char *attr)
}
return NULL;
}
+
+
+long kai_tag_attr_to_long(
+ struct kai_tag_t *t, const char *attr,
+ long base, int *flag)
+{
+ char *val = kai_tag_get_attr(t, attr);
+ if (val == NULL) {
+ /* attribute not present, fall back to base */
+ if (flag != NULL)
+ *flag = 1;
+ return base;
+ }
+
+ if (flag != NULL)
+ *flag = 0;
+ return strtol(val, NULL, 10);
+}