#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.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"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | env_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | env_write (struct ast_channel *chan, char *cmd, char *data, const char *value) |
static int | load_module (void) |
static int | stat_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Environment/filesystem dialplan functions" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | env_function |
static struct ast_custom_function | stat_function |
Definition in file func_env.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 158 of file func_env.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 158 of file func_env.c.
static int env_read | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 40 of file func_env.c.
References ast_copy_string().
00042 { 00043 char *ret = NULL; 00044 00045 *buf = '\0'; 00046 00047 if (data) 00048 ret = getenv(data); 00049 00050 if (ret) 00051 ast_copy_string(buf, ret, len); 00052 00053 return 0; 00054 }
static int env_write | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 56 of file func_env.c.
References ast_strlen_zero().
00058 { 00059 if (!ast_strlen_zero(data)) { 00060 if (!ast_strlen_zero(value)) { 00061 setenv(data, value, 1); 00062 } else { 00063 unsetenv(data); 00064 } 00065 } 00066 00067 return 0; 00068 }
static int load_module | ( | void | ) | [static] |
Definition at line 148 of file func_env.c.
References ast_custom_function_register(), env_function, and stat_function.
00149 { 00150 int res = 0; 00151 00152 res |= ast_custom_function_register(&env_function); 00153 res |= ast_custom_function_register(&stat_function); 00154 00155 return res; 00156 }
static int stat_read | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 70 of file func_env.c.
References ast_copy_string().
00072 { 00073 char *action; 00074 struct stat s; 00075 00076 ast_copy_string(buf, "0", len); 00077 00078 action = strsep(&data, "|"); 00079 if (stat(data, &s)) { 00080 return 0; 00081 } else { 00082 switch (*action) { 00083 case 'e': 00084 strcpy(buf, "1"); 00085 break; 00086 case 's': 00087 snprintf(buf, len, "%d", (unsigned int) s.st_size); 00088 break; 00089 case 'f': 00090 snprintf(buf, len, "%d", S_ISREG(s.st_mode) ? 1 : 0); 00091 break; 00092 case 'd': 00093 snprintf(buf, len, "%d", S_ISDIR(s.st_mode) ? 1 : 0); 00094 break; 00095 case 'M': 00096 snprintf(buf, len, "%d", (int) s.st_mtime); 00097 break; 00098 case 'A': 00099 snprintf(buf, len, "%d", (int) s.st_mtime); 00100 break; 00101 case 'C': 00102 snprintf(buf, len, "%d", (int) s.st_ctime); 00103 break; 00104 case 'm': 00105 snprintf(buf, len, "%o", (int) s.st_mode); 00106 break; 00107 } 00108 } 00109 00110 return 0; 00111 }
static int unload_module | ( | void | ) | [static] |
Definition at line 138 of file func_env.c.
References ast_custom_function_unregister(), env_function, and stat_function.
00139 { 00140 int res = 0; 00141 00142 res |= ast_custom_function_unregister(&env_function); 00143 res |= ast_custom_function_unregister(&stat_function); 00144 00145 return res; 00146 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Environment/filesystem dialplan functions" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 158 of file func_env.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 158 of file func_env.c.
struct ast_custom_function env_function [static] |
struct ast_custom_function stat_function [static] |