ReadFile application -- Reads in a File for you. More...
#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | load_module (void) |
static int | readfile_exec (struct ast_channel *chan, void *data) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Stores output of file into a variable" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
static char * | app_readfile = "ReadFile" |
static struct ast_module_info * | ast_module_info = &__mod_info |
ReadFile application -- Reads in a File for you.
Definition in file app_readfile.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 128 of file app_readfile.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 128 of file app_readfile.c.
static int load_module | ( | void | ) | [static] |
Definition at line 123 of file app_readfile.c.
References ast_register_application_xml, and readfile_exec().
{ return ast_register_application_xml(app_readfile, readfile_exec); }
static int readfile_exec | ( | struct ast_channel * | chan, |
void * | data | ||
) | [static] |
Definition at line 70 of file app_readfile.c.
References ast_free, ast_log(), ast_read_textfile(), ast_strdupa, ast_strlen_zero(), len(), LOG_ERROR, LOG_WARNING, pbx_builtin_setvar_helper(), s, and strsep().
Referenced by load_module().
{ int res=0; char *s, *varname=NULL, *file=NULL, *length=NULL, *returnvar=NULL; int len=0; static int deprecation_warning = 0; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "ReadFile require an argument!\n"); return -1; } s = ast_strdupa(data); varname = strsep(&s, "="); file = strsep(&s, ","); length = s; if (deprecation_warning++ % 10 == 0) ast_log(LOG_WARNING, "ReadFile has been deprecated in favor of Set(%s=${FILE(%s,0,%s)})\n", varname, file, length); if (!varname || !file) { ast_log(LOG_ERROR, "No file or variable specified!\n"); return -1; } if (length) { if ((sscanf(length, "%30d", &len) != 1) || (len < 0)) { ast_log(LOG_WARNING, "%s is not a positive number, defaulting length to max\n", length); len = 0; } } if ((returnvar = ast_read_textfile(file))) { if (len > 0) { if (len < strlen(returnvar)) returnvar[len]='\0'; else ast_log(LOG_WARNING, "%s is longer than %d, and %d \n", file, len, (int)strlen(returnvar)); } pbx_builtin_setvar_helper(chan, varname, returnvar); ast_free(returnvar); } return res; }
static int unload_module | ( | void | ) | [static] |
Definition at line 118 of file app_readfile.c.
References ast_unregister_application().
{ return ast_unregister_application(app_readfile); }
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Stores output of file into a variable" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 128 of file app_readfile.c.
char* app_readfile = "ReadFile" [static] |
Definition at line 68 of file app_readfile.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 128 of file app_readfile.c.