AGI - the Asterisk Gateway Interface. More...
#include "asterisk.h"#include <math.h>#include <signal.h>#include <sys/time.h>#include <sys/wait.h>#include <sys/stat.h>#include <pthread.h>#include "asterisk/paths.h"#include "asterisk/network.h"#include "asterisk/file.h"#include "asterisk/channel.h"#include "asterisk/pbx.h"#include "asterisk/module.h"#include "asterisk/astdb.h"#include "asterisk/callerid.h"#include "asterisk/cli.h"#include "asterisk/image.h"#include "asterisk/say.h"#include "asterisk/app.h"#include "asterisk/dsp.h"#include "asterisk/musiconhold.h"#include "asterisk/utils.h"#include "asterisk/lock.h"#include "asterisk/strings.h"#include "asterisk/manager.h"#include "asterisk/ast_version.h"#include "asterisk/speech.h"#include "asterisk/features.h"#include "asterisk/term.h"#include "asterisk/xmldoc.h"#include "asterisk/agi.h"
Go to the source code of this file.
Data Structures | |
| struct | agi_cmd |
| struct | agi_commands |
Defines | |
| #define | AGI_BUF_INITSIZE 256 |
| #define | AGI_BUF_LEN 2048 |
| #define | AGI_BUF_SIZE 1024 |
| #define | AGI_NANDFS_RETRY 3 |
| #define | AGI_PORT 4573 |
| #define | AMI_BUF_SIZE 2048 |
| #define | AST_API_MODULE |
| #define | MAX_AGI_CONNECT 2000 |
| #define | MAX_ARGS 128 |
| #define | MAX_CMD_LEN 80 |
| #define | TONE_BLOCK_SIZE 200 |
Enumerations | |
| enum | agi_result { AGI_RESULT_FAILURE = -1, AGI_RESULT_SUCCESS, AGI_RESULT_SUCCESS_FAST, AGI_RESULT_SUCCESS_ASYNC, AGI_RESULT_NOTFOUND, AGI_RESULT_HANGUP } |
Functions | |
| static void | __init_agi_buf (void) |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | action_add_agi_cmd (struct mansession *s, const struct message *m) |
| Add a new command to execute by the Async AGI application. | |
| static int | add_agi_cmd (struct ast_channel *chan, const char *cmd_buff, const char *cmd_id) |
| static int | add_to_agi (struct ast_channel *chan) |
| static void | agi_destroy_commands_cb (void *data) |
| static int | agi_exec (struct ast_channel *chan, void *data) |
| static int | agi_exec_full (struct ast_channel *chan, void *data, int enhanced, int dead) |
| static enum agi_result | agi_handle_command (struct ast_channel *chan, AGI *agi, char *buf, int dead) |
| int | ast_agi_register (struct ast_module *mod, agi_command *cmd) |
| Registers an AGI command. | |
| int | ast_agi_register_multiple (struct ast_module *mod, struct agi_command *cmd, unsigned int len) |
| Registers a group of AGI commands, provided as an array of struct agi_command entries. | |
| int | ast_agi_send (int fd, struct ast_channel *chan, char *fmt,...) |
| Sends a string of text to an application connected via AGI. | |
| int | ast_agi_unregister (struct ast_module *mod, agi_command *cmd) |
| Unregisters an AGI command. | |
| int | ast_agi_unregister_multiple (struct ast_module *mod, struct agi_command *cmd, unsigned int len) |
| Unregisters a group of AGI commands, provided as an array of struct agi_command entries. | |
| static int | deadagi_exec (struct ast_channel *chan, void *data) |
| static int | eagi_exec (struct ast_channel *chan, void *data) |
| static agi_command * | find_command (char *cmds[], int exact) |
| static void | free_agi_cmd (struct agi_cmd *cmd) |
| static struct agi_cmd * | get_agi_cmd (struct ast_channel *chan) |
| static int | handle_answer (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_asyncagi_break (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_autohangup (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_channelstatus (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static char * | handle_cli_agi_add_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| CLI command to add applications to execute in Async AGI. | |
| static char * | handle_cli_agi_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_cli_agi_dump_html (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_cli_agi_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static int | handle_controlstreamfile (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_dbdel (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_dbdeltree (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_dbget (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_dbput (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_exec (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_getdata (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_getoption (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| get option - really similar to the handle_streamfile, but with a timeout | |
| static int | handle_getvariable (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_getvariablefull (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_hangup (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_noop (struct ast_channel *chan, AGI *agi, int arg, char *argv[]) |
| static int | handle_recordfile (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_recvchar (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_recvtext (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_sayalpha (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_saydate (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_saydatetime (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_saydigits (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_saynumber (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| Say number in various language syntaxes. | |
| static int | handle_sayphonetic (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_saytime (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_sendimage (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_sendtext (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_setcallerid (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_setcontext (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_setextension (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_setmusic (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_setpriority (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_setvariable (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechactivategrammar (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechcreate (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechdeactivategrammar (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechdestroy (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechloadgrammar (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechrecognize (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechset (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_speechunloadgrammar (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_streamfile (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_tddmode (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static int | handle_verbose (struct ast_channel *chan, AGI *agi, int argc, char **argv) |
| static int | handle_waitfordigit (struct ast_channel *chan, AGI *agi, int argc, char *argv[]) |
| static char * | help_workhorse (int fd, char *match[]) |
| static enum agi_result | launch_asyncagi (struct ast_channel *chan, char *argv[], int *efd) |
| static enum agi_result | launch_netscript (char *agiurl, char *argv[], int *fds, int *efd, int *opid) |
| static enum agi_result | launch_script (struct ast_channel *chan, char *script, char *argv[], int *fds, int *efd, int *opid) |
| static int | load_module (void) |
| static int | parse_args (char *s, int *max, char *argv[]) |
| static enum agi_result | run_agi (struct ast_channel *chan, char *request, AGI *agi, int pid, int *status, int dead, int argc, char *argv[]) |
| static void | setup_env (struct ast_channel *chan, char *request, int fd, int enhanced, int argc, char *argv[]) |
| static int | speech_streamfile (struct ast_channel *chan, const char *filename, const char *preflang, int offset) |
| static int | unload_module (void) |
| static void | write_html_escaped (FILE *htmlfile, char *str) |
| Convert string to use HTML escaped characters. | |
| static int | write_htmldump (char *filename) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS , .description = "Asterisk Gateway Interface (AGI)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static struct ast_threadstorage | agi_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_agi_buf , .custom_init = NULL , } |
| static struct agi_commands | agi_commands |
| static struct ast_datastore_info | agi_commands_datastore_info |
| static int | agidebug = 0 |
| static char * | app = "AGI" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_cli_entry | cli_agi [] |
| static struct agi_command | commands [] |
| AGI commands list. | |
| static char * | deadapp = "DeadAGI" |
| static char * | deadsynopsis = "Executes AGI on a hungup channel" |
| static char * | descrip = " text string, one of SUCCESS | FAILURE | NOTFOUND | HANGUP\n" |
| static char * | eapp = "EAGI" |
| static char * | esynopsis = "Executes an EAGI compliant application" |
| static const char | mandescr_asyncagi [] = "\n" |
| static char * | synopsis = "Executes an AGI compliant application" |
| static char | usage_autohangup [] = " cause the autohangup feature to be disabled on this channel.\n" |
| static char | usage_controlstreamfile [] = " Note: ffchar and rewchar default to * and # respectively.\n" |
| static char | usage_recordfile [] = " preceded by \"s=\" and is also optional.\n" |
| static char | usage_recvchar [] = " -1 only on error/hangup.\n" |
| static char | usage_recvtext [] = " do not support the reception of text. Returns -1 for failure or 1 for success, and the string in parentheses.\n" |
| static char | usage_sayalpha [] = " -1 on error/hangup.\n" |
| static char | usage_saydate [] = " digit if one was pressed or -1 on error/hangup.\n" |
| static char | usage_saydatetime [] = " digit if one was pressed or -1 on error/hangup.\n" |
| static char | usage_saydigits [] = " -1 on error/hangup.\n" |
| static char | usage_saynumber [] = " -1 on error/hangup.\n" |
| static char | usage_sayphonetic [] = " if one was pressed, or -1 on error/hangup.\n" |
| static char | usage_saytime [] = " digit if one was pressed or -1 on error/hangup.\n" |
| static char | usage_sendimage [] = " should not include extensions.\n" |
| static char | usage_sendtext [] = " command only accepts a single argument.\n" |
| static char | usage_setcallerid [] = " Changes the callerid of the current channel.\n" |
| static char | usage_setcontext [] = " Sets the context for continuation upon exiting the application.\n" |
| static char | usage_setextension [] = " Changes the extension for continuation upon exiting the application.\n" |
| static char | usage_setpriority [] = " The priority must be a valid priority or label.\n" |
| static char | usage_setvariable [] = " Usage: SET VARIABLE <variablename> <value>\n" |
| static char | usage_speechactivategrammar [] = " Activates the specified grammar on the speech object.\n" |
| static char | usage_speechcreate [] = " Create a speech object to be used by the other Speech AGI commands.\n" |
| static char | usage_speechdeactivategrammar [] = " Deactivates the specified grammar on the speech object.\n" |
| static char | usage_speechdestroy [] = " Destroy the speech object created by SPEECH CREATE.\n" |
| static char | usage_speechloadgrammar [] = " Loads the specified grammar as the specified name.\n" |
| static char | usage_speechrecognize [] = " Plays back given prompt while listening for speech and dtmf.\n" |
| static char | usage_speechset [] = " Set an engine-specific setting.\n" |
| static char | usage_speechunloadgrammar [] = " Unloads the specified grammar.\n" |
| static char | usage_streamfile [] = " extension must not be included in the filename.\n" |
| static char | usage_tddmode [] = " successful, or 0 if channel is not TDD-capable.\n" |
| static char | usage_verbose [] = " Always returns 1.\n" |
| static char | usage_waitfordigit [] = " for the timeout value if you desire the call to block indefinitely.\n" |
AGI - the Asterisk Gateway Interface.
Definition in file res_agi.c.
| #define AGI_BUF_INITSIZE 256 |
Definition at line 374 of file res_agi.c.
Referenced by ast_agi_send().
| #define AGI_BUF_LEN 2048 |
Definition at line 320 of file res_agi.c.
Referenced by agi_exec_full(), and run_agi().
| #define AGI_BUF_SIZE 1024 |
Referenced by launch_asyncagi().
| #define AGI_PORT 4573 |
Definition at line 360 of file res_agi.c.
Referenced by launch_netscript().
| #define AMI_BUF_SIZE 2048 |
Referenced by launch_asyncagi().
| #define MAX_AGI_CONNECT 2000 |
Definition at line 358 of file res_agi.c.
Referenced by launch_netscript().
| #define MAX_ARGS 128 |
Definition at line 317 of file res_agi.c.
Referenced by agi_exec_full(), agi_handle_command(), and parse_args().
| #define MAX_CMD_LEN 80 |
Definition at line 318 of file res_agi.c.
Referenced by ast_agi_register(), ast_agi_unregister(), handle_cli_agi_show(), help_workhorse(), and write_htmldump().
| enum agi_result |
| static int action_add_agi_cmd | ( | struct mansession * | s, |
| const struct message * | m | ||
| ) | [static] |
Add a new command to execute by the Async AGI application.
| s | |
| m | It will append the application to the specified channel's queue if the channel is not inside Async AGI application it will return an error |
| 0 | on success or incorrect use |
| 1 | on failure to add the command ( most likely because the channel is not in Async AGI loop ) |
Definition at line 588 of file res_agi.c.
References add_agi_cmd(), ast_channel_unlock, ast_get_channel_by_name_locked(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), buf, chan, and ast_channel::name.
Referenced by load_module().
{
const char *channel = astman_get_header(m, "Channel");
const char *cmdbuff = astman_get_header(m, "Command");
const char *cmdid = astman_get_header(m, "CommandID");
struct ast_channel *chan;
char buf[256];
if (ast_strlen_zero(channel) || ast_strlen_zero(cmdbuff)) {
astman_send_error(s, m, "Both, Channel and Command are *required*");
return 0;
}
chan = ast_get_channel_by_name_locked(channel);
if (!chan) {
snprintf(buf, sizeof(buf), "Channel %s does not exists or cannot get its lock", channel);
astman_send_error(s, m, buf);
return 0;
}
if (add_agi_cmd(chan, cmdbuff, cmdid)) {
snprintf(buf, sizeof(buf), "Failed to add AGI command to channel %s queue", chan->name);
astman_send_error(s, m, buf);
ast_channel_unlock(chan);
return 0;
}
astman_send_ack(s, m, "Added AGI command to queue");
ast_channel_unlock(chan);
return 0;
}
| static int add_agi_cmd | ( | struct ast_channel * | chan, |
| const char * | cmd_buff, | ||
| const char * | cmd_id | ||
| ) | [static] |
Definition at line 468 of file res_agi.c.
References agi_commands, agi_commands_datastore_info, ast_calloc, ast_channel_datastore_find(), ast_free, AST_LIST_HEAD, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), ast_strdup, agi_cmd::cmd_buffer, agi_cmd::cmd_id, ast_datastore::data, agi_cmd::entry, LOG_WARNING, and ast_channel::name.
Referenced by action_add_agi_cmd(), and handle_cli_agi_add_cmd().
{
struct ast_datastore *store;
struct agi_cmd *cmd;
AST_LIST_HEAD(, agi_cmd) *agi_commands;
store = ast_channel_datastore_find(chan, &agi_commands_datastore_info, NULL);
if (!store) {
ast_log(LOG_WARNING, "Channel %s is not at Async AGI.\n", chan->name);
return -1;
}
agi_commands = store->data;
cmd = ast_calloc(1, sizeof(*cmd));
if (!cmd) {
return -1;
}
cmd->cmd_buffer = ast_strdup(cmd_buff);
if (!cmd->cmd_buffer) {
ast_free(cmd);
return -1;
}
cmd->cmd_id = ast_strdup(cmd_id);
if (!cmd->cmd_id) {
ast_free(cmd->cmd_buffer);
ast_free(cmd);
return -1;
}
AST_LIST_LOCK(agi_commands);
AST_LIST_INSERT_TAIL(agi_commands, cmd, entry);
AST_LIST_UNLOCK(agi_commands);
return 0;
}
| static int add_to_agi | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 501 of file res_agi.c.
References agi_commands_datastore_info, ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_lock, ast_channel_unlock, ast_datastore_alloc(), ast_datastore_free(), AST_LIST_HEAD, AST_LIST_HEAD_INIT, ast_log(), ast_datastore::data, and LOG_ERROR.
Referenced by launch_asyncagi().
{
struct ast_datastore *datastore;
AST_LIST_HEAD(, agi_cmd) *agi_cmds_list;
/* check if already on AGI */
ast_channel_lock(chan);
datastore = ast_channel_datastore_find(chan, &agi_commands_datastore_info, NULL);
ast_channel_unlock(chan);
if (datastore) {
/* we already have an AGI datastore, let's just
return success */
return 0;
}
/* the channel has never been on Async AGI,
let's allocate it's datastore */
datastore = ast_datastore_alloc(&agi_commands_datastore_info, "AGI");
if (!datastore) {
return -1;
}
agi_cmds_list = ast_calloc(1, sizeof(*agi_cmds_list));
if (!agi_cmds_list) {
ast_log(LOG_ERROR, "Unable to allocate Async AGI commands list.\n");
ast_datastore_free(datastore);
return -1;
}
datastore->data = agi_cmds_list;
AST_LIST_HEAD_INIT(agi_cmds_list);
ast_channel_lock(chan);
ast_channel_datastore_add(chan, datastore);
ast_channel_unlock(chan);
return 0;
}
| static void agi_destroy_commands_cb | ( | void * | data | ) | [static] |
Definition at line 420 of file res_agi.c.
References ast_free, AST_LIST_HEAD, AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, agi_cmd::entry, and free_agi_cmd().
{
struct agi_cmd *cmd;
AST_LIST_HEAD(, agi_cmd) *chan_cmds = data;
AST_LIST_LOCK(chan_cmds);
while ( (cmd = AST_LIST_REMOVE_HEAD(chan_cmds, entry)) ) {
free_agi_cmd(cmd);
}
AST_LIST_UNLOCK(chan_cmds);
AST_LIST_HEAD_DESTROY(chan_cmds);
ast_free(chan_cmds);
}
| static int agi_exec | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
Definition at line 3297 of file res_agi.c.
References agi_exec_full(), and ast_check_hangup().
Referenced by deadagi_exec(), and load_module().
{
if (!ast_check_hangup(chan))
return agi_exec_full(chan, data, 0, 0);
else
return agi_exec_full(chan, data, 0, 1);
}
| static int agi_exec_full | ( | struct ast_channel * | chan, |
| void * | data, | ||
| int | enhanced, | ||
| int | dead | ||
| ) | [static] |
Definition at line 3230 of file res_agi.c.
References ast_channel::_state, AGI_BUF_LEN, AGI_RESULT_FAILURE, AGI_RESULT_HANGUP, AGI_RESULT_NOTFOUND, AGI_RESULT_SUCCESS, AGI_RESULT_SUCCESS_ASYNC, AGI_RESULT_SUCCESS_FAST, ast_answer(), AST_APP_ARG, ast_copy_string(), ast_debug, AST_DECLARE_APP_ARGS, ast_log(), ast_safe_fork_cleanup(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strlen_zero(), buf, launch_script(), LOG_WARNING, MAX_ARGS, pbx_builtin_setvar_helper(), run_agi(), and status.
Referenced by agi_exec(), and eagi_exec().
{
enum agi_result res;
char buf[AGI_BUF_LEN] = "", *tmp = buf;
int fds[2], efd = -1, pid;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(arg)[MAX_ARGS];
);
AGI agi;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
return -1;
}
if (dead)
ast_debug(3, "Hungup channel detected, running agi in dead mode.\n");
ast_copy_string(buf, data, sizeof(buf));
memset(&agi, 0, sizeof(agi));
AST_STANDARD_APP_ARGS(args, tmp);
args.argv[args.argc] = NULL;
#if 0
/* Answer if need be */
if (chan->_state != AST_STATE_UP) {
if (ast_answer(chan))
return -1;
}
#endif
res = launch_script(chan, args.argv[0], args.argv, fds, enhanced ? &efd : NULL, &pid);
/* Async AGI do not require run_agi(), so just proceed if normal AGI
or Fast AGI are setup with success. */
if (res == AGI_RESULT_SUCCESS || res == AGI_RESULT_SUCCESS_FAST) {
int status = 0;
agi.fd = fds[1];
agi.ctrl = fds[0];
agi.audio = efd;
agi.fast = (res == AGI_RESULT_SUCCESS_FAST) ? 1 : 0;
res = run_agi(chan, args.argv[0], &agi, pid, &status, dead, args.argc, args.argv);
/* If the fork'd process returns non-zero, set AGISTATUS to FAILURE */
if ((res == AGI_RESULT_SUCCESS || res == AGI_RESULT_SUCCESS_FAST) && status)
res = AGI_RESULT_FAILURE;
if (fds[1] != fds[0])
close(fds[1]);
if (efd > -1)
close(efd);
}
ast_safe_fork_cleanup();
switch (res) {
case AGI_RESULT_SUCCESS:
case AGI_RESULT_SUCCESS_FAST:
case AGI_RESULT_SUCCESS_ASYNC:
pbx_builtin_setvar_helper(chan, "AGISTATUS", "SUCCESS");
break;
case AGI_RESULT_FAILURE:
pbx_builtin_setvar_helper(chan, "AGISTATUS", "FAILURE");
break;
case AGI_RESULT_NOTFOUND:
pbx_builtin_setvar_helper(chan, "AGISTATUS", "NOTFOUND");
break;
case AGI_RESULT_HANGUP:
pbx_builtin_setvar_helper(chan, "AGISTATUS", "HANGUP");
return -1;
}
return 0;
}
| static enum agi_result agi_handle_command | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| char * | buf, | ||
| int | dead | ||
| ) | [static] |
Definition at line 2780 of file res_agi.c.
References AGI_RESULT_FAILURE, AGI_RESULT_SUCCESS, ast_agi_send(), ast_cdr_setapp(), ast_check_hangup(), ast_module_ref(), ast_module_unref(), ast_random(), ast_strdupa, ast_strlen_zero(), ast_channel::cdr, agi_command::dead, EVENT_FLAG_AGI, agi_state::fd, find_command(), agi_command::handler, manager_event, MAX_ARGS, agi_command::mod, ast_channel::name, parse_args(), RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, ast_module_info::self, and agi_command::usage.
Referenced by launch_asyncagi(), and run_agi().
{
char *argv[MAX_ARGS];
int argc = MAX_ARGS, res;
agi_command *c;
const char *ami_res = "Unknown Result";
char *ami_cmd = ast_strdupa(buf);
int command_id = ast_random(), resultcode = 200;
manager_event(EVENT_FLAG_AGI, "AGIExec",
"SubEvent: Start\r\n"
"Channel: %s\r\n"
"CommandId: %d\r\n"
"Command: %s\r\n", chan->name, command_id, ami_cmd);
parse_args(buf, &argc, argv);
if ((c = find_command(argv, 0)) && (!dead || (dead && c->dead))) {
/* if this command wasnt registered by res_agi, be sure to usecount
the module we are using */
if (c->mod != ast_module_info->self)
ast_module_ref(c->mod);
/* If the AGI command being executed is an actual application (using agi exec)
the app field will be updated in pbx_exec via handle_exec */
if (chan->cdr && !ast_check_hangup(chan) && strcasecmp(argv[0], "EXEC"))
ast_cdr_setapp(chan->cdr, "AGI", buf);
res = c->handler(chan, agi, argc, argv);
if (c->mod != ast_module_info->self)
ast_module_unref(c->mod);
switch (res) {
case RESULT_SHOWUSAGE: ami_res = "Usage"; resultcode = 520; break;
case RESULT_FAILURE: ami_res = "Failure"; resultcode = -1; break;
case RESULT_SUCCESS: ami_res = "Success"; resultcode = 200; break;
}
manager_event(EVENT_FLAG_AGI, "AGIExec",
"SubEvent: End\r\n"
"Channel: %s\r\n"
"CommandId: %d\r\n"
"Command: %s\r\n"
"ResultCode: %d\r\n"
"Result: %s\r\n", chan->name, command_id, ami_cmd, resultcode, ami_res);
switch(res) {
case RESULT_SHOWUSAGE:
if (ast_strlen_zero(c->usage)) {
ast_agi_send(agi->fd, chan, "520 Invalid command syntax. Proper usage not available.\n");
} else {
ast_agi_send(agi->fd, chan, "520-Invalid command syntax. Proper usage follows:\n");
ast_agi_send(agi->fd, chan, "%s", c->usage);
ast_agi_send(agi->fd, chan, "520 End of proper usage.\n");
}
break;
case RESULT_FAILURE:
/* The RESULT_FAILURE code is usually because the channel hungup. */
return AGI_RESULT_FAILURE;
default:
break;
}
} else if ((c = find_command(argv, 0))) {
ast_agi_send(agi->fd, chan, "511 Command Not Permitted on a dead channel\n");
manager_event(EVENT_FLAG_AGI, "AGIExec",
"SubEvent: End\r\n"
"Channel: %s\r\n"
"CommandId: %d\r\n"
"Command: %s\r\n"
"ResultCode: 511\r\n"
"Result: Command not permitted on a dead channel\r\n", chan->name, command_id, ami_cmd);
} else {
ast_agi_send(agi->fd, chan, "510 Invalid or unknown command\n");
manager_event(EVENT_FLAG_AGI, "AGIExec",
"SubEvent: End\r\n"
"Channel: %s\r\n"
"CommandId: %d\r\n"
"Command: %s\r\n"
"ResultCode: 510\r\n"
"Result: Invalid or unknown command\r\n", chan->name, command_id, ami_cmd);
}
return AGI_RESULT_SUCCESS;
}
| int ast_agi_register | ( | struct ast_module * | mod, |
| agi_command * | cmd | ||
| ) |
Registers an AGI command.
| mod | Pointer to the module_info structure for the module that is registering the command |
| cmd | Pointer to the descriptor for the command |
Definition at line 2559 of file res_agi.c.
References ast_join(), AST_LIST_INSERT_TAIL, ast_log(), ast_module_ref(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, AST_STATIC_DOC, ast_strdup, ast_strlen_zero(), ast_verb, AST_XML_DOC, ast_xmldoc_build_description(), ast_xmldoc_build_seealso(), ast_xmldoc_build_synopsis(), ast_xmldoc_build_syntax(), agi_command::cmda, agi_command::docsrc, find_command(), agi_command::list, LOG_WARNING, MAX_CMD_LEN, agi_command::mod, agi_command::seealso, ast_module_info::self, agi_command::summary, agi_command::syntax, and agi_command::usage.
Referenced by ast_agi_register_multiple(), and load_module().
{
char fullcmd[MAX_CMD_LEN];
ast_join(fullcmd, sizeof(fullcmd), cmd->cmda);
if (!find_command(cmd->cmda,1)) {
cmd->docsrc = AST_STATIC_DOC;
if (ast_strlen_zero(cmd->summary) && ast_strlen_zero(cmd->usage)) {
#ifdef AST_XML_DOCS
*((char **) &cmd->summary) = ast_xmldoc_build_synopsis("agi", fullcmd);
*((char **) &cmd->usage) = ast_xmldoc_build_description("agi", fullcmd);
*((char **) &cmd->syntax) = ast_xmldoc_build_syntax("agi", fullcmd);
*((char **) &cmd->seealso) = ast_xmldoc_build_seealso("agi", fullcmd);
*((enum ast_doc_src *) &cmd->docsrc) = AST_XML_DOC;
#elif (!defined(HAVE_NULLSAFE_PRINTF))
*((char **) &cmd->summary) = ast_strdup("");
*((char **) &cmd->usage) = ast_strdup("");
*((char **) &cmd->syntax) = ast_strdup("");
*((char **) &cmd->seealso) = ast_strdup("");
#endif
}
cmd->mod = mod;
AST_RWLIST_WRLOCK(&agi_commands);
AST_LIST_INSERT_TAIL(&agi_commands, cmd, list);
AST_RWLIST_UNLOCK(&agi_commands);
if (mod != ast_module_info->self)
ast_module_ref(ast_module_info->self);
ast_verb(2, "AGI Command '%s' registered\n",fullcmd);
return 1;
} else {
ast_log(LOG_WARNING, "Command already registered!\n");
return 0;
}
}
| int ast_agi_register_multiple | ( | struct ast_module * | mod, |
| struct agi_command * | cmd, | ||
| unsigned int | len | ||
| ) |
Registers a group of AGI commands, provided as an array of struct agi_command entries.
| mod | Pointer to the module_info structure for the module that is registering the commands |
| cmd | Pointer to the first entry in the array of command descriptors |
| len | Length of the array (use the ARRAY_LEN macro to determine this easily) |
Definition at line 2633 of file res_agi.c.
References ast_agi_register(), ast_agi_unregister(), and len().
Referenced by load_module().
{
unsigned int i, x = 0;
for (i = 0; i < len; i++) {
if (ast_agi_register(mod, cmd + i) == 1) {
x++;
continue;
}
/* registration failed, unregister everything
that had been registered up to that point
*/
for (; x > 0; x--) {
/* we are intentionally ignoring the
result of ast_agi_unregister() here,
but it should be safe to do so since
we just registered these commands and
the only possible way for unregistration
to fail is if the command is not
registered
*/
(void) ast_agi_unregister(mod, cmd + x - 1);
}
return -1;
}
return 0;
}
| int ast_agi_send | ( | int | fd, |
| struct ast_channel * | chan, | ||
| char * | fmt, | ||
| ... | |||
| ) |
Sends a string of text to an application connected via AGI.
| fd | The file descriptor for the AGI session (from struct agi_state) |
| chan | Pointer to an associated Asterisk channel, if any |
| fmt | printf-style format string |
Definition at line 376 of file res_agi.c.
References agi_buf, AGI_BUF_INITSIZE, ast_carefulwrite(), ast_log(), ast_str_buffer(), ast_str_set_va(), ast_str_strlen(), ast_str_thread_get(), ast_verbose(), buf, LOG_ERROR, and ast_channel::name.
Referenced by agi_handle_command(), handle_answer(), handle_asyncagi_break(), handle_autohangup(), handle_channelstatus(), handle_controlstreamfile(), handle_dbdel(), handle_dbdeltree(), handle_dbget(), handle_dbput(), handle_exec(), handle_getdata(), handle_getoption(), handle_getvariable(), handle_getvariablefull(), handle_gosub(), handle_hangup(), handle_noop(), handle_recordfile(), handle_recvchar(), handle_recvtext(), handle_sayalpha(), handle_saydate(), handle_saydatetime(), handle_saydigits(), handle_saynumber(), handle_sayphonetic(), handle_saytime(), handle_sendimage(), handle_sendtext(), handle_setcallerid(), handle_setcontext(), handle_setextension(), handle_setmusic(), handle_setpriority(), handle_setvariable(), handle_speechactivategrammar(), handle_speechcreate(), handle_speechdeactivategrammar(), handle_speechdestroy(), handle_speechloadgrammar(), handle_speechrecognize(), handle_speechset(), handle_speechunloadgrammar(), handle_streamfile(), handle_tddmode(), handle_verbose(), handle_waitfordigit(), launch_netscript(), and setup_env().
{
int res = 0;
va_list ap;
struct ast_str *buf;
if (!(buf = ast_str_thread_get(&agi_buf, AGI_BUF_INITSIZE)))
return -1;
va_start(ap, fmt);
res = ast_str_set_va(&buf, 0, fmt, ap);
va_end(ap);
if (res == -1) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
if (agidebug) {
if (chan) {
ast_verbose("<%s>AGI Tx >> %s", chan->name, ast_str_buffer(buf));
} else {
ast_verbose("AGI Tx >> %s", ast_str_buffer(buf));
}
}
return ast_carefulwrite(fd, ast_str_buffer(buf), ast_str_strlen(buf), 100);
}
| int ast_agi_unregister | ( | struct ast_module * | mod, |
| agi_command * | cmd | ||
| ) |
Unregisters an AGI command.
| mod | Pointer to the module_info structure for the module that is unregistering the command |
| cmd | Pointer to the descriptor for the command |
Definition at line 2596 of file res_agi.c.
References ast_free, ast_join(), ast_log(), ast_module_unref(), AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, AST_XML_DOC, agi_command::cmda, agi_command::docsrc, agi_command::list, LOG_WARNING, MAX_CMD_LEN, agi_command::seealso, ast_module_info::self, agi_command::summary, agi_command::syntax, and agi_command::usage.
Referenced by ast_agi_register_multiple(), ast_agi_unregister_multiple(), and unload_module().
{
struct agi_command *e;
int unregistered = 0;
char fullcmd[MAX_CMD_LEN];
ast_join(fullcmd, sizeof(fullcmd), cmd->cmda);
AST_RWLIST_WRLOCK(&agi_commands);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&agi_commands, e, list) {
if (cmd == e) {
AST_RWLIST_REMOVE_CURRENT(list);
if (mod != ast_module_info->self)
ast_module_unref(ast_module_info->self);
#ifdef AST_XML_DOCS
if (e->docsrc == AST_XML_DOC) {
ast_free(e->summary);
ast_free(e->usage);
ast_free(e->syntax);
ast_free(e->seealso);
e->summary = NULL, e->usage = NULL;
e->syntax = NULL, e->seealso = NULL;
}
#endif
unregistered=1;
break;
}
}
AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&agi_commands);
if (unregistered)
ast_verb(2, "AGI Command '%s' unregistered\n",fullcmd);
else
ast_log(LOG_WARNING, "Unable to unregister command: '%s'!\n",fullcmd);
return unregistered;
}
| int ast_agi_unregister_multiple | ( | struct ast_module * | mod, |
| struct agi_command * | cmd, | ||
| unsigned int | len | ||
| ) |
Unregisters a group of AGI commands, provided as an array of struct agi_command entries.
| mod | Pointer to the module_info structure for the module that is unregistering the commands |
| cmd | Pointer to the first entry in the array of command descriptors |
| len | Length of the array (use the ARRAY_LEN macro to determine this easily) |
Definition at line 2663 of file res_agi.c.
References ast_agi_unregister(), and len().
Referenced by unload_module().
{
unsigned int i;
int res = 0;
for (i = 0; i < len; i++) {
/* remember whether any of the unregistration
attempts failed... there is no recourse if
any of them do
*/
res |= ast_agi_unregister(mod, cmd + i);
}
return res;
}
| static int deadagi_exec | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
Definition at line 3327 of file res_agi.c.
References agi_exec(), ast_log(), and LOG_WARNING.
Referenced by load_module().
{
ast_log(LOG_WARNING, "DeadAGI has been deprecated, please use AGI in all cases!\n");
return agi_exec(chan, data);
}
| static int eagi_exec | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
Definition at line 3305 of file res_agi.c.
References agi_exec_full(), ast_check_hangup(), AST_FORMAT_SLINEAR, ast_getformatname(), ast_log(), ast_set_read_format(), LOG_ERROR, LOG_WARNING, ast_channel::name, and ast_channel::readformat.
Referenced by load_module().
{
int readformat, res;
if (ast_check_hangup(chan)) {
ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n");
return 0;
}
readformat = chan->readformat;
if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", chan->name);
return -1;
}
res = agi_exec_full(chan, data, 1, 0);
if (!res) {
if (ast_set_read_format(chan, readformat)) {
ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(readformat));
}
}
return res;
}
| static agi_command * find_command | ( | char * | cmds[], |
| int | exact | ||
| ) | [static] |
Definition at line 2679 of file res_agi.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, agi_command::cmda, agi_command::list, and match().
Referenced by agi_handle_command(), ast_agi_register(), and handle_cli_agi_show().
{
int y, match;
struct agi_command *e;
AST_RWLIST_RDLOCK(&agi_commands);
AST_RWLIST_TRAVERSE(&agi_commands, e, list) {
if (!e->cmda[0])
break;
/* start optimistic */
match = 1;
for (y = 0; match && cmds[y]; y++) {
/* If there are no more words in the command (and we're looking for
an exact match) or there is a difference between the two words,
then this is not a match */
if (!e->cmda[y] && !exact)
break;
/* don't segfault if the next part of a command doesn't exist */
if (!e->cmda[y]) {
AST_RWLIST_UNLOCK(&agi_commands);
return NULL;
}
if (strcasecmp(e->cmda[y], cmds[y]))
match = 0;
}
/* If more words are needed to complete the command then this is not
a candidate (unless we're looking for a really inexact answer */
if ((exact > -1) && e->cmda[y])
match = 0;
if (match) {
AST_RWLIST_UNLOCK(&agi_commands);
return e;
}
}
AST_RWLIST_UNLOCK(&agi_commands);
return NULL;
}
| static void free_agi_cmd | ( | struct agi_cmd * | cmd | ) | [static] |
Definition at line 412 of file res_agi.c.
References ast_free.
Referenced by agi_destroy_commands_cb(), and launch_asyncagi().
{
ast_free(cmd->cmd_buffer);
ast_free(cmd->cmd_id);
ast_free(cmd);
}
| static struct agi_cmd* get_agi_cmd | ( | struct ast_channel * | chan | ) | [static, read] |
Definition at line 447 of file res_agi.c.
References agi_commands, agi_commands_datastore_info, ast_channel_datastore_find(), ast_channel_lock, ast_channel_unlock, AST_LIST_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log(), ast_datastore::data, agi_cmd::entry, LOG_ERROR, and ast_channel::name.
Referenced by launch_asyncagi().
{
struct ast_datastore *store;
struct agi_cmd *cmd;
AST_LIST_HEAD(, agi_cmd) *agi_commands;
ast_channel_lock(chan);
store = ast_channel_datastore_find(chan, &agi_commands_datastore_info, NULL);
ast_channel_unlock(chan);
if (!store) {
ast_log(LOG_ERROR, "Hu? datastore disappeared at Async AGI on Channel %s!\n", chan->name);
return NULL;
}
agi_commands = store->data;
AST_LIST_LOCK(agi_commands);
cmd = AST_LIST_REMOVE_HEAD(agi_commands, entry);
AST_LIST_UNLOCK(agi_commands);
return cmd;
}
| static int handle_answer | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1024 of file res_agi.c.
References ast_channel::_state, ast_agi_send(), ast_answer(), AST_STATE_UP, agi_state::fd, RESULT_FAILURE, and RESULT_SUCCESS.
{
int res = 0;
/* Answer the channel */
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_asyncagi_break | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1036 of file res_agi.c.
References ast_agi_send(), agi_state::fd, and RESULT_FAILURE.
{
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_FAILURE;
}
| static int handle_autohangup | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1674 of file res_agi.c.
References ast_agi_send(), ast_channel_setwhentohangup_tv(), agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
double timeout;
struct timeval whentohangup = { 0, 0 };
if (argc != 3)
return RESULT_SHOWUSAGE;
if (sscanf(argv[2], "%30lf", &timeout) != 1)
return RESULT_SHOWUSAGE;
if (timeout < 0)
timeout = 0;
if (timeout) {
whentohangup.tv_sec = timeout;
whentohangup.tv_usec = (timeout - whentohangup.tv_sec) * 1000000.0;
}
ast_channel_setwhentohangup_tv(chan, whentohangup);
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_channelstatus | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1789 of file res_agi.c.
References ast_channel::_state, ast_agi_send(), ast_channel_unlock, ast_get_channel_by_name_locked(), agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
struct ast_channel *c;
if (argc == 2) {
/* no argument: supply info on the current channel */
ast_agi_send(agi->fd, chan, "200 result=%d\n", chan->_state);
return RESULT_SUCCESS;
} else if (argc == 3) {
/* one argument: look for info on the specified channel */
c = ast_get_channel_by_name_locked(argv[2]);
if (c) {
ast_agi_send(agi->fd, chan, "200 result=%d\n", c->_state);
ast_channel_unlock(c);
return RESULT_SUCCESS;
}
/* if we get this far no channel name matched the argument given */
ast_agi_send(agi->fd, chan, "200 result=-1\n");
return RESULT_SUCCESS;
} else {
return RESULT_SHOWUSAGE;
}
}
| static char* handle_cli_agi_add_cmd | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
CLI command to add applications to execute in Async AGI.
| e | |
| cmd | |
| a |
| CLI_SUCCESS | on success |
| NULL | when init or tab completion is used |
Definition at line 545 of file res_agi.c.
References add_agi_cmd(), ast_cli_args::argc, ast_cli_args::argv, ast_channel_unlock, ast_complete_channels(), ast_get_channel_by_name_locked(), ast_log(), chan, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::line, LOG_DEBUG, LOG_WARNING, ast_cli_args::n, ast_channel::name, ast_cli_args::pos, ast_cli_entry::usage, and ast_cli_args::word.
{
struct ast_channel *chan;
switch (cmd) {
case CLI_INIT:
e->command = "agi exec";
e->usage = "Usage: agi exec <channel name> <app and arguments> [id]\n"
" Add AGI command to the execute queue of the specified channel in Async AGI\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2)
return ast_complete_channels(a->line, a->word, a->pos, a->n, 2);
return NULL;
}
if (a->argc < 4)
return CLI_SHOWUSAGE;
chan = ast_get_channel_by_name_locked(a->argv[2]);
if (!chan) {
ast_log(LOG_WARNING, "Channel %s does not exists or cannot lock it\n", a->argv[2]);
return CLI_FAILURE;
}
if (add_agi_cmd(chan, a->argv[3], (a->argc > 4 ? a->argv[4] : ""))) {
ast_log(LOG_WARNING, "failed to add AGI command to queue of channel %s\n", chan->name);
ast_channel_unlock(chan);
return CLI_FAILURE;
}
ast_log(LOG_DEBUG, "Added AGI command to channel %s queue\n", chan->name);
ast_channel_unlock(chan);
return CLI_SUCCESS;
}
| static char* handle_cli_agi_debug | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 1954 of file res_agi.c.
References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, and ast_cli_entry::usage.
{
switch (cmd) {
case CLI_INIT:
e->command = "agi set debug [on|off]";
e->usage =
"Usage: agi set debug [on|off]\n"
" Enables/disables dumping of AGI transactions for\n"
" debugging purposes.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc != e->args)
return CLI_SHOWUSAGE;
if (strncasecmp(a->argv[3], "off", 3) == 0) {
agidebug = 0;
} else if (strncasecmp(a->argv[3], "on", 2) == 0) {
agidebug = 1;
} else {
return CLI_SHOWUSAGE;
}
ast_cli(a->fd, "AGI Debugging %sabled\n", agidebug ? "En" : "Dis");
return CLI_SUCCESS;
}
| static char* handle_cli_agi_dump_html | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 3206 of file res_agi.c.
References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, ast_cli_entry::usage, and write_htmldump().
{
switch (cmd) {
case CLI_INIT:
e->command = "agi dump html";
e->usage =
"Usage: agi dump html <filename>\n"
" Dumps the AGI command list in HTML format to the given\n"
" file.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc != e->args + 1)
return CLI_SHOWUSAGE;
if (write_htmldump(a->argv[e->args]) < 0) {
ast_cli(a->fd, "Could not create file '%s'\n", a->argv[e->args]);
return CLI_SHOWUSAGE;
}
ast_cli(a->fd, "AGI HTML commands dumped to: %s\n", a->argv[e->args]);
return CLI_SUCCESS;
}
| static char* handle_cli_agi_show | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 3014 of file res_agi.c.
References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), ast_free, ast_join(), ast_malloc, AST_TERM_MAX_ESCAPE_CHARS, AST_XML_DOC, ast_xmldoc_printable(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, COLOR_CYAN, COLOR_MAGENTA, ast_cli_entry::command, agi_command::dead, description, agi_command::docsrc, ast_cli_args::fd, find_command(), help_workhorse(), MAX_CMD_LEN, S_OR, agi_command::seealso, agi_command::summary, agi_command::syntax, term_color(), agi_command::usage, and ast_cli_entry::usage.
{
struct agi_command *command;
char fullcmd[MAX_CMD_LEN];
int error = 0;
switch (cmd) {
case CLI_INIT:
e->command = "agi show commands [topic]";
e->usage =
"Usage: agi show commands [topic] <topic>\n"
" When called with a topic as an argument, displays usage\n"
" information on the given command. If called without a\n"
" topic, it provides a list of AGI commands.\n";
case CLI_GENERATE:
return NULL;
}
if (a->argc < e->args - 1 || (a->argc >= e->args && strcasecmp(a->argv[e->args - 1], "topic")))
return CLI_SHOWUSAGE;
if (a->argc > e->args - 1) {
command = find_command(a->argv + e->args, 1);
if (command) {
char *synopsis = NULL, *description = NULL, *syntax = NULL, *seealso = NULL;
char info[30 + MAX_CMD_LEN]; /* '-= Info about...' */
char infotitle[30 + MAX_CMD_LEN + AST_TERM_MAX_ESCAPE_CHARS]; /* '-= Info about...' with colors */
char syntitle[11 + AST_TERM_MAX_ESCAPE_CHARS]; /* [Syntax]\n with colors */
char desctitle[15 + AST_TERM_MAX_ESCAPE_CHARS]; /* [Description]\n with colors */
char deadtitle[13 + AST_TERM_MAX_ESCAPE_CHARS]; /* [Runs Dead]\n with colors */
char deadcontent[3 + AST_TERM_MAX_ESCAPE_CHARS]; /* 'Yes' or 'No' with colors */
char seealsotitle[12 + AST_TERM_MAX_ESCAPE_CHARS]; /* [See Also]\n with colors */
char stxtitle[10 + AST_TERM_MAX_ESCAPE_CHARS]; /* [Syntax]\n with colors */
size_t synlen, desclen, seealsolen, stxlen;
term_color(syntitle, "[Synopsis]\n", COLOR_MAGENTA, 0, sizeof(syntitle));
term_color(desctitle, "[Description]\n", COLOR_MAGENTA, 0, sizeof(desctitle));
term_color(deadtitle, "[Runs Dead]\n", COLOR_MAGENTA, 0, sizeof(deadtitle));
term_color(seealsotitle, "[See Also]\n", COLOR_MAGENTA, 0, sizeof(seealsotitle));
term_color(stxtitle, "[Syntax]\n", COLOR_MAGENTA, 0, sizeof(stxtitle));
term_color(deadcontent, command->dead ? "Yes" : "No", COLOR_CYAN, 0, sizeof(deadcontent));
ast_join(fullcmd, sizeof(fullcmd), a->argv + e->args);
snprintf(info, sizeof(info), "\n -= Info about agi '%s' =- ", fullcmd);
term_color(infotitle, info, COLOR_CYAN, 0, sizeof(infotitle));
#ifdef AST_XML_DOCS
if (command->docsrc == AST_XML_DOC) {
synopsis = ast_xmldoc_printable(S_OR(command->summary, "Not available"), 1);
description = ast_xmldoc_printable(S_OR(command->usage, "Not available"), 1);
seealso = ast_xmldoc_printable(S_OR(command->seealso, "Not available"), 1);
if (!seealso || !description || !synopsis) {
error = 1;
goto return_cleanup;
}
} else
#endif
{
synlen = strlen(S_OR(command->summary, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
synopsis = ast_malloc(synlen);
desclen = strlen(S_OR(command->usage, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
description = ast_malloc(desclen);
seealsolen = strlen(S_OR(command->seealso, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
seealso = ast_malloc(seealsolen);
if (!synopsis || !description || !seealso) {
error = 1;
goto return_cleanup;
}
term_color(synopsis, S_OR(command->summary, "Not available"), COLOR_CYAN, 0, synlen);
term_color(description, S_OR(command->usage, "Not available"), COLOR_CYAN, 0, desclen);
term_color(seealso, S_OR(command->seealso, "Not available"), COLOR_CYAN, 0, seealsolen);
}
stxlen = strlen(S_OR(command->syntax, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
syntax = ast_malloc(stxlen);
if (!syntax) {
error = 1;
goto return_cleanup;
}
term_color(syntax, S_OR(command->syntax, "Not available"), COLOR_CYAN, 0, stxlen);
ast_cli(a->fd, "%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n", infotitle, stxtitle, syntax,
desctitle, description, syntitle, synopsis, deadtitle, deadcontent,
seealsotitle, seealso);
return_cleanup:
ast_free(synopsis);
ast_free(description);
ast_free(syntax);
ast_free(seealso);
} else {
if (find_command(a->argv + e->args, -1)) {
return help_workhorse(a->fd, a->argv + e->args);
} else {
ast_join(fullcmd, sizeof(fullcmd), a->argv + e->args);
ast_cli(a->fd, "No such command '%s'.\n", fullcmd);
}
}
} else {
return help_workhorse(a->fd, NULL);
}
return (error ? CLI_FAILURE : CLI_SUCCESS);
}
| static int handle_controlstreamfile | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1154 of file res_agi.c.
References ast_agi_send(), ast_control_streamfile(), ast_strlen_zero(), agi_state::fd, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, skipms, and stop.
{
int res = 0, skipms = 3000;
char *fwd = "#", *rev = "*", *suspend = NULL, *stop = NULL; /* Default values */
if (argc < 5 || argc > 9) {
return RESULT_SHOWUSAGE;
}
if (!ast_strlen_zero(argv[4])) {
stop = argv[4];
}
if ((argc > 5) && (sscanf(argv[5], "%30d", &skipms) != 1)) {
return RESULT_SHOWUSAGE;
}
if (argc > 6 && !ast_strlen_zero(argv[6])) {
fwd = argv[6];
}
if (argc > 7 && !ast_strlen_zero(argv[7])) {
rev = argv[7];
}
if (argc > 8 && !ast_strlen_zero(argv[8])) {
suspend = argv[8];
}
res = ast_control_streamfile(chan, argv[3], fwd, rev, stop, suspend, NULL, skipms, NULL);
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_dbdel | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1928 of file res_agi.c.
References ast_agi_send(), ast_db_del(), agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if (argc != 4)
return RESULT_SHOWUSAGE;
res = ast_db_del(argv[2], argv[3]);
ast_agi_send(agi->fd, chan, "200 result=%c\n", res ? '0' : '1');
return RESULT_SUCCESS;
}
| static int handle_dbdeltree | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1939 of file res_agi.c.
References ast_agi_send(), ast_db_deltree(), agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if ((argc < 3) || (argc > 4))
return RESULT_SHOWUSAGE;
if (argc == 4)
res = ast_db_deltree(argv[2], argv[3]);
else
res = ast_db_deltree(argv[2], NULL);
ast_agi_send(agi->fd, chan, "200 result=%c\n", res ? '0' : '1');
return RESULT_SUCCESS;
}
| static int handle_dbget | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1884 of file res_agi.c.
References ast_agi_send(), ast_db_get(), ast_free, ast_str_buffer(), ast_str_create(), ast_str_make_space(), ast_str_size(), ast_str_strlen(), ast_str_update(), buf, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
struct ast_str *buf;
if (argc != 4)
return RESULT_SHOWUSAGE;
if (!(buf = ast_str_create(16))) {
ast_agi_send(agi->fd, chan, "200 result=-1\n");
return RESULT_SUCCESS;
}
do {
res = ast_db_get(argv[2], argv[3], ast_str_buffer(buf), ast_str_size(buf));
ast_str_update(buf);
if (ast_str_strlen(buf) < ast_str_size(buf) - 1) {
break;
}
if (ast_str_make_space(&buf, ast_str_size(buf) * 2)) {
break;
}
} while (1);
if (res)
ast_agi_send(agi->fd, chan, "200 result=0\n");
else
ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", ast_str_buffer(buf));
ast_free(buf);
return RESULT_SUCCESS;
}
| static int handle_dbput | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1917 of file res_agi.c.
References ast_agi_send(), ast_db_put(), agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if (argc != 5)
return RESULT_SHOWUSAGE;
res = ast_db_put(argv[2], argv[3], argv[4]);
ast_agi_send(agi->fd, chan, "200 result=%c\n", res ? '0' : '1');
return RESULT_SUCCESS;
}
| static int handle_exec | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1721 of file res_agi.c.
References ast_agi_send(), ast_clear_flag, ast_compat_res_agi, AST_FLAG_DISABLE_WORKAROUNDS, ast_log(), ast_masq_park_call(), ast_set_flag, ast_strlen_zero(), ast_test_flag, ast_verb, agi_state::fd, LOG_WARNING, PARK_APP_NAME, pbx_exec(), pbx_findapp(), and RESULT_SHOWUSAGE.
{
int res, workaround;
struct ast_app *app_to_exec;
if (argc < 2)
return RESULT_SHOWUSAGE;
ast_verb(3, "AGI Script Executing Application: (%s) Options: (%s)\n", argv[1], argc >= 3 ? argv[2] : "");
if ((app_to_exec = pbx_findapp(argv[1]))) {
if(!strcasecmp(argv[1], PARK_APP_NAME)) {
ast_masq_park_call(chan, NULL, 0, NULL);
}
if (!(workaround = ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS))) {
ast_set_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS);
}
if (ast_compat_res_agi && argc >= 3 && !ast_strlen_zero(argv[2])) {
char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr, *vptr;
for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
if (*vptr == ',') {
*cptr++ = '\\';
*cptr++ = ',';
} else if (*vptr == '|') {
*cptr++ = ',';
} else {
*cptr++ = *vptr;
}
}
*cptr = '\0';
res = pbx_exec(chan, app_to_exec, compat);
} else {
res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : argv[2]);
}
if (!workaround) {
ast_clear_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS);
}
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]);
res = -2;
}
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
/* Even though this is wrong, users are depending upon this result. */
return res;
}
| static int handle_getdata | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1432 of file res_agi.c.
References ast_agi_send(), ast_app_getdata_full(), agi_state::audio, agi_state::ctrl, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res, max, timeout;
char data[1024];
if (argc < 3)
return RESULT_SHOWUSAGE;
if (argc >= 4)
timeout = atoi(argv[3]);
else
timeout = 0;
if (argc >= 5)
max = atoi(argv[4]);
else
max = 1024;
res = ast_app_getdata_full(chan, argv[2], data, max, timeout, agi->audio, agi->ctrl);
if (res == 2) /* New command */
return RESULT_SUCCESS;
else if (res == 1)
ast_agi_send(agi->fd, chan, "200 result=%s (timeout)\n", data);
else if (res < 0 )
ast_agi_send(agi->fd, chan, "200 result=-1\n");
else
ast_agi_send(agi->fd, chan, "200 result=%s\n", data);
return RESULT_SUCCESS;
}
| static int handle_getoption | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
get option - really similar to the handle_streamfile, but with a timeout
Definition at line 1240 of file res_agi.c.
References ast_agi_send(), ast_applystream(), ast_debug, ast_log(), ast_openstream(), ast_openvstream(), ast_playstream(), ast_seekstream(), ast_stopstream(), ast_tellstream(), ast_verb, ast_waitfordigit_full(), ast_waitstream_full(), agi_state::audio, agi_state::ctrl, ast_pbx::dtimeoutms, agi_state::fd, ast_channel::language, LOG_WARNING, ast_channel::pbx, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, ast_channel::stream, and ast_filestream::vfs.
{
int res, vres;
struct ast_filestream *fs, *vfs;
long sample_offset = 0, max_length;
int timeout = 0;
char *edigits = "";
if ( argc < 4 || argc > 5 )
return RESULT_SHOWUSAGE;
if ( argv[3] )
edigits = argv[3];
if ( argc == 5 )
timeout = atoi(argv[4]);
else if (chan->pbx->dtimeoutms) {
/* by default dtimeout is set to 5sec */
timeout = chan->pbx->dtimeoutms; /* in msec */
}
if (!(fs = ast_openstream(chan, argv[2], chan->language))) {
ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", 0, sample_offset);
ast_log(LOG_WARNING, "Unable to open %s\n", argv[2]);
return RESULT_SUCCESS;
}
if ((vfs = ast_openvstream(chan, argv[2], chan->language)))
ast_debug(1, "Ooh, found a video stream, too\n");
ast_verb(3, "Playing '%s' (escape_digits=%s) (timeout %d)\n", argv[2], edigits, timeout);
ast_seekstream(fs, 0, SEEK_END);
max_length = ast_tellstream(fs);
ast_seekstream(fs, sample_offset, SEEK_SET);
res = ast_applystream(chan, fs);
if (vfs)
vres = ast_applystream(chan, vfs);
ast_playstream(fs);
if (vfs)
ast_playstream(vfs);
res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
/* this is to check for if ast_waitstream closed the stream, we probably are at
* the end of the stream, return that amount, else check for the amount */
sample_offset = (chan->stream)?ast_tellstream(fs):max_length;
ast_stopstream(chan);
if (res == 1) {
/* Stop this command, don't print a result line, as there is a new command */
return RESULT_SUCCESS;
}
/* If the user didnt press a key, wait for digitTimeout*/
if (res == 0 ) {
res = ast_waitfordigit_full(chan, timeout, agi->audio, agi->ctrl);
/* Make sure the new result is in the escape digits of the GET OPTION */
if ( !strchr(edigits,res) )
res=0;
}
ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", res, sample_offset);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_getvariable | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1821 of file res_agi.c.
References ast_agi_send(), ast_func_read(), ast_strlen_zero(), agi_state::fd, pbx_retrieve_variable(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
char *ret;
char tempstr[1024] = "";
if (argc != 3)
return RESULT_SHOWUSAGE;
/* check if we want to execute an ast_custom_function */
if (!ast_strlen_zero(argv[2]) && (argv[2][strlen(argv[2]) - 1] == ')')) {
ret = ast_func_read(chan, argv[2], tempstr, sizeof(tempstr)) ? NULL : tempstr;
} else {
pbx_retrieve_variable(chan, argv[2], &ret, tempstr, sizeof(tempstr), NULL);
}
if (ret)
ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", ret);
else
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_getvariablefull | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1844 of file res_agi.c.
References ast_agi_send(), ast_channel_unlock, ast_get_channel_by_name_locked(), chan, agi_state::fd, ast_channel::name, pbx_substitute_variables_helper(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
char tmp[4096] = "";
struct ast_channel *chan2=NULL;
if ((argc != 4) && (argc != 5))
return RESULT_SHOWUSAGE;
if (argc == 5 && strcasecmp(chan->name, argv[4])) {
chan2 = ast_get_channel_by_name_locked(argv[4]);
} else {
chan2 = chan;
}
if (chan2) {
pbx_substitute_variables_helper(chan2, argv[3], tmp, sizeof(tmp) - 1);
ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", tmp);
} else {
ast_agi_send(agi->fd, chan, "200 result=0\n");
}
if (chan2 && (chan2 != chan))
ast_channel_unlock(chan2);
return RESULT_SUCCESS;
}
| static int handle_hangup | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1694 of file res_agi.c.
References ast_agi_send(), ast_channel_unlock, ast_get_channel_by_name_locked(), ast_softhangup(), AST_SOFTHANGUP_EXPLICIT, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
struct ast_channel *c;
if (argc == 1) {
/* no argument: hangup the current channel */
ast_softhangup(chan,AST_SOFTHANGUP_EXPLICIT);
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
} else if (argc == 2) {
/* one argument: look for info on the specified channel */
c = ast_get_channel_by_name_locked(argv[1]);
if (c) {
/* we have a matching channel */
ast_softhangup(c,AST_SOFTHANGUP_EXPLICIT);
ast_agi_send(agi->fd, chan, "200 result=1\n");
ast_channel_unlock(c);
return RESULT_SUCCESS;
}
/* if we get this far no channel name matched the argument given */
ast_agi_send(agi->fd, chan, "200 result=-1\n");
return RESULT_SUCCESS;
} else {
return RESULT_SHOWUSAGE;
}
}
| static int handle_noop | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | arg, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1983 of file res_agi.c.
References ast_agi_send(), agi_state::fd, and RESULT_SUCCESS.
{
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_recordfile | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1495 of file res_agi.c.
References ast_agi_send(), ast_applystream(), ast_closestream(), AST_CONTROL_VIDUPDATE, ast_dsp_free(), ast_dsp_get_threshold_from_settings(), ast_dsp_new(), ast_dsp_set_threshold(), ast_dsp_silence(), AST_FILE_MODE, AST_FORMAT_SLINEAR, AST_FRAME_DTMF, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_indicate(), ast_log(), ast_read(), ast_seekstream(), ast_set_read_format(), ast_stream_rewind(), ast_streamfile(), ast_tellstream(), ast_truncstream(), ast_tvdiff_ms(), ast_tvnow(), ast_waitfor(), ast_waitstream(), ast_writefile(), ast_writestream(), f, agi_state::fd, ast_frame::frametype, ast_channel::language, LOG_WARNING, ast_channel::name, ast_channel::readformat, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, ast_channel::stream, ast_frame::subclass, THRESHOLD_SILENCE, and ast_dsp::totalsilence.
{
struct ast_filestream *fs;
struct ast_frame *f;
struct timeval start;
long sample_offset = 0;
int res = 0;
int ms;
struct ast_dsp *sildet=NULL; /* silence detector dsp */
int totalsilence = 0;
int dspsilence = 0;
int silence = 0; /* amount of silence to allow */
int gotsilence = 0; /* did we timeout for silence? */
char *silencestr = NULL;
int rfmt = 0;
/* XXX EAGI FIXME XXX */
if (argc < 6)
return RESULT_SHOWUSAGE;
if (sscanf(argv[5], "%30d", &ms) != 1)
return RESULT_SHOWUSAGE;
if (argc > 6)
silencestr = strchr(argv[6],'s');
if ((argc > 7) && (!silencestr))
silencestr = strchr(argv[7],'s');
if ((argc > 8) && (!silencestr))
silencestr = strchr(argv[8],'s');
if (silencestr) {
if (strlen(silencestr) > 2) {
if ((silencestr[0] == 's') && (silencestr[1] == '=')) {
silencestr++;
silencestr++;
if (silencestr)
silence = atoi(silencestr);
if (silence > 0)
silence *= 1000;
}
}
}
if (silence > 0) {
rfmt = chan->readformat;
res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return RESULT_FAILURE;
}
sildet = ast_dsp_new();
if (!sildet) {
ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
ast_agi_send(agi->fd, chan, "200 result=-1\n");
return RESULT_FAILURE;
}
ast_dsp_set_threshold(sildet, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE));
}
/* backward compatibility, if no offset given, arg[6] would have been
* caught below and taken to be a beep, else if it is a digit then it is a
* offset */
if ((argc >6) && (sscanf(argv[6], "%30ld", &sample_offset) != 1) && (!strchr(argv[6], '=')))
res = ast_streamfile(chan, "beep", chan->language);
if ((argc > 7) && (!strchr(argv[7], '=')))
res = ast_streamfile(chan, "beep", chan->language);
if (!res)
res = ast_waitstream(chan, argv[4]);
if (res) {
ast_agi_send(agi->fd, chan, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
} else {
fs = ast_writefile(argv[2], argv[3], NULL, O_CREAT | O_WRONLY | (sample_offset ? O_APPEND : 0), 0, AST_FILE_MODE);
if (!fs) {
res = -1;
ast_agi_send(agi->fd, chan, "200 result=%d (writefile)\n", res);
if (sildet)
ast_dsp_free(sildet);
return RESULT_FAILURE;
}
/* Request a video update */
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
chan->stream = fs;
ast_applystream(chan,fs);
/* really should have checks */
ast_seekstream(fs, sample_offset, SEEK_SET);
ast_truncstream(fs);
start = ast_tvnow();
while ((ms < 0) || ast_tvdiff_ms(ast_tvnow(), start) < ms) {
res = ast_waitfor(chan, ms - ast_tvdiff_ms(ast_tvnow(), start));
if (res < 0) {
ast_closestream(fs);
ast_agi_send(agi->fd, chan, "200 result=%d (waitfor) endpos=%ld\n", res,sample_offset);
if (sildet)
ast_dsp_free(sildet);
return RESULT_FAILURE;
}
f = ast_read(chan);
if (!f) {
ast_agi_send(agi->fd, chan, "200 result=%d (hangup) endpos=%ld\n", -1, sample_offset);
ast_closestream(fs);
if (sildet)
ast_dsp_free(sildet);
return RESULT_FAILURE;
}
switch(f->frametype) {
case AST_FRAME_DTMF:
if (strchr(argv[4], f->subclass)) {
/* This is an interrupting chracter, so rewind to chop off any small
amount of DTMF that may have been recorded
*/
ast_stream_rewind(fs, 200);
ast_truncstream(fs);
sample_offset = ast_tellstream(fs);
ast_agi_send(agi->fd, chan, "200 result=%d (dtmf) endpos=%ld\n", f->subclass, sample_offset);
ast_closestream(fs);
ast_frfree(f);
if (sildet)
ast_dsp_free(sildet);
return RESULT_SUCCESS;
}
break;
case AST_FRAME_VOICE:
ast_writestream(fs, f);
/* this is a safe place to check progress since we know that fs
* is valid after a write, and it will then have our current
* location */
sample_offset = ast_tellstream(fs);
if (silence > 0) {
dspsilence = 0;
ast_dsp_silence(sildet, f, &dspsilence);
if (dspsilence) {
totalsilence = dspsilence;
} else {
totalsilence = 0;
}
if (totalsilence > silence) {
/* Ended happily with silence */
gotsilence = 1;
break;
}
}
break;
case AST_FRAME_VIDEO:
ast_writestream(fs, f);
default:
/* Ignore all other frames */
break;
}
ast_frfree(f);
if (gotsilence)
break;
}
if (gotsilence) {
ast_stream_rewind(fs, silence-1000);
ast_truncstream(fs);
sample_offset = ast_tellstream(fs);
}
ast_agi_send(agi->fd, chan, "200 result=%d (timeout) endpos=%ld\n", res, sample_offset);
ast_closestream(fs);
}
if (silence > 0) {
res = ast_set_read_format(chan, rfmt);
if (res)
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
ast_dsp_free(sildet);
}
return RESULT_SUCCESS;
}
| static int handle_recvchar | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1074 of file res_agi.c.
References ast_agi_send(), ast_recvchar(), agi_state::fd, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if (argc != 3)
return RESULT_SHOWUSAGE;
res = ast_recvchar(chan,atoi(argv[2]));
if (res == 0) {
ast_agi_send(agi->fd, chan, "200 result=%d (timeout)\n", res);
return RESULT_SUCCESS;
}
if (res > 0) {
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return RESULT_SUCCESS;
}
ast_agi_send(agi->fd, chan, "200 result=%d (hangup)\n", res);
return RESULT_FAILURE;
}
| static int handle_recvtext | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1094 of file res_agi.c.
References ast_agi_send(), ast_free, ast_recvtext(), buf, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
char *buf;
if (argc != 3)
return RESULT_SHOWUSAGE;
buf = ast_recvtext(chan, atoi(argv[2]));
if (buf) {
ast_agi_send(agi->fd, chan, "200 result=1 (%s)\n", buf);
ast_free(buf);
} else {
ast_agi_send(agi->fd, chan, "200 result=-1\n");
}
return RESULT_SUCCESS;
}
| static int handle_sayalpha | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1340 of file res_agi.c.
References ast_agi_send(), ast_say_character_str_full, agi_state::audio, agi_state::ctrl, agi_state::fd, ast_channel::language, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if (argc != 4)
return RESULT_SHOWUSAGE;
res = ast_say_character_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
if (res == 1) /* New command */
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_saydate | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1354 of file res_agi.c.
References ast_agi_send(), ast_say_date, agi_state::fd, ast_channel::language, num, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res, num;
if (argc != 4)
return RESULT_SHOWUSAGE;
if (sscanf(argv[2], "%30d", &num) != 1)
return RESULT_SHOWUSAGE;
res = ast_say_date(chan, num, argv[3], chan->language);
if (res == 1)
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_saydatetime | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1384 of file res_agi.c.
References ast_agi_send(), ast_get_time_t(), ast_say_date_with_format, ast_strlen_zero(), agi_state::fd, format, ast_channel::language, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res = 0;
time_t unixtime;
char *format, *zone = NULL;
if (argc < 4)
return RESULT_SHOWUSAGE;
if (argc > 4) {
format = argv[4];
} else {
/* XXX this doesn't belong here, but in the 'say' module */
if (!strcasecmp(chan->language, "de")) {
format = "A dBY HMS";
} else {
format = "ABdY 'digits/at' IMp";
}
}
if (argc > 5 && !ast_strlen_zero(argv[5]))
zone = argv[5];
if (ast_get_time_t(argv[2], &unixtime, 0, NULL))
return RESULT_SHOWUSAGE;
res = ast_say_date_with_format(chan, unixtime, argv[3], chan->language, format, zone);
if (res == 1)
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_saydigits | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1324 of file res_agi.c.
References ast_agi_send(), ast_say_digit_str_full, agi_state::audio, agi_state::ctrl, agi_state::fd, ast_channel::language, num, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res, num;
if (argc != 4)
return RESULT_SHOWUSAGE;
if (sscanf(argv[2], "%30d", &num) != 1)
return RESULT_SHOWUSAGE;
res = ast_say_digit_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
if (res == 1) /* New command */
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_saynumber | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Say number in various language syntaxes.
Definition at line 1309 of file res_agi.c.
References ast_agi_send(), ast_say_number_full, agi_state::audio, agi_state::ctrl, agi_state::fd, ast_channel::language, num, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res, num;
if (argc < 4 || argc > 5)
return RESULT_SHOWUSAGE;
if (sscanf(argv[2], "%30d", &num) != 1)
return RESULT_SHOWUSAGE;
res = ast_say_number_full(chan, num, argv[3], chan->language, argc > 4 ? argv[4] : NULL, agi->audio, agi->ctrl);
if (res == 1)
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_sayphonetic | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1418 of file res_agi.c.
References ast_agi_send(), ast_say_phonetic_str_full, agi_state::audio, agi_state::ctrl, agi_state::fd, ast_channel::language, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if (argc != 4)
return RESULT_SHOWUSAGE;
res = ast_say_phonetic_str_full(chan, argv[2], argv[3], chan->language, agi->audio, agi->ctrl);
if (res == 1) /* New command */
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_saytime | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1369 of file res_agi.c.
References ast_agi_send(), ast_say_time, agi_state::fd, ast_channel::language, num, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res, num;
if (argc != 4)
return RESULT_SHOWUSAGE;
if (sscanf(argv[2], "%30d", &num) != 1)
return RESULT_SHOWUSAGE;
res = ast_say_time(chan, num, argv[3], chan->language);
if (res == 1)
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_sendimage | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1138 of file res_agi.c.
References ast_agi_send(), ast_check_hangup(), ast_send_image(), agi_state::fd, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if (argc != 3) {
return RESULT_SHOWUSAGE;
}
res = ast_send_image(chan, argv[2]);
if (!ast_check_hangup(chan)) {
res = 0;
}
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_sendtext | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1055 of file res_agi.c.
References ast_agi_send(), ast_sendtext(), agi_state::fd, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res;
if (argc != 3)
return RESULT_SHOWUSAGE;
/* At the moment, the parser (perhaps broken) returns with
the last argument PLUS the newline at the end of the input
buffer. This probably needs to be fixed, but I wont do that
because other stuff may break as a result. The right way
would probably be to strip off the trailing newline before
parsing, then here, add a newline at the end of the string
before sending it to ast_sendtext --DUDE */
res = ast_sendtext(chan, argv[2]);
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_setcallerid | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1768 of file res_agi.c.
References ast_agi_send(), ast_callerid_parse(), ast_copy_string(), ast_set_callerid(), ast_shrink_phone_number(), agi_state::fd, and RESULT_SUCCESS.
{
char tmp[256]="";
char *l = NULL, *n = NULL;
if (argv[2]) {
ast_copy_string(tmp, argv[2], sizeof(tmp));
ast_callerid_parse(tmp, &n, &l);
if (l)
ast_shrink_phone_number(l);
else
l = "";
if (!n)
n = "";
ast_set_callerid(chan, l, n, NULL);
}
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_setcontext | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1459 of file res_agi.c.
References ast_agi_send(), ast_copy_string(), ast_channel::context, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
if (argc != 3)
return RESULT_SHOWUSAGE;
ast_copy_string(chan->context, argv[2], sizeof(chan->context));
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_setextension | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1469 of file res_agi.c.
References ast_agi_send(), ast_copy_string(), ast_channel::exten, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
if (argc != 3)
return RESULT_SHOWUSAGE;
ast_copy_string(chan->exten, argv[2], sizeof(chan->exten));
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_setmusic | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1989 of file res_agi.c.
References ast_agi_send(), ast_moh_start(), ast_moh_stop(), agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
if (argc < 3) {
return RESULT_SHOWUSAGE;
}
if (!strncasecmp(argv[2], "on", 2))
ast_moh_start(chan, argc > 3 ? argv[3] : NULL, NULL);
else if (!strncasecmp(argv[2], "off", 3))
ast_moh_stop(chan);
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_setpriority | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1478 of file res_agi.c.
References ast_agi_send(), ast_explicit_goto(), ast_findlabel_extension(), ast_channel::cid, ast_callerid::cid_num, ast_channel::context, ast_channel::exten, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int pri;
if (argc != 3)
return RESULT_SHOWUSAGE;
if (sscanf(argv[2], "%30d", &pri) != 1) {
if ((pri = ast_findlabel_extension(chan, chan->context, chan->exten, argv[2], chan->cid.cid_num)) < 1)
return RESULT_SHOWUSAGE;
}
ast_explicit_goto(chan, NULL, NULL, pri);
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_setvariable | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1812 of file res_agi.c.
References ast_agi_send(), agi_state::fd, pbx_builtin_setvar_helper(), and RESULT_SUCCESS.
{
if (argv[3])
pbx_builtin_setvar_helper(chan, argv[2], argv[3]);
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_speechactivategrammar | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2085 of file res_agi.c.
References ast_agi_send(), ast_speech_grammar_activate(), agi_state::fd, RESULT_SHOWUSAGE, RESULT_SUCCESS, and agi_state::speech.
{
if (argc != 4)
return RESULT_SHOWUSAGE;
if (!agi->speech) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
if (ast_speech_grammar_activate(agi->speech, argv[3]))
ast_agi_send(agi->fd, chan, "200 result=0\n");
else
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_speechcreate | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2002 of file res_agi.c.
References ast_agi_send(), AST_FORMAT_SLINEAR, ast_speech_new(), agi_state::fd, RESULT_SUCCESS, and agi_state::speech.
{
/* If a structure already exists, return an error */
if (agi->speech) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
if ((agi->speech = ast_speech_new(argv[2], AST_FORMAT_SLINEAR)))
ast_agi_send(agi->fd, chan, "200 result=1\n");
else
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
| static int handle_speechdeactivategrammar | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2103 of file res_agi.c.
References ast_agi_send(), ast_speech_grammar_deactivate(), agi_state::fd, RESULT_SHOWUSAGE, RESULT_SUCCESS, and agi_state::speech.
{
if (argc != 4)
return RESULT_SHOWUSAGE;
if (!agi->speech) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
if (ast_speech_grammar_deactivate(agi->speech, argv[3]))
ast_agi_send(agi->fd, chan, "200 result=0\n");
else
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_speechdestroy | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2036 of file res_agi.c.
References ast_agi_send(), ast_speech_destroy(), agi_state::fd, RESULT_SUCCESS, and agi_state::speech.
{
if (agi->speech) {
ast_speech_destroy(agi->speech);
agi->speech = NULL;
ast_agi_send(agi->fd, chan, "200 result=1\n");
} else {
ast_agi_send(agi->fd, chan, "200 result=0\n");
}
return RESULT_SUCCESS;
}
| static int handle_speechloadgrammar | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2049 of file res_agi.c.
References ast_agi_send(), ast_speech_grammar_load(), agi_state::fd, RESULT_SHOWUSAGE, RESULT_SUCCESS, and agi_state::speech.
{
if (argc != 5)
return RESULT_SHOWUSAGE;
if (!agi->speech) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
if (ast_speech_grammar_load(agi->speech, argv[3], argv[4]))
ast_agi_send(agi->fd, chan, "200 result=0\n");
else
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_speechrecognize | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2140 of file res_agi.c.
References ast_agi_send(), ast_build_string(), ast_clear_flag, AST_CONTROL_HANGUP, AST_FORMAT_SLINEAR, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frfree, AST_LIST_NEXT, ast_mutex_lock(), ast_mutex_unlock(), ast_read(), ast_sched_runq(), ast_sched_wait(), ast_set_read_format(), ast_speech_change_state(), AST_SPEECH_QUIET, ast_speech_results_get(), ast_speech_start(), AST_SPEECH_STATE_DONE, AST_SPEECH_STATE_NOT_READY, AST_SPEECH_STATE_READY, AST_SPEECH_STATE_WAIT, ast_speech_write(), ast_stopstream(), ast_strlen_zero(), ast_tellstream(), ast_test_flag, ast_waitfor(), buf, ast_frame::data, ast_frame::datalen, agi_state::fd, ast_frame::frametype, ast_speech_result::grammar, ast_channel::language, ast_speech_result::list, ast_speech::lock, ast_speech::processing_sound, prompt, ast_frame::ptr, ast_channel::readformat, RESULT_SHOWUSAGE, RESULT_SUCCESS, ast_speech::results, ast_channel::sched, ast_speech_result::score, agi_state::speech, speech_streamfile(), ast_speech::state, ast_channel::stream, ast_channel::streamid, ast_frame::subclass, ast_speech_result::text, and ast_channel::timingfunc.
{
struct ast_speech *speech = agi->speech;
char *prompt, dtmf = 0, tmp[4096] = "", *buf = tmp;
int timeout = 0, offset = 0, old_read_format = 0, res = 0, i = 0;
long current_offset = 0;
const char *reason = NULL;
struct ast_frame *fr = NULL;
struct ast_speech_result *result = NULL;
size_t left = sizeof(tmp);
time_t start = 0, current;
if (argc < 4)
return RESULT_SHOWUSAGE;
if (!speech) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
prompt = argv[2];
timeout = atoi(argv[3]);
/* If offset is specified then convert from text to integer */
if (argc == 5)
offset = atoi(argv[4]);
/* We want frames coming in signed linear */
old_read_format = chan->readformat;
if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
/* Setup speech structure */
if (speech->state == AST_SPEECH_STATE_NOT_READY || speech->state == AST_SPEECH_STATE_DONE) {
ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY);
ast_speech_start(speech);
}
/* Start playing prompt */
speech_streamfile(chan, prompt, chan->language, offset);
/* Go into loop reading in frames, passing to speech thingy, checking for hangup, all that jazz */
while (ast_strlen_zero(reason)) {
/* Run scheduled items */
ast_sched_runq(chan->sched);
/* See maximum time of waiting */
if ((res = ast_sched_wait(chan->sched)) < 0)
res = 1000;
/* Wait for frame */
if (ast_waitfor(chan, res) > 0) {
if (!(fr = ast_read(chan))) {
reason = "hangup";
break;
}
}
/* Perform timeout check */
if ((timeout > 0) && (start > 0)) {
time(¤t);
if ((current - start) >= timeout) {
reason = "timeout";
if (fr)
ast_frfree(fr);
break;
}
}
/* Check the speech structure for any changes */
ast_mutex_lock(&speech->lock);
/* See if we need to quiet the audio stream playback */
if (ast_test_flag(speech, AST_SPEECH_QUIET) && chan->stream) {
current_offset = ast_tellstream(chan->stream);
ast_stopstream(chan);
ast_clear_flag(speech, AST_SPEECH_QUIET);
}
/* Check each state */
switch (speech->state) {
case AST_SPEECH_STATE_READY:
/* If the stream is done, start timeout calculation */
if ((timeout > 0) && start == 0 && ((!chan->stream) || (chan->streamid == -1 && chan->timingfunc == NULL))) {
ast_stopstream(chan);
time(&start);
}
/* Write audio frame data into speech engine if possible */
if (fr && fr->frametype == AST_FRAME_VOICE)
ast_speech_write(speech, fr->data.ptr, fr->datalen);
break;
case AST_SPEECH_STATE_WAIT:
/* Cue waiting sound if not already playing */
if ((!chan->stream) || (chan->streamid == -1 && chan->timingfunc == NULL)) {
ast_stopstream(chan);
/* If a processing sound exists, or is not none - play it */
if (!ast_strlen_zero(speech->processing_sound) && strcasecmp(speech->processing_sound, "none"))
speech_streamfile(chan, speech->processing_sound, chan->language, 0);
}
break;
case AST_SPEECH_STATE_DONE:
/* Get the results */
speech->results = ast_speech_results_get(speech);
/* Change state to not ready */
ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY);
reason = "speech";
break;
default:
break;
}
ast_mutex_unlock(&speech->lock);
/* Check frame for DTMF or hangup */
if (fr) {
if (fr->frametype == AST_FRAME_DTMF) {
reason = "dtmf";
dtmf = fr->subclass;
} else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_HANGUP) {
reason = "hangup";
}
ast_frfree(fr);
}
}
if (!strcasecmp(reason, "speech")) {
/* Build string containing speech results */
for (result = speech->results; result; result = AST_LIST_NEXT(result, list)) {
/* Build result string */
ast_build_string(&buf, &left, "%sscore%d=%d text%d=\"%s\" grammar%d=%s", (i > 0 ? " " : ""), i, result->score, i, result->text, i, result->grammar);
/* Increment result count */
i++;
}
/* Print out */
ast_agi_send(agi->fd, chan, "200 result=1 (speech) endpos=%ld results=%d %s\n", current_offset, i, tmp);
} else if (!strcasecmp(reason, "dtmf")) {
ast_agi_send(agi->fd, chan, "200 result=1 (digit) digit=%c endpos=%ld\n", dtmf, current_offset);
} else if (!strcasecmp(reason, "hangup") || !strcasecmp(reason, "timeout")) {
ast_agi_send(agi->fd, chan, "200 result=1 (%s) endpos=%ld\n", reason, current_offset);
} else {
ast_agi_send(agi->fd, chan, "200 result=0 endpos=%ld\n", current_offset);
}
return RESULT_SUCCESS;
}
| static int handle_speechset | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2018 of file res_agi.c.
References ast_agi_send(), ast_speech_change(), agi_state::fd, RESULT_SHOWUSAGE, RESULT_SUCCESS, and agi_state::speech.
{
/* Check for minimum arguments */
if (argc != 4)
return RESULT_SHOWUSAGE;
/* Check to make sure speech structure exists */
if (!agi->speech) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
ast_speech_change(agi->speech, argv[2], argv[3]);
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_speechunloadgrammar | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 2067 of file res_agi.c.
References ast_agi_send(), ast_speech_grammar_unload(), agi_state::fd, RESULT_SHOWUSAGE, RESULT_SUCCESS, and agi_state::speech.
{
if (argc != 4)
return RESULT_SHOWUSAGE;
if (!agi->speech) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
if (ast_speech_grammar_unload(agi->speech, argv[3]))
ast_agi_send(agi->fd, chan, "200 result=0\n");
else
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_streamfile | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1190 of file res_agi.c.
References ast_agi_send(), ast_applystream(), ast_debug, ast_openstream(), ast_openvstream(), ast_playstream(), ast_seekstream(), ast_stopstream(), ast_tellstream(), ast_verb, ast_waitstream_full(), agi_state::audio, agi_state::ctrl, agi_state::fd, ast_channel::language, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, ast_channel::stream, and ast_filestream::vfs.
{
int res, vres;
struct ast_filestream *fs, *vfs;
long sample_offset = 0, max_length;
char *edigits = "";
if (argc < 4 || argc > 5)
return RESULT_SHOWUSAGE;
if (argv[3])
edigits = argv[3];
if ((argc > 4) && (sscanf(argv[4], "%30ld", &sample_offset) != 1))
return RESULT_SHOWUSAGE;
if (!(fs = ast_openstream(chan, argv[2], chan->language))) {
ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", 0, sample_offset);
return RESULT_SUCCESS;
}
if ((vfs = ast_openvstream(chan, argv[2], chan->language)))
ast_debug(1, "Ooh, found a video stream, too\n");
ast_verb(3, "Playing '%s' (escape_digits=%s) (sample_offset %ld)\n", argv[2], edigits, sample_offset);
ast_seekstream(fs, 0, SEEK_END);
max_length = ast_tellstream(fs);
ast_seekstream(fs, sample_offset, SEEK_SET);
res = ast_applystream(chan, fs);
if (vfs)
vres = ast_applystream(chan, vfs);
ast_playstream(fs);
if (vfs)
ast_playstream(vfs);
res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
/* this is to check for if ast_waitstream closed the stream, we probably are at
* the end of the stream, return that amount, else check for the amount */
sample_offset = (chan->stream) ? ast_tellstream(fs) : max_length;
ast_stopstream(chan);
if (res == 1) {
/* Stop this command, don't print a result line, as there is a new command */
return RESULT_SUCCESS;
}
ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", res, sample_offset);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static int handle_tddmode | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1111 of file res_agi.c.
References ast_agi_send(), ast_channel_setoption(), AST_OPTION_TDD, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res, x;
if (argc != 3)
return RESULT_SHOWUSAGE;
if (!strncasecmp(argv[2],"on",2)) {
x = 1;
} else {
x = 0;
}
if (!strncasecmp(argv[2],"mate",4)) {
x = 2;
}
if (!strncasecmp(argv[2],"tdd",3)) {
x = 1;
}
res = ast_channel_setoption(chan, AST_OPTION_TDD, &x, sizeof(char), 0);
if (res != RESULT_SUCCESS) {
ast_agi_send(agi->fd, chan, "200 result=0\n");
} else {
ast_agi_send(agi->fd, chan, "200 result=1\n");
}
return RESULT_SUCCESS;
}
| static int handle_verbose | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char ** | argv | ||
| ) | [static] |
Definition at line 1867 of file res_agi.c.
References ast_agi_send(), ast_verb, ast_channel::data, agi_state::fd, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int level = 0;
if (argc < 2)
return RESULT_SHOWUSAGE;
if (argv[2])
sscanf(argv[2], "%30d", &level);
ast_verb(level, "%s: %s\n", chan->data, argv[1]);
ast_agi_send(agi->fd, chan, "200 result=1\n");
return RESULT_SUCCESS;
}
| static int handle_waitfordigit | ( | struct ast_channel * | chan, |
| AGI * | agi, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 1042 of file res_agi.c.
References ast_agi_send(), ast_waitfordigit_full(), agi_state::audio, agi_state::ctrl, agi_state::fd, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
{
int res, to;
if (argc != 4)
return RESULT_SHOWUSAGE;
if (sscanf(argv[3], "%30d", &to) != 1)
return RESULT_SHOWUSAGE;
res = ast_waitfordigit_full(chan, to, agi->audio, agi->ctrl);
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
| static char* help_workhorse | ( | int | fd, |
| char * | match[] | ||
| ) | [static] |
Definition at line 2533 of file res_agi.c.
References ast_cli(), ast_join(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_SUCCESS, agi_command::cmda, agi_command::dead, agi_command::list, MAX_CMD_LEN, S_OR, and agi_command::summary.
Referenced by handle_cli_agi_show().
{
char fullcmd[MAX_CMD_LEN], matchstr[MAX_CMD_LEN];
struct agi_command *e;
if (match)
ast_join(matchstr, sizeof(matchstr), match);
ast_cli(fd, "%5.5s %30.30s %s\n","Dead","Command","Description");
AST_RWLIST_RDLOCK(&agi_commands);
AST_RWLIST_TRAVERSE(&agi_commands, e, list) {
if (!e->cmda[0])
break;
/* Hide commands that start with '_' */
if ((e->cmda[0])[0] == '_')
continue;
ast_join(fullcmd, sizeof(fullcmd), e->cmda);
if (match && strncasecmp(matchstr, fullcmd, strlen(matchstr)))
continue;
ast_cli(fd, "%5.5s %30.30s %s\n", e->dead ? "Yes" : "No" , fullcmd, S_OR(e->summary, "Not available"));
}
AST_RWLIST_UNLOCK(&agi_commands);
return CLI_SUCCESS;
}
| static enum agi_result launch_asyncagi | ( | struct ast_channel * | chan, |
| char * | argv[], | ||
| int * | efd | ||
| ) | [static] |
Definition at line 618 of file res_agi.c.
References add_to_agi(), AGI_BUF_SIZE, agi_handle_command(), AGI_RESULT_FAILURE, AGI_RESULT_HANGUP, AGI_RESULT_SUCCESS_ASYNC, AMI_BUF_SIZE, ast_check_hangup(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_frfree, ast_log(), ast_read(), ast_speech_destroy(), ast_strlen_zero(), ast_uri_encode(), ast_waitfor(), agi_state::audio, agi_cmd::cmd_buffer, agi_cmd::cmd_id, agi_state::ctrl, EVENT_FLAG_AGI, f, agi_state::fast, agi_state::fd, ast_frame::frametype, free_agi_cmd(), get_agi_cmd(), LOG_DEBUG, LOG_ERROR, LOG_WARNING, manager_event, ast_channel::name, quit, setup_env(), agi_state::speech, and ast_frame::subclass.
Referenced by launch_script().
{
/* This buffer sizes might cause truncation if the AGI command writes more data
than AGI_BUF_SIZE as result. But let's be serious, is there an AGI command
that writes a response larger than 1024 bytes?, I don't think so, most of
them are just result=blah stuff. However probably if GET VARIABLE is called
and the variable has large amount of data, that could be a problem. We could
make this buffers dynamic, but let's leave that as a second step.
AMI_BUF_SIZE is twice AGI_BUF_SIZE just for the sake of choosing a safe
number. Some characters of AGI buf will be url encoded to be sent to manager
clients. An URL encoded character will take 3 bytes, but again, to cause
truncation more than about 70% of the AGI buffer should be URL encoded for
that to happen. Not likely at all.
On the other hand. I wonder if read() could eventually return less data than
the amount already available in the pipe? If so, how to deal with that?
So far, my tests on Linux have not had any problems.
*/
#define AGI_BUF_SIZE 1024
#define AMI_BUF_SIZE 2048
struct ast_frame *f;
struct agi_cmd *cmd;
int res, fds[2];
int timeout = 100;
char agi_buffer[AGI_BUF_SIZE + 1];
char ami_buffer[AMI_BUF_SIZE];
enum agi_result returnstatus = AGI_RESULT_SUCCESS_ASYNC;
AGI async_agi;
if (efd) {
ast_log(LOG_WARNING, "Async AGI does not support Enhanced AGI yet\n");
return AGI_RESULT_FAILURE;
}
/* add AsyncAGI datastore to the channel */
if (add_to_agi(chan)) {
ast_log(LOG_ERROR, "failed to start Async AGI on channel %s\n", chan->name);
return AGI_RESULT_FAILURE;
}
/* this pipe allows us to create a "fake" AGI struct to use
the AGI commands */
res = pipe(fds);
if (res) {
ast_log(LOG_ERROR, "failed to create Async AGI pipe\n");
/* intentionally do not remove datastore, added with
add_to_agi(), from channel. It will be removed when
the channel is hung up anyways */
return AGI_RESULT_FAILURE;
}
/* handlers will get the pipe write fd and we read the AGI responses
from the pipe read fd */
async_agi.fd = fds[1];
async_agi.ctrl = fds[1];
async_agi.audio = -1; /* no audio support */
async_agi.fast = 0;
async_agi.speech = NULL;
/* notify possible manager users of a new channel ready to
receive commands */
setup_env(chan, "async", fds[1], 0, 0, NULL);
/* read the environment */
res = read(fds[0], agi_buffer, AGI_BUF_SIZE);
if (!res) {
ast_log(LOG_ERROR, "failed to read from Async AGI pipe on channel %s\n", chan->name);
returnstatus = AGI_RESULT_FAILURE;
goto quit;
}
agi_buffer[res] = '\0';
/* encode it and send it thru the manager so whoever is going to take
care of AGI commands on this channel can decide which AGI commands
to execute based on the setup info */
ast_uri_encode(agi_buffer, ami_buffer, AMI_BUF_SIZE, 1);
manager_event(EVENT_FLAG_AGI, "AsyncAGI", "SubEvent: Start\r\nChannel: %s\r\nEnv: %s\r\n", chan->name, ami_buffer);
while (1) {
/* bail out if we need to hangup */
if (ast_check_hangup(chan)) {
ast_log(LOG_DEBUG, "ast_check_hangup returned true on chan %s\n", chan->name);
break;
}
/* retrieve a command
(commands are added via the manager or the cli threads) */
cmd = get_agi_cmd(chan);
if (cmd) {
/* OK, we have a command, let's call the
command handler. */
res = agi_handle_command(chan, &async_agi, cmd->cmd_buffer, 0);
if (res < 0) {
free_agi_cmd(cmd);
break;
}
/* the command handler must have written to our fake
AGI struct fd (the pipe), let's read the response */
res = read(fds[0], agi_buffer, AGI_BUF_SIZE);
if (!res) {
returnstatus = AGI_RESULT_FAILURE;
ast_log(LOG_ERROR, "failed to read from AsyncAGI pipe on channel %s\n", chan->name);
free_agi_cmd(cmd);
break;
}
/* we have a response, let's send the response thru the
manager. Include the CommandID if it was specified
when the command was added */
agi_buffer[res] = '\0';
ast_uri_encode(agi_buffer, ami_buffer, AMI_BUF_SIZE, 1);
if (ast_strlen_zero(cmd->cmd_id))
manager_event(EVENT_FLAG_AGI, "AsyncAGI", "SubEvent: Exec\r\nChannel: %s\r\nResult: %s\r\n", chan->name, ami_buffer);
else
manager_event(EVENT_FLAG_AGI, "AsyncAGI", "SubEvent: Exec\r\nChannel: %s\r\nCommandID: %s\r\nResult: %s\r\n", chan->name, cmd->cmd_id, ami_buffer);
free_agi_cmd(cmd);
} else {
/* no command so far, wait a bit for a frame to read */
res = ast_waitfor(chan, timeout);
if (res < 0) {
ast_log(LOG_DEBUG, "ast_waitfor returned <= 0 on chan %s\n", chan->name);
break;
}
if (res == 0)
continue;
f = ast_read(chan);
if (!f) {
ast_log(LOG_DEBUG, "No frame read on channel %s, going out ...\n", chan->name);
returnstatus = AGI_RESULT_HANGUP;
break;
}
/* is there any other frame we should care about
besides AST_CONTROL_HANGUP? */
if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
ast_log(LOG_DEBUG, "Got HANGUP frame on channel %s, going out ...\n", chan->name);
ast_frfree(f);
break;
}
ast_frfree(f);
}
}
if (async_agi.speech) {
ast_speech_destroy(async_agi.speech);
}
quit:
/* notify manager users this channel cannot be
controlled anymore by Async AGI */
manager_event(EVENT_FLAG_AGI, "AsyncAGI", "SubEvent: End\r\nChannel: %s\r\n", chan->name);
/* close the pipe */
close(fds[0]);
close(fds[1]);
/* intentionally don't get rid of the datastore. So commands can be
still in the queue in case AsyncAGI gets called again.
Datastore destructor will be called on channel destroy anyway */
return returnstatus;
#undef AGI_BUF_SIZE
#undef AMI_BUF_SIZE
}
| static enum agi_result launch_netscript | ( | char * | agiurl, |
| char * | argv[], | ||
| int * | fds, | ||
| int * | efd, | ||
| int * | opid | ||
| ) | [static] |
Definition at line 780 of file res_agi.c.
References AGI_PORT, AGI_RESULT_FAILURE, AGI_RESULT_SUCCESS_FAST, ast_agi_send(), ast_debug, ast_gethostbyname(), ast_log(), ast_poll, ast_strdupa, ast_strlen_zero(), errno, hp, LOG_WARNING, MAX_AGI_CONNECT, and s.
Referenced by launch_script().
{
int s, flags, res, port = AGI_PORT;
struct pollfd pfds[1];
char *host, *c, *script = "";
struct sockaddr_in addr_in;
struct hostent *hp;
struct ast_hostent ahp;
/* agiusl is "agi://host.domain[:port][/script/name]" */
host = ast_strdupa(agiurl + 6); /* Remove agi:// */
/* Strip off any script name */
if ((c = strchr(host, '/'))) {
*c = '\0';
c++;
script = c;
}
if ((c = strchr(host, ':'))) {
*c = '\0';
c++;
port = atoi(c);
}
if (efd) {
ast_log(LOG_WARNING, "AGI URI's don't support Enhanced AGI yet\n");
return -1;
}
if (!(hp = ast_gethostbyname(host, &ahp))) {
ast_log(LOG_WARNING, "Unable to locate host '%s'\n", host);
return -1;
}
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ast_log(LOG_WARNING, "Unable to create socket: %s\n", strerror(errno));
return -1;
}
if ((flags = fcntl(s, F_GETFL)) < 0) {
ast_log(LOG_WARNING, "Fcntl(F_GETFL) failed: %s\n", strerror(errno));
close(s);
return -1;
}
if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) {
ast_log(LOG_WARNING, "Fnctl(F_SETFL) failed: %s\n", strerror(errno));
close(s);
return -1;
}
memset(&addr_in, 0, sizeof(addr_in));
addr_in.sin_family = AF_INET;
addr_in.sin_port = htons(port);
memcpy(&addr_in.sin_addr, hp->h_addr, sizeof(addr_in.sin_addr));
if (connect(s, (struct sockaddr *)&addr_in, sizeof(addr_in)) && (errno != EINPROGRESS)) {
ast_log(LOG_WARNING, "Connect failed with unexpected error: %s\n", strerror(errno));
close(s);
return AGI_RESULT_FAILURE;
}
pfds[0].fd = s;
pfds[0].events = POLLOUT;
while ((res = ast_poll(pfds, 1, MAX_AGI_CONNECT)) != 1) {
if (errno != EINTR) {
if (!res) {
ast_log(LOG_WARNING, "FastAGI connection to '%s' timed out after MAX_AGI_CONNECT (%d) milliseconds.\n",
agiurl, MAX_AGI_CONNECT);
} else
ast_log(LOG_WARNING, "Connect to '%s' failed: %s\n", agiurl, strerror(errno));
close(s);
return AGI_RESULT_FAILURE;
}
}
if (ast_agi_send(s, NULL, "agi_network: yes\n") < 0) {
if (errno != EINTR) {
ast_log(LOG_WARNING, "Connect to '%s' failed: %s\n", agiurl, strerror(errno));
close(s);
return AGI_RESULT_FAILURE;
}
}
/* If we have a script parameter, relay it to the fastagi server */
/* Script parameters take the form of: AGI(agi://my.example.com/?extension=${EXTEN}) */
if (!ast_strlen_zero(script))
ast_agi_send(s, NULL, "agi_network_script: %s\n", script);
ast_debug(4, "Wow, connected!\n");
fds[0] = s;
fds[1] = s;
*opid = -1;
return AGI_RESULT_SUCCESS_FAST;
}
| static enum agi_result launch_script | ( | struct ast_channel * | chan, |
| char * | script, | ||
| char * | argv[], | ||
| int * | fds, | ||
| int * | efd, | ||
| int * | opid | ||
| ) | [static] |
Definition at line 868 of file res_agi.c.
References AGI_RESULT_FAILURE, AGI_RESULT_NOTFOUND, AGI_RESULT_SUCCESS, ast_child_verbose(), ast_close_fds_above_n(), ast_config_AST_AGI_DIR, ast_config_AST_CONFIG_DIR, ast_config_AST_CONFIG_FILE, ast_config_AST_DATA_DIR, ast_config_AST_KEY_DIR, ast_config_AST_LOG_DIR, ast_config_AST_MODULE_DIR, ast_config_AST_MONITOR_DIR, ast_config_AST_RUN_DIR, ast_config_AST_SPOOL_DIR, ast_config_AST_VAR_DIR, ast_log(), ast_safe_fork(), ast_set_priority(), ast_verb, errno, launch_asyncagi(), launch_netscript(), LOG_WARNING, and setenv().
Referenced by agi_exec_full().
{
char tmp[256];
int pid, toast[2], fromast[2], audio[2], res;
struct stat st;
if (!strncasecmp(script, "agi://", 6))
return launch_netscript(script, argv, fds, efd, opid);
if (!strncasecmp(script, "agi:async", sizeof("agi:async")-1))
return launch_asyncagi(chan, argv, efd);
if (script[0] != '/') {
snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_AGI_DIR, script);
script = tmp;
}
/* Before even trying let's see if the file actually exists */
if (stat(script, &st)) {
ast_log(LOG_WARNING, "Failed to execute '%s': File does not exist.\n", script);
return AGI_RESULT_NOTFOUND;
}
if (pipe(toast)) {
ast_log(LOG_WARNING, "Unable to create toast pipe: %s\n",strerror(errno));
return AGI_RESULT_FAILURE;
}
if (pipe(fromast)) {
ast_log(LOG_WARNING, "unable to create fromast pipe: %s\n", strerror(errno));
close(toast[0]);
close(toast[1]);
return AGI_RESULT_FAILURE;
}
if (efd) {
if (pipe(audio)) {
ast_log(LOG_WARNING, "unable to create audio pipe: %s\n", strerror(errno));
close(fromast[0]);
close(fromast[1]);
close(toast[0]);
close(toast[1]);
return AGI_RESULT_FAILURE;
}
res = fcntl(audio[1], F_GETFL);
if (res > -1)
res = fcntl(audio[1], F_SETFL, res | O_NONBLOCK);
if (res < 0) {
ast_log(LOG_WARNING, "unable to set audio pipe parameters: %s\n", strerror(errno));
close(fromast[0]);
close(fromast[1]);
close(toast[0]);
close(toast[1]);
close(audio[0]);
close(audio[1]);
return AGI_RESULT_FAILURE;
}
}
if ((pid = ast_safe_fork(1)) < 0) {
ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
return AGI_RESULT_FAILURE;
}
if (!pid) {
/* Pass paths to AGI via environmental variables */
setenv("AST_CONFIG_DIR", ast_config_AST_CONFIG_DIR, 1);
setenv("AST_CONFIG_FILE", ast_config_AST_CONFIG_FILE, 1);
setenv("AST_MODULE_DIR", ast_config_AST_MODULE_DIR, 1);
setenv("AST_SPOOL_DIR", ast_config_AST_SPOOL_DIR, 1);
setenv("AST_MONITOR_DIR", ast_config_AST_MONITOR_DIR, 1);
setenv("AST_VAR_DIR", ast_config_AST_VAR_DIR, 1);
setenv("AST_DATA_DIR", ast_config_AST_DATA_DIR, 1);
setenv("AST_LOG_DIR", ast_config_AST_LOG_DIR, 1);
setenv("AST_AGI_DIR", ast_config_AST_AGI_DIR, 1);
setenv("AST_KEY_DIR", ast_config_AST_KEY_DIR, 1);
setenv("AST_RUN_DIR", ast_config_AST_RUN_DIR, 1);
/* Don't run AGI scripts with realtime priority -- it causes audio stutter */
ast_set_priority(0);
/* Redirect stdin and out, provide enhanced audio channel if desired */
dup2(fromast[0], STDIN_FILENO);
dup2(toast[1], STDOUT_FILENO);
if (efd)
dup2(audio[0], STDERR_FILENO + 1);
else
close(STDERR_FILENO + 1);
/* Close everything but stdin/out/error */
ast_close_fds_above_n(STDERR_FILENO + 1);
/* Execute script */
/* XXX argv should be deprecated in favor of passing agi_argX paramaters */
execv(script, argv);
/* Can't use ast_log since FD's are closed */
ast_child_verbose(1, "Failed to execute '%s': %s", script, strerror(errno));
/* Special case to set status of AGI to failure */
fprintf(stdout, "failure\n");
fflush(stdout);
_exit(1);
}
ast_verb(3, "Launched AGI Script %s\n", script);
fds[0] = toast[0];
fds[1] = fromast[1];
if (efd)
*efd = audio[1];
/* close what we're not using in the parent */
close(toast[1]);
close(fromast[0]);
if (efd)
close(audio[0]);
*opid = pid;
return AGI_RESULT_SUCCESS;
}
| static int load_module | ( | void | ) | [static] |
Definition at line 3353 of file res_agi.c.
References action_add_agi_cmd(), agi_exec(), ARRAY_LEN, ast_agi_register_multiple(), ast_cli_register_multiple(), ast_manager_register2(), ast_register_application, cli_agi, commands, deadagi_exec(), eagi_exec(), EVENT_FLAG_AGI, mandescr_asyncagi, and ast_module_info::self.
{
ast_cli_register_multiple(cli_agi, ARRAY_LEN(cli_agi));
/* we can safely ignore the result of ast_agi_register_multiple() here, since it cannot fail, as
no other commands have been registered yet
*/
(void) ast_agi_register_multiple(ast_module_info->self, commands, ARRAY_LEN(commands));
ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
ast_register_application(eapp, eagi_exec, esynopsis, descrip);
ast_manager_register2("AGI", EVENT_FLAG_AGI, action_add_agi_cmd, "Add an AGI command to execute by Async AGI", mandescr_asyncagi);
return ast_register_application(app, agi_exec, synopsis, descrip);
}
| static int parse_args | ( | char * | s, |
| int * | max, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 2717 of file res_agi.c.
References ast_log(), LOG_WARNING, MAX_ARGS, and s.
Referenced by agi_handle_command().
{
int x = 0, quoted = 0, escaped = 0, whitespace = 1;
char *cur;
cur = s;
while(*s) {
switch(*s) {
case '"':
/* If it's escaped, put a literal quote */
if (escaped)
goto normal;
else
quoted = !quoted;
if (quoted && whitespace) {
/* If we're starting a quote, coming off white space start a new word, too */
argv[x++] = cur;
whitespace=0;
}
escaped = 0;
break;
case ' ':
case '\t':
if (!quoted && !escaped) {
/* If we're not quoted, mark this as whitespace, and
end the previous argument */
whitespace = 1;
*(cur++) = '\0';
} else
/* Otherwise, just treat it as anything else */
goto normal;
break;
case '\\':
/* If we're escaped, print a literal, otherwise enable escaping */
if (escaped) {
goto normal;
} else {
escaped=1;
}
break;
default:
normal:
if (whitespace) {
if (x >= MAX_ARGS -1) {
ast_log(LOG_WARNING, "Too many arguments, truncating\n");
break;
}
/* Coming off of whitespace, start the next argument */
argv[x++] = cur;
whitespace=0;
}
*(cur++) = *s;
escaped=0;
}
s++;
}
/* Null terminate */
*(cur++) = '\0';
argv[x] = NULL;
*max = x;
return 0;
}
| static enum agi_result run_agi | ( | struct ast_channel * | chan, |
| char * | request, | ||
| AGI * | agi, | ||
| int | pid, | ||
| int * | status, | ||
| int | dead, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 2857 of file res_agi.c.
References AGI_BUF_LEN, agi_handle_command(), AGI_NANDFS_RETRY, AGI_RESULT_FAILURE, AGI_RESULT_HANGUP, AGI_RESULT_SUCCESS, ast_channel_lock, ast_channel_unlock, ast_check_hangup(), ast_debug, ast_false(), AST_FRAME_VOICE, ast_frfree, ast_log(), ast_read(), ast_speech_destroy(), ast_strlen_zero(), ast_verb, ast_verbose(), ast_waitfor_nandfds(), agi_state::audio, buf, chan, agi_state::ctrl, ast_frame::data, ast_frame::datalen, errno, f, agi_state::fast, agi_state::fd, ast_frame::frametype, len(), LOG_WARNING, ast_channel::name, pbx_builtin_getvar_helper(), ast_frame::ptr, setup_env(), and agi_state::speech.
Referenced by agi_exec_full().
{
struct ast_channel *c;
int outfd, ms, needhup = 0;
enum agi_result returnstatus = AGI_RESULT_SUCCESS;
struct ast_frame *f;
char buf[AGI_BUF_LEN];
char *res = NULL;
FILE *readf;
/* how many times we'll retry if ast_waitfor_nandfs will return without either
channel or file descriptor in case select is interrupted by a system call (EINTR) */
int retry = AGI_NANDFS_RETRY;
int send_sighup;
const char *sighup_str;
ast_channel_lock(chan);
sighup_str = pbx_builtin_getvar_helper(chan, "AGISIGHUP");
send_sighup = ast_strlen_zero(sighup_str) || !ast_false(sighup_str);
ast_channel_unlock(chan);
if (!(readf = fdopen(agi->ctrl, "r"))) {
ast_log(LOG_WARNING, "Unable to fdopen file descriptor\n");
if (send_sighup && pid > -1)
kill(pid, SIGHUP);
close(agi->ctrl);
return AGI_RESULT_FAILURE;
}
setlinebuf(readf);
setup_env(chan, request, agi->fd, (agi->audio > -1), argc, argv);
for (;;) {
if (needhup) {
needhup = 0;
dead = 1;
if (send_sighup) {
if (pid > -1) {
kill(pid, SIGHUP);
} else if (agi->fast) {
send(agi->ctrl, "HANGUP\n", 7, 0);
}
}
}
ms = -1;
if (dead) {
c = ast_waitfor_nandfds(&chan, 0, &agi->ctrl, 1, NULL, &outfd, &ms);
} else if (!ast_check_hangup(chan)) {
c = ast_waitfor_nandfds(&chan, 1, &agi->ctrl, 1, NULL, &outfd, &ms);
} else {
/*
* Read the channel control queue until it is dry so we can
* switch to dead mode.
*/
c = chan;
}
if (c) {
retry = AGI_NANDFS_RETRY;
/* Idle the channel until we get a command */
f = ast_read(c);
if (!f) {
ast_debug(1, "%s hungup\n", chan->name);
needhup = 1;
if (!returnstatus) {
returnstatus = AGI_RESULT_HANGUP;
}
} else {
/* If it's voice, write it to the audio pipe */
if ((agi->audio > -1) && (f->frametype == AST_FRAME_VOICE)) {
/* Write, ignoring errors */
if (write(agi->audio, f->data.ptr, f->datalen) < 0) {
}
}
ast_frfree(f);
}
} else if (outfd > -1) {
size_t len = sizeof(buf);
size_t buflen = 0;
enum agi_result cmd_status;
retry = AGI_NANDFS_RETRY;
buf[0] = '\0';
while (len > 1) {
res = fgets(buf + buflen, len, readf);
if (feof(readf))
break;
if (ferror(readf) && ((errno != EINTR) && (errno != EAGAIN)))
break;
if (res != NULL && !agi->fast)
break;
buflen = strlen(buf);
if (buflen && buf[buflen - 1] == '\n')
break;
len = sizeof(buf) - buflen;
if (agidebug)
ast_verbose( "AGI Rx << temp buffer %s - errno %s\n", buf, strerror(errno));
}
if (!buf[0]) {
/* Program terminated */
ast_verb(3, "<%s>AGI Script %s completed, returning %d\n", chan->name, request, returnstatus);
if (pid > 0)
waitpid(pid, status, 0);
/* No need to kill the pid anymore, since they closed us */
pid = -1;
break;
}
/* Special case for inability to execute child process */
if (*buf && strncasecmp(buf, "failure", 7) == 0) {
returnstatus = AGI_RESULT_FAILURE;
break;
}
/* get rid of trailing newline, if any */
if (*buf && buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
if (agidebug)
ast_verbose("<%s>AGI Rx << %s\n", chan->name, buf);
cmd_status = agi_handle_command(chan, agi, buf, dead);
switch (cmd_status) {
case AGI_RESULT_FAILURE:
if (dead || !ast_check_hangup(chan)) {
/* The failure was not because of a hangup. */
returnstatus = AGI_RESULT_FAILURE;
}
break;
default:
break;
}
} else {
if (--retry <= 0) {
ast_log(LOG_WARNING, "No channel, no fd?\n");
returnstatus = AGI_RESULT_FAILURE;
break;
}
}
}
if (agi->speech) {
ast_speech_destroy(agi->speech);
}
/* Notify process */
if (send_sighup) {
if (pid > -1) {
if (kill(pid, SIGHUP)) {
ast_log(LOG_WARNING, "unable to send SIGHUP to AGI process %d: %s\n", pid, strerror(errno));
} else { /* Give the process a chance to die */
usleep(1);
}
waitpid(pid, status, WNOHANG);
} else if (agi->fast) {
send(agi->ctrl, "HANGUP\n", 7, 0);
}
}
fclose(readf);
return returnstatus;
}
| static void setup_env | ( | struct ast_channel * | chan, |
| char * | request, | ||
| int | fd, | ||
| int | enhanced, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) | [static] |
Definition at line 982 of file res_agi.c.
References ast_channel::accountcode, ast_agi_send(), ast_get_version(), ast_channel::cid, ast_callerid::cid_ani2, ast_callerid::cid_dnid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, ast_callerid::cid_rdnis, ast_callerid::cid_tns, ast_callerid::cid_ton, ast_channel::context, ast_channel::exten, ast_channel::language, ast_channel::name, ast_channel::priority, S_OR, ast_channel::tech, ast_channel_tech::type, and ast_channel::uniqueid.
Referenced by launch_asyncagi(), and run_agi().
{
int count;
/* Print initial environment, with agi_request always being the first
thing */
ast_agi_send(fd, chan, "agi_request: %s\n", request);
ast_agi_send(fd, chan, "agi_channel: %s\n", chan->name);
ast_agi_send(fd, chan, "agi_language: %s\n", chan->language);
ast_agi_send(fd, chan, "agi_type: %s\n", chan->tech->type);
ast_agi_send(fd, chan, "agi_uniqueid: %s\n", chan->uniqueid);
ast_agi_send(fd, chan, "agi_version: %s\n", ast_get_version());
/* ANI/DNIS */
ast_agi_send(fd, chan, "agi_callerid: %s\n", S_OR(chan->cid.cid_num, "unknown"));
ast_agi_send(fd, chan, "agi_calleridname: %s\n", S_OR(chan->cid.cid_name, "unknown"));
ast_agi_send(fd, chan, "agi_callingpres: %d\n", chan->cid.cid_pres);
ast_agi_send(fd, chan, "agi_callingani2: %d\n", chan->cid.cid_ani2);
ast_agi_send(fd, chan, "agi_callington: %d\n", chan->cid.cid_ton);
ast_agi_send(fd, chan, "agi_callingtns: %d\n", chan->cid.cid_tns);
ast_agi_send(fd, chan, "agi_dnid: %s\n", S_OR(chan->cid.cid_dnid, "unknown"));
ast_agi_send(fd, chan, "agi_rdnis: %s\n", S_OR(chan->cid.cid_rdnis, "unknown"));
/* Context information */
ast_agi_send(fd, chan, "agi_context: %s\n", chan->context);
ast_agi_send(fd, chan, "agi_extension: %s\n", chan->exten);
ast_agi_send(fd, chan, "agi_priority: %d\n", chan->priority);
ast_agi_send(fd, chan, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0");
/* User information */
ast_agi_send(fd, chan, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");
ast_agi_send(fd, chan, "agi_threadid: %ld\n", (long)pthread_self());
/* Send any parameters to the fastagi server that have been passed via the agi application */
/* Agi application paramaters take the form of: AGI(/path/to/example/script|${EXTEN}) */
for(count = 1; count < argc; count++)
ast_agi_send(fd, chan, "agi_arg_%d: %s\n", count, argv[count]);
/* End with empty return */
ast_agi_send(fd, chan, "\n");
}
| static int speech_streamfile | ( | struct ast_channel * | chan, |
| const char * | filename, | ||
| const char * | preflang, | ||
| int | offset | ||
| ) | [static] |
Definition at line 2121 of file res_agi.c.
References ast_applystream(), ast_openstream(), ast_playstream(), and ast_seekstream().
Referenced by handle_speechrecognize().
{
struct ast_filestream *fs = NULL;
if (!(fs = ast_openstream(chan, filename, preflang)))
return -1;
if (offset)
ast_seekstream(fs, offset, SEEK_SET);
if (ast_applystream(chan, fs))
return -1;
if (ast_playstream(fs))
return -1;
return 0;
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 3340 of file res_agi.c.
References ARRAY_LEN, ast_agi_unregister_multiple(), ast_cli_unregister_multiple(), ast_manager_unregister(), ast_unregister_application(), cli_agi, commands, and ast_module_info::self.
{
ast_cli_unregister_multiple(cli_agi, ARRAY_LEN(cli_agi));
/* we can safely ignore the result of ast_agi_unregister_multiple() here, since it cannot fail, as
we know that these commands were registered by this module and are still registered
*/
(void) ast_agi_unregister_multiple(ast_module_info->self, commands, ARRAY_LEN(commands));
ast_unregister_application(eapp);
ast_unregister_application(deadapp);
ast_manager_unregister("AGI");
return ast_unregister_application(app);
}
| static void write_html_escaped | ( | FILE * | htmlfile, |
| char * | str | ||
| ) | [static] |
Convert string to use HTML escaped characters.
Definition at line 3120 of file res_agi.c.
References str.
Referenced by write_htmldump().
{
char *cur = str;
while(*cur) {
switch (*cur) {
case '<':
fprintf(htmlfile, "%s", "<");
break;
case '>':
fprintf(htmlfile, "%s", ">");
break;
case '&':
fprintf(htmlfile, "%s", "&");
break;
case '"':
fprintf(htmlfile, "%s", """);
break;
default:
fprintf(htmlfile, "%c", *cur);
break;
}
cur++;
}
return;
}
| static int write_htmldump | ( | char * | filename | ) | [static] |
Definition at line 3148 of file res_agi.c.
References ast_free, ast_join(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_xmldoc_printable(), agi_command::cmda, agi_command::list, MAX_CMD_LEN, strsep(), agi_command::summary, agi_command::usage, and write_html_escaped().
Referenced by handle_cli_agi_dump_html().
{
struct agi_command *command;
char fullcmd[MAX_CMD_LEN];
FILE *htmlfile;
if (!(htmlfile = fopen(filename, "wt")))
return -1;
fprintf(htmlfile, "<HTML>\n<HEAD>\n<TITLE>AGI Commands</TITLE>\n</HEAD>\n");
fprintf(htmlfile, "<BODY>\n<CENTER><B><H1>AGI Commands</H1></B></CENTER>\n\n");
fprintf(htmlfile, "<TABLE BORDER=\"0\" CELLSPACING=\"10\">\n");
AST_RWLIST_RDLOCK(&agi_commands);
AST_RWLIST_TRAVERSE(&agi_commands, command, list) {
#ifdef AST_XML_DOCS
char *stringptmp;
#endif
char *tempstr, *stringp;
if (!command->cmda[0]) /* end ? */
break;
/* Hide commands that start with '_' */
if ((command->cmda[0])[0] == '_')
continue;
ast_join(fullcmd, sizeof(fullcmd), command->cmda);
fprintf(htmlfile, "<TR><TD><TABLE BORDER=\"1\" CELLPADDING=\"5\" WIDTH=\"100%%\">\n");
fprintf(htmlfile, "<TR><TH ALIGN=\"CENTER\"><B>%s - %s</B></TH></TR>\n", fullcmd, command->summary);
#ifdef AST_XML_DOCS
stringptmp = ast_xmldoc_printable(command->usage, 0);
stringp = stringptmp;
#else
stringp = command->usage;
#endif
tempstr = strsep(&stringp, "\n");
fprintf(htmlfile, "<TR><TD ALIGN=\"CENTER\">");
write_html_escaped(htmlfile, tempstr);
fprintf(htmlfile, "</TD></TR>\n");
fprintf(htmlfile, "<TR><TD ALIGN=\"CENTER\">\n");
while ((tempstr = strsep(&stringp, "\n")) != NULL) {
write_html_escaped(htmlfile, tempstr);
fprintf(htmlfile, "<BR>\n");
}
fprintf(htmlfile, "</TD></TR>\n");
fprintf(htmlfile, "</TABLE></TD></TR>\n\n");
#ifdef AST_XML_DOCS
ast_free(stringptmp);
#endif
}
AST_RWLIST_UNLOCK(&agi_commands);
fprintf(htmlfile, "</TABLE>\n</BODY>\n</HTML>\n");
fclose(htmlfile);
return 0;
}
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS , .description = "Asterisk Gateway Interface (AGI)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
struct ast_threadstorage agi_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_agi_buf , .custom_init = NULL , } [static] |
Definition at line 373 of file res_agi.c.
Referenced by ast_agi_send().
struct agi_commands agi_commands [static] |
Referenced by add_agi_cmd(), and get_agi_cmd().
struct ast_datastore_info agi_commands_datastore_info [static] |
{
.type = "AsyncAGI",
.destroy = agi_destroy_commands_cb
}
Definition at line 434 of file res_agi.c.
Referenced by add_agi_cmd(), add_to_agi(), and get_agi_cmd().
struct ast_module_info* ast_module_info = &__mod_info [static] |
struct ast_cli_entry cli_agi[] [static] |
Definition at line 3333 of file res_agi.c.
Referenced by load_module(), and unload_module().
struct agi_command commands[] [static] |
AGI commands list.
Definition at line 2482 of file res_agi.c.
Referenced by aji_dinfo_handler(), dundi_showframe(), load_module(), and unload_module().
char* deadsynopsis = "Executes AGI on a hungup channel" [static] |
char* descrip = " text string, one of SUCCESS | FAILURE | NOTFOUND | HANGUP\n" [static] |
char* esynopsis = "Executes an EAGI compliant application" [static] |
const char mandescr_asyncagi[] = "\n" [static] |
Definition at line 439 of file res_agi.c.
Referenced by load_module().
char usage_autohangup[] = " cause the autohangup feature to be disabled on this channel.\n" [static] |
char usage_controlstreamfile[] = " Note: ffchar and rewchar default to * and # respectively.\n" [static] |
char usage_recordfile[] = " preceded by \"s=\" and is also optional.\n" [static] |
char usage_recvchar[] = " -1 only on error/hangup.\n" [static] |
char usage_recvtext[] = " do not support the reception of text. Returns -1 for failure or 1 for success, and the string in parentheses.\n" [static] |
char usage_sayalpha[] = " -1 on error/hangup.\n" [static] |
char usage_saydate[] = " digit if one was pressed or -1 on error/hangup.\n" [static] |
char usage_saydatetime[] = " digit if one was pressed or -1 on error/hangup.\n" [static] |
char usage_saydigits[] = " -1 on error/hangup.\n" [static] |
char usage_saynumber[] = " -1 on error/hangup.\n" [static] |
char usage_sayphonetic[] = " if one was pressed, or -1 on error/hangup.\n" [static] |
char usage_saytime[] = " digit if one was pressed or -1 on error/hangup.\n" [static] |
char usage_sendimage[] = " should not include extensions.\n" [static] |
char usage_sendtext[] = " command only accepts a single argument.\n" [static] |
char usage_setcallerid[] = " Changes the callerid of the current channel.\n" [static] |
char usage_setcontext[] = " Sets the context for continuation upon exiting the application.\n" [static] |
char usage_setextension[] = " Changes the extension for continuation upon exiting the application.\n" [static] |
char usage_setpriority[] = " The priority must be a valid priority or label.\n" [static] |
char usage_setvariable[] = " Usage: SET VARIABLE <variablename> <value>\n" [static] |
char usage_speechactivategrammar[] = " Activates the specified grammar on the speech object.\n" [static] |
char usage_speechcreate[] = " Create a speech object to be used by the other Speech AGI commands.\n" [static] |
char usage_speechdeactivategrammar[] = " Deactivates the specified grammar on the speech object.\n" [static] |
char usage_speechdestroy[] = " Destroy the speech object created by SPEECH CREATE.\n" [static] |
char usage_speechloadgrammar[] = " Loads the specified grammar as the specified name.\n" [static] |
char usage_speechrecognize[] = " Plays back given prompt while listening for speech and dtmf.\n" [static] |
char usage_speechset[] = " Set an engine-specific setting.\n" [static] |
char usage_speechunloadgrammar[] = " Unloads the specified grammar.\n" [static] |
char usage_streamfile[] = " extension must not be included in the filename.\n" [static] |
char usage_tddmode[] = " successful, or 0 if channel is not TDD-capable.\n" [static] |
char usage_verbose[] = " Always returns 1.\n" [static] |
char usage_waitfordigit[] = " for the timeout value if you desire the call to block indefinitely.\n" [static] |