summaryrefslogtreecommitdiff
path: root/funcs/func_strings.c
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2008-01-09 21:37:26 +0000
committerTerry Wilson <twilson@digium.com>2008-01-09 21:37:26 +0000
commit3570ad103d9f37f60f2f1ac0e21bab02bd1051e7 (patch)
treea60d56d18dfd1b80f57e5bc99e3b1fc1c2999bfe /funcs/func_strings.c
parent46f4c8946f54f5ab04921c1d08dd5b4c808bccff (diff)
Added a new module, res_phoneprov, which allows auto-provisioning of phones
based on configuration templates that use Asterisk dialplan function and variable substitution. It should be possible to create phone profiles and templates that work for the majority of phones provisioned over http. It is currently only intended to provision a single user account per phone. An example profile and set of templates for Polycom phones is provided. NOTE: Polycom firmware is not included, but should be placed in AST_DATA_DIR/phoneprov/configs to match up with the included templates. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@97634 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_strings.c')
-rw-r--r--funcs/func_strings.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index da234949a..54730e108 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -30,6 +30,7 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <regex.h>
+#include <ctype.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
@@ -800,6 +801,40 @@ static struct ast_custom_function keypadhash_function = {
.desc = "Example: ${KEYPADHASH(Les)} returns \"537\"\n",
};
+static int string_toupper(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ char *bufptr = buf, *dataptr = data;
+
+ while ((bufptr < buf + len - 1) && (*bufptr++ = toupper(*dataptr++)));
+
+ return 0;
+}
+
+static struct ast_custom_function toupper_function = {
+ .name = "TOUPPER",
+ .synopsis = "Convert the string to upper case.",
+ .syntax = "TOUPPER(<string>)",
+ .read = string_toupper,
+ .desc = "Example: ${TOUPPER(Example)} returns \"EXAMPLE\"\n",
+};
+
+static int string_tolower(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ char *bufptr = buf, *dataptr = data;
+
+ while ((bufptr < buf + len - 1) && (*bufptr++ = tolower(*dataptr++)));
+
+ return 0;
+}
+
+static struct ast_custom_function tolower_function = {
+ .name = "TOLOWER",
+ .synopsis = "Convert the string to lower case.",
+ .syntax = "TOLOWER(<string>)",
+ .read = string_tolower,
+ .desc = "Example: ${TOLOWER(Example)} returns \"example\"\n",
+};
+
static int unload_module(void)
{
int res = 0;
@@ -818,6 +853,8 @@ static int unload_module(void)
res |= ast_custom_function_unregister(&hashkeys_function);
res |= ast_custom_function_unregister(&hash_function);
res |= ast_unregister_application(app_clearhash);
+ res |= ast_custom_function_unregister(&toupper_function);
+ res |= ast_custom_function_unregister(&tolower_function);
return res;
}
@@ -840,6 +877,8 @@ static int load_module(void)
res |= ast_custom_function_register(&hashkeys_function);
res |= ast_custom_function_register(&hash_function);
res |= ast_register_application(app_clearhash, exec_clearhash, syn_clearhash, desc_clearhash);
+ res |= ast_custom_function_register(&toupper_function);
+ res |= ast_custom_function_register(&tolower_function);
return res;
}