[Asterisk-code-review] func_sayfiles: Retrieve say file names (asterisk[master])

N A asteriskteam at digium.com
Fri Aug 6 12:43:21 CDT 2021


Attention is currently required from: Joshua Colp, George Joseph.
N A has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16226 )

Change subject: func_sayfiles: Retrieve say file names
......................................................................


Patch Set 9:

(14 comments)

Patchset:

PS7: 
> > Looks like I just forgot to update the XML documentation. […]
Done


File doc/CHANGES-staging/say.txt:

https://gerrit.asterisk.org/c/asterisk/+/16226/comment/e910a44a_4410d4b3 
PS8, Line 3: function to 
> function "SAYFILES" to
Done


File funcs/func_sayfiles.c:

https://gerrit.asterisk.org/c/asterisk/+/16226/comment/eb34e9f9_0c846f28 
PS8, Line 64: Files played by SayNumber()
> Files played by SayNumber().  Currently supported for English only.
Done


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/38b4d8b4_6a6e5a6a 
PS8, Line 67: SayMoney()
> It's in say.c.
Whoops, looks like a whole file was missing from this review... my bad.


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/9da94042_77ab6671 
PS8, Line 82: <ref type="application">SayMoney</ref>
> Remove the "money" stuff from this review and put it and the SayMoney() application in a new review.
Ack


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/441552ae_74497153 
PS8, Line 148: #ifdef TEST_FRAMEWORK
> points for the unit test. […]
Ack


File include/asterisk/say.h:

https://gerrit.asterisk.org/c/asterisk/+/16226/comment/2e60adf4_f1c73120 
PS8, Line 146:  * function to pronounce monetary amounts
             :  */
             : int ast_say_money_str(struct ast_channel *chan, const char *num,
             : 	const char *ints, const char *lang);
             : 
             : SAY_EXTERN int (* ast_say_money_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_money_str_full);
             : 
> I'm a bit confused, what's incomplete about the SayMoney app currently? Or just shouldn't be here?
Ack


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/38a5ea29_9bd06a17 
PS8, Line 206: _full
> You can remove the _full from the "get" functions. […]
Done


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/01998425_8c8bd7dd 
PS8, Line 232: /*!
             :  * \brief Returns an ast_str of files for SayMoney playback.
             :  *
             :  * \param str Text to be translated to the corresponding audio files.
             :  * \param lang Channel language
             :  *
             :  * Computes the list of files to be played by SayMoney.
             :  *
             :  * \retval ampersand-separated string of Asterisk sound files that can be played back.
             :  */
             : struct ast_str* ast_get_money_str_full(const char *str, const char *lang);
> See above
Ack


File main/say.c:

https://gerrit.asterisk.org/c/asterisk/+/16226/comment/0284094f_0367ed51 
PS8, Line 63: _full
> As mentioned in the say.h, you can remove the _full from the "get" functions.
Done


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/a6c7e362_8013e868 
PS8, Line 363: struct ast_str* ast_get_money_str_full(const char *str, const char *lang)
             : {
             : 	const char *fnr;
             : 
             : 	double dollars = 0;
             : 	int amt, cents;
             : 	struct ast_str *fnrecurse;
             : 
             : 	struct ast_str *filenames = ast_str_create(20);
             : 	ast_str_reset(filenames);
             : 
             : 	if (sscanf(str, "%30lf", &dollars) != 1) {
             : 		amt = 0;
             : 	} else { /* convert everything to cents */
             : 		amt = dollars * 100;
             : 	}
             : 
             : 	/* Just the cents after the dollar decimal point */
             : 	cents = amt - (((int) dollars) * 100);
             : 	ast_debug(1, "Cents is %d, amount is %d\n", cents, amt);
             : 
             : 	if (amt >= 100) {
             : 		fnrecurse = ast_get_number_str_full((amt / 100), lang);
             : 		fnr = ast_str_buffer(fnrecurse);
             : 		ast_str_append(&filenames, 0, "%s", fnr);
             : 
             : 		/* If this is it, end on a down pitch, otherwise up pitch */
             : 		if (amt < 200) {
             : 			ast_str_append(&filenames, 0, "&%s", (cents > 0) ? "letters/dollar_" : "letters/dollar");
             : 		} else {
             : 			ast_str_append(&filenames, 0, "&%s", "dollars");
             : 		}
             : 
             : 		/* If dollars and cents, add "and" in the middle */
             : 		if (cents > 0) {
             : 			ast_str_append(&filenames, 0, "&%s", "and");
             : 		}
             : 	}
             : 
             : 	if (cents > 0) {
             : 		ast_debug(1, "Entered cents block\n");
             : 		fnrecurse = ast_get_number_str_full(cents, lang);
             : 		fnr = ast_str_buffer(fnrecurse);
             : 		ast_str_append(&filenames, 0, (amt < 100 ? "%s" : "&%s"), fnr);
             : 		ast_str_append(&filenames, 0, "&%s", (cents == 1) ? "cent" : "cents");
             : 	} else if (amt == 0) {
             : 		fnrecurse = ast_get_digit_str_full("0", lang);
             : 		fnr = ast_str_buffer(fnrecurse);
             : 		ast_str_append(&filenames, 0, "%s", fnr);
             : 		ast_str_append(&filenames, 0, "&%s", "cents");
             : 	}
             : 
             : 	return filenames;
             : }
             : 
             : static int say_money_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
             : {
             : 	const char *fn;
             : 	int res = 0;
             : 
             : 	struct ast_str *filenames = ast_get_money_str_full(str, lang);
             : 	char *files = ast_str_buffer(filenames);
             : 
             : 	while ((fn = strsep(&files, "&"))) {
             : 		res = ast_streamfile(chan, fn, lang);
             : 		if (!res) {
             : 			if ((audiofd  > -1) && (ctrlfd > -1))
             : 				res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
             : 			else
             : 				res = ast_waitstream(chan, ints);
             : 		}
             : 		ast_stopstream(chan);
             : 	}
             : 
             : 	ast_free(filenames);
             : 
             : 	return res;
             : }
> Remove money support for now and add it in another review that also has the SayMoney application.
Ack


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/87e2f7f4_83e9be4d 
PS8, Line 442: st_get_number_str_full
> Because the number functions are language-specific, you should make this a private function named ge […]
Done


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/c2ef8d68_b120ca9b 
PS8, Line 753: ast_get_number_str_full
> get_number_str_en
Done


https://gerrit.asterisk.org/c/asterisk/+/16226/comment/d6d01c86_5a229ce8 
PS8, Line 9582: 	ast_say_money_str_full = say_money_str_full;
> Remove for now.
Ack



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16226
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: If9718c89353b8e153d84add3cc4637b79585db19
Gerrit-Change-Number: 16226
Gerrit-PatchSet: 9
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-CC: Joshua Colp <jcolp at sangoma.com>
Gerrit-Attention: Joshua Colp <jcolp at sangoma.com>
Gerrit-Attention: George Joseph <gjoseph at digium.com>
Gerrit-Comment-Date: Fri, 06 Aug 2021 17:43:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: N A <mail at interlinked.x10host.com>
Comment-In-Reply-To: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210806/b5ccfc75/attachment-0001.html>


More information about the asterisk-code-review mailing list