Sat Aug 6 00:39:29 2011

Asterisk developer's documentation


func_global.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2006, Tilghman Lesher
00005  *
00006  * Tilghman Lesher <func_global__200605@the-tilghman.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief Global variable dialplan functions
00022  *
00023  * \author Tilghman Lesher <func_global__200605@the-tilghman.com>
00024  */
00025 
00026 #include "asterisk.h"
00027 
00028 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 40722 $")
00029 
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <sys/types.h>
00034 #include <sys/stat.h>
00035 
00036 #include "asterisk/module.h"
00037 #include "asterisk/channel.h"
00038 #include "asterisk/pbx.h"
00039 #include "asterisk/utils.h"
00040 
00041 static int global_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
00042 {
00043    const char *var = pbx_builtin_getvar_helper(NULL, data);
00044 
00045    *buf = '\0';
00046 
00047    if (var)
00048       ast_copy_string(buf, var, len);
00049 
00050    return 0;
00051 }
00052 
00053 static int global_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
00054 {
00055    pbx_builtin_setvar_helper(NULL, data, value);
00056 
00057    return 0;
00058 }
00059 
00060 static struct ast_custom_function global_function = {
00061    .name = "GLOBAL",
00062    .synopsis = "Gets or sets the global variable specified",
00063    .syntax = "GLOBAL(<varname>)",
00064    .read = global_read,
00065    .write = global_write,
00066 };
00067 
00068 static int unload_module(void)
00069 {
00070    int res = 0;
00071 
00072    res |= ast_custom_function_unregister(&global_function);
00073 
00074    return res;
00075 }
00076 
00077 static int load_module(void)
00078 {
00079    int res = 0;
00080 
00081    res |= ast_custom_function_register(&global_function);
00082 
00083    return res;
00084 }
00085 
00086 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Global variable dialplan functions");

Generated on Sat Aug 6 00:39:29 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7