summaryrefslogtreecommitdiff
path: root/main/say.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-08-22 22:33:48 +0000
committerKinsey Moore <kmoore@digium.com>2013-08-22 22:33:48 +0000
commit7b032c1adb10d79f8610e88d2baf5cacf3ba9f58 (patch)
tree7c10a365fa41daaf9ad9bb1535d6ebad188cb406 /main/say.c
parentaefebebd37add82bbea2d3423a5fc5f28feb2c60 (diff)
Add SayAlphaCase and similar functionality for AGI
This adds a new dialplan application, SayAlphaCase, that performs much the same function as SayAlpha except that it takes additional options which allow the user to specify whether the case of each letter should be announced for uppercase, lowercase, or all letters. Similar functionality has been added to the SAY ALPHA AGI command via an optional parameter. Original Patch by: Kevin Scott Adams Reported by: Kevin Scott Adams Review: https://reviewboard.asterisk.org/r/2725/ (closes issue ASTERISK-20782) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397493 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/say.c')
-rw-r--r--main/say.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/main/say.c b/main/say.c
index 295d4110f..ed0a7b524 100644
--- a/main/say.c
+++ b/main/say.c
@@ -61,13 +61,15 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang);
-static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
+static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity, int audiofd, int ctrlfd)
{
const char *fn;
char fnbuf[10], asciibuf[20] = "letters/ascii";
char ltr;
int num = 0;
int res = 0;
+ int upper = 0;
+ int lower = 0;
while (str[num] && !res) {
fn = NULL;
@@ -121,9 +123,35 @@ static int say_character_str_full(struct ast_channel *chan, const char *str, con
break;
default:
ltr = str[num];
- if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */
- strcpy(fnbuf, "letters/X");
- fnbuf[8] = ltr;
+ if ('A' <= ltr && ltr <= 'Z') {
+ ltr += 'a' - 'A'; /* file names are all lower-case */
+ switch (sensitivity) {
+ case AST_SAY_CASE_UPPER:
+ case AST_SAY_CASE_ALL:
+ upper = !upper;
+ case AST_SAY_CASE_LOWER:
+ case AST_SAY_CASE_NONE:
+ break;
+ }
+ } else if ('a' <= ltr && ltr <= 'z') {
+ switch (sensitivity) {
+ case AST_SAY_CASE_LOWER:
+ case AST_SAY_CASE_ALL:
+ lower = !lower;
+ case AST_SAY_CASE_UPPER:
+ case AST_SAY_CASE_NONE:
+ break;
+ }
+ }
+
+ if (upper) {
+ strcpy(fnbuf, "uppercase");
+ } else if (lower) {
+ strcpy(fnbuf, "lowercase");
+ } else {
+ strcpy(fnbuf, "letters/X");
+ fnbuf[8] = ltr;
+ }
fn = fnbuf;
}
if ((fn && ast_fileexists(fn, NULL, lang) > 0) ||
@@ -137,6 +165,9 @@ static int say_character_str_full(struct ast_channel *chan, const char *str, con
}
ast_stopstream(chan);
}
+ if (upper || lower) {
+ continue;
+ }
num++;
}