Help with say.c


#1

I was wondering if somebody can help me to complete this code, numbers 20 through 99 are said in reverse order, i.e. 21 is “one-and twenty” and 68 is “eight-and sixty”. also 221 i want it to say “two hunderd and-one-and twenty”, same thing for 2121 “two thouthand and-two hundred and-one-and twenty”. to make it more clear number 100 to 900 i want to add “and” to it if it has fraction ie: 621 "six hundred and-one and-twenty"
so i need “and” after every 100-900 as well as 1000-9000.
the numbers 100-900 i want to have seprate sound file for example 200 sould have the sound file “two-hundred” and 2000 -9000 also has to be the same because it is different than english
could you please help?

/*! \brief ast_say_number_full_da: Danish syntax /
/
New files:
static int ast_say_number_full_da(struct ast_channel *chan, int num, const char *ints, const char *language, const char options, int audiofd, int ctrlfd)
{
int res = 0;
int playh = 0;
int playa = 0;
int cn = 1; /
+1 = commune; -1 = neuter */
char fn[256] = “”;
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);

if (options && !strncasecmp(options, "n",1)) cn = -1;

while(!res && (num || playh || playa )) {
			if (num < 0) {
		snprintf(fn, sizeof(fn), "digits/minus");
		if ( num > INT_MIN ) {
			num = -num;
		} else {
			num = 0;
		}	
	} else if (playh) {
		snprintf(fn, sizeof(fn), "digits/hundred");
		playh = 0;
	} else if (playa) {
		snprintf(fn, sizeof(fn), "digits/and");
		playa = 0;
	} else if (num == 1 && cn == -1) {
		snprintf(fn, sizeof(fn), "digits/1N");
		num = 0;
	} else if (num < 20) {
		snprintf(fn, sizeof(fn), "digits/%d", num);
		num = 0;
	} else if (num < 100) {
		int ones = num % 10;
		if (ones) {
			snprintf(fn, sizeof(fn), "digits/%d-and", ones);
			num -= ones;
		} else {
			snprintf(fn, sizeof(fn), "digits/%d", num);
			num = 0;
		}
	} else {
		if (num < 1000) {
			int hundreds = num / 100;
			if (hundreds == 1)
				snprintf(fn, sizeof(fn), "digits/1N");
			else
				snprintf(fn, sizeof(fn), "digits/%d", (num / 100));

			playh++;
			num -= 100 * hundreds;
			if (num)
				playa++;

		} else {
			if (num < 1000000) {
				res = ast_say_number_full_da(chan, num / 1000, ints, language, "n", audiofd, ctrlfd);
				if (res)
					return res;
				num = num % 1000;
				snprintf(fn, sizeof(fn), "digits/thousand");
			} else {
				if (num < 1000000000) {
					int millions = num / 1000000;
					res = ast_say_number_full_da(chan, millions, ints, language, "c", audiofd, ctrlfd);
					if (res)
						return res;
					if (millions == 1)
						snprintf(fn, sizeof(fn), "digits/million");
					else
						snprintf(fn, sizeof(fn), "digits/millions");
					num = num % 1000000;
				} else {
					ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
					res = -1;
				}
			}
			if (num && num < 100)
				playa++;
		}
	}
	if (!res) {
		if(!ast_streamfile(chan, fn, language)) {
			if ((audiofd > -1) && (ctrlfd > -1)) 
				res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
			else  
				res = ast_waitstream(chan, ints);
		}
		ast_stopstream(chan);
	}
}
return res;

}