From dab79fabb96eead4240a11c7c31a0b9cc5321f2e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 6 Jun 2015 22:41:24 +0100 Subject: [PATCH] Moved stanza_new function --- src/server/stanza.c | 21 +++++++++++++++++++++ src/server/stanza.h | 1 + src/server/stanzas.c | 21 --------------------- src/server/stanzas.h | 1 - 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/server/stanza.c b/src/server/stanza.c index 177b6b8..dd26c89 100644 --- a/src/server/stanza.c +++ b/src/server/stanza.c @@ -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) { diff --git a/src/server/stanza.h b/src/server/stanza.h index d8a3b42..e76860b 100644 --- a/src/server/stanza.h +++ b/src/server/stanza.h @@ -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 diff --git a/src/server/stanzas.c b/src/server/stanzas.c index 322ea1a..864a6b9 100644 --- a/src/server/stanzas.c +++ b/src/server/stanzas.c @@ -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) { diff --git a/src/server/stanzas.h b/src/server/stanzas.h index afe23ed..3eaec5a 100644 --- a/src/server/stanzas.h +++ b/src/server/stanzas.h @@ -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);