From 99cddc64242598cc486062e921c327bdb2b1aae7 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 17 Aug 2005 15:16:22 +0000 Subject: [PATCH] added external file to hold the commonly used jabber XML git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@488 9efc2488-bf62-4759-914b-345cdb29e865 --- src/jserver/jserver-c.c | 21 +++++++-------------- src/jserver/jserver-c.h | 1 + src/jserver/jserver-c_session.c | 10 +++------- src/jserver/jserver-c_session.h | 2 ++ src/jserver/jstrings.h | 17 +++++++++++++++++ 5 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 src/jserver/jstrings.h diff --git a/src/jserver/jserver-c.c b/src/jserver/jserver-c.c index d7e923e..9590708 100644 --- a/src/jserver/jserver-c.c +++ b/src/jserver/jserver-c.c @@ -1,16 +1,5 @@ #include "jserver-c.h" -/* ------------------------------------------------ - some pre-packaged Jabber XML - ------------------------------------------------ */ -static const char* xml_parse_error = "" - "" - "syntax error"; - -static const char* xml_login_ok = ""; - - jserver* jserver_init() { jserver* js = safe_malloc(sizeof(jserver)); js->mgr = safe_malloc(sizeof(socket_manager)); @@ -112,7 +101,8 @@ void jserver_client_login_ok(void* blob) { jclient_node* node = (jclient_node*) blob; if(node == NULL) return; info_handler("Client logging in ok => %d", node->id); - jserver_send_id(node->id, xml_login_ok); + //jserver_send_id(node->id, xml_login_ok); + jserver_send_id(node->id, JSTRING_LOGIN_OK); } void jserver_client_handle_msg( @@ -249,10 +239,13 @@ int jserver_send(jserver* js, int from_id, char* to_addr, const char* msg_xml) { info_handler("replying with error..."); char buf[2048]; memset(buf, 0, 2048); + /* snprintf(buf, 2047, "" "NOT ADDING BODY", to_addr, from->addr ); + */ + snprintf(buf, 2047, JSTRING_NO_RECIPIENT, to_addr, from->addr ); jserver_send_id(from_id, buf); } } @@ -299,7 +292,8 @@ void jserver_handle_request(void* js_blob, if(_jserver_push_client_data(node, data) == -1) { warning_handler("Client sent bad data, disconnecting..."); - jserver_send_id(node->id, xml_parse_error); + //jserver_send_id(node->id, xml_parse_error); + jserver_send_id(node->id, JSTRING_PARSE_ERROR); _jserver_remove_client(js, node->addr); } else { @@ -310,4 +304,3 @@ void jserver_handle_request(void* js_blob, - diff --git a/src/jserver/jserver-c.h b/src/jserver/jserver-c.h index 36026ec..d215a12 100644 --- a/src/jserver/jserver-c.h +++ b/src/jserver/jserver-c.h @@ -2,6 +2,7 @@ #include "logging.h" #include "socket_bundle.h" #include "jserver-c_session.h" +#include "jstrings.h" diff --git a/src/jserver/jserver-c_session.c b/src/jserver/jserver-c_session.c index 4652ccb..7c69c1c 100644 --- a/src/jserver/jserver-c_session.c +++ b/src/jserver/jserver-c_session.c @@ -83,13 +83,9 @@ void sax_start_element( debug_handler("jserver-c_session received opening stream from client on domain %s", session->current_domain); - char buf[512]; - memset(buf,0,512); - - /* reply with the stock jabber login response */ - sprintf(buf, "", - session->current_domain, from_domain); + char buf[1024]; + memset(buf,0,1024); + snprintf(buf, 1023, JSTRING_START_STREAM, session->current_domain, from_domain); debug_handler("Session Sending: %s", buf); diff --git a/src/jserver/jserver-c_session.h b/src/jserver/jserver-c_session.h index 9761339..d90b048 100644 --- a/src/jserver/jserver-c_session.h +++ b/src/jserver/jserver-c_session.h @@ -3,6 +3,8 @@ #include "utils.h" #include "logging.h" +#include "jstrings.h" + #include #include diff --git a/src/jserver/jstrings.h b/src/jserver/jstrings.h new file mode 100644 index 0000000..bc9878c --- /dev/null +++ b/src/jserver/jstrings.h @@ -0,0 +1,17 @@ +/* ------------------------------------------------ + some pre-packaged Jabber XML + ------------------------------------------------ */ + +#ifndef _JSTRINGS_H_ +#define _JSTRINGS_H_ + +#define JSTRING_START_STREAM "" /* this will need to by dynamic when we add login handling */ + + +#define JSTRING_PARSE_ERROR "syntax error" + +#define JSTRING_LOGIN_OK "" + +#define JSTRING_NO_RECIPIENT "NOT ADDING BODY" + +#endif -- 2.11.0