Fri Aug 17 00:17:15 2018

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 /*** MODULEINFO
00027    <support_level>core</support_level>
00028  ***/
00029 
00030 #include "asterisk.h"
00031 
00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 369001 $")
00033 
00034 #include "asterisk/chanvars.h"
00035 #include "asterisk/strings.h"
00036 #include "asterisk/utils.h"
00037 
00038 #ifdef MALLOC_DEBUG
00039 struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function)
00040 #else
00041 struct ast_var_t *ast_var_assign(const char *name, const char *value)
00042 #endif
00043 {  
00044    struct ast_var_t *var;
00045    int name_len = strlen(name) + 1;
00046    int value_len = strlen(value) + 1;
00047 
00048 #ifdef MALLOC_DEBUG
00049    if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) {
00050 #else
00051    if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
00052 #endif
00053       return NULL;
00054    }
00055 
00056    ast_copy_string(var->name, name, name_len);
00057    var->value = var->name + name_len;
00058    ast_copy_string(var->value, value, value_len);
00059    
00060    return var;
00061 }  
00062    
00063 void ast_var_delete(struct ast_var_t *var)
00064 {
00065    if (var)
00066       ast_free(var);
00067 }
00068 
00069 const char *ast_var_name(const struct ast_var_t *var)
00070 {
00071    const char *name;
00072 
00073    if (var == NULL || (name = var->name) == NULL)
00074       return NULL;
00075    /* Return the name without the initial underscores */
00076    if (name[0] == '_') {
00077       name++;
00078       if (name[0] == '_')
00079          name++;
00080    }
00081    return name;
00082 }
00083 
00084 const char *ast_var_full_name(const struct ast_var_t *var)
00085 {
00086    return (var ? var->name : NULL);
00087 }
00088 
00089 const char *ast_var_value(const struct ast_var_t *var)
00090 {
00091    return (var ? var->value : NULL);
00092 }
00093 
00094 

Generated on 17 Aug 2018 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1