Added stanza module
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
core
|
core
|
||||||
server
|
stabber
|
||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
@@ -13,10 +13,7 @@ src/config.h.in
|
|||||||
src/config.h.in~
|
src/config.h.in~
|
||||||
src/server/.deps/
|
src/server/.deps/
|
||||||
src/server/.dirstamp
|
src/server/.dirstamp
|
||||||
src/server/clients.o
|
*.o
|
||||||
src/server/server.o
|
|
||||||
src/server/parser.o
|
|
||||||
src/server/xmppclient.o
|
|
||||||
|
|
||||||
src/stamp-h1
|
src/stamp-h1
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
bin_PROGRAMS = server
|
bin_PROGRAMS = stabber
|
||||||
server_SOURCES = src/server/server.c src/server/xmppclient.h src/server/xmppclient.c src/server/parser.h src/server/parser.c
|
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
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "server/parser.h"
|
#include "server/parser.h"
|
||||||
#include "server/xmppclient.h"
|
#include "server/xmppclient.h"
|
||||||
|
#include "server/stanza.h"
|
||||||
|
|
||||||
static int depth = 0;
|
static int depth = 0;
|
||||||
static int do_reset = 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 auth_func auth_cb = NULL;
|
||||||
static XMPPClient *xmppclient;
|
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 XMPPStanza *curr_stanza;
|
||||||
static GList *stanzas;
|
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
|
void
|
||||||
parser_show_stanzas(void)
|
parser_show_stanzas(void)
|
||||||
{
|
{
|
||||||
|
|||||||
34
src/server/stanza.c
Normal file
34
src/server/stanza.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/server/stanza.h
Normal file
20
src/server/stanza.h
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user