Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:48:41 2009

## Asterisk developer's documentation

# chanvars.h File Reference

Channel Variables. More...

`#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

| AST_LIST_HEAD_NOLOCK (varshead, ast_var_t)
struct ast_var_t * | ast_var_assign (const char *name, const char *value)
void | ast_var_delete (struct ast_var_t *var)
char * | ast_var_full_name (struct ast_var_t *var)
char * | ast_var_name (struct ast_var_t *var)
char * | ast_var_value (struct ast_var_t *var)

## Detailed Description

Channel Variables.

Definition in file chanvars.h.

## Function Documentation

AST_LIST_HEAD_NOLOCK | ( | varshead | ,
|  | ast_var_t |  |
| ) |  |  |

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

Definition at line 36 of file chanvars.c.

References ast_log(), calloc, LOG_WARNING, ast_var_t::name, ast_var_t::value, and var.

Referenced by ast_cdr_copy_vars(), ast_cdr_setvar(), ast_channel_inherit_variables(), clone_variables(), dundi_lookup_local(), loopback_helper(), pbx_builtin_pushvar_helper(), and pbx_builtin_setvar_helper().

    00037 {
    00038    int i;
    00039    struct ast_var_t *var;
    00040
    00041    var = calloc(sizeof(struct ast_var_t) + strlen(name) + 1 + strlen(value) + 1, sizeof(char));
    00042
    00043    if (var == NULL) {
    00044       ast_log(LOG_WARNING, "Out of memory\n");
    00045       return NULL;
    00046    }
    00047
    00048    i = strlen(name) + 1;
    00049    ast_copy_string(var->name, name, i);
    00050    var->value = var->name + i;
    00051    ast_copy_string(var->value, value, strlen(value) + 1);
    00052
    00053    return var;
    00054 }

void ast_var_delete | ( | struct ast_var_t * | var | ) |

Definition at line 56 of file chanvars.c.

References free.

Referenced by ast_cdr_free_vars(), ast_cdr_setvar(), ast_channel_free(), dundi_lookup_local(), loopback_helper(), pbx_builtin_clear_globals(), and pbx_builtin_setvar_helper().

    00057 {
    00058    if (var)
    00059       free(var);
    00060 }

char* ast_var_full_name | ( | struct ast_var_t * | var | ) |

Definition at line 81 of file chanvars.c.

References ast_var_t::name.

Referenced by ast_channel_inherit_variables(), and launch_page().

    00082 {
    00083    return (var ? var->name : NULL);
    00084 }

char* ast_var_name | ( | struct ast_var_t * | var | ) |

Definition at line 62 of file chanvars.c.

References ast_var_t::name, and name.

Referenced by aPGSQL_fetch(), ast_cdr_copy_vars(), ast_cdr_getvar_internal(), ast_cdr_serialize_variables(), ast_cdr_setvar(), ast_channel_inherit_variables(), mgcp_call(), pbx_builtin_getvar_helper(), pbx_builtin_serialize_variables(), pbx_builtin_setvar_helper(), pbx_retrieve_variable(), sip_call(), and transmit_invite().

    00063 {
    00064    char *name;
    00065
    00066    if (var == NULL)
    00067       return NULL;
    00068    if (var->name == NULL)
    00069       return NULL;
    00070    /* Return the name without the initial underscores */
    00071    if (var->name[0] == '_') {
    00072       if (var->name[1] == '_')
    00073          name = (char*)&(var->name[2]);
    00074       else
    00075          name = (char*)&(var->name[1]);
    00076    } else
    00077       name = var->name;
    00078    return name;
    00079 }

char* ast_var_value | ( | struct ast_var_t * | var | ) |

Definition at line 86 of file chanvars.c.

References ast_var_t::value.

Referenced by aPGSQL_fetch(), ast_cdr_copy_vars(), ast_cdr_getvar_internal(), ast_cdr_serialize_variables(), ast_channel_inherit_variables(), launch_page(), mgcp_call(), pbx_builtin_getvar_helper(), pbx_builtin_serialize_variables(), pbx_retrieve_variable(), sip_call(), and transmit_invite().

    00087 {
    00088    return (var ? var->value : NULL);
    00089 }