diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-07-17 19:19:35 -0400 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-07-17 19:19:35 -0400 |
commit | 2ee5e732c456c722b1456bdbc8b203098681b4de (patch) | |
tree | b71550eb13832ea37d3a5a5ae52b6990b28f2da2 /dpip | |
parent | d53595dd6d4a1d6431aa8d439c63e30cb27525a0 (diff) |
Added a_Dpip_get_attr_l() to DPIP's API
Diffstat (limited to 'dpip')
-rw-r--r-- | dpip/dpip.c | 18 | ||||
-rw-r--r-- | dpip/dpip.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/dpip/dpip.c b/dpip/dpip.c index 5d83a2e9..bf6667d3 100644 --- a/dpip/dpip.c +++ b/dpip/dpip.c @@ -107,17 +107,18 @@ char *a_Dpip_build_cmd(const char *format, ...) } /* - * Task: given a tag and an attribute name, return its value. - * (stuffing of ' is removed here) + * Task: given a tag, its size and an attribute name, return the + * attribute value (stuffing of ' is removed here). + * * Return value: the attribute value, or NULL if not present or malformed. */ -char *a_Dpip_get_attr(char *tag, size_t tagsize, const char *attrname) +char *a_Dpip_get_attr_l(char *tag, size_t tagsize, const char *attrname) { uint_t i, n = 0, found = 0; char *p, *q, *start, *val = NULL; DpipTagParsingState state = SEEK_NAME; - if (!attrname || !*attrname) + if (!tag || !tagsize || !attrname || !*attrname) return NULL; for (i = 1; i < tagsize && !found; ++i) { @@ -164,5 +165,14 @@ char *a_Dpip_get_attr(char *tag, size_t tagsize, const char *attrname) return val; } +/* + * Task: given a tag and an attribute name, return its value. + * Return value: the attribute value, or NULL if not present or malformed. + */ +char *a_Dpip_get_attr(char *tag, const char *attrname) +{ + return (tag ? a_Dpip_get_attr_l(tag, strlen(tag), attrname) : NULL); +} + /* ------------------------------------------------------------------------- */ diff --git a/dpip/dpip.h b/dpip/dpip.h index 29bb5fcf..584bf89e 100644 --- a/dpip/dpip.h +++ b/dpip/dpip.h @@ -23,7 +23,8 @@ char *a_Dpip_build_cmd(const char *format, ...); * (dpip character escaping is removed here) * Return value: the attribute value, or NULL if not present or malformed. */ -char *a_Dpip_get_attr(char *tag, size_t tagsize, const char *attrname); +char *a_Dpip_get_attr(char *tag, const char *attrname); +char *a_Dpip_get_attr_l(char *tag, size_t tagsize, const char *attrname); #ifdef __cplusplus |