1
0
Fork 0

improved detokenizer_shell module: Script now receives 2nd argument as request-ip

This commit is contained in:
bagyenda 2006-05-08 06:42:35 +00:00
parent bc4ef69c40
commit 50fd9b03aa
1 changed files with 14 additions and 2 deletions

View File

@ -35,16 +35,28 @@ static int mms_detokenizer_fini(void)
return 0;
}
static Octstr *mms_detokenize(Octstr * token, Octstr *request_ip)
static Octstr *mms_detokenize(Octstr *token, Octstr *request_ip)
{
Octstr *cmd = NULL, *msisdn = NULL;
Octstr *tmp1, *tmp2;
FILE *fp;
char buf[4096];
if (script == NULL || octstr_len(script) == 0)
return NULL;
cmd = octstr_format("%s '%s'", octstr_get_cstr(script), octstr_get_cstr(token));
tmp1 = octstr_duplicate(token ? token : octstr_imm(""));
tmp2 = octstr_duplicate(request_ip ? request_ip : octstr_imm(""));
escape_shell_chars(tmp1);
escape_shell_chars(tmp2);
cmd = octstr_format("%s %s %s",
octstr_get_cstr(script),
octstr_get_cstr(tmp1),
octstr_get_cstr(tmp2));
octstr_destroy(tmp1);
octstr_destroy(tmp2);
info(0, "Calling \"%s\"", octstr_get_cstr(cmd));
if ((fp = popen(octstr_get_cstr(cmd), "r"))) {
if (fgets(buf, sizeof buf, fp) != NULL) {