73 static int config_function_read(
struct ast_channel *chan,
const char *cmd,
char *data,
74 char *buf,
size_t len)
91 if (ast_strlen_zero(data)) {
92 ast_log(LOG_ERROR,
"AST_CONFIG() requires an argument\n");
99 if (ast_strlen_zero(args.filename)) {
100 ast_log(LOG_ERROR,
"AST_CONFIG() requires a filename\n");
104 if (ast_strlen_zero(args.category)) {
105 ast_log(LOG_ERROR,
"AST_CONFIG() requires a category\n");
109 if (ast_strlen_zero(args.variable)) {
110 ast_log(LOG_ERROR,
"AST_CONFIG() requires a variable\n");
114 if (!ast_strlen_zero(args.index)) {
115 if (!sscanf(args.index,
"%d", &index)) {
116 ast_log(LOG_ERROR,
"AST_CONFIG() index must be an integer\n");
121 if (!(cfg =
ast_config_load(args.filename, cfg_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
125 if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
129 if (!strcmp(cur->filename, args.filename)) {
138 if (!(cur =
ast_calloc(1,
sizeof(*cur) + strlen(args.filename) + 1))) {
143 strcpy(cur->filename, args.filename);
146 if (!(cfg =
ast_config_load(args.filename, cfg_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
161 if (!strcmp(cur->filename, args.filename)) {
167 if (!(cur =
ast_calloc(1,
sizeof(*cur) + strlen(args.filename) + 1))) {
172 strcpy(cur->filename, args.filename);
183 if (strcasecmp(args.variable, var->
name)) {
198 ast_debug(1,
"'%s' not found at index %d in [%s] of '%s'. Maximum index found: %d\n",
199 args.variable, index, args.category, args.filename, ix);
213 .
name =
"AST_CONFIG",
214 .read = config_function_read,
217 static int unload_module(
void)
223 while ((current = AST_RWLIST_REMOVE_HEAD(&
configs,
entry))) {
232 static int load_module(
void)
237 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Asterisk configuration file variable access");
struct ast_variable * next
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Structure for variables, used for configurations and for channel variables.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
struct ast_variable * ast_category_root(struct ast_config *config, char *cat)
returns the root ast_variable of a config
#define ast_config_load(filename, flags)
Load a config file.
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Data structure associated with a custom dialplan function.
#define ast_debug(level,...)
Log a DEBUG message.
Core PBX routines and definitions.
#define ast_calloc(num, len)
A wrapper for calloc()
Structure used to handle boolean flags.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
#define AST_APP_ARG(name)
Define an application argument.