提交 e2575f91 authored 作者: Tristan Mahé's avatar Tristan Mahé

set variable

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk/contrib@15043 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 e19e4f31
...@@ -42,6 +42,7 @@ static command_binding_t bindings[_MAX_CMD] = { ...@@ -42,6 +42,7 @@ static command_binding_t bindings[_MAX_CMD] = {
{ {"HANGUP" , NULL}, handle_hangup }, { {"HANGUP" , NULL}, handle_hangup },
{ {"STREAM", "FILE" , NULL}, handle_streamfile }, { {"STREAM", "FILE" , NULL}, handle_streamfile },
{ {"SET", "CALLERID" , NULL}, handle_set_caller_id }, { {"SET", "CALLERID" , NULL}, handle_set_caller_id },
{ {"SET", "VARIABLE" , NULL}, handle_set_variable },
}; };
/* /*
...@@ -435,6 +436,35 @@ static int handle_set_caller_id(esl_handle_t *eslC,int fd,int *argc, char *argv[ ...@@ -435,6 +436,35 @@ static int handle_set_caller_id(esl_handle_t *eslC,int fd,int *argc, char *argv[
return res; return res;
} }
/*
* SET VARIABLE
*/
static int handle_set_variable(esl_handle_t *eslC,int fd,int *argc, char *argv[]) {
int res;
int size;
char *buf=NULL;
if (*argc != 4)
return -1;
if (argv[2] && argv[3]) {
size = strlen(argv[2]) + strlen(argv[3]) + 1;
buf = malloc(size + 1);
snprintf(buf,size +1 ,"%s=%s",argv[2],argv[3]);
}
else
return -1;
res = do_execute(eslC,"set",buf,NULL,NULL);
size = safe_int_snprintf_buffer(&buf,"200 result=%d\n\n",res);
res = write(fd,buf,size);
free(buf);
return res;
}
/* /*
* STREAM FILE agi cmd * STREAM FILE agi cmd
* TODO: rewrites with good string handling :) * TODO: rewrites with good string handling :)
......
...@@ -111,16 +111,20 @@ static int handle_streamfile(esl_handle_t *eslC,int fd,int *argc, char *argv[_MA ...@@ -111,16 +111,20 @@ static int handle_streamfile(esl_handle_t *eslC,int fd,int *argc, char *argv[_MA
static int handle_set_caller_id(esl_handle_t *eslC,int fd,int *argc, char *argv[_MAX_CMD_ARGS]); static int handle_set_caller_id(esl_handle_t *eslC,int fd,int *argc, char *argv[_MAX_CMD_ARGS]);
static int handle_set_variable(esl_handle_t *eslC,int fd,int *argc, char *argv[_MAX_CMD_ARGS]);
/* TODO /* TODO
* - ANSWER : OK
* - EXEC application OPTIONS * - EXEC application OPTIONS
* - GET DATA filetoplay timeout maxdigits * - GET DATA filetoplay timeout maxdigits
* - GET VARIABLE variablename * - GET VARIABLE variablename
* - HANGUP 'channelname' * - HANGUP 'channelname' : TODO channel name to hangup
* - RECORD FILE filename format escapedigits timeout offsetsamples BEEP s=silence * - RECORD FILE filename format escapedigits timeout offsetsamples BEEP s=silence
* - SAY DIGITS * - SAY DIGITS
* - set autohangup time * - set autohangup time
* - set music on|off class * - set music on|off class
* - set variable * - set variable: should be OK ( untested )
* - stream file filename <escape digits> [sample offset] * - set callerid: should be OK ( untested )
* - stream file filename <escape digits> [sample offset] : TODO: check result offset and terminator var used ( FSCORE-455 )
* - wait for digit timeout * - wait for digit timeout
*/ */
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论