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>
28 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
34 #include "asterisk/chanvars.h"
35 #include "asterisk/logger.h"
36 #include "asterisk/strings.h"
37 #include "asterisk/utils.h"
39 struct ast_var_t
*ast_var_assign(const char *name
, const char *value
)
41 struct ast_var_t
*var
;
42 int name_len
= strlen(name
) + 1;
43 int value_len
= strlen(value
) + 1;
45 if (!(var
= ast_calloc(sizeof(*var
) + name_len
+ value_len
, sizeof(char)))) {
49 ast_copy_string(var
->name
, name
, name_len
);
50 var
->value
= var
->name
+ name_len
;
51 ast_copy_string(var
->value
, value
, value_len
);
56 void ast_var_delete(struct ast_var_t
*var
)
62 const char *ast_var_name(const struct ast_var_t
*var
)
66 if (var
== NULL
|| (name
= var
->name
) == NULL
)
68 /* Return the name without the initial underscores */
77 const char *ast_var_full_name(const struct ast_var_t
*var
)
79 return (var
? var
->name
: NULL
);
82 const char *ast_var_value(const struct ast_var_t
*var
)
84 return (var
? var
->value
: NULL
);