Abstracted XML parser library and switched to autotools building.
expat is still the default parser, but libxml2 can also be used via an option to the configure script. New parsers can easily be added by implementing a parser_foo.c that uses the interface defined in parser.h.
This commit is contained in:
39
src/stanza.c
39
src/stanza.c
@@ -400,45 +400,6 @@ char *xmpp_stanza_get_name(xmpp_stanza_t * const stanza)
|
||||
return stanza->data;
|
||||
}
|
||||
|
||||
/** Set or replace attributes on a stanza.
|
||||
* This function replaces all previous attributes (if any) with the
|
||||
* attributes given. It is used primarily by the XML parser during
|
||||
* stanza creation. All strings in the array are copied before placing them
|
||||
* inside the stanza object.
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
* @param attr an array of strings with the attributes in the following
|
||||
* format: attr[i] = attribute name, attr[i+1] = attribute value
|
||||
*
|
||||
* @return XMPP_EOK on success, a number less than 0 on failure (XMPP_EMEM,
|
||||
* XMPP_EINVOP)
|
||||
*
|
||||
* @ingroup Stanza
|
||||
*/
|
||||
int xmpp_stanza_set_attributes(xmpp_stanza_t * const stanza,
|
||||
const char * const * const attr)
|
||||
{
|
||||
int i;
|
||||
char *value;
|
||||
|
||||
if (stanza->attributes != NULL)
|
||||
hash_release(stanza->attributes);
|
||||
|
||||
stanza->attributes = hash_new(stanza->ctx, 8, xmpp_free);
|
||||
if (!stanza->attributes) return XMPP_EMEM;
|
||||
|
||||
for (i = 0; attr[i]; i += 2) {
|
||||
value = xmpp_strdup(stanza->ctx, attr[i + 1]);
|
||||
if (!value) {
|
||||
/* FIXME: memory allocation error */
|
||||
continue;
|
||||
}
|
||||
hash_add(stanza->attributes, attr[i], value);
|
||||
}
|
||||
|
||||
return XMPP_EOK;
|
||||
}
|
||||
|
||||
/** Count the attributes in a stanza object.
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
|
||||
Reference in New Issue
Block a user