Moved stanza_new function
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user