mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
The amazing disappearing and reappearing patch... This time with documentation explaining it.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6821 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -66,6 +66,34 @@ value "blabla".
|
|||||||
In fact, everything contained ${here} is just replaced with the value of
|
In fact, everything contained ${here} is just replaced with the value of
|
||||||
the variable "here".
|
the variable "here".
|
||||||
|
|
||||||
|
____________________
|
||||||
|
VARIABLE INHERITANCE
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Variable names which are prefixed by "_" will be inherited to channels
|
||||||
|
that are created in the process of servicing the original channel in
|
||||||
|
which the variable was set. When the inheritance takes place, the
|
||||||
|
prefix will be removed in the channel inheriting the variable. If the
|
||||||
|
name is prefixed by "__" in the channel, then the variable is
|
||||||
|
inherited and the "__" will remain intact in the new channel.
|
||||||
|
|
||||||
|
In the dialplan, all references to these variables refer to the same
|
||||||
|
variable, regardless of having a prefix or not. Note that setting any
|
||||||
|
version of the variable removes any other version of the variable,
|
||||||
|
regardless of prefix.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
Set(__FOO=bar) ; Sets an inherited version of "FOO" variable
|
||||||
|
Set(FOO=bar) ; Removes the inherited version and sets a local
|
||||||
|
; variable.
|
||||||
|
|
||||||
|
However,
|
||||||
|
|
||||||
|
NoOp(${__FOO}) is identical to NoOp(${FOO})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_______________________________
|
_______________________________
|
||||||
REMOVING CHARACTERS FROM STRING
|
REMOVING CHARACTERS FROM STRING
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
10
pbx.c
10
pbx.c
@@ -5885,14 +5885,22 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const
|
|||||||
{
|
{
|
||||||
struct ast_var_t *newvariable;
|
struct ast_var_t *newvariable;
|
||||||
struct varshead *headp;
|
struct varshead *headp;
|
||||||
|
const char *nametail = name;
|
||||||
|
|
||||||
if (name[strlen(name)-1] == ')')
|
if (name[strlen(name)-1] == ')')
|
||||||
return ast_func_write(chan, name, value);
|
return ast_func_write(chan, name, value);
|
||||||
|
|
||||||
headp = (chan) ? &chan->varshead : &globals;
|
headp = (chan) ? &chan->varshead : &globals;
|
||||||
|
|
||||||
|
/* For comparison purposes, we have to strip leading underscores */
|
||||||
|
if (*nametail == '_') {
|
||||||
|
nametail++;
|
||||||
|
if (*nametail == '_')
|
||||||
|
nametail++;
|
||||||
|
}
|
||||||
|
|
||||||
AST_LIST_TRAVERSE (headp, newvariable, entries) {
|
AST_LIST_TRAVERSE (headp, newvariable, entries) {
|
||||||
if (strcasecmp(ast_var_name(newvariable), name) == 0) {
|
if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
|
||||||
/* there is already such a variable, delete it */
|
/* there is already such a variable, delete it */
|
||||||
AST_LIST_REMOVE(headp, newvariable, entries);
|
AST_LIST_REMOVE(headp, newvariable, entries);
|
||||||
ast_var_delete(newvariable);
|
ast_var_delete(newvariable);
|
||||||
|
Reference in New Issue
Block a user