[sr-dev] git:master:a7bedbdd: app_python: proper usage of pv in cfg function parameters

Daniel-Constantin Mierla miconda at gmail.com
Fri Feb 10 12:03:32 CET 2017


Module: kamailio
Branch: master
Commit: a7bedbddc9865f878659aa1b44719d3265361127
URL: https://github.com/kamailio/kamailio/commit/a7bedbddc9865f878659aa1b44719d3265361127

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-02-10T11:59:36+01:00

app_python: proper usage of pv in cfg function parameters

---

Modified: src/modules/app_python/app_python_mod.c
Modified: src/modules/app_python/python_exec.c

---

Diff:  https://github.com/kamailio/kamailio/commit/a7bedbddc9865f878659aa1b44719d3265361127.diff
Patch: https://github.com/kamailio/kamailio/commit/a7bedbddc9865f878659aa1b44719d3265361127.patch

---

diff --git a/src/modules/app_python/app_python_mod.c b/src/modules/app_python/app_python_mod.c
index 2901c63..6f3e51d 100644
--- a/src/modules/app_python/app_python_mod.c
+++ b/src/modules/app_python/app_python_mod.c
@@ -24,6 +24,7 @@
 
 #include "../../core/str.h"
 #include "../../core/sr_module.h"
+#include "../../core/mod_fix.h"
 #include "../../core/kemi.h"
 
 #include "python_exec.h"
@@ -68,8 +69,10 @@ static param_export_t params[]={
  * Exported functions
  */
 static cmd_export_t cmds[] = {
-	{ "python_exec", (cmd_function)python_exec1, 1,  NULL, 0,	ANY_ROUTE },
-	{ "python_exec", (cmd_function)python_exec2, 2,  NULL, 0,	ANY_ROUTE },
+	{ "python_exec", (cmd_function)python_exec1, 1,  fixup_spve_null,
+		0,	ANY_ROUTE },
+	{ "python_exec", (cmd_function)python_exec2, 2,  fixup_spve_spve,
+		0,	ANY_ROUTE },
 	{ 0, 0, 0, 0, 0, 0 }
 };
 
diff --git a/src/modules/app_python/python_exec.c b/src/modules/app_python/python_exec.c
index 506c23a..2bf7ed1 100644
--- a/src/modules/app_python/python_exec.c
+++ b/src/modules/app_python/python_exec.c
@@ -28,6 +28,7 @@
 #include "../../core/dprint.h"
 #include "../../core/action.h"
 #include "../../core/config.h"
+#include "../../core/mod_fix.h"
 #include "../../core/parser/parse_uri.h"
 
 #include "python_exec.h"
@@ -183,7 +184,12 @@ int apy_exec(sip_msg_t *_msg, char *fname, char *fparam, int emode)
  */
 int python_exec1(sip_msg_t *_msg, char *method_name, char *foobar)
 {
-	return apy_exec(_msg, method_name, NULL, 1);
+	str method = STR_NULL;
+	if(fixup_get_svalue(_msg, (gparam_t*)method_name, &method)<0) {
+		LM_ERR("cannot get the python method to be executed\n");
+		return -1;
+	}
+	return apy_exec(_msg, method.s, NULL, 1);
 }
 
 /**
@@ -191,5 +197,15 @@ int python_exec1(sip_msg_t *_msg, char *method_name, char *foobar)
  */
 int python_exec2(sip_msg_t *_msg, char *method_name, char *mystr)
 {
-	return apy_exec(_msg, method_name, mystr, 1);
+	str method = STR_NULL;
+	str param = STR_NULL;
+	if(fixup_get_svalue(_msg, (gparam_t*)method_name, &method)<0) {
+		LM_ERR("cannot get the python method to be executed\n");
+		return -1;
+	}
+	if(fixup_get_svalue(_msg, (gparam_t*)mystr, &param)<0) {
+		LM_ERR("cannot get the parameter of the python method\n");
+		return -1;
+	}
+	return apy_exec(_msg, method.s, param.s, 1);
 }




More information about the sr-dev mailing list