diff --git a/.gitignore b/.gitignore index 53dcda0..ccd697b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ core -server +stabber Makefile Makefile.in aclocal.m4 @@ -13,10 +13,7 @@ src/config.h.in src/config.h.in~ src/server/.deps/ src/server/.dirstamp -src/server/clients.o -src/server/server.o -src/server/parser.o -src/server/xmppclient.o +*.o src/stamp-h1 diff --git a/Makefile.am b/Makefile.am index 02615d3..b23f9c2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,2 +1,2 @@ -bin_PROGRAMS = server -server_SOURCES = src/server/server.c src/server/xmppclient.h src/server/xmppclient.c src/server/parser.h src/server/parser.c +bin_PROGRAMS = stabber +stabber_SOURCES = src/server/server.c src/server/xmppclient.h src/server/xmppclient.c src/server/parser.h src/server/parser.c src/server/stanza.h src/server/stanza.c diff --git a/src/server/parser.c b/src/server/parser.c index d89a05b..276f16d 100644 --- a/src/server/parser.c +++ b/src/server/parser.c @@ -5,6 +5,7 @@ #include "server/parser.h" #include "server/xmppclient.h" +#include "server/stanza.h" static int depth = 0; static int do_reset = 0; @@ -14,52 +15,9 @@ static stream_end_func stream_end_cb = NULL; static auth_func auth_cb = NULL; static XMPPClient *xmppclient; -typedef struct xmpp_attr_t { - const char *name; - const char *value; -} XMPPAttr; - -typedef struct xmpp_stanza_t { - const char *name; - GList *attrs; - GList *children; - GString *content; - struct xmpp_stanza_t *parent; -} XMPPStanza; - static XMPPStanza *curr_stanza; static GList *stanzas; -void -show_stanza(XMPPStanza *stanza) -{ - printf("NAME : %s\n", stanza->name); - - if (stanza->content && stanza->content->len > 0) { - printf("CONTENT: %s\n", stanza->content->str); - } - - if (stanza->attrs) { - GList *curr_attr = stanza->attrs; - while (curr_attr) { - XMPPAttr *attr = curr_attr->data; - printf("ATTR : %s='%s'\n", attr->name, attr->value); - - curr_attr = g_list_next(curr_attr); - } - } - - if (stanza->children) { - printf("CHILDREN:\n"); - GList *curr_child = stanza->children; - while (curr_child) { - XMPPStanza *child = curr_child->data; - show_stanza(child); - curr_child = g_list_next(curr_child); - } - } -} - void parser_show_stanzas(void) { diff --git a/src/server/stanza.c b/src/server/stanza.c new file mode 100644 index 0000000..2c52572 --- /dev/null +++ b/src/server/stanza.c @@ -0,0 +1,34 @@ +#include +#include + +#include "server/stanza.h" + +void +show_stanza(XMPPStanza *stanza) +{ + printf("NAME : %s\n", stanza->name); + + if (stanza->content && stanza->content->len > 0) { + printf("CONTENT: %s\n", stanza->content->str); + } + + if (stanza->attrs) { + GList *curr_attr = stanza->attrs; + while (curr_attr) { + XMPPAttr *attr = curr_attr->data; + printf("ATTR : %s='%s'\n", attr->name, attr->value); + + curr_attr = g_list_next(curr_attr); + } + } + + if (stanza->children) { + printf("CHILDREN:\n"); + GList *curr_child = stanza->children; + while (curr_child) { + XMPPStanza *child = curr_child->data; + show_stanza(child); + curr_child = g_list_next(curr_child); + } + } +} diff --git a/src/server/stanza.h b/src/server/stanza.h new file mode 100644 index 0000000..1f94b2e --- /dev/null +++ b/src/server/stanza.h @@ -0,0 +1,20 @@ +#ifndef __H_STANZA +#define __H_STANZA + +typedef struct xmpp_attr_t { + const char *name; + const char *value; +} XMPPAttr; + +typedef struct xmpp_stanza_t { + const char *name; + GList *attrs; + GList *children; + GString *content; + struct xmpp_stanza_t *parent; +} XMPPStanza; + +void +show_stanza(XMPPStanza *stanza); + +#endif