diff options
| author | Marcel Holtmann <marcel@holtmann.org> | 2007-01-20 16:56:52 +0000 | 
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2007-01-20 16:56:52 +0000 | 
| commit | 5e43e2ef30c178c13a81aaafeacd06b3e8cd7a65 (patch) | |
| tree | 039dd16c81005b08632a5e50b4274cbbd3ac48b5 | |
| parent | bb3cd7888177a4d0e23a5790d3fe26f008345164 (diff) | |
Add example of GLib based parser
| -rw-r--r-- | common/sdp-glib.c | 28 | 
1 files changed, 28 insertions, 0 deletions
| diff --git a/common/sdp-glib.c b/common/sdp-glib.c index 15212994..fa0e8a17 100644 --- a/common/sdp-glib.c +++ b/common/sdp-glib.c @@ -27,9 +27,37 @@  #include <glib.h> +#include "logging.h"  #include "sdp-xml.h" +static void element_start(GMarkupParseContext *context, +		const gchar *element_name, const gchar **attribute_names, +		const gchar **attribute_values, gpointer user_data, GError **error) +{ +	debug("<%s>", element_name); +} + +static void element_end(GMarkupParseContext *context, +		const gchar *element_name, gpointer user_data, GError **error) +{ +	debug("</%s>", element_name); +} + +static GMarkupParser parser = { +	element_start, element_end, NULL, NULL, NULL +}; +  sdp_record_t *sdp_xml_parse_record(const char *data, int size)  { +	GMarkupParseContext *ctx; + +	ctx = g_markup_parse_context_new(&parser, 0, NULL, NULL); + +	if (g_markup_parse_context_parse(ctx, data, size, NULL) == FALSE) { +		error("XML parsing error"); +	} + +	g_markup_parse_context_free(ctx); +  	return NULL;  } | 
