diff --git a/funcs/func_global.c b/funcs/func_global.c
index 4b5e0d659c..74f58663b4 100644
--- a/funcs/func_global.c
+++ b/funcs/func_global.c
@@ -53,6 +53,40 @@
Set or get the value of a global variable specified in varname
+
+
+ Deletes a specified global variable.
+
+
+
+ Global variable name
+
+
+
+ Delete the global variable specified in varname.
+ Will succeed if the global variable exists or not.
+
+
+ [GLOBAL]
+ [DELETE]
+
+
+
+
+ Check if a global variable exists or not.
+
+
+
+ Global variable name
+
+
+
+ Returns 1 if global variable exists or 0 otherwise.
+
+
+ [VARIABLE_EXISTS]
+
+
Gets or sets the shared variable specified.
@@ -145,6 +179,33 @@ static struct ast_custom_function global_function = {
.write = global_write,
};
+static int global_delete_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+ pbx_builtin_setvar_helper(NULL, data, NULL);
+
+ return 0;
+}
+
+static struct ast_custom_function global_delete_function = {
+ .name = "GLOBAL_DELETE",
+ .write = global_delete_write,
+};
+
+static int global_exists_read(struct ast_channel *chan, const char *cmd, char *data,
+ char *buf, size_t len)
+{
+ const char *var = pbx_builtin_getvar_helper(NULL, data);
+
+ strcpy(buf, var ? "1" : "0");
+
+ return 0;
+}
+
+static struct ast_custom_function global_exists_function = {
+ .name = "GLOBAL_EXISTS",
+ .read = global_exists_read,
+};
+
static int shared_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
struct ast_datastore *varstore;
@@ -313,6 +374,8 @@ static int unload_module(void)
int res = 0;
res |= ast_custom_function_unregister(&global_function);
+ res |= ast_custom_function_unregister(&global_delete_function);
+ res |= ast_custom_function_unregister(&global_exists_function);
res |= ast_custom_function_unregister(&shared_function);
return res;
@@ -323,6 +386,8 @@ static int load_module(void)
int res = 0;
res |= ast_custom_function_register(&global_function);
+ res |= ast_custom_function_register(&global_delete_function);
+ res |= ast_custom_function_register(&global_exists_function);
res |= ast_custom_function_register(&shared_function);
return res;
diff --git a/funcs/func_logic.c b/funcs/func_logic.c
index b1411f2f19..943102f8b5 100644
--- a/funcs/func_logic.c
+++ b/funcs/func_logic.c
@@ -111,6 +111,39 @@
+
+
+ Deletes a specified channel variable.
+
+
+
+ Channel variable name
+
+
+
+ Delete the channel variable specified in varname.
+ Will succeed if the channel variable exists or not.
+
+
+ [GLOBAL_DELETE]
+
+
+
+
+ Check if a dialplan variable exists or not.
+
+
+
+ Channel variable name
+
+
+
+ Returns 1 if channel variable exists or 0 otherwise.
+
+
+ [GLOBAL_EXISTS]
+
+
***/
static int isnull(struct ast_channel *chan, const char *cmd, char *data,
@@ -273,6 +306,23 @@ static int import_read2(struct ast_channel *chan, const char *cmd, char *data, s
return import_helper(chan, cmd, data, NULL, str, len);
}
+static int delete_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+ pbx_builtin_setvar_helper(chan, data, NULL);
+
+ return 0;
+}
+
+static int variable_exists_read(struct ast_channel *chan, const char *cmd, char *data,
+ char *buf, size_t len)
+{
+ const char *var = pbx_builtin_getvar_helper(chan, data);
+
+ strcpy(buf, var ? "1" : "0");
+
+ return 0;
+}
+
static struct ast_custom_function isnull_function = {
.name = "ISNULL",
.read = isnull,
@@ -307,6 +357,16 @@ static struct ast_custom_function import_function = {
.read2 = import_read2,
};
+static struct ast_custom_function delete_function = {
+ .name = "DELETE",
+ .write = delete_write,
+};
+
+static struct ast_custom_function variable_exists_function = {
+ .name = "VARIABLE_EXISTS",
+ .read = variable_exists_read,
+};
+
static int unload_module(void)
{
int res = 0;
@@ -317,6 +377,8 @@ static int unload_module(void)
res |= ast_custom_function_unregister(&if_function);
res |= ast_custom_function_unregister(&if_time_function);
res |= ast_custom_function_unregister(&import_function);
+ res |= ast_custom_function_unregister(&delete_function);
+ res |= ast_custom_function_unregister(&variable_exists_function);
return res;
}
@@ -331,6 +393,8 @@ static int load_module(void)
res |= ast_custom_function_register(&if_function);
res |= ast_custom_function_register(&if_time_function);
res |= ast_custom_function_register(&import_function);
+ res |= ast_custom_function_register(&delete_function);
+ res |= ast_custom_function_register(&variable_exists_function);
return res;
}