Module: sip-router
Branch: master
Commit: ac560678f44064bffb263e199f66029da926162b
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ac56067…
Author: pd <peter.dunkley(a)crocodile-rcs.com>
Committer: pd <peter.dunkley(a)crocodile-rcs.com>
Date: Wed Oct 19 11:40:20 2011 +0100
modules_k/alias_db: exported alias_db API for use in app_lua
---
modules_k/alias_db/alias_db.c | 30 +++++++++++++++++++++++++++++-
modules_k/alias_db/alookup.c | 10 ++--------
modules_k/alias_db/alookup.h | 2 +-
3 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/modules_k/alias_db/alias_db.c b/modules_k/alias_db/alias_db.c
index 0606cd9..c36ce1f 100644
--- a/modules_k/alias_db/alias_db.c
+++ b/modules_k/alias_db/alias_db.c
@@ -38,6 +38,7 @@
#include "../../mod_fix.h"
#include "alookup.h"
+#include "api.h"
MODULE_VERSION
@@ -53,6 +54,7 @@ static int child_init(int rank);
/* Module initialization function prototype */
static int mod_init(void);
+static int w_alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2);
/* Module parameter variables */
static str db_url = str_init(DEFAULT_RODB_URL);
@@ -69,8 +71,10 @@ db_func_t adbf; /* DB functions */
/* Exported functions */
static cmd_export_t cmds[] = {
- {"alias_db_lookup", (cmd_function)alias_db_lookup, 1, fixup_spve_null, 0,
+ {"alias_db_lookup", (cmd_function)w_alias_db_lookup, 1, fixup_spve_null, 0,
REQUEST_ROUTE|FAILURE_ROUTE},
+ {"bind_alias_db", (cmd_function)bind_alias_db, 1, 0, 0,
+ 0},
{0, 0, 0, 0, 0, 0}
};
@@ -166,3 +170,27 @@ static void destroy(void)
}
}
+static int w_alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2)
+{
+ str table_s;
+
+ if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0)
+ {
+ LM_ERR("invalid table parameter\n");
+ return -1;
+ }
+
+ return alias_db_lookup(_msg, table_s);
+}
+
+int bind_alias_db(struct alias_db_binds *pxb)
+{
+ if (pxb == NULL)
+ {
+ LM_WARN("bind_alias_db: Cannot load alias_db API into a NULL
pointer\n");
+ return -1;
+ }
+
+ pxb->alias_db_lookup = alias_db_lookup;
+ return 0;
+}
diff --git a/modules_k/alias_db/alookup.c b/modules_k/alias_db/alookup.c
index 33bb65a..f353981 100644
--- a/modules_k/alias_db/alookup.c
+++ b/modules_k/alias_db/alookup.c
@@ -70,20 +70,14 @@ static inline int rewrite_ruri(struct sip_msg* _m, char* _s)
/**
*
*/
-int alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2)
+int alias_db_lookup(struct sip_msg* _msg, str table_s)
{
- str user_s, table_s;
+ str user_s;
db_key_t db_keys[2] = {&alias_user_column, &alias_domain_column};
db_val_t db_vals[2];
db_key_t db_cols[] = {&user_column, &domain_column};
db1_res_t* db_res = NULL;
int i;
-
- if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0)
- {
- LM_ERR("invalid table parameter\n");
- return -1;
- }
if (parse_sip_msg_uri(_msg) < 0)
return -1;
diff --git a/modules_k/alias_db/alookup.h b/modules_k/alias_db/alookup.h
index 0ff0d0d..e397186 100644
--- a/modules_k/alias_db/alookup.h
+++ b/modules_k/alias_db/alookup.h
@@ -32,6 +32,6 @@
#include "../../parser/msg_parser.h"
-int alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2);
+int alias_db_lookup(struct sip_msg* _msg, str _table);
#endif /* _ALOOKUP_H_ */