mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-03 20:38:59 +00:00 
			
		
		
		
	- restructured build tree and makefiles to eliminate recursion problems - support for embedded modules - support for static builds - simpler cross-compilation support - simpler module/loader interface (no exported symbols) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
		
			
				
	
	
		
			87 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Asterisk -- An open source telephony toolkit.
 | 
						|
 *
 | 
						|
 * Copyright (C) 2006, Tilghman Lesher
 | 
						|
 *
 | 
						|
 * Tilghman Lesher <func_global__200605@the-tilghman.com>
 | 
						|
 *
 | 
						|
 * See http://www.asterisk.org for more information about
 | 
						|
 * the Asterisk project. Please do not directly contact
 | 
						|
 * any of the maintainers of this project for assistance;
 | 
						|
 * the project provides a web site, mailing lists and IRC
 | 
						|
 * channels for your use.
 | 
						|
 *
 | 
						|
 * This program is free software, distributed under the terms of
 | 
						|
 * the GNU General Public License Version 2. See the LICENSE file
 | 
						|
 * at the top of the source tree.
 | 
						|
 */
 | 
						|
 | 
						|
/*! \file
 | 
						|
 *
 | 
						|
 * \brief Global variable dialplan functions
 | 
						|
 *
 | 
						|
 * \author Tilghman Lesher <func_global__200605@the-tilghman.com>
 | 
						|
 */
 | 
						|
 | 
						|
#include "asterisk.h"
 | 
						|
 | 
						|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 | 
						|
 | 
						|
#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/utils.h"
 | 
						|
 | 
						|
static int global_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 | 
						|
{
 | 
						|
	const char *var = pbx_builtin_getvar_helper(NULL, data);
 | 
						|
 | 
						|
	*buf = '\0';
 | 
						|
 | 
						|
	if (var)
 | 
						|
		ast_copy_string(buf, var, len);
 | 
						|
 | 
						|
	return 0;
 | 
						|
}
 | 
						|
 | 
						|
static int global_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
 | 
						|
{
 | 
						|
	pbx_builtin_setvar_helper(NULL, data, value);
 | 
						|
 | 
						|
	return 0;
 | 
						|
}
 | 
						|
 | 
						|
static struct ast_custom_function global_function = {
 | 
						|
	.name = "GLOBAL",
 | 
						|
	.synopsis = "Gets or sets the global variable specified",
 | 
						|
	.syntax = "GLOBAL(<varname>)",
 | 
						|
	.read = global_read,
 | 
						|
	.write = global_write,
 | 
						|
};
 | 
						|
 | 
						|
static int unload_module(void)
 | 
						|
{
 | 
						|
	int res = 0;
 | 
						|
 | 
						|
	res |= ast_custom_function_unregister(&global_function);
 | 
						|
 | 
						|
	return res;
 | 
						|
}
 | 
						|
 | 
						|
static int load_module(void)
 | 
						|
{
 | 
						|
	int res = 0;
 | 
						|
 | 
						|
	res |= ast_custom_function_register(&global_function);
 | 
						|
 | 
						|
	return res;
 | 
						|
}
 | 
						|
 | 
						|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Global variable dialplan functions");
 |