--- a/console/linphonec.c 2013-05-10 15:07:00.000000000 +0200 +++ b/console/linphonec.c 2014-01-05 19:31:41.911495591 +0100 @@ -27,6 +27,7 @@ #ifndef _WIN32_WCE #include #include +#include #include #include #include @@ -159,6 +160,7 @@ LPC_AUTH_STACK auth_stack; static int trace_level = 0; static char *logfile_name = NULL; +static char *dtmf_path = NULL; static char configfile_name[PATH_MAX]; static char zrtpsecrets[PATH_MAX]; static const char *factory_configfile_name=NULL; @@ -412,6 +414,38 @@ char *from=linphone_call_get_remote_address_as_string(call); fprintf(stdout,"Receiving tone %c from %s\n",dtmf,from); fflush(stdout); + + if (dtmf_path != NULL && *dtmf_path != '\x00') { +#if !defined(_WIN32_WCE) + pid_t pid; + + linphonec_out("Spawning DTMF app.\n"); + + pid = fork(); + if (pid < 0) + linphonec_out("DTMF app spawn failed.\n"); + else if (pid == 0) { + char dtmfs[2]; + dtmfs[0] = (char)dtmf; + dtmfs[1] = '\x00'; + + char * args[4]; + args[0] = dtmf_path; + args[1] = dtmfs; + args[2] = from; + args[3] = NULL; + + execv(dtmf_path, args); + + exit(-1); + } else + if (waitpid(pid, NULL, 0) == -1) + linphonec_out("Waiting for DTMF app exit failed.\n"); +#else + linphonec_out("FIXME: implement spawning DTMF app on this platform.\n"); +#endif + } + ms_free(from); } @@ -910,6 +944,7 @@ " -D enable video display only (disabled by default)\n" " -S show general state messages (disabled by default)\n" " --wid windowid force embedding of video window into provided windowid (disabled by default)\n" +" --dtmf path spawn (synchronously) app on provided path on DTMF event with digit as first param and source as second (disabled by default)\n" " -v or --version display version and exits.\n"); exit(exit_status); @@ -1270,6 +1305,12 @@ lpc_video_params.wid = window_id; } } + else if (strncmp ("--dtmf", argv[arg_num], 6) == 0) + { + arg_num++; + if (arg_num < argc) + dtmf_path = argv[arg_num]; + } else if (old_arg_num == arg_num) { fprintf (stderr, "ERROR: bad arguments\n");