Thu Jul 9 13:40:32 2009

Asterisk developer's documentation


chanvars.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief Channel Variables
00022  *
00023  * \author Mark Spencer <markster@digium.com> 
00024  */
00025 
00026 #include "asterisk.h"
00027 
00028 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 89425 $")
00029 
00030 #include "asterisk/chanvars.h"
00031 #include "asterisk/strings.h"
00032 #include "asterisk/utils.h"
00033 
00034 struct ast_var_t *ast_var_assign(const char *name, const char *value)
00035 {  
00036    struct ast_var_t *var;
00037    int name_len = strlen(name) + 1;
00038    int value_len = strlen(value) + 1;
00039 
00040    if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
00041       return NULL;
00042    }
00043 
00044    ast_copy_string(var->name, name, name_len);
00045    var->value = var->name + name_len;
00046    ast_copy_string(var->value, value, value_len);
00047    
00048    return var;
00049 }  
00050    
00051 void ast_var_delete(struct ast_var_t *var)
00052 {
00053    if (var)
00054       ast_free(var);
00055 }
00056 
00057 const char *ast_var_name(const struct ast_var_t *var)
00058 {
00059    const char *name;
00060 
00061    if (var == NULL || (name = var->name) == NULL)
00062       return NULL;
00063    /* Return the name without the initial underscores */
00064    if (name[0] == '_') {
00065       name++;
00066       if (name[0] == '_')
00067          name++;
00068    }
00069    return name;
00070 }
00071 
00072 const char *ast_var_full_name(const struct ast_var_t *var)
00073 {
00074    return (var ? var->name : NULL);
00075 }
00076 
00077 const char *ast_var_value(const struct ast_var_t *var)
00078 {
00079    return (var ? var->value : NULL);
00080 }
00081 
00082 

Generated on Thu Jul 9 13:40:32 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7