Moved stanza_new function

This commit is contained in:
James Booth
2015-06-06 22:41:24 +01:00
parent ddd1bf99a4
commit dab79fabb9
4 changed files with 22 additions and 22 deletions

View File

@@ -32,6 +32,27 @@ typedef struct parse_state_t {
XMPPStanza *curr_stanza;
} ParseState;
XMPPStanza*
stanza_new(const char *name, const char **attributes)
{
XMPPStanza *stanza = malloc(sizeof(XMPPStanza));
stanza->name = strdup(name);
stanza->content = NULL;
stanza->children = NULL;
stanza->attrs = NULL;
if (attributes[0]) {
int i;
for (i = 0; attributes[i]; i += 2) {
XMPPAttr *attr = malloc(sizeof(XMPPAttr));
attr->name = strdup(attributes[i]);
attr->value = strdup(attributes[i+1]);
stanza->attrs = g_list_append(stanza->attrs, attr);
}
}
return stanza;
}
static void
start_element(void *data, const char *element, const char **attributes)
{