From 9cea81b035e0446659b2b5d4d746210db9ebc9b8 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" <kpfleming@digium.com> Date: Sun, 15 May 2005 23:32:38 +0000 Subject: [PATCH] rename SetVar application to Set, deprecate SetVar git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5688 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- UPGRADE.txt | 31 ++++++++++--------- apps/app_groupcount.c | 2 +- apps/app_setcidname.c | 2 +- apps/app_setcidnum.c | 2 +- apps/app_setrdnis.c | 2 +- configs/queues.conf.sample | 2 +- doc/README.cdr | 9 ++---- doc/README.variables | 32 ++++++++++---------- pbx.c | 61 ++++++++++++++++++++++++++------------ 9 files changed, 82 insertions(+), 61 deletions(-) diff --git a/UPGRADE.txt b/UPGRADE.txt index 54ada6c952..196a0e53c6 100755 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -35,6 +35,9 @@ IAX: Applications: +* With the addition of dialplan functions (which operate similarly + to variables), the SetVar application has been renamed to Set. + * The CallerPres application has been removed. Use SetCallerPres instead. It accepts both numeric and symbolic names. @@ -42,9 +45,9 @@ Applications: CheckGroup have been deprecated in favor of functions. Here is a table of their replacements: - GetGroupCount([groupname][@category] GROUP_COUNT([groupname][@category]) SetVar(GROUPCOUNT=${GROUP_COUNT()}) - GroupMatchCount(groupmatch[@category]) GROUP_MATCH_COUNT(groupmatch[@category]) SetVar(GROUPCOUNT=${GROUP_MATCH_COUNT(SIP/.*)}) - SetGroup(groupname[@category]) GROUP([category])=groupname SetVar(GROUP()=test) + GetGroupCount([groupname][@category] GROUP_COUNT([groupname][@category]) Set(GROUPCOUNT=${GROUP_COUNT()}) + GroupMatchCount(groupmatch[@category]) GROUP_MATCH_COUNT(groupmatch[@category]) Set(GROUPCOUNT=${GROUP_MATCH_COUNT(SIP/.*)}) + SetGroup(groupname[@category]) GROUP([category])=groupname Set(GROUP()=test) CheckGroup(max[@category]) N/A GotoIf($[ ${GROUP_COUNT()} > 5 ]?103) Note that CheckGroup does not have a direct replacement. There is @@ -56,35 +59,35 @@ Applications: * The applications DBGet and DBPut have been deprecated in favor of functions. Here is a table of their replacements: - DBGet(foo=family/key) SetVar(foo=${DB(family/key)}) - DBPut(family/key=${foo}) SetVar(${DB(family/key)}=${foo}) + DBGet(foo=family/key) Set(foo=${DB(family/key)}) + DBPut(family/key=${foo}) Set(${DB(family/key)}=${foo}) * The application SetLanguage has been deprecated in favor of the function LANGUAGE(). - SetLanguage(fr) SetVar(LANGUAGE()=fr) + SetLanguage(fr) Set(LANGUAGE()=fr) The LANGUAGE function can also return the currently set language: - SetVar(MYLANG=${LANGUAGE()}) + Set(MYLANG=${LANGUAGE()}) * The applications AbsoluteTimeout, DigitTimeout, and ResponseTimeout have been deprecated in favor of the function TIMEOUT(timeouttype): - AbsoluteTimeout(300) SetVar(TIMEOUT(absolute)=300) - DigitTimeout(15) SetVar(TIMEOUT(digit)=15) - ResponseTimeout(15) SetVar(TIMEOUT(response)=15) + AbsoluteTimeout(300) Set(TIMEOUT(absolute)=300) + DigitTimeout(15) Set(TIMEOUT(digit)=15) + ResponseTimeout(15) Set(TIMEOUT(response)=15) The TIMEOUT() function can also return the currently set timeouts: - SetVar(DTIMEOUT=${TIMEOUT(digit)}) + Set(DTIMEOUT=${TIMEOUT(digit)}) * The applications SetCIDName, SetCIDNum, and SetRDNIS have been deprecated in favor of the CALLERID(datatype) function: - SetCIDName(Joe Cool) SetVar(CALLERID(name)=Joe Cool) - SetCIDNum(2025551212) SetVar(CALLERID(number)=2025551212) - SetRDNIS(2024561414) SetVar(CALLERID(RDNIS)=2024561414) + SetCIDName(Joe Cool) Set(CALLERID(name)=Joe Cool) + SetCIDNum(2025551212) Set(CALLERID(number)=2025551212) + SetRDNIS(2024561414) Set(CALLERID(RDNIS)=2024561414) Queues: diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c index ed6ef2e6f2..f7ac15763d 100755 --- a/apps/app_groupcount.c +++ b/apps/app_groupcount.c @@ -227,7 +227,7 @@ static char *group_count_descrip = static char *group_set_descrip = "Usage: SetGroup(groupname[@category])\n" " Sets the channel group to the specified value. Equivalent to\n" -"SetVar(GROUP=group). Always returns 0.\n"; +"Set(GROUP=group). Always returns 0.\n"; static char *group_check_descrip = "Usage: CheckGroup(max[@category])\n" diff --git a/apps/app_setcidname.c b/apps/app_setcidname.c index b3bd3745c2..9a8dc2baa9 100755 --- a/apps/app_setcidname.c +++ b/apps/app_setcidname.c @@ -51,7 +51,7 @@ static int setcallerid_exec(struct ast_channel *chan, void *data) static int deprecation_warning = 0; if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetCIDName is deprecated, please use SetVar(CALLERID(name)=value) instead.\n"); + ast_log(LOG_WARNING, "SetCIDName is deprecated, please use Set(CALLERID(name)=value) instead.\n"); deprecation_warning = 1; } diff --git a/apps/app_setcidnum.c b/apps/app_setcidnum.c index fb75b9e78f..481c1dc5d7 100755 --- a/apps/app_setcidnum.c +++ b/apps/app_setcidnum.c @@ -53,7 +53,7 @@ static int setcallerid_exec(struct ast_channel *chan, void *data) static int deprecation_warning = 0; if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetCIDNum is deprecated, please use SetVar(CALLERID(number)=value) instead.\n"); + ast_log(LOG_WARNING, "SetCIDNum is deprecated, please use Set(CALLERID(number)=value) instead.\n"); deprecation_warning = 1; } diff --git a/apps/app_setrdnis.c b/apps/app_setrdnis.c index 1321bae35d..0192973cbc 100755 --- a/apps/app_setrdnis.c +++ b/apps/app_setrdnis.c @@ -49,7 +49,7 @@ static int setrdnis_exec(struct ast_channel *chan, void *data) static int deprecation_warning = 0; if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetRDNIS is deprecated, please use SetVar(CALLERID(rdnis)=value) instead.\n"); + ast_log(LOG_WARNING, "SetRDNIS is deprecated, please use Set(CALLERID(rdnis)=value) instead.\n"); deprecation_warning = 1; } diff --git a/configs/queues.conf.sample b/configs/queues.conf.sample index f4e73d7e54..310d4cf750 100755 --- a/configs/queues.conf.sample +++ b/configs/queues.conf.sample @@ -113,7 +113,7 @@ persistentmembers = yes ; To enable monitoring, simply specify "monitor-format"; it will be disabled ; otherwise. ; -; You can specify the monitor filename with by calling SetVar(MONITOR_FILENAME=foo) +; You can specify the monitor filename with by calling Set(MONITOR_FILENAME=foo) ; Otherwise it will use ${UNIQUEID} ; ; monitor-format = gsm|wav|wav49 diff --git a/doc/README.cdr b/doc/README.cdr index 8dadf22b4b..7a5440ebf0 100755 --- a/doc/README.cdr +++ b/doc/README.cdr @@ -30,7 +30,6 @@ Applications * Authenticate Authenticates and sets the account code * SetCDRUserField Set CDR user field * AppendCDRUserField Append data to CDR User field - * SetVarCDR Set CDR Vars For more information, use the "show application" command. You can set default account codes and AMA flags for devices in @@ -77,7 +76,7 @@ ____________________________________ CDR Variables ------------------------------------ -If the channel has a cdr, that cdr record has it's own set of variables which +If the channel has a cdr, that cdr record has its own set of variables which can be accessed just like channel variables. The following builtin variables are available. @@ -100,11 +99,7 @@ ${CDR(accountcode)} The channel's account code. ${CDR(uniqueid)} The channel's unique id. ${CDR(userfield)} The channels uses specified field. - -In addition, you can set your own extra variables with the application SetVarCDR(var=val) -or a traditional SetVAR(CDR(var=val) to anything you want. - -SetVar(CDR(var)=val) will set the var to all cdr in a stack of cdrs. +In addition, you can set your own extra variables by using Set(CDR(name)=value). ______________________________ cdr_csv2 diff --git a/doc/README.variables b/doc/README.variables index 68784b1493..05955bdbac 100755 --- a/doc/README.variables +++ b/doc/README.variables @@ -41,23 +41,23 @@ They are stored in the respective channel structure. To set a variable to a particular value, do : - exten => 1,2,SetVar(varname=value) + exten => 1,2,Set(varname=value) You can substitute the value of a variable everywhere using ${variablename}. For example, to stringwise append $lala to $blabla and store result in $koko, do: - exten => 1,2,SetVar(koko=${blabla}${lala}) + exten => 1,2,Set(koko=${blabla}${lala}) There are two reference modes - reference by value and reference by name. To refer to a variable with its name (as an argument to a function that requires a variable), just write the name. To refer to the variable's value, -enclose it inside ${}. For example, SetVar takes as the first argument +enclose it inside ${}. For example, Set takes as the first argument (before the =) a variable name, so: - exten => 1,2,SetVar(koko=lala) - exten => 1,3,SetVar(${koko}=blabla) + exten => 1,2,Set(koko=lala) + exten => 1,3,Set(${koko}=blabla) stores to the variable "koko" the value "lala" and to variable "lala" the value "blabla". @@ -78,7 +78,7 @@ to a variable, simply append a colon and the number of characters to remove from the beginning of the string to the variable name. ;Remove the first character of extension, save in "number" variable - exten => _9X.,1,SetVar(number=${EXTEN:1}) + exten => _9X.,1,Set(number=${EXTEN:1}) Assuming we've dialed 918005551234, the value saved to the 'number' variable would be 18005551234. This is useful in situations when we require users to @@ -91,7 +91,7 @@ example will save the numbers 1234 to the 'number' variable, still assuming we've dialed 918005551234. ;Remove everything before the last four digits of the dialed string - exten => _9X.,1,SetVar(number=${EXTEN:-4}) + exten => _9X.,1,Set(number=${EXTEN:-4}) We can also limit the number of characters from our offset position that we wish to use. This is done by appending a second colon and length value to the @@ -99,7 +99,7 @@ variable name. The following example will save the numbers 555 to the 'number' variable. ;Only save the middle numbers 555 from the string 918005551234 - exten => _9X.,1,SetVar(number=${EXTEN:5:3}) + exten => _9X.,1,Set(number=${EXTEN:5:3}) The length value can also be used in conjunction with a negative offset. This may be useful if the length of the string is unknown, but the trailing digits @@ -108,7 +108,7 @@ even if the string starts with more characters than expected (unlike the previous example). ;Save the numbers 555 to the 'number' variable - exten => _9X.,1,SetVar(number=${EXTEN:-7:3}) + exten => _9X.,1,Set(number=${EXTEN:-7:3}) If a negative length value is entered, it is ignored and Asterisk will match to the end of the string. @@ -127,14 +127,14 @@ by at least one space. For example, after the sequence: -exten => 1,1,SetVar(lala=$[1 + 2]) -exten => 1,2,SetVar(koko=$[2 * ${lala}]) +exten => 1,1,Set(lala=$[1 + 2]) +exten => 1,2,Set(koko=$[2 * ${lala}]) the value of variable koko is "6". And, further: -exten => 1,1,SetVar(lala=$[1+2]); +exten => 1,1,Set(lala=$[1+2]); will not work as you might have expected. Since all the chars in the single token "1+2" are not numbers, it will be evaluated as the string "1+2". Again, @@ -143,7 +143,7 @@ uses a space (at least one), to separate "tokens". and, further: -exten => 1,1,SetVar,"lala=$[ 1 + 2 ]"; +exten => 1,1,Set,"lala=$[ 1 + 2 ]"; will parse as intended. Extra spaces are ignored. @@ -242,9 +242,9 @@ above, eg : Example of use : -exten => s,2,SetVar(vara=1) -exten => s,3,SetVar(varb=$[${vara} + 2]) -exten => s,4,SetVar(varc=$[${varb} * 2]) +exten => s,2,Set(vara=1) +exten => s,3,Set(varb=$[${vara} + 2]) +exten => s,4,Set(varc=$[${varb} * 2]) exten => s,5,GotoIf($[${varc} = 6]?99|1:s|6) ___________________________ diff --git a/pbx.c b/pbx.c index f173a86827..ebadafd361 100755 --- a/pbx.c +++ b/pbx.c @@ -205,6 +205,7 @@ static int pbx_builtin_saynumber(struct ast_channel *, void *); static int pbx_builtin_saydigits(struct ast_channel *, void *); static int pbx_builtin_saycharacters(struct ast_channel *, void *); static int pbx_builtin_sayphonetic(struct ast_channel *, void *); +static int pbx_builtin_setvar_old(struct ast_channel *, void *); int pbx_builtin_setvar(struct ast_channel *, void *); static int pbx_builtin_importvar(struct ast_channel *, void *); @@ -231,7 +232,7 @@ static struct pbx_builtin { "Set absolute maximum time of call", " AbsoluteTimeout(seconds): Set the absolute maximum amount of time permitted\n" "for a call. A setting of 0 disables the timeout. Always returns 0.\n" - "AbsoluteTimeout has been deprecated in favor of SetVar(TIMEOUT(absolute)=timeout)\n" + "AbsoluteTimeout has been deprecated in favor of Set(TIMEOUT(absolute)=timeout)\n" }, { "Answer", pbx_builtin_answer, @@ -284,7 +285,7 @@ static struct pbx_builtin { "(and thus control would be passed to the 'i' extension, or if it doesn't\n" "exist the call would be terminated). The default timeout is 5 seconds.\n" "Always returns 0.\n" - "DigitTimeout has been deprecated in favor of SetVar(TIMEOUT(digit)=timeout)\n" + "DigitTimeout has been deprecated in favor of Set(TIMEOUT(digit)=timeout)\n" }, { "Goto", pbx_builtin_goto, @@ -368,7 +369,7 @@ static struct pbx_builtin { "amount of time, control will pass to the 't' extension if it exists, and\n" "if not the call would be terminated. The default timeout is 10 seconds.\n" "Always returns 0.\n" - "ResponseTimeout has been deprecated in favor of SetVar(TIMEOUT(response)=timeout)\n" + "ResponseTimeout has been deprecated in favor of Set(TIMEOUT(response)=timeout)\n" }, { "Ringing", pbx_builtin_ringing, @@ -428,19 +429,29 @@ static struct pbx_builtin { "For some language codes, SetLanguage also changes the syntax of some\n" "Asterisk functions, like SayNumber.\n" "Always returns 0.\n" - "SetLanguage has been deprecated in favor of SetVar(LANGUAGE()=language)\n" + "SetLanguage has been deprecated in favor of Set(LANGUAGE()=language)\n" }, - { "SetVar", pbx_builtin_setvar, - "Set channel variable(s)", - " SetVar(name1=value1|name2=value2|..[|options])\n" - "You can specify up to 24 name / value pairs to be set as channel variables.\n" - "If a variable name is prefixed with _, it will be inherited into channels\n" - "created from this one. If a variable name is prefixed with __, it will be\n" - "inherited into channels created from this one and all child channels.\n" - "The last arg (if it doesn't contain '=') is interpreted as a string of\n" - "options. Valid options are:\n" - " g - Set variable globally instead of on the channel\n" + { "Set", pbx_builtin_setvar, + "Set channel variable(s) or function value(s)", + " Set(name1=value1|name2=value2|..[|options])\n" + "This function can be used to set the value of channel variables\n" + "or dialplan functions. It will accept up to 24 name/value pairs.\n" + "When setting variables, if the variable name is prefixed with _,\n" + "the variable will be inherited into channels created from the\n" + "current channel. If the variable name is prefixed with __,\n" + "the variable will be inherited into channels created from the\n" + "current channel and all child channels.\n" + "The last argument, if it does not contain '=', is interpreted\n" + "as a string of options. The valid options are:\n" + " g - Set variable globally instead of on the channel\n" + " (applies only to variables, not functions)\n" + }, + + { "SetVar", pbx_builtin_setvar_old, + "Set channel variable(s)", + " SetVar(name1=value1|name2=value2|..[|options])\n" + "SetVar has been deprecated in favor of Set.\n" }, { "ImportVar", pbx_builtin_importvar, @@ -5260,7 +5271,7 @@ static int pbx_builtin_setlanguage(struct ast_channel *chan, void *data) static int deprecation_warning = 0; if (!deprecation_warning) { - ast_log(LOG_WARNING, "SetLanguage is deprecated, please use SetVar(LANGUAGE()=language) instead.\n"); + ast_log(LOG_WARNING, "SetLanguage is deprecated, please use Set(LANGUAGE()=language) instead.\n"); deprecation_warning = 1; } @@ -5580,7 +5591,7 @@ static int pbx_builtin_atimeout(struct ast_channel *chan, void *data) int x = atoi((char *) data); if (!deprecation_warning) { - ast_log(LOG_WARNING, "AbsoluteTimeout is deprecated, please use SetVar(TIMEOUT(absolute)=timeout) instead.\n"); + ast_log(LOG_WARNING, "AbsoluteTimeout is deprecated, please use Set(TIMEOUT(absolute)=timeout) instead.\n"); deprecation_warning = 1; } @@ -5596,7 +5607,7 @@ static int pbx_builtin_rtimeout(struct ast_channel *chan, void *data) static int deprecation_warning = 0; if (!deprecation_warning) { - ast_log(LOG_WARNING, "ResponseTimeout is deprecated, please use SetVar(TIMEOUT(response)=timeout) instead.\n"); + ast_log(LOG_WARNING, "ResponseTimeout is deprecated, please use Set(TIMEOUT(response)=timeout) instead.\n"); deprecation_warning = 1; } @@ -5616,7 +5627,7 @@ static int pbx_builtin_dtimeout(struct ast_channel *chan, void *data) static int deprecation_warning = 0; if (!deprecation_warning) { - ast_log(LOG_WARNING, "DigitTimeout is deprecated, please use SetVar(TIMEOUT(digit)=timeout) instead.\n"); + ast_log(LOG_WARNING, "DigitTimeout is deprecated, please use Set(TIMEOUT(digit)=timeout) instead.\n"); deprecation_warning = 1; } @@ -5722,6 +5733,18 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const } } +int pbx_builtin_setvar_old(struct ast_channel *chan, void *data) +{ + static int deprecation_warning = 0; + + if (!deprecation_warning) { + ast_log(LOG_WARNING, "SetVar is deprecated, please use Set instead.\n"); + deprecation_warning = 1; + } + + return pbx_builtin_setvar(chan, data); +} + int pbx_builtin_setvar(struct ast_channel *chan, void *data) { char *name, *value, *mydata; @@ -5731,7 +5754,7 @@ int pbx_builtin_setvar(struct ast_channel *chan, void *data) int x; if (!data || ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "SetVar requires at least one variable name/value pair.\n"); + ast_log(LOG_WARNING, "Set requires at least one variable name/value pair.\n"); return 0; } -- GitLab