Explorar o código

speeddial(s): updated to use common sl module

Daniel-Constantin Mierla %!s(int64=15) %!d(string=hai) anos
pai
achega
621eba8a3a

+ 8 - 5
modules_s/speeddial/sdlookup.c

@@ -86,7 +86,8 @@ int sd_lookup(struct sip_msg* _msg, char* _index, char* _str2)
 	
 	tables[i].lookup_num->match[2].v.lstr = _msg->parsed_uri.user;
 
-	DBG("speeddial: Looking up (uid:%.*s,username:%.*s,did:%.*s)\n", uid.len, uid.s,
+	DBG("speeddial: Looking up (uid:%.*s,username:%.*s,did:%.*s)\n",
+			uid.len, uid.s,
 	    _msg->parsed_uri.user.len, _msg->parsed_uri.user.s,
 	    did.len, did.s);
 	
@@ -96,7 +97,8 @@ int sd_lookup(struct sip_msg* _msg, char* _index, char* _str2)
 	}
 
 	if (res == NULL) {
-		DBG("speeddial: No SIP URI found for speeddial (num:%.*s, uid:%.*s, did:%.*s)\n",
+		DBG("speeddial: No SIP URI found for speeddial (num:%.*s, uid:%.*s,"
+			" did:%.*s)\n",
 			_msg->parsed_uri.user.len,
 			_msg->parsed_uri.user.s,
 			uid.len, uid.s,
@@ -120,7 +122,8 @@ int sd_lookup(struct sip_msg* _msg, char* _index, char* _str2)
 	}
 
 	if (rec == NULL) {
-		DBG("speeddial: No usable SIP URI found for (num:%.*s, uid:%.*s, did:%.*s)\n",
+		DBG("speeddial: No usable SIP URI found for (num:%.*s, uid:%.*s,"
+			" did:%.*s)\n",
 			_msg->parsed_uri.user.len,
 			_msg->parsed_uri.user.s,
 			uid.len, uid.s,
@@ -150,13 +153,13 @@ int sd_lookup(struct sip_msg* _msg, char* _index, char* _str2)
 	return 1;
 
 err_server:
-	if (sl.reply(_msg, 500, "Server Internal Error") == -1)
+	if (slb.zreply(_msg, 500, "Server Internal Error") == -1)
 	{
 		LOG(L_ERR, "sd_lookup: Error while sending reply\n");
 	}
 	return 0;
 err_badreq:
-	if (sl.reply(_msg, 400, "Bad Request") == -1)
+	if (slb.zreply(_msg, 400, "Bad Request") == -1)
 	{
 		LOG(L_ERR, "sd_lookup: Error while sending reply\n");
 	}

+ 6 - 13
modules_s/speeddial/speeddial.c

@@ -37,7 +37,7 @@
 #include "../../dprint.h"
 #include "../../error.h"
 #include "../../mem/mem.h"
-#include "../sl/sl.h"
+#include "../../modules/sl/sl.h"
 #include "sdlookup.h"
 #include "speeddial.h"
 
@@ -71,7 +71,7 @@ struct db_table_name* tables = NULL;
 unsigned int tables_no = 0;
 
 
-sl_api_t sl;
+sl_api_t slb;
 
 
 /* Exported functions */
@@ -176,21 +176,14 @@ static int child_init(int rank)
  */
 static int mod_init(void)
 {
-	bind_sl_t bind_sl;
-
 	DBG("speeddial module - initializing\n");
 
-	/**
-	 * We will need sl_send_reply from stateless
-	 * module for sending replies
-	 */
-
-        bind_sl = (bind_sl_t)find_export("bind_sl", 0, 0);
-	if (!bind_sl) {
-		ERR("This module requires sl module\n");
+	/* bind the SL API */
+	if (sl_load_api(&slb)!=0) {
+		LM_ERR("cannot bind to SL API\n");
 		return -1;
 	}
-	if (bind_sl(&sl) < 0) return -1;
+
 	return 0;
 }
 

+ 2 - 2
modules_s/speeddial/speeddial.h

@@ -34,7 +34,7 @@
 #define _SPEEDDIAL_H_
 
 #include "../../lib/srdb2/db.h"
-#include "../sl/sl.h"
+#include "../../modules/sl/sl.h"
 #include "../../parser/msg_parser.h"
 
 
@@ -55,6 +55,6 @@ struct db_table_name {
 extern struct db_table_name* tables;
 extern unsigned int tables_no;
 
-extern sl_api_t sl;
+extern sl_api_t slb;
 
 #endif /* _SPEEDDIAL_H_ */