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)
{

View File

@@ -38,6 +38,7 @@ typedef struct xmpp_stanza_t {
struct xmpp_stanza_t *parent;
} XMPPStanza;
XMPPStanza* stanza_new(const char *name, const char **attributes);
XMPPStanza* parse_stanza(char *stanza_text);
#endif

View File

@@ -31,27 +31,6 @@
pthread_mutex_t stanzas_lock;
static GList *stanzas;
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;
}
void
stanza_show(XMPPStanza *stanza)
{

View File

@@ -27,7 +27,6 @@
#include "server/stanza.h"
XMPPStanza* stanza_new(const char *name, const char **attributes);
void stanza_show(XMPPStanza *stanza);
void stanza_show_all(void);
void stanza_add(XMPPStanza *stanza);