#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Include dependency graph for func_shell.c:
Go to the source code of this file.
Functions | |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"SHELL dialplan function") | |
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 |
\ Inspiration and Guidance from Russell! Thank You!
Definition in file func_shell.c.
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"SHELL dialplan function" | ||||
) |
static int load_module | ( | void | ) | [static] |
Definition at line 84 of file func_shell.c.
References ast_custom_function_register(), and shell_function.
00085 { 00086 return ast_custom_function_register(&shell_function); 00087 }
static int shell_helper | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 42 of file func_shell.c.
References ast_log(), ast_strlen_zero(), and LOG_WARNING.
00044 { 00045 if (ast_strlen_zero(data)) { 00046 ast_log(LOG_WARNING, "Missing Argument! Example: Set(foo=${SHELL(echo \"bar\")})\n"); 00047 return -1; 00048 } 00049 00050 if (len >= 1) { 00051 FILE *ptr; 00052 char plbuff[4096]; 00053 00054 ptr = popen(data, "r"); 00055 while (fgets(plbuff, sizeof(plbuff), ptr)) { 00056 strncat(buf, plbuff, len - strlen(buf) - 1); 00057 } 00058 pclose(ptr); 00059 } 00060 00061 return 0; 00062 }
static int unload_module | ( | void | ) | [static] |
Definition at line 79 of file func_shell.c.
References ast_custom_function_unregister(), and shell_function.
00080 { 00081 return ast_custom_function_unregister(&shell_function); 00082 }
struct ast_custom_function shell_function [static] |