Beispiel #1
0
static switch_status_t hu_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
	char sbuf[16] = "";
	char *forint;

	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1))) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	forint = sbuf;

	if (sbuf[0] == '+') {
		forint++;
	}

	if (sbuf[0] == '-') {
		say_file("currency/negative.wav");
		forint++;
	}

	hu_say_general_count(session, forint, say_args, args);
	say_file("currency/forint.wav");

	return SWITCH_STATUS_SUCCESS;
}
Beispiel #2
0
static switch_status_t de_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
	char sbuf[16] = "";			/* enough for 999,999,999,999.99 (w/o the commas or leading $) */
	char *dollars = NULL;
	char *cents = NULL;

	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1))) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	dollars = sbuf;

	if ((cents = strchr(sbuf, '.'))) {
		*cents++ = '\0';
		if (strlen(cents) > 2) {
			cents[2] = '\0';
		}
	}

	/* If positive sign - skip over" */
	if (sbuf[0] == '+') {
		dollars++;
	}

	/* If negative say "negative" */
	if (sbuf[0] == '-') {
		say_file("currency/negative.wav");
		dollars++;
	}

 
	/* Say dollar amount */
	if (atoi(dollars) == 1) {
		say_file("digits/s-1.wav");
		say_file("currency/dollar.wav");
	} else {
		de_say_general_count(session, dollars, say_args, args);
		say_file("currency/dollars.wav");
	}

	/* Say cents */
	if (cents) {
		/* Say "and" */
		say_file("currency/and.wav");
		if (atoi(cents) == 1) {
			say_file("digits/s-1.wav");
			say_file("currency/cent.wav");
		} else {
			de_say_general_count(session, cents, say_args, args);
			say_file("currency/cents.wav");
		}
	} else {
		say_file("digits/0.wav");
		say_file("currency/cents.wav");
	}

	return SWITCH_STATUS_SUCCESS;
}
Beispiel #3
0
static switch_status_t en_say_money(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args, char *main_currency_file_single, char *main_currency_file_plural, char *fractional_currency_file_single, char *fractional_currency_file_plural)
{
	char sbuf[16] = "";			/* enough for 999,999,999,999.99 (w/o the commas or leading $) */
	char *dollars = NULL;
	char *cents = NULL;

	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1))) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	dollars = sbuf;

	if ((cents = strchr(sbuf, '.'))) {
		*cents++ = '\0';
		if (strlen(cents) > 2) {
			cents[2] = '\0';
		}
	}

	/* If positive sign - skip over" */
	if (sbuf[0] == '+') {
		dollars++;
	}

	/* If negative say "negative" */
	if (sbuf[0] == '-') {
		switch_say_file(sh, "currency/negative");
		dollars++;
	}

	/* Say dollar amount */
	en_say_general_count(sh, dollars, say_args);
	if (atoi(dollars) == 1) {
		switch_say_file(sh, main_currency_file_single);
	} else {
		switch_say_file(sh, main_currency_file_plural);
	}
	

	/* Say cents */
	if (cents) {
		/* Say "and" */
		switch_say_file(sh, "currency/and");

		en_say_general_count(sh, cents, say_args);
		if (atoi(cents) == 1) {
			switch_say_file(sh, fractional_currency_file_single);
		} else {
			switch_say_file(sh, fractional_currency_file_plural);
		}
	}

	return SWITCH_STATUS_SUCCESS;
}
Beispiel #4
0
static switch_status_t zh_CN_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
	char sbuf[16] = "";			/* enough for 999,999,999,999.99 (w/o the commas or leading $) */
	char dbuf[16] = "";			/* enough for digits/x.wav */
	char *yuan = NULL;
	char *rest = NULL;
	int i;

	if (strlen(tosay) > 15 || !switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1)) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	yuan = sbuf;

	if ((rest = strchr(sbuf, '.'))) {
		*rest++ = '\0';
	}

	/* If positive sign - skip over" */
	if (sbuf[0] == '+') {
		yuan++;
	}

	/* If negative say "negative" */
	if (sbuf[0] == '-') {
		say_file("currency/negative.wav");
		yuan++;
	}

	/* Say dollar amount */
	zh_say_general_count(session, yuan, say_args, args);
	say_file("currency/yuan.wav");

	if (!rest) return SWITCH_STATUS_SUCCESS;

	/* Say cents */
	for (i=0; *rest; i++, rest++) {
	sprintf(dbuf, "digits/%c.wav", *rest);
		say_file(dbuf);
		if (i == 0) {
			say_file("currency/jiao.wav");
		} else if (i == 1) {
			say_file("currency/fen.wav");
		} else if (i == 2) {
			say_file("currency/li.wav");
		}  /* else just say the rest of digits */
	}

	return SWITCH_STATUS_SUCCESS;
}
static switch_status_t fa_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
	char sbuf[16] = "";			/* enough for 999,999,999,999.99 (w/o the commas or leading $) */
	char *rials = NULL;
	char *cents = NULL;

	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
		/* valid characters are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	rials = sbuf;

	if ((cents = strchr(sbuf, '.'))) {
		*cents++ = '\0';
		if (strlen(cents) > 2) {
			cents[2] = '\0';
		}
	}

	/* If positive sign - skip over" */
	if (sbuf[0] == '+') {
		say_file("currency/positive-e.wav");
		rials++;
	}

	/* If negative say "negative" */
	if (sbuf[0] == '-') {
		say_file("currency/negative-e.wav");
		rials++;
	}

	/* Say rial amount */
	fa_say_general_count(session, rials, say_args, args);
	say_file("currency/rials.wav");

	return SWITCH_STATUS_SUCCESS;
}
Beispiel #6
0
static switch_status_t ru_say_money(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args,say_opt_t *say_opt)
{
	char sbuf[16] = "";
	char *rubles = NULL;
	char *kopecks = NULL;
	int irubles = 0;
	int iruble = 0;
	int ikopecks = 0;
	int ikopeck = 0;
//	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_money %s say_opt->currency=%d\n", tosay,say_opt->currency);

	if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1))) {
		//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
		return SWITCH_STATUS_GENERR;
	}

	rubles = sbuf;
	if ((kopecks = strchr(sbuf, '.'))) {
		*kopecks++ = '\0';
		if (strlen(kopecks) > 2) {
			kopecks[2] = '\0';
		}
	}

	if (sbuf[0] == '+') {
		rubles++;
	}

	if (sbuf[0] == '-') {
		switch_say_file(sh, "currency/minus");
		rubles++;
	}


	ru_say_count(sh, rubles, matrix_currency[say_opt->currency].first_gender,matrix_currency[say_opt->currency].first_cases);

	if (rubles) {
		irubles = atoi(rubles) % 100;
		iruble = atoi(rubles) % 10;
	}
	if (iruble<5) {
	    if ((irubles>10)&&(irubles<15)) {
		switch_say_file(sh, "currency/%s",matrix_currency[say_opt->currency].first[5]);
	    }
	    else {
		switch_say_file(sh, "currency/%s",matrix_currency[say_opt->currency].first[iruble]);
	    }
	}
	else {
	    switch_say_file(sh, "currency/%s",matrix_currency[say_opt->currency].first[5]);
	}
	    
	    
	/* Say kopecks */
	ru_say_count(sh, kopecks, matrix_currency[say_opt->currency].second_gender,matrix_currency[say_opt->currency].second_cases);

	if (kopecks) {
		ikopecks = atoi(kopecks) % 100;
		ikopeck = atoi(kopecks) % 10;
	}

	if (ikopeck<5) {
	    if ((ikopecks>10)&&(ikopecks<15)) {
		switch_say_file(sh, "currency/%s",matrix_currency[say_opt->currency].second[5]);
	    }
	    else {
    		switch_say_file(sh, "currency/%s",matrix_currency[say_opt->currency].second[ikopeck]);
	    }
	}
	else {
	    switch_say_file(sh, "currency/%s",matrix_currency[say_opt->currency].second[5]);
	}



	return SWITCH_STATUS_SUCCESS;
}