diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-05-21 15:13:50 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-05-21 15:13:50 +0000 |
commit | cb5898ff72875b9c24d7fc44cddb005f4495dff3 (patch) | |
tree | cbc164cbc25ef4771f0535b5b89dad7201c08b30 /common | |
parent | 00ce8acd7add7b70e0493fef533d1c9c54bab7b7 (diff) |
Fix SDP pattern extraction for XML
Diffstat (limited to 'common')
-rw-r--r-- | common/sdp-expat.c | 3 | ||||
-rw-r--r-- | common/sdp-glib.c | 6 | ||||
-rw-r--r-- | common/sdp-xml.c | 31 | ||||
-rw-r--r-- | common/sdp-xml.h | 5 |
4 files changed, 28 insertions, 17 deletions
diff --git a/common/sdp-expat.c b/common/sdp-expat.c index b591bbcc..b8136528 100644 --- a/common/sdp-expat.c +++ b/common/sdp-expat.c @@ -116,7 +116,8 @@ static void convert_xml_to_sdp_start(void *data, const char *el, const char **at } } - context->stack_head->data = sdp_xml_parse_datatype(el, context->stack_head); + context->stack_head->data = sdp_xml_parse_datatype(el, + context->stack_head, context->sdprec); /* Could not parse an entry */ if (context->stack_head->data == NULL) diff --git a/common/sdp-glib.c b/common/sdp-glib.c index a24464ce..f280d0d1 100644 --- a/common/sdp-glib.c +++ b/common/sdp-glib.c @@ -115,8 +115,8 @@ static void element_start(GMarkupParseContext *context, } } - ctx_data->stack_head->data = - sdp_xml_parse_datatype(element_name, ctx_data->stack_head); + ctx_data->stack_head->data = sdp_xml_parse_datatype(element_name, + ctx_data->stack_head, ctx_data->record); if (ctx_data->stack_head->data == NULL) error("Can't parse element %s", element_name); @@ -213,7 +213,7 @@ sdp_record_t *sdp_xml_parse_record(const char *data, int size) record = sdp_record_alloc(); if (!record) { - sdp_record_free(record); + free(ctx_data); return NULL; } diff --git a/common/sdp-xml.c b/common/sdp-xml.c index db07f03b..12457ea6 100644 --- a/common/sdp-xml.c +++ b/common/sdp-xml.c @@ -440,17 +440,20 @@ static sdp_data_t *sdp_xml_parse_uuid128(const char *data) return sdp_data_alloc(SDP_UUID128, &val); } -sdp_data_t *sdp_xml_parse_uuid(const char *data) +sdp_data_t *sdp_xml_parse_uuid(const char *data, sdp_record_t *record) { - int len; + sdp_data_t *uuid; char *endptr; uint32_t val; uint16_t val2; + int len; len = strlen(data); - if (len == 36) - return sdp_xml_parse_uuid128(data); + if (len == 36) { + uuid = sdp_xml_parse_uuid128(data); + goto result; + } val = strtoll(data, &endptr, 16); @@ -458,15 +461,20 @@ sdp_data_t *sdp_xml_parse_uuid(const char *data) if (*endptr != '\0') return NULL; - if (val > USHRT_MAX) - return sdp_data_alloc(SDP_UUID32, &val); + if (val > USHRT_MAX) { + uuid = sdp_data_alloc(SDP_UUID32, &val); + goto result; + } val2 = val; - return sdp_data_alloc(SDP_UUID16, &val2); + uuid = sdp_data_alloc(SDP_UUID16, &val2); - /* Should never get here */ - return NULL; +result: + if (record && uuid) + sdp_pattern_add_uuid(record, &uuid->val.uuid); + + return uuid; } sdp_data_t *sdp_xml_parse_int(const char * data, uint8_t dtd) @@ -759,7 +767,8 @@ struct sdp_xml_data *sdp_xml_data_expand(struct sdp_xml_data *elem) return elem; } -sdp_data_t *sdp_xml_parse_datatype(const char *el, struct sdp_xml_data *elem) +sdp_data_t *sdp_xml_parse_datatype(const char *el, struct sdp_xml_data *elem, + sdp_record_t *record) { const char *data = elem->text; @@ -786,7 +795,7 @@ sdp_data_t *sdp_xml_parse_datatype(const char *el, struct sdp_xml_data *elem) else if (!strcmp(el, "int128")) return sdp_xml_parse_int(data, SDP_INT128); else if (!strcmp(el, "uuid")) - return sdp_xml_parse_uuid(data); + return sdp_xml_parse_uuid(data, record); else if (!strcmp(el, "url")) return sdp_xml_parse_url(data); else if (!strcmp(el, "text")) diff --git a/common/sdp-xml.h b/common/sdp-xml.h index 2d4d7d79..1ab6bb19 100644 --- a/common/sdp-xml.h +++ b/common/sdp-xml.h @@ -37,7 +37,7 @@ sdp_data_t *sdp_xml_parse_nil(const char *data); sdp_data_t *sdp_xml_parse_text(const char *data, char encoding); sdp_data_t *sdp_xml_parse_url(const char *data); sdp_data_t *sdp_xml_parse_int(const char *data, uint8_t dtd); -sdp_data_t *sdp_xml_parse_uuid(const char *data); +sdp_data_t *sdp_xml_parse_uuid(const char *data, sdp_record_t *record); struct sdp_xml_data { char *text; /* Pointer to the current buffer */ @@ -53,7 +53,8 @@ struct sdp_xml_data *sdp_xml_data_alloc(); void sdp_xml_data_free(struct sdp_xml_data *elem); struct sdp_xml_data *sdp_xml_data_expand(struct sdp_xml_data *elem); -sdp_data_t *sdp_xml_parse_datatype(const char *el, struct sdp_xml_data *elem); +sdp_data_t *sdp_xml_parse_datatype(const char *el, struct sdp_xml_data *elem, + sdp_record_t *record); sdp_record_t *sdp_xml_parse_record(const char *data, int size); |