[svn-commits] kmoore: branch kmoore/say_alpha_tweaks r397427 - in /team/kmoore/say_alpha_tw...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Aug 22 11:50:02 CDT 2013
Author: kmoore
Date: Thu Aug 22 11:49:59 2013
New Revision: 397427
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397427
Log:
Avoid changing the behavior of SayAlpha by putting the new functionality in SayAlphaCase
Modified:
team/kmoore/say_alpha_tweaks/apps/app_chanspy.c
team/kmoore/say_alpha_tweaks/apps/app_directory.c
team/kmoore/say_alpha_tweaks/apps/app_voicemail.c
team/kmoore/say_alpha_tweaks/include/asterisk/say.h
team/kmoore/say_alpha_tweaks/main/channel.c
team/kmoore/say_alpha_tweaks/main/pbx.c
team/kmoore/say_alpha_tweaks/main/say.c
team/kmoore/say_alpha_tweaks/res/res_agi.c
Modified: team/kmoore/say_alpha_tweaks/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/apps/app_chanspy.c?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/apps/app_chanspy.c (original)
+++ team/kmoore/say_alpha_tweaks/apps/app_chanspy.c Thu Aug 22 11:49:59 2013
@@ -1048,7 +1048,7 @@
break;
}
} else {
- res = ast_say_character_str(chan, peer_name, "", ast_channel_language(chan), 0);
+ res = ast_say_character_str(chan, peer_name, "", ast_channel_language(chan), AST_SAY_CASE_NONE);
}
}
if (ptr && (num = atoi(ptr))) {
Modified: team/kmoore/say_alpha_tweaks/apps/app_directory.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/apps/app_directory.c?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/apps/app_directory.c (original)
+++ team/kmoore/say_alpha_tweaks/apps/app_directory.c Thu Aug 22 11:49:59 2013
@@ -281,13 +281,13 @@
/* If Option 'e' was specified, also read the extension number with the name */
if (ast_test_flag(flags, OPT_SAYEXTENSION)) {
ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
- res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), 0);
+ res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
}
} else {
- res = ast_say_character_str(chan, S_OR(name, ext), AST_DIGIT_ANY, ast_channel_language(chan), 0);
+ res = ast_say_character_str(chan, S_OR(name, ext), AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
if (!ast_strlen_zero(name) && ast_test_flag(flags, OPT_SAYEXTENSION)) {
ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
- res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), 0);
+ res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
}
}
Modified: team/kmoore/say_alpha_tweaks/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/apps/app_voicemail.c?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/apps/app_voicemail.c (original)
+++ team/kmoore/say_alpha_tweaks/apps/app_voicemail.c Thu Aug 22 11:49:59 2013
@@ -13683,7 +13683,7 @@
ast_debug(3, "Greeting not found for '%s@%s', falling back to mailbox number.\n", args_copy, context);
res = ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
if (!res) {
- res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan), 0);
+ res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
}
}
Modified: team/kmoore/say_alpha_tweaks/include/asterisk/say.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/include/asterisk/say.h?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/include/asterisk/say.h (original)
+++ team/kmoore/say_alpha_tweaks/include/asterisk/say.h Thu Aug 22 11:49:59 2013
@@ -148,13 +148,23 @@
*/
SAY_EXTERN int (* ast_say_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_full);
+/*!
+ * \brief Controls how ast_say_character_str denotes the case of characters in a string
+ */
+enum ast_say_case_sensitivity {
+ AST_SAY_CASE_NONE, /*!< Do not distinguish case on any letters */
+ AST_SAY_CASE_LOWER, /*!< Denote case only on lower case letters, upper case is assumed otherwise */
+ AST_SAY_CASE_UPPER, /*!< Denote case only on upper case letters, lower case is assumed otherwise */
+ AST_SAY_CASE_ALL, /*!< Denote case on all letters, upper and lower */
+};
+
/*! \brief
* function to pronounce character and phonetic strings
*/
int ast_say_character_str(struct ast_channel *chan, const char *num,
- const char *ints, const char *lang, int casesensitive);
+ const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity);
-SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int casesensitive, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
+SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
int ast_say_phonetic_str(struct ast_channel *chan, const char *num,
const char *ints, const char *lang);
Modified: team/kmoore/say_alpha_tweaks/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/main/channel.c?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/main/channel.c (original)
+++ team/kmoore/say_alpha_tweaks/main/channel.c Thu Aug 22 11:49:59 2013
@@ -7792,9 +7792,9 @@
}
int ast_say_character_str(struct ast_channel *chan, const char *str,
- const char *ints, const char *lang, int casesensitive)
-{
- return ast_say_character_str_full(chan, str, ints, lang, casesensitive, -1, -1);
+ const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
+{
+ return ast_say_character_str_full(chan, str, ints, lang, sensitivity, -1, -1);
}
int ast_say_phonetic_str(struct ast_channel *chan, const char *str,
Modified: team/kmoore/say_alpha_tweaks/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/main/pbx.c?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/main/pbx.c (original)
+++ team/kmoore/say_alpha_tweaks/main/pbx.c Thu Aug 22 11:49:59 2013
@@ -11305,32 +11305,45 @@
static int pbx_builtin_saycharacters_case(struct ast_channel *chan, const char *data)
{
int res = 0;
- int casesensitive = 0;
+ int sensitivity = 0;
char *parse;
AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(options);
AST_APP_ARG(characters);
- AST_APP_ARG(options);
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "SayAlpha requires an argument (characters)\n");
+ ast_log(LOG_WARNING, "SayAlphaCase requires two arguments (options, characters)\n");
return 0;
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
- if (args.options) {
- if (strcasecmp(args.options, "i") && strcasecmp(args.options, "s")) {
- ast_log(LOG_WARNING, "SayAlpha case sensitive option is either 'i' or 's'\n");
- return 0;
- }
- if (!strcasecmp(args.options, "s")) {
- casesensitive = 1;
- }
- }
-
- res = ast_say_character_str(chan, args.characters, "", ast_channel_language(chan), casesensitive);
+ if (!args.options || strlen(args.options) != 1) {
+ ast_log(LOG_WARNING, "SayAlphaCase options are mutually exclusive and required\n");
+ return 0;
+ }
+
+ switch (args.options[0]) {
+ case 'a':
+ sensitivity = AST_SAY_CASE_ALL;
+ break;
+ case 'l':
+ sensitivity = AST_SAY_CASE_LOWER;
+ break;
+ case 'n':
+ sensitivity = AST_SAY_CASE_NONE;
+ break;
+ case 'u':
+ sensitivity = AST_SAY_CASE_UPPER;
+ break;
+ default:
+ ast_log(LOG_WARNING, "Invalid option: '%s'\n", args.options);
+ return 0;
+ }
+
+ res = ast_say_character_str(chan, args.characters, "", ast_channel_language(chan), sensitivity);
return res;
}
@@ -11340,7 +11353,7 @@
int res = 0;
if (data) {
- res = ast_say_character_str(chan, data, "", ast_channel_language(chan), 0);
+ res = ast_say_character_str(chan, data, "", ast_channel_language(chan), AST_SAY_CASE_NONE);
}
return res;
Modified: team/kmoore/say_alpha_tweaks/main/say.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/main/say.c?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/main/say.c (original)
+++ team/kmoore/say_alpha_tweaks/main/say.c Thu Aug 22 11:49:59 2013
@@ -61,7 +61,7 @@
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 casesensitive, 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";
@@ -69,6 +69,7 @@
int num = 0;
int res = 0;
int upper = 0;
+ int lower = 0;
while (str[num] && !res) {
fn = NULL;
@@ -124,14 +125,34 @@
ltr = str[num];
if ('A' <= ltr && ltr <= 'Z') {
ltr += 'a' - 'A'; /* file names are all lower-case */
- if (casesensitive) {
+ 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");
+ ast_verbose("Saying uppercase\n");
+ } else if (lower) {
+ strcpy(fnbuf, "lowercase");
+ ast_verbose("Saying lowercase\n");
} else {
strcpy(fnbuf, "letters/X");
+ ast_verbose("Saying letter\n");
fnbuf[8] = ltr;
}
fn = fnbuf;
@@ -147,7 +168,7 @@
}
ast_stopstream(chan);
}
- if (upper) {
+ if (upper || lower) {
continue;
}
num++;
Modified: team/kmoore/say_alpha_tweaks/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/res/res_agi.c?view=diff&rev=397427&r1=397426&r2=397427
==============================================================================
--- team/kmoore/say_alpha_tweaks/res/res_agi.c (original)
+++ team/kmoore/say_alpha_tweaks/res/res_agi.c Thu Aug 22 11:49:59 2013
@@ -2313,19 +2313,37 @@
static int handle_sayalpha(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
- int casesensitive = 0;
+ int sensitivity = AST_SAY_CASE_NONE;
if (argc < 4 || argc > 5) {
return RESULT_SHOWUSAGE;
}
if (argc > 4) {
- if (strcasecmp(argv[4], "i") && strcasecmp(argv[4], "s")) {
+ switch (argv[4][0]) {
+ case 'a':
+ case 'A':
+ sensitivity = AST_SAY_CASE_ALL;
+ break;
+ case 'l':
+ case 'L':
+ sensitivity = AST_SAY_CASE_LOWER;
+ break;
+ case 'n':
+ case 'N':
+ sensitivity = AST_SAY_CASE_NONE;
+ break;
+ case 'u':
+ case 'U':
+ sensitivity = AST_SAY_CASE_UPPER;
+ break;
+ case '\0':
+ break;
+ default:
return RESULT_SHOWUSAGE;
}
- casesensitive = (!strcasecmp(argv[4], "s") ? 1 : 0);
- }
- res = ast_say_character_str_full(chan, argv[2], argv[3], ast_channel_language(chan), casesensitive, agi->audio, agi->ctrl);
+ }
+ res = ast_say_character_str_full(chan, argv[2], argv[3], ast_channel_language(chan), sensitivity, agi->audio, agi->ctrl);
if (res == 1) /* New command */
return RESULT_SUCCESS;
ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
More information about the svn-commits
mailing list