Moved more functions to stanza module

This commit is contained in:
James Booth
2015-05-15 00:12:47 +01:00
parent c6fe602fd8
commit debac69cbb
4 changed files with 32 additions and 22 deletions

View File

@@ -9,26 +9,14 @@
static int depth = 0;
static int do_reset = 0;
static XML_Parser parser;
static XMPPClient *xmppclient;
static XMPPStanza *curr_stanza;
static stream_start_func stream_start_cb = NULL;
static stream_end_func stream_end_cb = NULL;
static auth_func auth_cb = NULL;
static XMPPClient *xmppclient;
static XMPPStanza *curr_stanza;
static GList *stanzas;
void
parser_show_stanzas(void)
{
GList *curr = stanzas;
while (curr) {
XMPPStanza *stanza = curr->data;
show_stanza(stanza);
printf("\n");
curr = g_list_next(curr);
}
}
static void
start_element(void *data, const char *element, const char **attribute)
@@ -76,7 +64,7 @@ end_element(void *data, const char *element)
curr_stanza->parent->children = g_list_append(curr_stanza->parent->children, curr_stanza);
curr_stanza = curr_stanza->parent;
} else {
stanzas = g_list_append(stanzas, curr_stanza);
stanza_add(curr_stanza);
}
if (depth == 0) {

View File

@@ -7,6 +7,7 @@
#include "server/xmppclient.h"
#include "server/parser.h"
#include "server/stanza.h"
#define XML_START "<?xml version=\"1.0\"?>"
@@ -221,7 +222,7 @@ int main(int argc , char *argv[])
printf("RECV: ");
listen_to(client);
parser_show_stanzas();
stanza_show_all();
//
// res = listen_for(client, STREAM_REQ);

View File

@@ -3,8 +3,10 @@
#include "server/stanza.h"
static GList *stanzas;
void
show_stanza(XMPPStanza *stanza)
stanza_show(XMPPStanza *stanza)
{
printf("NAME : %s\n", stanza->name);
@@ -27,8 +29,26 @@ show_stanza(XMPPStanza *stanza)
GList *curr_child = stanza->children;
while (curr_child) {
XMPPStanza *child = curr_child->data;
show_stanza(child);
stanza_show(child);
curr_child = g_list_next(curr_child);
}
}
}
void
stanza_show_all(void)
{
GList *curr = stanzas;
while (curr) {
XMPPStanza *stanza = curr->data;
stanza_show(stanza);
printf("\n");
curr = g_list_next(curr);
}
}
void
stanza_add(XMPPStanza *stanza)
{
stanzas = g_list_append(stanzas, stanza);
}

View File

@@ -14,7 +14,8 @@ typedef struct xmpp_stanza_t {
struct xmpp_stanza_t *parent;
} XMPPStanza;
void
show_stanza(XMPPStanza *stanza);
void stanza_show(XMPPStanza *stanza);
void stanza_show_all(void);
void stanza_add(XMPPStanza *stanza);
#endif