summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-06-03 22:05:16 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-06-03 22:05:16 +0000
commit76506b7baa23b192b35313b41d00fd153567369e (patch)
tree1128255ba26efd55114897a12cea38a75f674c31
parent5866b0dfe81e8aec98bf7691cfe7001cd0b54bc2 (diff)
Move compatibility options into asterisk.conf, default them to on for upgrades,
and off for new installations. This includes the translation from pipes to commas for pbx_realtime and the EXEC command for AGI, as well as the change to the Set application not to support multiple variables at once. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@120171 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--Makefile5
-rw-r--r--configs/pbx_realtime.conf11
-rw-r--r--include/asterisk/options.h12
-rw-r--r--main/asterisk.c15
-rw-r--r--main/pbx.c4
-rw-r--r--pbx/pbx_realtime.c17
-rw-r--r--res/res_agi.c18
7 files changed, 54 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index 570c774e6..65e0a5ffd 100644
--- a/Makefile
+++ b/Makefile
@@ -687,6 +687,11 @@ samples: adsi
echo ";astctlowner = root" ; \
echo ";astctlgroup = apache" ; \
echo ";astctl = asterisk.ctl" ; \
+ echo "" ; \
+ echo "[compat]" ; \
+ echo "pbx_realtime=1.6" ; \
+ echo "res_agi=1.6" ; \
+ echo "app_set=1.6" ; \
) > $(DESTDIR)$(ASTCONFPATH) ; \
else \
echo "Skipping asterisk.conf creation"; \
diff --git a/configs/pbx_realtime.conf b/configs/pbx_realtime.conf
deleted file mode 100644
index 022b3e934..000000000
--- a/configs/pbx_realtime.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-[general]
-; The native delimiters for application arguments changed in 1.6 to be commas,
-; instead of pipes. For people who don't want to upgrade their databases
-; immediately, there is this compatibility option, which will allow them to
-; use pipes, via a translation done at runtime. Set compat to 1.4, if you
-; want to turn this translation ON. Set compat to 1.6 if you've already made
-; the transition.
-;
-; compat=1.4
-compat=1.6
-
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index 794a75759..3b639e6b9 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -112,6 +112,18 @@ enum ast_option_flags {
extern struct ast_flags ast_options;
+enum ast_compat_flags {
+ AST_COMPAT_DELIM_PBX_REALTIME = (1 << 0),
+ AST_COMPAT_DELIM_RES_AGI = (1 << 1),
+ AST_COMPAT_APP_SET = (1 << 2),
+};
+
+#define ast_compat_pbx_realtime ast_test_flag(&ast_compat, AST_COMPAT_DELIM_PBX_REALTIME)
+#define ast_compat_res_agi ast_test_flag(&ast_compat, AST_COMPAT_DELIM_RES_AGI)
+#define ast_compat_app_set ast_test_flag(&ast_compat, AST_COMPAT_APP_SET)
+
+extern struct ast_flags ast_compat;
+
extern int option_verbose;
extern int option_maxfiles; /*!< Max number of open file handles (files, sockets) */
extern int option_debug; /*!< Debugging */
diff --git a/main/asterisk.c b/main/asterisk.c
index a5683c745..7d3079938 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -156,6 +156,7 @@ int daemon(int, int); /* defined in libresolv of all places */
/*! @{ */
struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };
+struct ast_flags ast_compat = { 7 };
int option_verbose; /*!< Verbosity level */
int option_debug; /*!< Debug level */
@@ -2774,6 +2775,20 @@ static void ast_readconfig(void)
#endif
}
}
+ for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) {
+ float version;
+ if (sscanf(v->value, "%f", &version) != 1) {
+ ast_log(LOG_WARNING, "Compatibility version for option '%s' is not a number: '%s'\n", v->name, v->value);
+ continue;
+ }
+ if (!strcasecmp(v->name, "app_set")) {
+ ast_set2_flag(&ast_compat, version < 1.5 ? 1 : 0, AST_COMPAT_APP_SET);
+ } else if (!strcasecmp(v->name, "res_agi")) {
+ ast_set2_flag(&ast_compat, version < 1.5 ? 1 : 0, AST_COMPAT_DELIM_RES_AGI);
+ } else if (!strcasecmp(v->name, "pbx_realtime")) {
+ ast_set2_flag(&ast_compat, version < 1.5 ? 1 : 0, AST_COMPAT_DELIM_PBX_REALTIME);
+ }
+ }
ast_config_destroy(cfg);
}
diff --git a/main/pbx.c b/main/pbx.c
index a18d29e9a..2b0ee7603 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -7856,6 +7856,10 @@ int pbx_builtin_setvar(struct ast_channel *chan, void *data)
{
char *name, *value, *mydata;
+ if (ast_compat_app_set) {
+ return pbx_builtin_setvar_multiple(chan, data);
+ }
+
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Set requires one variable name/value pair.\n");
return 0;
diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c
index 6e5a9f7e1..4fb06c867 100644
--- a/pbx/pbx_realtime.c
+++ b/pbx/pbx_realtime.c
@@ -53,9 +53,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define EXT_DATA_SIZE 256
-/* If set to 0, translate commas to "\," and pipes to "," */
-static int compat16 = 1;
-
/* Realtime switch looks up extensions in the supplied realtime table.
[context@][realtimetable][/options]
@@ -179,7 +176,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
if (!strcasecmp(v->name, "app"))
app = ast_strdupa(v->value);
else if (!strcasecmp(v->name, "appdata")) {
- if (!compat16) {
+ if (ast_compat_pbx_realtime) {
char *ptr;
int in = 0;
tmp = alloca(strlen(v->value) * 2 + 1);
@@ -270,18 +267,6 @@ static int unload_module(void)
static int load_module(void)
{
- struct ast_flags flags = { 0 };
- struct ast_config *cfg = ast_config_load("pbx_realtime.conf", flags);
- if (cfg) {
- const char *tmp = ast_variable_retrieve(cfg, "general", "compat");
- if (tmp && strncmp(tmp, "1.6", 3)) {
- compat16 = 0;
- } else {
- compat16 = 1;
- }
- ast_config_destroy(cfg);
- }
-
if (ast_register_switch(&realtime_switch))
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_SUCCESS;
diff --git a/res/res_agi.c b/res/res_agi.c
index 57cf128da..952c28c27 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -1456,7 +1456,23 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, char **argv
ast_verb(3, "AGI Script Executing Application: (%s) Options: (%s)\n", argv[1], argv[2]);
if ((app = pbx_findapp(argv[1]))) {
- res = pbx_exec(chan, app, argv[2]);
+ if (ast_compat_res_agi && !ast_strlen_zero(argv[2])) {
+ char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr, *vptr;
+ for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
+ if (*vptr == ',') {
+ *cptr++ = '\\';
+ *cptr++ = ',';
+ } else if (*vptr == '|') {
+ *cptr++ = ',';
+ } else {
+ *cptr++ = *vptr;
+ }
+ }
+ *cptr = '\0';
+ res = pbx_exec(chan, app, compat);
+ } else {
+ res = pbx_exec(chan, app, argv[2]);
+ }
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]);
res = -2;