[sr-dev] git:master: * modules_s/xmlrpc: allow use of k ls module api

Juha Heinanen jh at tutpro.com
Sat Jul 4 21:38:21 CEST 2009


Module: sip-router
Branch: master
Commit: f90164d0f430ab891f29e82125a56eddc3cf319a
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f90164d0f430ab891f29e82125a56eddc3cf319a

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date:   Sat Jul  4 22:36:41 2009 +0300

* modules_s/xmlrpc: allow use of k ls module api

- Added Makefile #define for choosing between s and k sl API.

---

 modules_s/xmlrpc/Makefile |    8 +++++++-
 modules_s/xmlrpc/xmlrpc.c |   29 +++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/modules_s/xmlrpc/Makefile b/modules_s/xmlrpc/Makefile
index f0d76c2..93651a6 100644
--- a/modules_s/xmlrpc/Makefile
+++ b/modules_s/xmlrpc/Makefile
@@ -3,6 +3,9 @@
 # 
 # WARNING: do not run this directly, it should be run by the master Makefile
 
+# Set to true if you want to use K sl module API
+USE_K_SL_API=false
+
 include ../../Makefile.defs
 auto_gen=
 NAME=xmlrpc.so
@@ -11,5 +14,8 @@ LIBS +=-lxml2
 
 DEFS+=-DSER_MOD_INTERFACE
 
-include ../../Makefile.modules
+ifeq ($(USE_K_SL_API),true)
+DEFS+=-DUSE_K_SL_API
+endif
 
+include ../../Makefile.modules
diff --git a/modules_s/xmlrpc/xmlrpc.c b/modules_s/xmlrpc/xmlrpc.c
index f97bf89..6b90298 100644
--- a/modules_s/xmlrpc/xmlrpc.c
+++ b/modules_s/xmlrpc/xmlrpc.c
@@ -55,7 +55,11 @@
 #include "../../msg_translator.h"
 #include "../../select.h"
 #include "../../receive.h" /* needed by process_rpc / receive_msg() */
+#ifdef USE_K_SL_API
+#include "../../modules_k/sl/sl_api.h"
+#else
 #include "../sl/sl.h"
+#endif
 #include "../../nonsip_hooks.h"
 #include "../../action.h" /* run_actions */
 #include "../../script_cb.h" /* exec_*_script_cb */
@@ -378,7 +382,11 @@ static char* xmlrpc_route=0; /* default is the main route */
 /** Reference to the sl (stateless replies) module of SER The sl module of SER
  * is needed so that the xmlrpc SER module can send replies back to clients
  */
+#ifdef USE_K_SL_API
+struct sl_binds sl;
+#else
 sl_api_t sl;
+#endif
 
 static int xmlrpc_route_no=DEFAULT_RT;
 
@@ -725,10 +733,20 @@ static int send_reply(sip_msg_t* msg, str* body)
 		return -1;
 	}
 
+#ifdef USE_K_SL_API
+	str s;
+	s.s = "OK";
+	s.len = 2;
+	if (sl.send_reply(msg, 200, &s) == -1) {
+		ERR("Error while sending reply\n");
+		return -1;
+	}
+#else
 	if (sl.reply(msg, 200, "OK") == -1) {
 		ERR("Error while sending reply\n");
 		return -1;
 	}
+#endif
 
 	return 0;
 }
@@ -1961,7 +1979,6 @@ select_row_t xmlrpc_sel[] = {
 
 static int mod_init(void)
 {
-	bind_sl_t bind_sl;
 	struct nonsip_hook nsh;
 	int route_no;
 	
@@ -1984,12 +2001,20 @@ static int mod_init(void)
               * We will need sl_send_reply from stateless
 	      * module for sending replies
 	      */
-        bind_sl = (bind_sl_t)find_export("bind_sl", 0, 0);
+#ifdef USE_K_SL_API
+	if (load_sl_api(&sl)!=0) {
+		ERR("This module requires sl module\n");
+		return -1;
+	}
+#else
+    	bind_sl_t bind_sl;
+	bind_sl = (bind_sl_t)find_export("bind_sl", 0, 0);
 	if (!bind_sl) {
 		ERR("This module requires sl module\n");
 		return -1;
 	}
 	if (bind_sl(&sl) < 0) return -1;
+#endif
 
 	func_param.send = (rpc_send_f)rpc_send;
 	func_param.fault = (rpc_fault_f)rpc_fault;




More information about the sr-dev mailing list