2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.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 Channel Variables
23 * \author Mark Spencer <markster@digium.com>
27 <support_level>core</support_level>
32 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
34 #include "asterisk/chanvars.h"
35 #include "asterisk/strings.h"
36 #include "asterisk/utils.h"
39 struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function)
41 struct ast_var_t *ast_var_assign(const char *name, const char *value)
44 struct ast_var_t *var;
45 int name_len = strlen(name) + 1;
46 int value_len = strlen(value) + 1;
49 if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) {
51 if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
56 ast_copy_string(var->name, name, name_len);
57 var->value = var->name + name_len;
58 ast_copy_string(var->value, value, value_len);
63 void ast_var_delete(struct ast_var_t *var)
69 const char *ast_var_name(const struct ast_var_t *var)
73 if (var == NULL || (name = var->name) == NULL)
75 /* Return the name without the initial underscores */
84 const char *ast_var_full_name(const struct ast_var_t *var)
86 return (var ? var->name : NULL);
89 const char *ast_var_value(const struct ast_var_t *var)
91 return (var ? var->value : NULL);