chanvars.h File Reference

#include <asterisk/linkedlists.h>

Include dependency graph for chanvars.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_var_t

Functions

struct ast_var_tast_var_assign (char *name, char *value)
void ast_var_delete (struct ast_var_t *var)
char * ast_var_name (struct ast_var_t *var)
char * ast_var_value (struct ast_var_t *var)


Function Documentation

struct ast_var_t* ast_var_assign ( char *  name,
char *  value 
) [read]

Definition at line 20 of file chanvars.c.

00021 {
00022    int i;
00023    struct ast_var_t *var;
00024    
00025    var = malloc(sizeof(struct ast_var_t));
00026 
00027    if (var == NULL)
00028    {
00029       ast_log(LOG_WARNING, "Out of memory\n");
00030       return NULL;
00031    }
00032    
00033    i = strlen(value);
00034    var->value = malloc(i + 1);
00035    if (var->value == NULL)
00036    {
00037       ast_log(LOG_WARNING, "Out of memory\n");
00038       free(var);
00039       return NULL;
00040    }
00041 
00042    strncpy(var->value, value, i);
00043    var->value[i] = '\0';
00044    
00045    i = strlen(name);
00046    var->name = malloc(i + 1);
00047    if (var->name == NULL)
00048    {
00049       ast_log(LOG_WARNING, "Out of memory\n");
00050       free(var->value);
00051       free(var);
00052       return NULL;
00053    }
00054 
00055    strncpy(var->name, name, i); 
00056    var->name[i] = '\0';
00057 
00058    return var;
00059 }  

void ast_var_delete ( struct ast_var_t var  ) 

Definition at line 61 of file chanvars.c.

00062 {
00063    if (var == NULL) return;
00064 
00065    if (var->name != NULL) free(var->name);
00066    if (var->value != NULL) free(var->value);
00067 
00068    free(var);
00069 }

char* ast_var_name ( struct ast_var_t var  ) 

Definition at line 71 of file chanvars.c.

00072 {
00073    return (var != NULL ? var->name : NULL);
00074 }

char* ast_var_value ( struct ast_var_t var  ) 

Definition at line 76 of file chanvars.c.

00077 {
00078    return (var != NULL ? var->value : NULL);
00079 }


Generated on Wed Oct 28 17:00:52 2009 for Asterisk by  doxygen 1.5.6