Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions
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_t_ast_var_assign (const char *name, const char *value, const char *file, int lineno, const char *function)
 
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 marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file chanvars.c.

Function Documentation

◆ _ast_var_assign()

struct ast_var_t * _ast_var_assign ( const char *  name,
const char *  value,
const char *  file,
int  lineno,
const char *  function 
)

Definition at line 36 of file chanvars.c.

37{
38 struct ast_var_t *var;
39 int name_len = strlen(name) + 1;
40 int value_len = strlen(value) + 1;
41
42 var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char),
43 file, lineno, function);
44 if (!var) {
45 return NULL;
46 }
47
48 ast_copy_string(var->name, name, name_len);
49 var->value = var->name + name_len;
50 ast_copy_string(var->value, value, value_len);
51
52 return var;
53}
#define var
Definition: ast_expr2f.c:605
void * __ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc
Definition: astmm.c:1603
static const char name[]
Definition: format_mp3.c:68
#define NULL
Definition: resample.c:96
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
int value
Definition: syslog.c:37

References __ast_calloc(), ast_copy_string(), make_ari_stubs::file, name, NULL, value, and var.

◆ ast_var_delete()

void ast_var_delete ( struct ast_var_t var)

◆ ast_var_find()

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

Definition at line 85 of file chanvars.c.

86{
87 struct ast_var_t *var;
88
90 if (!strcmp(name, var->name)) {
91 return var->value;
92 }
93 }
94 return NULL;
95}
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
struct ast_var_t::@211 entries

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

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

◆ ast_var_full_name()

const char * ast_var_full_name ( const struct ast_var_t var)

Definition at line 75 of file chanvars.c.

76{
77 return (var ? var->name : NULL);
78}

References NULL, and var.

Referenced by ast_channel_inherit_variables(), ast_unreal_call_setup(), and inherit_channel_vars_from_id().

◆ ast_var_list_clone()

struct varshead * ast_var_list_clone ( struct varshead head)

Definition at line 124 of file chanvars.c.

125{
126 struct varshead *clone;
127 struct ast_var_t *var, *newvar;
128
129 if (!head) {
130 return NULL;
131 }
132
133 clone = ast_var_list_create();
134 if (!clone) {
135 return NULL;
136 }
137
139 newvar = ast_var_assign(var->name, var->value);
140 if (!newvar) {
142 return NULL;
143 }
144 AST_VAR_LIST_INSERT_TAIL(clone, newvar);
145 }
146
147 return clone;
148}
void ast_var_list_destroy(struct varshead *head)
Definition: chanvars.c:109
struct varshead * ast_var_list_create(void)
Definition: chanvars.c:97
static void AST_VAR_LIST_INSERT_TAIL(struct varshead *head, struct ast_var_t *var)
Definition: chanvars.h:51
#define AST_VAR_LIST_TRAVERSE(head, var)
Definition: chanvars.h:49
#define ast_var_assign(name, value)
Definition: chanvars.h:40

References ast_var_assign, ast_var_list_create(), ast_var_list_destroy(), AST_VAR_LIST_INSERT_TAIL(), AST_VAR_LIST_TRAVERSE, NULL, and var.

Referenced by build_extension().

◆ ast_var_list_create()

struct varshead * ast_var_list_create ( void  )

Definition at line 97 of file chanvars.c.

98{
99 struct varshead *head;
100
101 head = ast_calloc(1, sizeof(*head));
102 if (!head) {
103 return NULL;
104 }
106 return head;
107}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:681

References ast_calloc, AST_LIST_HEAD_INIT_NOLOCK, and NULL.

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

◆ ast_var_list_destroy()

void ast_var_list_destroy ( struct varshead head)

Definition at line 109 of file chanvars.c.

110{
111 struct ast_var_t *var;
112
113 if (!head) {
114 return;
115 }
116
117 while ((var = AST_LIST_REMOVE_HEAD(head, entries))) {
119 }
120
121 ast_free(head);
122}
void ast_var_delete(struct ast_var_t *var)
Definition: chanvars.c:55
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833

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

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

◆ ast_var_name()

const char * ast_var_name ( const struct ast_var_t var)

◆ ast_var_value()

const char * ast_var_value ( const struct ast_var_t var)