diff options
Diffstat (limited to 'src/xml/xml.c')
-rw-r--r-- | src/xml/xml.c | 22 |
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); + } } |