Newer
Older
else
snprintf(fn, sizeof(fn), "digits/1000000S");
if ((num % 1000000) &&
Mark Spencer
committed
/* no thousands */
((!((num / 1000) % 1000) && ((num % 1000) < 100 || !(num % 100))) ||
Mark Spencer
committed
/* no hundreds and below */
(!(num % 1000) && (((num / 1000) % 1000) < 100 || !((num / 1000) % 100))) ) )
playh = 1;
num = num % 1000000;
}
Mark Spencer
committed
if (!res) {
if (!ast_streamfile(chan, fn, language)) {
Mark Spencer
committed
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
res = ast_waitstream(chan, ints);
}
ast_stopstream(chan);
}
if (!res && playh) {
res = wait_file(chan, ints, "digits/pt-e", language);
ast_stopstream(chan);
playh = 0;
}
}
return res;
}
Mark Spencer
committed
/*! \brief ast_say_number_full_se: Swedish syntax */
Mark Spencer
committed
static int ast_say_number_full_se(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;
char fn[256] = "";
Mark Spencer
committed
int cn = 1; /* +1 = commune; -1 = neuter */
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)) {
Mark Spencer
committed
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
num = -num;
} else {
num = 0;
Mark Spencer
committed
}
} else if (playh) {
snprintf(fn, sizeof(fn), "digits/hundred");
playh = 0;
} else if (num < 20) {
snprintf(fn, sizeof(fn), "digits/%d", num);
num = 0;
} else if (num < 100) {
snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
num -= ((num / 10) * 10);
} else if (num == 1 && cn == -1) { /* En eller ett? */
snprintf(fn, sizeof(fn), "digits/1N");
num = 0;
} else {
if (num < 1000){
snprintf(fn, sizeof(fn), "digits/%d", (num/100));
playh++;
num -= ((num / 100) * 100);
} else {
Mark Spencer
committed
if (num < 1000000) { /* 1,000,000 */
res = ast_say_number_full_se(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
if (res) {
return res;
}
num = num % 1000;
snprintf(fn, sizeof(fn), "digits/thousand");
} else {
Mark Spencer
committed
if (num < 1000000000) { /* 1,000,000,000 */
res = ast_say_number_full_se(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);
if (res) {
return res;
}
Mark Spencer
committed
num = num % 1000000;
snprintf(fn, sizeof(fn), "digits/million");
} else {
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
}
Mark Spencer
committed
}
if (!res) {
if(!ast_streamfile(chan, fn, language)) {
Mark Spencer
committed
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
res = ast_waitstream(chan, ints);
ast_stopstream(chan);
}
}
}
return res;
}
/*! \brief ast_say_number_full_tw: Taiwanese / Chinese syntax */
Mark Spencer
committed
static int ast_say_number_full_tw(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
{
int res = 0;
int playh = 0;
char fn[256] = "";
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && (num || playh)) {
Mark Spencer
committed
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 (num < 10) {
snprintf(fn, sizeof(fn), "digits/%d", num);
num = 0;
} else if (num < 100) {
snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
num -= ((num / 10) * 10);
} else {
if (num < 1000){
snprintf(fn, sizeof(fn), "digits/%d", (num/100));
playh++;
num -= ((num / 100) * 100);
} else {
if (num < 1000000) { /* 1,000,000 */
res = ast_say_number_full_tw(chan, num / 1000, ints, language, audiofd, ctrlfd);
if (res)
return res;
num = num % 1000;
snprintf(fn, sizeof(fn), "digits/thousand");
} else {
if (num < 1000000000) { /* 1,000,000,000 */
res = ast_say_number_full_tw(chan, num / 1000000, ints, language, audiofd, ctrlfd);
if (res)
return res;
num = num % 1000000;
snprintf(fn, sizeof(fn), "digits/million");
} else {
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
}
}
if (!res) {
if(!ast_streamfile(chan, fn, language)) {
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
res = ast_waitstream(chan, ints);
}
ast_stopstream(chan);
}
}
return res;
}
/*! \brief determine last digits for thousands/millions (ru) */
static int get_lastdigits_ru(int num) {
if (num < 20) {
return num;
} else if (num < 100) {
return get_lastdigits_ru(num % 10);
} else if (num < 1000) {
return get_lastdigits_ru(num % 100);
}
return 0; /* number too big */
}
/*! \brief ast_say_number_full_ru: Russian syntax */
/*! \brief additional files:
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
n00.gsm (one hundred, two hundred, ...)
thousand.gsm
million.gsm
thousands-i.gsm (tisyachi)
million-a.gsm (milliona)
thousands.gsm
millions.gsm
1f.gsm (odna)
2f.gsm (dve)
where 'n' from 1 to 9
*/
static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
int res = 0;
int lastdigits = 0;
char fn[256] = "";
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && (num)) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) {
num = -num;
} else {
num = 0;
}
} else if (num < 20) {
if(options && strlen(options) == 1 && num < 3) {
snprintf(fn, sizeof(fn), "digits/%d%s", num, options);
} else {
snprintf(fn, sizeof(fn), "digits/%d", num);
}
num = 0;
} else if (num < 100) {
snprintf(fn, sizeof(fn), "digits/%d", num - (num % 10));
num %= 10;
} else if (num < 1000){
snprintf(fn, sizeof(fn), "digits/%d", num - (num % 100));
num %= 100;
} else if (num < 1000000) { /* 1,000,000 */
lastdigits = get_lastdigits_ru(num / 1000);
/* say thousands */
if (lastdigits < 3) {
res = ast_say_number_full_ru(chan, num / 1000, ints, language, "f", audiofd, ctrlfd);
} else {
res = ast_say_number_full_ru(chan, num / 1000, ints, language, NULL, audiofd, ctrlfd);
}
if (res)
return res;
if (lastdigits == 1) {
snprintf(fn, sizeof(fn), "digits/thousand");
} else if (lastdigits > 1 && lastdigits < 5) {
snprintf(fn, sizeof(fn), "digits/thousands-i");
} else {
snprintf(fn, sizeof(fn), "digits/thousands");
}
num %= 1000;
} else if (num < 1000000000) { /* 1,000,000,000 */
lastdigits = get_lastdigits_ru(num / 1000000);
/* say millions */
res = ast_say_number_full_ru(chan, num / 1000000, ints, language, NULL, audiofd, ctrlfd);
if (res)
return res;
if (lastdigits == 1) {
snprintf(fn, sizeof(fn), "digits/million");
} else if (lastdigits > 1 && lastdigits < 5) {
snprintf(fn, sizeof(fn), "digits/million-a");
} else {
snprintf(fn, sizeof(fn), "digits/millions");
}
num %= 1000000;
} else {
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
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;
}
/*! \brief ast_say_enumeration_full: call language-specific functions */
Mark Spencer
committed
/* Called from AGI */
int ast_say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
if (!strcasecmp(language,"en") ) { /* English syntax */
return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd));
} else if (!strcasecmp(language, "da") ) { /* Danish syntax */
return(ast_say_enumeration_full_da(chan, num, ints, language, options, audiofd, ctrlfd));
Mark Spencer
committed
} else if (!strcasecmp(language, "de") ) { /* German syntax */
return(ast_say_enumeration_full_de(chan, num, ints, language, options, audiofd, ctrlfd));
}
/* Default to english */
return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd));
}
/*! \brief ast_say_enumeration: call language-specific functions without file descriptors */
Mark Spencer
committed
int ast_say_enumeration(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
Mark Spencer
committed
return(ast_say_enumeration_full(chan, num, ints, language, options, -1, -1));
}
/*! \brief ast_say_enumeration_full_en: English syntax */
Mark Spencer
committed
/* This is the default syntax, if no other syntax defined in this file is used */
static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
{
int res = 0, t = 0;
Mark Spencer
committed
while(!res && num) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) {
num = -num;
} else {
num = 0;
}
Mark Spencer
committed
snprintf(fn, sizeof(fn), "digits/h-%d", num);
Mark Spencer
committed
} else if (num < 100) {
int tens = num / 10;
num = num % 10;
if (num == 0) {
snprintf(fn, sizeof(fn), "digits/h-%d", (tens * 10));
} else {
snprintf(fn, sizeof(fn), "digits/%d", (tens * 10));
}
Mark Spencer
committed
int hundreds = num / 100;
num = num % 100;
if (hundreds > 1 || t == 1) {
res = ast_say_number_full_en(chan, hundreds, ints, language, audiofd, ctrlfd);
}
if (res)
return res;
if (num) {
snprintf(fn, sizeof(fn), "digits/hundred");
Mark Spencer
committed
snprintf(fn, sizeof(fn), "digits/h-hundred");
Mark Spencer
committed
} else if (num < 1000000) {
int thousands = num / 1000;
num = num % 1000;
if (thousands > 1 || t == 1) {
res = ast_say_number_full_en(chan, thousands, ints, language, audiofd, ctrlfd);
Mark Spencer
committed
if (res)
return res;
if (num) {
snprintf(fn, sizeof(fn), "digits/thousand");
} else {
snprintf(fn, sizeof(fn), "digits/h-thousand");
Mark Spencer
committed
t = 1;
} else if (num < 1000000000) {
int millions = num / 1000000;
num = num % 1000000;
t = 1;
res = ast_say_number_full_en(chan, millions, ints, language, audiofd, ctrlfd);
if (res)
return res;
if (num) {
snprintf(fn, sizeof(fn), "digits/million");
} else {
snprintf(fn, sizeof(fn), "digits/h-million");
Mark Spencer
committed
} else if (num < INT_MAX) {
int billions = num / 1000000000;
num = num % 1000000000;
t = 1;
res = ast_say_number_full_en(chan, billions, ints, language, audiofd, ctrlfd);
if (res)
return res;
if (num) {
snprintf(fn, sizeof(fn), "digits/billion");
} else {
snprintf(fn, sizeof(fn), "digits/h-billion");
Mark Spencer
committed
} else if (num == INT_MAX) {
snprintf(fn, sizeof(fn), "digits/h-last");
num = 0;
} else {
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
Mark Spencer
committed
Mark Spencer
committed
if (!ast_streamfile(chan, fn, language)) {
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
} else {
res = ast_waitstream(chan, ints);
}
}
ast_stopstream(chan);
Mark Spencer
committed
}
Mark Spencer
committed
return res;
/*! \brief ast_say_enumeration_full_da: Danish syntax */
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
static int ast_say_enumeration_full_da(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
/* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */
int res = 0, t = 0;
char fn[256] = "", fna[256] = "";
char *gender;
if (options && !strncasecmp(options, "f",1)) {
gender = "F";
} else if (options && !strncasecmp(options, "n",1)) {
gender = "N";
} else {
gender = "";
}
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && num) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) {
num = -num;
} else {
num = 0;
}
} else if (num < 100 && t) {
snprintf(fn, sizeof(fn), "digits/and");
t = 0;
} else if (num < 20) {
snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
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/h-%d%s", num, gender);
num = 0;
}
} else if (num == 100 && t == 0) {
snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender);
num = 0;
} else if (num < 1000) {
int hundreds = num / 100;
num = num % 100;
if (hundreds == 1) {
snprintf(fn, sizeof(fn), "digits/1N");
} else {
snprintf(fn, sizeof(fn), "digits/%d", hundreds);
}
if (num) {
snprintf(fna, sizeof(fna), "digits/hundred");
} else {
snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
}
t = 1;
} else if (num < 1000000) {
int thousands = num / 1000;
num = num % 1000;
if (thousands == 1) {
if (num) {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/thousand");
} else {
if (t) {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender);
} else {
snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
}
}
} else {
res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
if (res) {
return res;
}
if (num) {
snprintf(fn, sizeof(fn), "digits/thousand");
} else {
snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
}
}
t = 1;
} else if (num < 1000000000) {
int millions = num / 1000000;
num = num % 1000000;
if (millions == 1) {
if (num) {
snprintf(fn, sizeof(fn), "digits/1F");
snprintf(fna, sizeof(fna), "digits/million");
} else {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/h-million%s", gender);
}
} else {
res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
if (res) {
return res;
}
if (num) {
snprintf(fn, sizeof(fn), "digits/millions");
} else {
snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
}
}
t = 1;
} else if (num < INT_MAX) {
int billions = num / 1000000000;
num = num % 1000000000;
if (billions == 1) {
if (num) {
snprintf(fn, sizeof(fn), "digits/1F");
snprintf(fna, sizeof(fna), "digits/milliard");
} else {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender);
}
} else {
res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
if (res)
return res;
if (num) {
snprintf(fn, sizeof(fna), "digits/milliards");
} else {
snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender);
}
}
t = 1;
} else if (num == INT_MAX) {
snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
num = 0;
} else {
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
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);
if (!res) {
if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) {
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
} else {
res = ast_waitstream(chan, ints);
}
}
ast_stopstream(chan);
strcpy(fna, "");
}
}
}
return res;
}
/*! \brief ast_say_enumeration_full_de: German syntax */
Mark Spencer
committed
static int ast_say_enumeration_full_de(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
Mark Spencer
committed
/* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */
int res = 0, t = 0;
char fn[256] = "", fna[256] = "";
char *gender;
if (options && !strncasecmp(options, "f",1)) {
gender = "F";
} else if (options && !strncasecmp(options, "n",1)) {
gender = "N";
} else {
gender = "";
}
Mark Spencer
committed
if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
Mark Spencer
committed
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
while(!res && num) {
if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) {
num = -num;
} else {
num = 0;
}
} else if (num < 100 && t) {
snprintf(fn, sizeof(fn), "digits/and");
t = 0;
} else if (num < 20) {
snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
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/h-%d%s", num, gender);
num = 0;
}
} else if (num == 100 && t == 0) {
snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender);
num = 0;
} else if (num < 1000) {
int hundreds = num / 100;
num = num % 100;
if (hundreds == 1) {
snprintf(fn, sizeof(fn), "digits/1N");
} else {
snprintf(fn, sizeof(fn), "digits/%d", hundreds);
}
if (num) {
snprintf(fna, sizeof(fna), "digits/hundred");
} else {
snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
}
t = 1;
} else if (num < 1000000) {
int thousands = num / 1000;
num = num % 1000;
if (thousands == 1) {
if (num) {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/thousand");
} else {
if (t) {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender);
} else {
snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
}
}
} else {
res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
if (res) {
return res;
}
if (num) {
snprintf(fn, sizeof(fn), "digits/thousand");
} else {
snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
}
}
t = 1;
} else if (num < 1000000000) {
int millions = num / 1000000;
num = num % 1000000;
if (millions == 1) {
if (num) {
snprintf(fn, sizeof(fn), "digits/1F");
snprintf(fna, sizeof(fna), "digits/million");
} else {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/h-million%s", gender);
}
} else {
res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
if (res) {
return res;
}
if (num) {
snprintf(fn, sizeof(fn), "digits/millions");
} else {
snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
}
}
t = 1;
} else if (num < INT_MAX) {
int billions = num / 1000000000;
num = num % 1000000000;
if (billions == 1) {
if (num) {
snprintf(fn, sizeof(fn), "digits/1F");
snprintf(fna, sizeof(fna), "digits/milliard");
} else {
snprintf(fn, sizeof(fn), "digits/1N");
snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender);
}
} else {
res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
if (res)
return res;
if (num) {
snprintf(fn, sizeof(fna), "digits/milliards");
} else {
snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender);
}
}
t = 1;
} else if (num == INT_MAX) {
snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
num = 0;
} else {
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
if (!res) {
if (!ast_streamfile(chan, fn, language)) {
Mark Spencer
committed
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else
res = ast_waitstream(chan, ints);
}
ast_stopstream(chan);
if (!res) {
if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
Mark Spencer
committed
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
} else {
res = ast_waitstream(chan, ints);
}
}
ast_stopstream(chan);
strcpy(fna, "");
}
}
}
return res;
}
int ast_say_date(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
if (!strcasecmp(lang, "en") ) { /* English syntax */
return(ast_say_date_en(chan, t, ints, lang));
} else if (!strcasecmp(lang, "da") ) { /* Danish syntax */
return(ast_say_date_da(chan, t, ints, lang));
Mark Spencer
committed
} else if (!strcasecmp(lang, "de") ) { /* German syntax */
return(ast_say_date_de(chan, t, ints, lang));
} else if (!strcasecmp(lang, "fr") ) { /* French syntax */
return(ast_say_date_fr(chan, t, ints, lang));
} else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
return(ast_say_date_nl(chan, t, ints, lang));
} else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
return(ast_say_date_pt(chan, t, ints, lang));
} else if (!strcasecmp(lang, "gr") ) { /* Greek syntax */
return(ast_say_date_gr(chan, t, ints, lang));
Mark Spencer
committed
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
}
/* Default to English */
return(ast_say_date_en(chan, t, ints, lang));
}
/* English syntax */
int ast_say_date_en(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
ast_localtime(&t,&tm,NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
Mark Spencer
committed
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
return res;
}
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
/* Danish syntax */
int ast_say_date_da(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
ast_localtime(&t,&tm,NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL);
if (!res)
res = ast_waitstream(chan, ints);
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
/* Year */
int year = tm.tm_year + 1900;
if (year > 1999) { /* year 2000 and later */
res = ast_say_number(chan, year, ints, lang, (char *) NULL);
} else {
if (year < 1100) {
/* I'm not going to handle 1100 and prior */
/* We'll just be silent on the year, instead of bombing out. */
} else {
/* year 1100 to 1999. will anybody need this?!? */
snprintf(fn,sizeof(fn), "digits/%d", (year / 100) );
res = wait_file(chan, ints, fn, lang);
if (!res) {
res = wait_file(chan,ints, "digits/hundred", lang);
if (!res && year % 100 != 0) {
res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
}
}
}
}
}
return res;
}
Mark Spencer
committed
/* German syntax */
int ast_say_date_de(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
ast_localtime(&t,&tm,NULL);
Mark Spencer
committed
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
Mark Spencer
committed
res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL);
if (!res)
Mark Spencer
committed
res = ast_waitstream(chan, ints);
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
/* Year */
int year = tm.tm_year + 1900;
if (year > 1999) { /* year 2000 and later */
res = ast_say_number(chan, year, ints, lang, (char *) NULL);
} else {
if (year < 1100) {
/* I'm not going to handle 1100 and prior */
/* We'll just be silent on the year, instead of bombing out. */
} else {
/* year 1100 to 1999. will anybody need this?!? */
/* say 1967 as 'neunzehn hundert sieben und sechzig' */
Mark Spencer
committed
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
snprintf(fn,sizeof(fn), "digits/%d", (year / 100) );
res = wait_file(chan, ints, fn, lang);
if (!res) {
res = wait_file(chan,ints, "digits/hundred", lang);
if (!res && year % 100 != 0) {
res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL);
}
}
}
}
}
return res;
}
/* French syntax */
int ast_say_date_fr(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
ast_localtime(&t,&tm,NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
if (!res)
Mark Spencer
committed
res = ast_waitstream(chan, ints);
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
return res;
}
Mark Spencer
committed
/* Dutch syntax */
int ast_say_date_nl(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
ast_localtime(&t,&tm,NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
Mark Spencer
committed
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
return res;
}
/* Portuguese syntax */
int ast_say_date_pt(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
ast_localtime(&t,&tm,NULL);
localtime_r(&t,&tm);
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
if (!res)
res = wait_file(chan, ints, fn, lang);
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
if (!res)
res = wait_file(chan, ints, "digits/pt-de", lang);
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
if (!res)
res = wait_file(chan, ints, fn, lang);
if (!res)
res = wait_file(chan, ints, "digits/pt-de", lang);
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
Mark Spencer
committed
Mark Spencer
committed
int ast_say_date_with_format(struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
{
/* If no format is given, use default english format */
if (format == NULL)
format = "ABdY 'digits/at' IMp";
if (!strcasecmp(lang, "en") ) { /* English syntax */
return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "da") ) { /* Danish syntax */
return(ast_say_date_with_format_da(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "de") ) { /* German syntax */
return(ast_say_date_with_format_de(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "es") || !strcasecmp(lang, "mx")) { /* Spanish syntax */
return(ast_say_date_with_format_es(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "he")) { /* Hebrew syntax */
return(ast_say_date_with_format_he(chan, time, ints, lang, format, timezone));
Mark Spencer
committed
} else if (!strcasecmp(lang, "fr") ) { /* French syntax */
return(ast_say_date_with_format_fr(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "it") ) { /* Italian syntax */
return(ast_say_date_with_format_it(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
return(ast_say_date_with_format_nl(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
return(ast_say_date_with_format_pt(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "tw") || !strcasecmp(lang, "zh") ) { /* Taiwanese / Chinese syntax */
return(ast_say_date_with_format_tw(chan, time, ints, lang, format, timezone));
} else if (!strcasecmp(lang, "gr") ) { /* Greek syntax */
return(ast_say_date_with_format_gr(chan, time, ints, lang, format, timezone));
}
/* Default to English */
return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone));
}
/* English syntax */
Mark Spencer
committed
int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
{
struct tm tm;
int res=0, offset, sndoffset;
char sndfile[256], nextmsg[256];
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
/* Literal name of a sound file */
sndoffset=0;
for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)