#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, const char *data) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Stores output of file into a variable" , .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, .load_pri = AST_MODPRI_DEFAULT, } |
| static char * | app_readfile = "ReadFile" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
Definition in file app_readfile.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 134 of file app_readfile.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 134 of file app_readfile.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 129 of file app_readfile.c.
References ast_register_application_xml, and readfile_exec().
00130 { 00131 return ast_register_application_xml(app_readfile, readfile_exec); 00132 }
| static int readfile_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
Definition at line 76 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(), and strsep().
Referenced by load_module().
00077 { 00078 int res=0; 00079 char *s, *varname=NULL, *file=NULL, *length=NULL, *returnvar=NULL; 00080 int len=0; 00081 static int deprecation_warning = 0; 00082 00083 if (ast_strlen_zero(data)) { 00084 ast_log(LOG_WARNING, "ReadFile require an argument!\n"); 00085 return -1; 00086 } 00087 00088 s = ast_strdupa(data); 00089 00090 varname = strsep(&s, "="); 00091 file = strsep(&s, ","); 00092 length = s; 00093 00094 if (deprecation_warning++ % 10 == 0) 00095 ast_log(LOG_WARNING, "ReadFile has been deprecated in favor of Set(%s=${FILE(%s,0,%s)})\n", varname, file, length); 00096 00097 if (!varname || !file) { 00098 ast_log(LOG_ERROR, "No file or variable specified!\n"); 00099 return -1; 00100 } 00101 00102 if (length) { 00103 if ((sscanf(length, "%30d", &len) != 1) || (len < 0)) { 00104 ast_log(LOG_WARNING, "%s is not a positive number, defaulting length to max\n", length); 00105 len = 0; 00106 } 00107 } 00108 00109 if ((returnvar = ast_read_textfile(file))) { 00110 if (len > 0) { 00111 if (len < strlen(returnvar)) 00112 returnvar[len]='\0'; 00113 else 00114 ast_log(LOG_WARNING, "%s is longer than %d, and %d \n", file, len, (int)strlen(returnvar)); 00115 } 00116 pbx_builtin_setvar_helper(chan, varname, returnvar); 00117 ast_free(returnvar); 00118 } 00119 00120 return res; 00121 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 124 of file app_readfile.c.
References ast_unregister_application().
00125 { 00126 return ast_unregister_application(app_readfile); 00127 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Stores output of file into a variable" , .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, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 134 of file app_readfile.c.
char* app_readfile = "ReadFile" [static] |
Definition at line 74 of file app_readfile.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 134 of file app_readfile.c.
1.5.6