2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2006, Tilghman Lesher
6 * Tilghman Lesher <func_global__200605@the-tilghman.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief Global variable dialplan functions
23 * \author Tilghman Lesher <func_global__200605@the-tilghman.com>
28 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
33 #include <sys/types.h>
36 #include "asterisk/module.h"
37 #include "asterisk/channel.h"
38 #include "asterisk/pbx.h"
39 #include "asterisk/utils.h"
41 static int global_read(struct ast_channel
*chan
, char *cmd
, char *data
, char *buf
, size_t len
)
43 const char *var
= pbx_builtin_getvar_helper(NULL
, data
);
48 ast_copy_string(buf
, var
, len
);
53 static int global_write(struct ast_channel
*chan
, char *cmd
, char *data
, const char *value
)
55 pbx_builtin_setvar_helper(NULL
, data
, value
);
60 static struct ast_custom_function global_function
= {
62 .synopsis
= "Gets or sets the global variable specified",
63 .syntax
= "GLOBAL(<varname>)",
65 .write
= global_write
,
68 static int unload_module(void)
72 res
|= ast_custom_function_unregister(&global_function
);
77 static int load_module(void)
81 res
|= ast_custom_function_register(&global_function
);
86 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Global variable dialplan functions");