aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_strings.c
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-09 21:37:26 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-09 21:37:26 +0000
commit11f6af8c7b1aa84f602cec7258bdb6ef8d29851d (patch)
treea60d56d18dfd1b80f57e5bc99e3b1fc1c2999bfe /funcs/func_strings.c
parent34c07ddcafffa916f65e5f4b0e356e7b29e47b2d (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: http://svn.digium.com/svn/asterisk/trunk@97634 f38db490-d61c-443f-a65b-d21fe96a405b
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;
}