Skip to content

Commit

Permalink
app_python: proper usage of pv in cfg function parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Feb 10, 2017
1 parent b8ff378 commit a7bedbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/modules/app_python/app_python_mod.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }
};

Expand Down
20 changes: 18 additions & 2 deletions src/modules/app_python/python_exec.c
Expand Up @@ -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"
Expand Down Expand Up @@ -183,13 +184,28 @@ 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);
}

/**
*
*/
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);
}

0 comments on commit a7bedbd

Please sign in to comment.