chanvars.c File Reference

Channel Variables. More...

#include "asterisk.h"
#include "asterisk/chanvars.h"
#include "asterisk/strings.h"
#include "asterisk/utils.h"

Include dependency graph for chanvars.c:

Go to the source code of this file.

Functions

struct ast_var_tast_var_assign (const char *name, const char *value)
void ast_var_delete (struct ast_var_t *var)
char * ast_var_find (const struct varshead *head, const char *name)
const char * ast_var_full_name (const struct ast_var_t *var)
struct varsheadast_var_list_clone (struct varshead *head)
struct varsheadast_var_list_create (void)
void ast_var_list_destroy (struct varshead *head)
const char * ast_var_name (const struct ast_var_t *var)
const char * ast_var_value (const struct ast_var_t *var)


Detailed Description

Channel Variables.

Author:
Mark Spencer <markster@digium.com>

Definition in file chanvars.c.


Function Documentation

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

Definition at line 41 of file chanvars.c.

References __ast_calloc(), ast_calloc, ast_copy_string(), ast_var_t::name, NULL, ast_var_t::value, and var.

Referenced by acf_iaxvar_write(), add_user_extension(), assign_and_insert(), ast_cel_fabricate_channel_from_event(), ast_channel_get_manager_vars(), ast_channel_get_vars(), ast_channel_inherit_variables(), ast_iax2_new(), ast_unreal_call_setup(), ast_var_list_clone(), authenticate_reply(), build_extension(), build_profile(), cdr_object_create_public_records(), clone_variables(), copy_variables(), do_say(), dundi_lookup_local(), frame_set_var(), get_defaults(), handle_aor(), handle_registrations(), iax2_dup_variable_datastore(), load_users(), loopback_subst(), mock_cdr_backend_cb(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), phoneprov_callback(), set_timezone_variables(), set_variable(), shared_write(), and socket_process_helper().

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 }

void ast_var_delete ( struct ast_var_t var  ) 

char* ast_var_find ( const struct varshead head,
const char *  name 
)

Definition at line 93 of file chanvars.c.

References AST_LIST_TRAVERSE, ast_var_t::entries, ast_var_t::name, NULL, and ast_var_t::value.

Referenced by add_user_extension(), ast_phoneprov_add_extension(), build_extension(), load_users(), phoneprov_callback(), phoneprov_destroy(), and users_apply_handler().

00094 {
00095    struct ast_var_t *var;
00096 
00097    AST_LIST_TRAVERSE(head, var, entries) {
00098       if (!strcmp(name, var->name)) {
00099          return var->value;
00100       }
00101    }
00102    return NULL;
00103 }

const char* ast_var_full_name ( const struct ast_var_t var  ) 

Definition at line 83 of file chanvars.c.

References ast_var_t::name, and NULL.

Referenced by ast_channel_inherit_variables(), and ast_unreal_call_setup().

00084 {
00085    return (var ? var->name : NULL);
00086 }

struct varshead* ast_var_list_clone ( struct varshead head  )  [read]

Definition at line 132 of file chanvars.c.

References ast_var_assign(), ast_var_list_create(), ast_var_list_destroy(), AST_VAR_LIST_INSERT_TAIL(), AST_VAR_LIST_TRAVERSE, ast_var_t::name, NULL, and ast_var_t::value.

Referenced by build_extension().

00133 {
00134    struct varshead *clone;
00135    struct ast_var_t *var, *newvar;
00136 
00137    if (!head) {
00138       return NULL;
00139    }
00140 
00141    clone = ast_var_list_create();
00142    if (!clone) {
00143       return NULL;
00144    }
00145 
00146    AST_VAR_LIST_TRAVERSE(head, var) {
00147       newvar = ast_var_assign(var->name, var->value);
00148       if (!newvar) {
00149          ast_var_list_destroy(clone);
00150          return NULL;
00151       }
00152       AST_VAR_LIST_INSERT_TAIL(clone, newvar);
00153    }
00154 
00155    return clone;
00156 }

struct varshead* ast_var_list_create ( void   )  [read]

Definition at line 105 of file chanvars.c.

References ast_calloc, AST_LIST_HEAD_INIT_NOLOCK, and NULL.

Referenced by ast_var_list_clone(), build_profile(), get_defaults(), handle_aor(), handle_registrations(), load_users(), and phoneprov_alloc().

00106 {
00107    struct varshead *head;
00108 
00109    head = ast_calloc(1, sizeof(*head));
00110    if (!head) {
00111       return NULL;
00112    }
00113    AST_LIST_HEAD_INIT_NOLOCK(head);
00114    return head;
00115 }

void ast_var_list_destroy ( struct varshead head  ) 

Definition at line 117 of file chanvars.c.

References ast_free, AST_LIST_REMOVE_HEAD, ast_var_delete(), and ast_var_t::entries.

Referenced by ast_var_list_clone(), delete_extension(), get_defaults(), handle_aor(), handle_registrations(), load_users(), and phoneprov_destroy().

00118 {
00119    struct ast_var_t *var;
00120 
00121    if (!head) {
00122       return;
00123    }
00124 
00125    while ((var = AST_LIST_REMOVE_HEAD(head, entries))) {
00126       ast_var_delete(var);
00127    }
00128 
00129    ast_free(head);
00130 }

const char* ast_var_name ( const struct ast_var_t var  ) 

const char* ast_var_value ( const struct ast_var_t var  ) 


Generated on Thu Apr 16 06:30:10 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6