#include "asterisk.h"#include "asterisk/module.h"#include "asterisk/channel.h"#include "asterisk/pbx.h"#include "asterisk/utils.h"#include "asterisk/app.h"
Go to the source code of this file.
Functions | |
| AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Returns the output of a shell command") | |
| static int | load_module (void) |
| static int | shell_helper (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | unload_module (void) |
Variables | |
| static struct ast_custom_function | shell_function |
SHELL function to return the value of a system call.
Definition in file func_shell.c.
| AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
| "Returns the output of a shell command" | ||||
| ) |
| static int load_module | ( | void | ) | [static] |
Definition at line 98 of file func_shell.c.
References ast_custom_function_register.
00099 { 00100 return ast_custom_function_register(&shell_function); 00101 }
| static int shell_helper | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 38 of file func_shell.c.
References ast_autoservice_start(), ast_autoservice_stop(), ast_log(), ast_strlen_zero(), and LOG_WARNING.
00040 { 00041 if (ast_strlen_zero(data)) { 00042 ast_log(LOG_WARNING, "Missing Argument! Example: Set(foo=${SHELL(echo \"bar\")})\n"); 00043 return -1; 00044 } 00045 00046 if (chan) 00047 ast_autoservice_start(chan); 00048 00049 if (len >= 1) { 00050 FILE *ptr; 00051 char plbuff[4096]; 00052 00053 ptr = popen(data, "r"); 00054 while (fgets(plbuff, sizeof(plbuff), ptr)) { 00055 strncat(buf, plbuff, len - strlen(buf) - 1); 00056 } 00057 pclose(ptr); 00058 } 00059 00060 if (chan) 00061 ast_autoservice_stop(chan); 00062 00063 return 0; 00064 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 93 of file func_shell.c.
References ast_custom_function_unregister().
00094 { 00095 return ast_custom_function_unregister(&shell_function); 00096 }
struct ast_custom_function shell_function [static] |
{
.name = "SHELL",
.read = shell_helper,
}
Definition at line 88 of file func_shell.c.
1.6.1