summaryrefslogtreecommitdiff
path: root/src/xml/xml.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-02-04 00:27:55 -0600
committersanine <sanine.not@pm.me>2023-02-04 00:27:55 -0600
commit0bb180e4ddeebf6d219a38b862ce3e8238f99c54 (patch)
tree9556fd77d16cdcee69ff0c9c0765c408ee88ae19 /src/xml/xml.c
parent6292c2bce712dcca01ded960dc5f93528da2b9ce (diff)
add kai_tag_attr_to_dup()
Diffstat (limited to 'src/xml/xml.c')
-rw-r--r--src/xml/xml.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/xml/xml.c b/src/xml/xml.c
index 24d544c..ee3c879 100644
--- a/src/xml/xml.c
+++ b/src/xml/xml.c
@@ -35,18 +35,26 @@ char * kai_tag_get_attr(struct kai_tag_t *t, const char *attr)
long kai_tag_attr_to_long(
- struct kai_tag_t *t, const char *attr,
- long base, int *flag)
+ struct kai_tag_t *t, const char *attr, long base)
{
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;
}
+ else {
+ return strtol(val, NULL, 10);
+ }
+}
+
- if (flag != NULL)
- *flag = 0;
- return strtol(val, NULL, 10);
+char *kai_tag_attr_to_dup(struct kai_tag_t *t, const char *attr)
+{
+ char *val = kai_tag_get_attr(t, attr);
+ if (val == NULL) {
+ return NULL;
+ }
+ else {
+ return strdup(val);
+ }
}