[asterisk-commits] branch oej/test-this-branch r13392 - in /team/oej/test-this-branch: ./ funcs/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Mar 18 04:29:26 MST 2006


Author: oej
Date: Sat Mar 18 05:29:23 2006
New Revision: 13392

URL: http://svn.digium.com/view/asterisk?rev=13392&view=rev
Log:
- Powerkill's toupper and tolower functions with some changes (#6668)

Modified:
    team/oej/test-this-branch/README.test-this-branch
    team/oej/test-this-branch/funcs/func_strings.c

Modified: team/oej/test-this-branch/README.test-this-branch
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/README.test-this-branch?rev=13392&r1=13391&r2=13392&view=diff
==============================================================================
--- team/oej/test-this-branch/README.test-this-branch (original)
+++ team/oej/test-this-branch/README.test-this-branch Sat Mar 18 05:29:23 2006
@@ -53,6 +53,8 @@
   (Note: I changed the name in this version...)
 - G.722 support in Asterisk (passthrough, formats) (andrew, #5084)
 - Fix race condition in voicemail (corydon76, #6714)
+- TOUPPER and TOLOWER ASCII functions (powerkill, #6668)
+  (With some changes)
 
 Things that has been commited to svn trunk:
 - Abandon Queue manager event (tim_ringenbach, #6459)

Modified: team/oej/test-this-branch/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/funcs/func_strings.c?rev=13392&r1=13391&r2=13392&view=diff
==============================================================================
--- team/oej/test-this-branch/funcs/func_strings.c (original)
+++ team/oej/test-this-branch/funcs/func_strings.c Sat Mar 18 05:29:23 2006
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <regex.h>
+#include <ctype.h>
 
 #include "asterisk.h"
 
@@ -422,6 +423,64 @@
 	.desc = "Example:  ${KEYPADHASH(Les)} returns \"537\"\n",
 };
 
+static int function_tolower(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+	int i = 0;
+
+	while (data[i]) {
+		if (data[i] & 0x80) {
+			unsigned char c = data[i];
+			if (c >= 192 && c <= 223) {
+				c += 32;
+				data[i] = (char) c;
+			}
+		} else {
+			data[i] = tolower(data[i]);
+		}
+		i++;
+	}
+	ast_copy_string(buf, data, len);
+	return 0;
+}
+
+static struct ast_custom_function tolower_function = {
+	.name = "TOLOWER",
+	.synopsis = "Returns the string in lowercase",
+	.syntax = "TOLOWER(<string>)",
+	.desc = "Using TOLOWER convert all ASCII characters from A to Z\n"
+		"to lowercase a to z.\n",
+	.read = function_tolower,
+};
+
+static int function_toupper(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+	int i = 0;
+	while (data[i]) {
+		if (data[i] & 0x80) {
+ 			unsigned char c = data[i];
+ 			if (c >= 224) {
+				c -= 32;
+				data[i] = (char)c;
+			}
+		} else {
+ 			data[i] = toupper(data[i]);
+		}
+		i++;
+	}
+	ast_copy_string(buf, data, len);
+	return 0;
+}
+
+
+static struct ast_custom_function toupper_function = {
+	.name = "TOUPPER",
+	.synopsis = "Returns the string in uppercase",
+	.syntax = "TOUPPER(<string>)",
+	.desc = "Using TOUPPER convert all ASCII characters from a to z\n"
+        	"to uppercase A to Z.\n",
+	.read = function_toupper,
+};
+
 static char *tdesc = "String handling dialplan functions";
 
 int unload_module(void)
@@ -438,6 +497,8 @@
 	res |= ast_custom_function_unregister(&strptime_function);
 	res |= ast_custom_function_unregister(&eval_function);
 	res |= ast_custom_function_unregister(&keypadhash_function);
+	res |= ast_custom_function_unregister(&tolower_function);
+	res |= ast_custom_function_unregister(&toupper_function);
 
 	return res;
 }
@@ -456,6 +517,8 @@
 	res |= ast_custom_function_register(&strptime_function);
 	res |= ast_custom_function_register(&eval_function);
 	res |= ast_custom_function_register(&keypadhash_function);
+        res |= ast_custom_function_register(&tolower_function);
+        res |= ast_custom_function_register(&toupper_function);
 
 	return res;
 }



More information about the asterisk-commits mailing list