From dc51afacc67bcf929fa7b56f1ccbc55f00b3b460 Mon Sep 17 00:00:00 2001
From: Tilghman Lesher <tilghman@meg.abyt.es>
Date: Mon, 26 Dec 2005 16:48:12 +0000
Subject: [PATCH] Bug 6057 - Deprecate builtins that have been replaced by
 functions

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7633 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 UPGRADE.txt | 18 ++++++++++++++++++
 pbx.c       | 17 ++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/UPGRADE.txt b/UPGRADE.txt
index 72f95c3e86..27c9a0cb87 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -8,3 +8,21 @@ Applications:
   marked deprecated in Asterisk 1.2.  An option to disable it was provided with
   the default value set to 'on'.  The default value for the global priority
   jumping option is now 'off'.
+
+* The applications Cut, Sort, DBGet, DBPut, SetCIDNum, SetCIDName, SetRDNIS,
+  AbsoluteTimeout, DigitTimeout, ResponseTimeout, SetLanguage, GetGroupCount,
+  and GetGroupMatchCount were all deprecated in version 1.2, and therefore have
+  been removed in this version.  You should use the equivalent dialplan
+  function in places where you have previously used one of these applications.
+
+* The application SetVar has been renamed to Set.  The syntax SetVar was marked
+  deprecated in version 1.2 and is no longer recognized in this version.
+
+Variables:
+
+* The builtin variables ${CALLERID}, ${CALLERIDNAME}, ${CALLERIDNUM},
+  ${CALLERANI}, ${DNID}, ${RDNIS}, ${DATETIME}, ${TIMESTAMP}, ${ACCOUNTCODE},
+  and ${LANGUAGE} have all been deprecated in favor of their related dialplan
+  functions.  You are encouraged to move towards the associated dialplan
+  function, as these variables will be removed in a future release.
+
diff --git a/pbx.c b/pbx.c
index 17dadbdf9b..efb45df00e 100644
--- a/pbx.c
+++ b/pbx.c
@@ -903,6 +903,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 	struct tm brokentime;
 	int offset, offset2, isfunc;
 	struct ast_var_t *variables;
+	char *deprecated = NULL;
 
 	if (c) 
 		headp=&c->varshead;
@@ -929,6 +930,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 						*ret = workspace;
 					} else
 						*ret = NULL;
+					deprecated = "CALLERID(all)";
 				} else if (!strcmp(var + 8, "NUM")) {
 					/* CALLERIDNUM */
 					if (c->cid.cid_num) {
@@ -936,6 +938,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 						*ret = workspace;
 					} else
 						*ret = NULL;
+					deprecated = "CALLERID(num)";
 				} else if (!strcmp(var + 8, "NAME")) {
 					/* CALLERIDNAME */
 					if (c->cid.cid_name) {
@@ -943,7 +946,9 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 						*ret = workspace;
 					} else
 						*ret = NULL;
-				}
+					deprecated = "CALLERID(name)";
+				} else
+					goto icky;
 			} else if (!strcmp(var + 6, "ANI")) {
 				/* CALLERANI */
 				if (c->cid.cid_ani) {
@@ -951,6 +956,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 					*ret = workspace;
 				} else
 					*ret = NULL;
+				deprecated = "CALLERID(ANI)";
 			} else
 				goto icky;
 		} else if (!strncmp(var + 4, "ING", 3)) {
@@ -980,6 +986,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 			*ret = workspace;
 		} else
 			*ret = NULL;
+		deprecated = "CALLERID(DNID)";
 	} else if (c && !strcmp(var, "HINT")) {
 		if (!ast_get_hint(workspace, workspacelen, NULL, 0, c, c->context, c->exten))
 			*ret = NULL;
@@ -999,6 +1006,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 			*ret = workspace;
 		} else
 			*ret = NULL;
+		deprecated = "CALLERID(RDNIS)";
 	} else if (c && !strcmp(var, "CONTEXT")) {
 		ast_copy_string(workspace, c->context, workspacelen);
 		*ret = workspace;
@@ -1023,6 +1031,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 			brokentime.tm_sec
 		);
 		*ret = workspace;
+		deprecated = "STRFTIME(${EPOCH},,\%m\%d\%Y-\%H:\%M:\%S)";
 	} else if (!strcmp(var, "TIMESTAMP")) {
 		thistime=time(NULL);
 		localtime_r(&thistime, &brokentime);
@@ -1036,6 +1045,7 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 			brokentime.tm_sec
 		);
 		*ret = workspace;
+		deprecated = "STRFTIME(${EPOCH},,\%Y\%m\%d-\%H\%M\%S)";
 	} else if (c && !strcmp(var, "UNIQUEID")) {
 		snprintf(workspace, workspacelen, "%s", c->uniqueid);
 		*ret = workspace;
@@ -1045,9 +1055,11 @@ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, c
 	} else if (c && !strcmp(var, "ACCOUNTCODE")) {
 		ast_copy_string(workspace, c->accountcode, workspacelen);
 		*ret = workspace;
+		deprecated = "CDR(accountcode)";
 	} else if (c && !strcmp(var, "LANGUAGE")) {
 		ast_copy_string(workspace, c->language, workspacelen);
 		*ret = workspace;
+		deprecated = "LANGUAGE()";
 	} else {
 icky:
 		if (headp) {
@@ -1081,6 +1093,9 @@ icky:
 			}
 		}
 	}
+	if (deprecated) {
+		ast_log(LOG_WARNING, "${%s} is deprecated.  Please use ${%s} instead.\n", var, deprecated);
+	}
 }
 
 /*! \brief CLI function to show installed custom functions 
-- 
GitLab