fix compilation warnings
[asterisk-bristuff.git] / funcs / func_global.c
blob50a84afde07faa0396de1355bb628677f58ba6e0
1 /*
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.
19 /*! \file
21 * \brief Global variable dialplan functions
23 * \author Tilghman Lesher <func_global__200605@the-tilghman.com>
26 #include "asterisk.h"
28 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <sys/types.h>
34 #include <sys/stat.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);
45 *buf = '\0';
47 if (var)
48 ast_copy_string(buf, var, len);
50 return 0;
53 static int global_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
55 pbx_builtin_setvar_helper(NULL, data, value);
57 return 0;
60 static struct ast_custom_function global_function = {
61 .name = "GLOBAL",
62 .synopsis = "Gets or sets the global variable specified",
63 .syntax = "GLOBAL(<varname>)",
64 .read = global_read,
65 .write = global_write,
68 static int unload_module(void)
70 int res = 0;
72 res |= ast_custom_function_unregister(&global_function);
74 return res;
77 static int load_module(void)
79 int res = 0;
81 res |= ast_custom_function_register(&global_function);
83 return res;
86 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Global variable dialplan functions");