AGI Extension interfaces - Asterisk Gateway Interface. More...
#include "asterisk/cli.h"

Go to the source code of this file.
Data Structures | |
| struct | agi_command |
| struct | agi_state |
Defines | |
| #define | AGI_WEAK |
Typedefs | |
| typedef struct agi_state | AGI |
Functions | |
| int AGI_WEAK | ast_agi_register (struct ast_module *mod, agi_command *cmd) |
| int AGI_WEAK | 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 AGI_WEAK | ast_agi_send (int fd, struct ast_channel *chan, char *fmt,...) |
| Sends a string of text to an application connected via AGI. | |
| int AGI_WEAK | ast_agi_unregister (struct ast_module *mod, agi_command *cmd) |
| int AGI_WEAK | 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. | |
AGI Extension interfaces - Asterisk Gateway Interface.
Definition in file agi.h.
| int AGI_WEAK ast_agi_register | ( | struct ast_module * | mod, | |
| agi_command * | cmd | |||
| ) |
Definition at line 2389 of file res_agi.c.
References ast_join(), AST_LIST_INSERT_TAIL, ast_log(), ast_module_ref(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, agi_command::cmda, find_command(), LOG_WARNING, and agi_command::mod.
Referenced by ast_agi_register_multiple(), and load_module().
02390 { 02391 char fullcmd[80]; 02392 02393 ast_join(fullcmd, sizeof(fullcmd), cmd->cmda); 02394 02395 if (!find_command(cmd->cmda,1)) { 02396 cmd->mod = mod; 02397 AST_RWLIST_WRLOCK(&agi_commands); 02398 AST_LIST_INSERT_TAIL(&agi_commands, cmd, list); 02399 AST_RWLIST_UNLOCK(&agi_commands); 02400 if (mod != ast_module_info->self) 02401 ast_module_ref(ast_module_info->self); 02402 ast_verb(2, "AGI Command '%s' registered\n",fullcmd); 02403 return 1; 02404 } else { 02405 ast_log(LOG_WARNING, "Command already registered!\n"); 02406 return 0; 02407 } 02408 }
| int AGI_WEAK 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 commands | |
| len | Length of the array (use the ARRAY_LEN macro to determine this easily) |
Definition at line 2437 of file res_agi.c.
References ast_agi_register(), and ast_agi_unregister().
Referenced by load_module().
02438 { 02439 unsigned int i, x = 0; 02440 02441 for (i = 0; i < len; i++) { 02442 if (ast_agi_register(mod, cmd + i) == 1) { 02443 x++; 02444 continue; 02445 } 02446 02447 /* registration failed, unregister everything 02448 that had been registered up to that point 02449 */ 02450 for (; x > 0; x--) { 02451 /* we are intentionally ignoring the 02452 result of ast_agi_unregister() here, 02453 but it should be safe to do so since 02454 we just registered these commands and 02455 the only possible way for unregistration 02456 to fail is if the command is not 02457 registered 02458 */ 02459 (void) ast_agi_unregister(mod, cmd + x - 1); 02460 } 02461 return -1; 02462 } 02463 02464 return 0; 02465 }
| int AGI_WEAK 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 118 of file res_agi.c.
References agi_buf, AGI_BUF_INITSIZE, ast_carefulwrite(), ast_log(), ast_str_set_va(), ast_str_thread_get(), ast_verbose, buf, LOG_ERROR, ast_str::str, and ast_str::used.
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().
00119 { 00120 int res = 0; 00121 va_list ap; 00122 struct ast_str *buf; 00123 00124 if (!(buf = ast_str_thread_get(&agi_buf, AGI_BUF_INITSIZE))) 00125 return -1; 00126 00127 va_start(ap, fmt); 00128 res = ast_str_set_va(&buf, 0, fmt, ap); 00129 va_end(ap); 00130 00131 if (res == -1) { 00132 ast_log(LOG_ERROR, "Out of memory\n"); 00133 return -1; 00134 } 00135 00136 if (agidebug) { 00137 if (chan) { 00138 ast_verbose("<%s>AGI Tx >> %s", chan->name, buf->str); 00139 } else { 00140 ast_verbose("AGI Tx >> %s", buf->str); 00141 } 00142 } 00143 00144 return ast_carefulwrite(fd, buf->str, buf->used, 100); 00145 }
| int AGI_WEAK ast_agi_unregister | ( | struct ast_module * | mod, | |
| agi_command * | cmd | |||
| ) |
Definition at line 2410 of file res_agi.c.
References 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, agi_command::cmda, and LOG_WARNING.
Referenced by ast_agi_register_multiple(), ast_agi_unregister_multiple(), and unload_module().
02411 { 02412 struct agi_command *e; 02413 int unregistered = 0; 02414 char fullcmd[80]; 02415 02416 ast_join(fullcmd, sizeof(fullcmd), cmd->cmda); 02417 02418 AST_RWLIST_WRLOCK(&agi_commands); 02419 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&agi_commands, e, list) { 02420 if (cmd == e) { 02421 AST_RWLIST_REMOVE_CURRENT(list); 02422 if (mod != ast_module_info->self) 02423 ast_module_unref(ast_module_info->self); 02424 unregistered=1; 02425 break; 02426 } 02427 } 02428 AST_RWLIST_TRAVERSE_SAFE_END; 02429 AST_RWLIST_UNLOCK(&agi_commands); 02430 if (unregistered) 02431 ast_verb(2, "AGI Command '%s' unregistered\n",fullcmd); 02432 else 02433 ast_log(LOG_WARNING, "Unable to unregister command: '%s'!\n",fullcmd); 02434 return unregistered; 02435 }
| int AGI_WEAK 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 commands | |
| len | Length of the array (use the ARRAY_LEN macro to determine this easily) |
Definition at line 2467 of file res_agi.c.
References ast_agi_unregister().
Referenced by unload_module().
02468 { 02469 unsigned int i; 02470 int res = 0; 02471 02472 for (i = 0; i < len; i++) { 02473 /* remember whether any of the unregistration 02474 attempts failed... there is no recourse if 02475 any of them do 02476 */ 02477 res |= ast_agi_unregister(mod, cmd + i); 02478 } 02479 02480 return res; 02481 }
1.6.1