Modified: freeswitch/trunk/contrib/gled/esl2agi/esl2agi.c (15099 => 15100)
--- freeswitch/trunk/contrib/gled/esl2agi/esl2agi.c 2009-10-06 15:30:30 UTC (rev 15099)
+++ freeswitch/trunk/contrib/gled/esl2agi/esl2agi.c 2009-10-06 15:47:12 UTC (rev 15100)
@@ -44,6 +44,7 @@
{ {"SET", "CALLERID" , NULL}, handle_set_caller_id },
{ {"SET", "VARIABLE" , NULL}, handle_set_variable },
{ {"EXEC", NULL}, handle_exec },
+ { {"GET", "DATA", NULL}, handle_getdata },
};
static command_binding_t exec_bindings[_MAX_CMD] = {
@@ -507,7 +508,7 @@
if ( (strstr("=",argv[1])) != NULL ) { /* Support for exec set var=value*/
if (strstr("(",argv[1]) != NULL && strstr(")",argv[1]) != NULL ) {
- /* TODO implement * func */
+ /* TODO implement * func(param)=value */
res = -1;
goto end;
}
@@ -537,6 +538,59 @@
}
/*
+ * GET DATA filetoplay timeout maxdigits
+ * will execute the play_and_get_digits app ( <min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> )
+ */
+
+static int handle_getdata(esl_handle_t *eslC,int fd,int *argc, char *argv[]) {
+ char *buf;
+ char *args;
+ int res=0;
+ int size;
+ esl_event_t *reply=NULL;
+
+ if (*argc > 5 && *argc < 3 ) {
+ res = -1;
+ goto end;
+ }
+
+ args = malloc(1024);
+ snprintf(args,1024,"1 %s 1 %s # %s invalid.wav play_get_digits_values \\d+",argv[4] ? argv[4] : "9999", argv[3] ? argv[3] : "2000", argv[2]);
+
+ if (do_execute(eslC,"play_and_get_digits",args,NULL,&reply) < 0 ) {
+ res = -1;
+ goto end;
+ }
+ else {
+ if (reply) {
+ res = fill_buffer_from_header(reply,&args,"variable_play_get_digits_values","%s");
+ }
+ else {
+ res = -1;
+ goto end;
+ }
+
+ }
+
+end:
+ if (args)
+ free(args);
+ if (res < 0) {
+ size = safe_int_snprintf_buffer(&buf,"200 result=%d\n\n",res);
+ }
+ else {
+ size = strlen(args) + 10;
+ buf = malloc(size + 1);
+ snprintf(buf,size + 1,"200 result=%s",args);
+ }
+
+ res = write(fd,buf,size);
+ free(buf);
+
+ return res;
+}
+
+/*
* STREAM FILE agi cmd
*/
static int handle_streamfile(esl_handle_t *eslC,int fd,int *argc, char *argv[]) {
Modified: freeswitch/trunk/contrib/gled/esl2agi/esl2agi.h (15099 => 15100)
--- freeswitch/trunk/contrib/gled/esl2agi/esl2agi.h 2009-10-06 15:30:30 UTC (rev 15099)
+++ freeswitch/trunk/contrib/gled/esl2agi/esl2agi.h 2009-10-06 15:47:12 UTC (rev 15100)
@@ -112,6 +112,8 @@
static int handle_streamfile(esl_handle_t *eslC,int fd,int *argc, char *argv[_MAX_CMD_ARGS]);
+static int handle_getdata(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]);
@@ -124,7 +126,7 @@
/* TODO
* - ANSWER : OK
- * - EXEC application OPTIONS
+ * - EXEC application OPTIONS: OK, now will need to add more bindings
* - GET DATA filetoplay timeout maxdigits
* - GET VARIABLE variablename
* - HANGUP 'channelname' : TODO channel name to hangup
@@ -134,6 +136,6 @@
* - set music on|off class
* - set variable: should be OK ( untested )
* - set callerid: should be OK ( untested )
- * - stream file filename <escape digits> [sample offset] : TODO: check result offset and terminator var used ( FSCORE-455 )
+ * - stream file filename <escape digits> [sample offset] : OK ( check when using offset todo )
* - wait for digit timeout
*/