Fri Feb 10 06:37:24 2012

Asterisk developer's documentation


say.c File Reference

Say numbers and dates (maybe words one day too). More...

#include "asterisk.h"
#include <netinet/in.h>
#include <time.h>
#include <ctype.h>
#include <math.h>
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/say.h"
#include "asterisk/lock.h"
#include "asterisk/localtime.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/test.h"

Include dependency graph for say.c:

Go to the source code of this file.

Data Structures

struct  odmiana

Defines

#define IL_DATE_STR   "AdBY"
#define IL_DATE_STR_FULL   IL_DATE_STR " 'digits/at' " IL_TIME_STR
#define IL_TIME_STR   "HM"
#define SAY_NUM_BUF_SIZE   256

Functions

static void __say_init (void)
 remap the 'say' functions to use those in this file
int ast_say_counted_adjective (struct ast_channel *chan, int num, const char adjective[], const char gender[])
int ast_say_counted_noun (struct ast_channel *chan, int num, const char noun[])
static int ast_say_date_da (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Danish syntax.
static int ast_say_date_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 German syntax.
static int ast_say_date_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 English syntax.
static int ast_say_date_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 French syntax.
static int ast_say_date_gr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Greek support.
static int ast_say_date_he (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Hebrew syntax.
static int ast_say_date_hu (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Hungarian syntax.
static int ast_say_date_ka (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Georgian syntax. e.g. "oriatas xuti tslis 5 noemberi".
static int ast_say_date_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Dutch syntax.
static int ast_say_date_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Portuguese syntax.
static int ast_say_date_th (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Thai syntax.
static int ast_say_date_with_format_da (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Danish syntax.
static int ast_say_date_with_format_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 German syntax.
static int ast_say_date_with_format_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 English syntax.
static int ast_say_date_with_format_es (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Spanish syntax.
static int ast_say_date_with_format_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 French syntax oclock = heure.
static int ast_say_date_with_format_gr (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Greek support.
static int ast_say_date_with_format_he (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 ast_say_date_with_format_he Say formatted date in Hebrew
static int ast_say_date_with_format_it (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Italian syntax.
static int ast_say_date_with_format_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Dutch syntax.
static int ast_say_date_with_format_pl (struct ast_channel *chan, time_t thetime, const char *ints, const char *lang, const char *format, const char *tzone)
 Polish syntax.
static int ast_say_date_with_format_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Portuguese syntax.
static int ast_say_date_with_format_th (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Thai syntax.
static int ast_say_date_with_format_vi (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Vietnamese syntax.
static int ast_say_date_with_format_zh (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
 Taiwanese / Chinese syntax.
static int ast_say_datetime_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 German syntax.
static int ast_say_datetime_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 English syntax.
static int ast_say_datetime_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 French syntax.
static int ast_say_datetime_from_now_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 English syntax.
static int ast_say_datetime_from_now_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 French syntax.
static int ast_say_datetime_from_now_he (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Hebrew syntax.
static int ast_say_datetime_from_now_ka (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Georgian syntax.
static int ast_say_datetime_from_now_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Portuguese syntax.
static int ast_say_datetime_gr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Greek support.
static int ast_say_datetime_he (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Hebrew syntax.
static int ast_say_datetime_hu (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Hungarian syntax.
static int ast_say_datetime_ka (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Georgian syntax. Say date, then say time.
static int ast_say_datetime_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Dutch syntax.
static int ast_say_datetime_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Portuguese syntax.
static int ast_say_datetime_pt_BR (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Brazilian Portuguese syntax.
static int ast_say_datetime_th (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Thai syntax.
static int ast_say_datetime_zh (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Taiwanese / Chinese syntax.
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)
 ast_say_enumeration_full_da: Danish syntax
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)
 ast_say_enumeration_full_de: German syntax
static int ast_say_enumeration_full_en (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_enumeration_full_en: English syntax
static int ast_say_enumeration_full_he (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
static int ast_say_enumeration_full_vi (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
static int ast_say_number_full_cs (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full_cs: Czech syntax
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)
 ast_say_number_full_da: Danish syntax New files:
  • In addition to English, the following sounds are required: "1N", "millions", "and" and "1-and" through "9-and"

static int ast_say_number_full_de (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full_de: German syntax
static int ast_say_number_full_en (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_en: English syntax
static int ast_say_number_full_en_GB (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_en_GB: British syntax New files:
  • In addition to American English, the following sounds are required: "and"

static int ast_say_number_full_es (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full_es: Spanish syntax
static int ast_say_number_full_fr (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full_fr: French syntax Extra sounds needed: 1F: feminin 'une' et: 'and'
static int ast_say_number_full_gr (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 Greek support A list of the files that you need to create -> digits/xilia = "xilia" -> digits/myrio = "ekatomyrio" -> digits/thousands = "xiliades" -> digits/millions = "ektatomyria" -> digits/[1..12] :: A pronunciation of th digits form 1 to 12 e.g. "tria" -> digits/[10..100] :: A pronunciation of the tens from 10 to 90 e.g. 80 = "ogdonta" Here we must note that we use digits/tens/100 to utter "ekato" and digits/hundred-100 to utter "ekaton" -> digits/hundred-[100...1000] :: A pronunciation of hundreds from 100 to 1000 e.g 400 = "terakosia". Here again we use hundreds/1000 for "xilia" and digits/thousnds for "xiliades".
static int ast_say_number_full_he (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
static int ast_say_number_full_hu (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_hu: Hungarian syntax
static int ast_say_number_full_it (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_it: Italian
static int ast_say_number_full_ka (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full_ka: Georgian syntax
static int ast_say_number_full_nl (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_nl: dutch syntax New files: digits/nl-en
static int ast_say_number_full_no (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full_no: Norwegian syntax New files: In addition to American English, the following sounds are required: "and", "1N"
static int ast_say_number_full_pl (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
static int ast_say_number_full_pt (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
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)
 ast_say_number_full_ru: Russian syntax
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)
 ast_say_number_full_se: Swedish syntax
static int ast_say_number_full_th (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 Thai syntax.
static int ast_say_number_full_ur (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
static int ast_say_number_full_vi (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_vi: Vietnamese syntax
static int ast_say_number_full_zh (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_zh: Taiwanese / Chinese syntax
static int ast_say_time_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 German syntax.
static int ast_say_time_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 English syntax.
static int ast_say_time_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 French syntax.
static int ast_say_time_gr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Greek support.
static int ast_say_time_he (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Hebrew syntax.
static int ast_say_time_hu (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Hungarian syntax.
static int ast_say_time_ka (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Georgian syntax. e.g. "otxi saati da eqvsi tsuti".
static int ast_say_time_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Dutch syntax.
static int ast_say_time_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Portuguese syntax.
static int ast_say_time_pt_BR (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Brazilian Portuguese syntax.
static int ast_say_time_th (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Thai syntax.
static int ast_say_time_zh (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 Taiwanese / Chinese syntax.
static char * ast_translate_number_ka (int num, char *res, int res_len)
 Georgian support.
static const char * counted_adjective_ending_ru (int num, const char gender[])
 In slavic languages such as Russian and Ukrainian the rules for declining adjectives are simpler than those for nouns. When counting we use only the singular (to which we give no suffix) and the genative plural (which we represent by adding an "x"). Oh, an in the singular gender matters so we append the supplied gender suffix ("m", "f", "n").
static const char * counted_noun_ending_en (int num)
 In English, we use the plural for everything but one. For example:
  • 1 degree
  • 2 degrees
  • 5 degrees The filename for the plural form is generated by appending "s". Note that purpose is to generate a unique filename, not to implement irregular declensions. Thus:
  • 1 man
  • 2 mans (the "mans" soundfile will of course say "men").

static const char * counted_noun_ending_slavic (int num)
 Counting of objects in slavic languages such as Russian and Ukrainian the rules are more complicated. There are two plural forms used in counting. They are the genative singular which we represent with the suffix "x1" and the genative plural which we represent with the suffix "x2". The base names of the soundfiles remain in English. For example:
  • 1 degree (soudfile says "gradus")
  • 2 degreex1 (soundfile says "gradusa")
  • 5 degreex2 (soundfile says "gradusov").

static int exp10_int (int power)
static int get_lastdigits_ru (int num)
 determine last digits for thousands/millions (ru)
static int gr_say_number_female (int num, struct ast_channel *chan, const char *ints, const char *lang)
 Greek digits/female-[1..4] : "Mia, dyo , treis, tessereis".
static char next_item (const char *format)
static char * pl_append (char *buffer, char *str)
static void pl_odtworz_plik (struct ast_channel *chan, const char *language, int audiofd, int ctrlfd, const char *ints, char *fn)
static char * pl_rzad_na_tekst (odmiana *odm, int i, int rzad)
static void powiedz (struct ast_channel *chan, const char *language, int audiofd, int ctrlfd, const char *ints, odmiana *odm, int rzad, int i)
static int say_character_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
static int say_date (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int say_date_with_format (struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone)
static int say_datetime (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int say_datetime_from_now (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int say_digit_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
static int say_enumeration_full (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_enumeration_full: call language-specific functions
static int say_number_full (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full: call language-specific functions
static int say_phonetic_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
static int say_time (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int wait_file (struct ast_channel *chan, const char *ints, const char *file, const char *lang)


Detailed Description

Say numbers and dates (maybe words one day too).

Author:
Mark Spencer <markster@digium.com>
Note:
12-16-2004 : Support for Greek added by InAccess Networks (work funded by HOL, www.hol.gr) George Konstantoulakis <gkon@inaccessnetworks.com>

2007-02-08 : Support for Georgian added by Alexander Shaduri <ashaduri@gmail.com>, Next Generation Networks (NGN).

2007-03-20 : Support for Thai added by Dome C. <dome@tel.co.th>, IP Crossing Co., Ltd.

Definition in file say.c.


Define Documentation

#define IL_DATE_STR   "AdBY"

#define IL_DATE_STR_FULL   IL_DATE_STR " 'digits/at' " IL_TIME_STR

#define IL_TIME_STR   "HM"

#define SAY_NUM_BUF_SIZE   256

Definition at line 1228 of file say.c.

Referenced by ast_say_number_full_he().


Function Documentation

static void __say_init ( void   )  [static]

int ast_say_counted_adjective ( struct ast_channel chan,
int  num,
const char  adjective[],
const char  gender[] 
)

Definition at line 8336 of file say.c.

References ast_channel_language(), ast_play_and_wait(), and counted_adjective_ending_ru().

08337 {
08338    char *temp;
08339    int temp_len;
08340    const char *ending;
08341    if (!strncasecmp(ast_channel_language(chan), "ru", 2)) {           /* Russian */
08342       ending = counted_adjective_ending_ru(num, gender);
08343    } else if (!strncasecmp(ast_channel_language(chan), "ua", 2)) {    /* Ukrainian */
08344       ending = counted_adjective_ending_ru(num, gender);
08345    } else if (!strncasecmp(ast_channel_language(chan), "pl", 2)) {    /* Polish */
08346       ending = counted_adjective_ending_ru(num, gender);
08347    } else {                                               /* English and default */
08348       ending = "";
08349    }
08350    temp = alloca((temp_len = (strlen(adjective) + strlen(ending) + 1)));
08351    snprintf(temp, temp_len, "%s%s", adjective, ending);
08352    return ast_play_and_wait(chan, temp);
08353 }

int ast_say_counted_noun ( struct ast_channel chan,
int  num,
const char  noun[] 
)

Definition at line 8294 of file say.c.

References ast_channel_language(), ast_play_and_wait(), counted_noun_ending_en(), and counted_noun_ending_slavic().

08295 {
08296    char *temp;
08297    int temp_len;
08298    const char *ending;
08299    if (!strncasecmp(ast_channel_language(chan), "ru", 2)) {        /* Russian */
08300       ending = counted_noun_ending_slavic(num);
08301    } else if (!strncasecmp(ast_channel_language(chan), "ua", 2)) { /* Ukrainian */
08302       ending = counted_noun_ending_slavic(num);
08303    } else if (!strncasecmp(ast_channel_language(chan), "pl", 2)) { /* Polish */
08304       ending = counted_noun_ending_slavic(num);
08305    } else {                                            /* English and default */
08306       ending = counted_noun_ending_en(num);
08307    }
08308    temp = alloca((temp_len = (strlen(noun) + strlen(ending) + 1)));
08309    snprintf(temp, temp_len, "%s%s", noun, ending);
08310    return ast_play_and_wait(chan, temp);
08311 }

int ast_say_date_da ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Danish syntax.

Definition at line 3354 of file say.c.

References ast_localtime(), ast_say_enumeration(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date().

03355 {
03356    struct timeval when = { t, 0 };
03357    struct ast_tm tm;
03358    char fn[256];
03359    int res = 0;
03360    ast_localtime(&when, &tm, NULL);
03361    if (!res) {
03362       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03363       res = ast_streamfile(chan, fn, lang);
03364       if (!res)
03365          res = ast_waitstream(chan, ints);
03366    }
03367    if (!res)
03368       res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL);
03369    if (!res)
03370       res = ast_waitstream(chan, ints);
03371    if (!res) {
03372       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03373       res = ast_streamfile(chan, fn, lang);
03374       if (!res)
03375          res = ast_waitstream(chan, ints);
03376    }
03377    if (!res) {
03378       /* Year */
03379       int year = tm.tm_year + 1900;
03380       if (year > 1999) {   /* year 2000 and later */
03381          res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
03382       } else {
03383          if (year < 1100) {
03384             /* I'm not going to handle 1100 and prior */
03385             /* We'll just be silent on the year, instead of bombing out. */
03386          } else {
03387              /* year 1100 to 1999. will anybody need this?!? */
03388             snprintf(fn, sizeof(fn), "digits/%d", (year / 100));
03389             res = wait_file(chan, ints, fn, lang);
03390             if (!res) {
03391                res = wait_file(chan, ints, "digits/hundred", lang);
03392                if (!res && year % 100 != 0) {
03393                   res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
03394                }
03395             }
03396          }
03397       }
03398    }
03399    return res;
03400 }

int ast_say_date_de ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

German syntax.

Definition at line 3403 of file say.c.

References ast_localtime(), ast_say_enumeration(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date().

03404 {
03405    struct timeval when = { t, 0 };
03406    struct ast_tm tm;
03407    char fn[256];
03408    int res = 0;
03409    ast_localtime(&when, &tm, NULL);
03410    if (!res) {
03411       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03412       res = ast_streamfile(chan, fn, lang);
03413       if (!res)
03414          res = ast_waitstream(chan, ints);
03415    }
03416    if (!res)
03417       res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL);
03418    if (!res)
03419       res = ast_waitstream(chan, ints);
03420    if (!res) {
03421       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03422       res = ast_streamfile(chan, fn, lang);
03423       if (!res)
03424          res = ast_waitstream(chan, ints);
03425    }
03426    if (!res) {
03427       /* Year */
03428       int year = tm.tm_year + 1900;
03429       if (year > 1999) {   /* year 2000 and later */
03430          res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
03431       } else {
03432          if (year < 1100) {
03433             /* I'm not going to handle 1100 and prior */
03434             /* We'll just be silent on the year, instead of bombing out. */
03435          } else {
03436              /* year 1100 to 1999. will anybody need this?!? */
03437              /* say 1967 as 'neunzehn hundert sieben und sechzig' */
03438             snprintf(fn, sizeof(fn), "digits/%d", (year / 100) );
03439             res = wait_file(chan, ints, fn, lang);
03440             if (!res) {
03441                res = wait_file(chan, ints, "digits/hundred", lang);
03442                if (!res && year % 100 != 0) {
03443                   res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
03444                }
03445             }
03446          }
03447       }
03448    }
03449    return res;
03450 }

int ast_say_date_en ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

English syntax.

Definition at line 3325 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

03326 {
03327    struct ast_tm tm;
03328    struct timeval when = { t, 0 };
03329    char fn[256];
03330    int res = 0;
03331    ast_localtime(&when, &tm, NULL);
03332    if (!res) {
03333       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03334       res = ast_streamfile(chan, fn, lang);
03335       if (!res)
03336          res = ast_waitstream(chan, ints);
03337    }
03338    if (!res) {
03339       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03340       res = ast_streamfile(chan, fn, lang);
03341       if (!res)
03342          res = ast_waitstream(chan, ints);
03343    }
03344    if (!res)
03345       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
03346    if (!res)
03347       res = ast_waitstream(chan, ints);
03348    if (!res)
03349       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03350    return res;
03351 }

int ast_say_date_fr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

French syntax.

Definition at line 3485 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

03486 {
03487    struct timeval when = { t, 0 };
03488    struct ast_tm tm;
03489    char fn[256];
03490    int res = 0;
03491    ast_localtime(&when, &tm, NULL);
03492    if (!res) {
03493       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03494       res = ast_streamfile(chan, fn, lang);
03495       if (!res)
03496          res = ast_waitstream(chan, ints);
03497    }
03498    if (!res)
03499       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
03500    if (!res)
03501       res = ast_waitstream(chan, ints);
03502    if (!res) {
03503       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03504       res = ast_streamfile(chan, fn, lang);
03505       if (!res)
03506          res = ast_waitstream(chan, ints);
03507    }
03508    if (!res)
03509       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03510    return res;
03511 }

static int ast_say_date_gr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Greek support.

The format is weekday - day - month -year

A list of the files that you need to create digits/day-[1..7] : "Deytera .. Paraskeyh" digits/months/1..12 : "Ianouariou .. Dekembriou" Attention the months are in "gekinh klhsh"

Definition at line 7367 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), gr_say_number_female(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

07368 {
07369    struct ast_tm tm;
07370    struct timeval when = { t, 0 };
07371    
07372    char fn[256];
07373    int res = 0;
07374    
07375 
07376    ast_localtime(&when, &tm, NULL);
07377    /* W E E K - D A Y */
07378    if (!res) {
07379       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
07380       res = ast_streamfile(chan, fn, lang);
07381       if (!res)
07382          res = ast_waitstream(chan, ints);
07383    }
07384    /* D A Y */
07385    if (!res) {
07386       gr_say_number_female(tm.tm_mday, chan, ints, lang);
07387    }
07388    /* M O N T H */
07389    if (!res) {
07390       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
07391       res = ast_streamfile(chan, fn, lang);
07392       if (!res)
07393          res = ast_waitstream(chan, ints);
07394    }
07395    /* Y E A R */
07396    if (!res)
07397       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
07398    return res; 
07399 }

int ast_say_date_he ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Hebrew syntax.

Definition at line 3606 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

03607 {
03608    struct timeval when = { t, 0 };
03609    struct ast_tm tm;
03610    char fn[256];
03611    int res = 0;
03612    ast_localtime(&when, &tm, NULL);
03613    if (!res) {
03614       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03615       res = ast_streamfile(chan, fn, lang);
03616       if (!res) {
03617          res = ast_waitstream(chan, ints);
03618       }
03619    }
03620    if (!res) {
03621       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03622       res = ast_streamfile(chan, fn, lang);
03623       if (!res) {
03624          res = ast_waitstream(chan, ints);
03625       }
03626    }
03627    if (!res) {
03628       res = ast_say_number(chan, tm.tm_mday, ints, lang, "m");
03629    }
03630    if (!res) {
03631       res = ast_waitstream(chan, ints);
03632    }
03633    if (!res) {
03634       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, "m");
03635    }
03636    return res;
03637 }

int ast_say_date_hu ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Hungarian syntax.

Definition at line 3453 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

03454 {
03455    struct timeval when = { t, 0 };
03456    struct ast_tm tm;
03457    char fn[256];
03458    int res = 0;
03459    ast_localtime(&when, &tm, NULL);
03460 
03461    if (!res)
03462       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03463    if (!res)
03464       res = ast_waitstream(chan, ints);
03465    if (!res) {
03466       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03467       res = ast_streamfile(chan, fn, lang);
03468       if (!res)
03469          res = ast_waitstream(chan, ints);
03470    }  
03471    if (!res)
03472       ast_say_number(chan, tm.tm_mday , ints, lang, (char *) NULL);
03473    if (!res)
03474       res = ast_waitstream(chan, ints);
03475    if (!res) {
03476       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03477       res = ast_streamfile(chan, fn, lang);
03478       if (!res)
03479          res = ast_waitstream(chan, ints);      
03480    }
03481    return res;
03482 }

static int ast_say_date_ka ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Georgian syntax. e.g. "oriatas xuti tslis 5 noemberi".

Georgian support for date/time requires the following files (*.gsm):

  • mon-1, mon-2, ... (ianvari, tebervali, ...)
  • day-1, day-2, ... (orshabati, samshabati, ...)
  • saati_da
  • tsuti
  • tslis

Definition at line 8117 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

08118 {
08119    struct timeval when = { t, 0 };
08120    struct ast_tm tm;
08121    char fn[256];
08122    int res = 0;
08123    ast_localtime(&when, &tm, NULL);
08124 
08125    if (!res)
08126       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
08127 
08128    if (!res) {
08129       snprintf(fn, sizeof(fn), "digits/tslis %d", tm.tm_wday);
08130       res = ast_streamfile(chan, fn, lang);
08131       if (!res)
08132          res = ast_waitstream(chan, ints);
08133    }
08134 
08135    if (!res) {
08136       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
08137 /*       if (!res)
08138          res = ast_waitstream(chan, ints);
08139 */
08140    }
08141 
08142    if (!res) {
08143       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
08144       res = ast_streamfile(chan, fn, lang);
08145       if (!res)
08146          res = ast_waitstream(chan, ints);
08147    }
08148    return res;
08149 
08150 }

int ast_say_date_nl ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Dutch syntax.

Definition at line 3514 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

03515 {
03516    struct timeval when = { t, 0 };
03517    struct ast_tm tm;
03518    char fn[256];
03519    int res = 0;
03520    ast_localtime(&when, &tm, NULL);
03521    if (!res) {
03522       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03523       res = ast_streamfile(chan, fn, lang);
03524       if (!res)
03525          res = ast_waitstream(chan, ints);
03526    }
03527    if (!res)
03528       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
03529    if (!res) {
03530       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03531       res = ast_streamfile(chan, fn, lang);
03532       if (!res)
03533          res = ast_waitstream(chan, ints);
03534    }
03535    if (!res)
03536       res = ast_waitstream(chan, ints);
03537    if (!res)
03538       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03539    return res;
03540 }

int ast_say_date_pt ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Portuguese syntax.

Definition at line 3579 of file say.c.

References ast_localtime(), ast_say_number(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date().

03580 {
03581    struct timeval when = { t, 0 };
03582    struct ast_tm tm;
03583    char fn[256];
03584    int res = 0;
03585 
03586    ast_localtime(&when, &tm, NULL);
03587    snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03588    if (!res)
03589       res = wait_file(chan, ints, fn, lang);
03590    if (!res)
03591       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
03592    if (!res)
03593       res = wait_file(chan, ints, "digits/pt-de", lang);
03594    snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03595    if (!res)
03596       res = wait_file(chan, ints, fn, lang);
03597    if (!res)
03598       res = wait_file(chan, ints, "digits/pt-de", lang);
03599    if (!res)
03600       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03601 
03602    return res;
03603 }

int ast_say_date_th ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Thai syntax.

Definition at line 3543 of file say.c.

References ast_copy_string(), ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_date().

03544 {
03545    struct timeval when = { t, 0 };
03546    struct ast_tm tm;
03547    char fn[256];
03548    int res = 0;
03549    ast_localtime(&when, &tm, NULL);
03550    if (!res) {
03551       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
03552       res = ast_streamfile(chan, fn, lang);
03553       ast_copy_string(fn, "digits/tee", sizeof(fn));
03554       res = ast_streamfile(chan, fn, lang);
03555       if (!res)
03556          res = ast_waitstream(chan, ints);
03557    }
03558    if (!res)
03559       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
03560    if (!res)
03561       res = ast_waitstream(chan, ints);
03562    if (!res) {
03563       ast_copy_string(fn, "digits/duan", sizeof(fn));
03564       res = ast_streamfile(chan, fn, lang);
03565       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
03566       res = ast_streamfile(chan, fn, lang);
03567       if (!res)
03568          res = ast_waitstream(chan, ints);
03569    }
03570    if (!res){
03571       ast_copy_string(fn, "digits/posor", sizeof(fn));
03572       res = ast_streamfile(chan, fn, lang);
03573       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03574    }  
03575    return res;
03576 }

int ast_say_date_with_format_da ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Danish syntax.

Definition at line 3935 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_enumeration(), ast_say_number(), ast_tvnow(), LOG_WARNING, next_item(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

03936 {
03937    struct timeval when = { t, 0 };
03938    struct ast_tm tm;
03939    int res=0, offset, sndoffset;
03940    char sndfile[256], nextmsg[256];
03941 
03942    if (!format)
03943       format = "A dBY HMS";
03944 
03945    ast_localtime(&when, &tm, tzone);
03946 
03947    for (offset=0 ; format[offset] != '\0' ; offset++) {
03948       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
03949       switch (format[offset]) {
03950          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
03951          case '\'':
03952             /* Literal name of a sound file */
03953             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
03954                sndfile[sndoffset] = format[offset];
03955             }
03956             sndfile[sndoffset] = '\0';
03957             res = wait_file(chan, ints, sndfile, lang);
03958             break;
03959          case 'A':
03960          case 'a':
03961             /* Sunday - Saturday */
03962             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
03963             res = wait_file(chan, ints, nextmsg, lang);
03964             break;
03965          case 'B':
03966          case 'b':
03967          case 'h':
03968             /* January - December */
03969             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
03970             res = wait_file(chan, ints, nextmsg, lang);
03971             break;
03972          case 'm':
03973             /* Month enumerated */
03974             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");   
03975             break;
03976          case 'd':
03977          case 'e':
03978             /* First - Thirtyfirst */
03979             res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");  
03980             break;
03981          case 'Y':
03982             /* Year */
03983             {
03984                int year = tm.tm_year + 1900;
03985                if (year > 1999) {   /* year 2000 and later */
03986                   res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
03987                } else {
03988                   if (year < 1100) {
03989                      /* I'm not going to handle 1100 and prior */
03990                      /* We'll just be silent on the year, instead of bombing out. */
03991                   } else {
03992                       /* year 1100 to 1999. will anybody need this?!? */
03993                       /* say 1967 as 'nineteen hundred seven and sixty' */
03994                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", (year / 100) );
03995                      res = wait_file(chan, ints, nextmsg, lang);
03996                      if (!res) {
03997                         res = wait_file(chan, ints, "digits/hundred", lang);
03998                         if (!res && year % 100 != 0) {
03999                            res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
04000                         }
04001                      }
04002                   }
04003                }
04004             }
04005             break;
04006          case 'I':
04007          case 'l':
04008             /* 12-Hour */
04009             res = wait_file(chan, ints, "digits/oclock", lang);
04010             if (tm.tm_hour == 0)
04011                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
04012             else if (tm.tm_hour > 12)
04013                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
04014             else
04015                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
04016             if (!res) {
04017                res = wait_file(chan, ints, nextmsg, lang);
04018             }
04019             break;
04020          case 'H':
04021             /* 24-Hour, single digit hours preceded by "oh" (0) */
04022             if (tm.tm_hour < 10 && tm.tm_hour > 0) {
04023                res = wait_file(chan, ints, "digits/0", lang);
04024             }
04025             /* FALLTRHU */
04026          case 'k':
04027             /* 24-Hour */
04028             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
04029             break;
04030          case 'M':
04031             /* Minute */
04032             if (tm.tm_min > 0 || next_item(&format[offset + 1]) == 'S') { /* zero 'digits/0' only if seconds follow */
04033                res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
04034             }
04035             if (!res && next_item(&format[offset + 1]) == 'S') { /* minutes only if seconds follow */
04036                if (tm.tm_min == 1) {
04037                   res = wait_file(chan, ints, "digits/minute", lang);
04038                } else {
04039                   res = wait_file(chan, ints, "digits/minutes", lang);
04040                }
04041             }
04042             break;
04043          case 'P':
04044          case 'p':
04045             /* AM/PM */
04046             if (tm.tm_hour > 11)
04047                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
04048             else
04049                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
04050             res = wait_file(chan, ints, nextmsg, lang);
04051             break;
04052          case 'Q':
04053             /* Shorthand for "Today", "Yesterday", or AdBY */
04054             /* XXX As emphasized elsewhere, this should the native way in your
04055              * language to say the date, with changes in what you say, depending
04056              * upon how recent the date is. XXX */
04057             {
04058                struct timeval now = ast_tvnow();
04059                struct ast_tm tmnow;
04060                time_t beg_today;
04061 
04062                ast_localtime(&now, &tmnow, tzone);
04063                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04064                /* In any case, it saves not having to do ast_mktime() */
04065                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04066                if (beg_today < t) {
04067                   /* Today */
04068                   res = wait_file(chan, ints, "digits/today", lang);
04069                } else if (beg_today - 86400 < t) {
04070                   /* Yesterday */
04071                   res = wait_file(chan, ints, "digits/yesterday", lang);
04072                } else {
04073                   res = ast_say_date_with_format_da(chan, t, ints, lang, "AdBY", tzone);
04074                }
04075             }
04076             break;
04077          case 'q':
04078             /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */
04079             /* XXX As emphasized elsewhere, this should the native way in your
04080              * language to say the date, with changes in what you say, depending
04081              * upon how recent the date is. XXX */
04082             {
04083                struct timeval now = ast_tvnow();
04084                struct ast_tm tmnow;
04085                time_t beg_today;
04086 
04087                ast_localtime(&now, &tmnow, tzone);
04088                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04089                /* In any case, it saves not having to do ast_mktime() */
04090                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04091                if (beg_today < t) {
04092                   /* Today */
04093                } else if ((beg_today - 86400) < t) {
04094                   /* Yesterday */
04095                   res = wait_file(chan, ints, "digits/yesterday", lang);
04096                } else if (beg_today - 86400 * 6 < t) {
04097                   /* Within the last week */
04098                   res = ast_say_date_with_format_da(chan, t, ints, lang, "A", tzone);
04099                } else {
04100                   res = ast_say_date_with_format_da(chan, t, ints, lang, "AdBY", tzone);
04101                }
04102             }
04103             break;
04104          case 'R':
04105             res = ast_say_date_with_format_da(chan, t, ints, lang, "HM", tzone);
04106             break;
04107          case 'S':
04108             /* Seconds */
04109             res = wait_file(chan, ints, "digits/and", lang);
04110             if (!res) {
04111                res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");  
04112                if (!res) {
04113                   res = wait_file(chan, ints, "digits/seconds", lang);
04114                }
04115             }
04116             break;
04117          case 'T':
04118             res = ast_say_date_with_format_da(chan, t, ints, lang, "HMS", tzone);
04119             break;
04120          case ' ':
04121          case '   ':
04122             /* Just ignore spaces and tabs */
04123             break;
04124          default:
04125             /* Unknown character */
04126             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04127       }
04128       /* Jump out on DTMF */
04129       if (res) {
04130          break;
04131       }
04132    }
04133    return res;
04134 }

int ast_say_date_with_format_de ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

German syntax.

Definition at line 4137 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_enumeration(), ast_say_number(), ast_tvnow(), LOG_WARNING, next_item(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

04138 {
04139    struct timeval when = { t, 0 };
04140    struct ast_tm tm;
04141    int res=0, offset, sndoffset;
04142    char sndfile[256], nextmsg[256];
04143 
04144    if (!format)
04145       format = "A dBY HMS";
04146 
04147    ast_localtime(&when, &tm, tzone);
04148 
04149    for (offset=0 ; format[offset] != '\0' ; offset++) {
04150       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04151       switch (format[offset]) {
04152          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04153          case '\'':
04154             /* Literal name of a sound file */
04155             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
04156                sndfile[sndoffset] = format[offset];
04157             }
04158             sndfile[sndoffset] = '\0';
04159             res = wait_file(chan, ints, sndfile, lang);
04160             break;
04161          case 'A':
04162          case 'a':
04163             /* Sunday - Saturday */
04164             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04165             res = wait_file(chan, ints, nextmsg, lang);
04166             break;
04167          case 'B':
04168          case 'b':
04169          case 'h':
04170             /* January - December */
04171             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04172             res = wait_file(chan, ints, nextmsg, lang);
04173             break;
04174          case 'm':
04175             /* Month enumerated */
04176             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");   
04177             break;
04178          case 'd':
04179          case 'e':
04180             /* First - Thirtyfirst */
04181             res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");  
04182             break;
04183          case 'Y':
04184             /* Year */
04185             {
04186                int year = tm.tm_year + 1900;
04187                if (year > 1999) {   /* year 2000 and later */
04188                   res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
04189                } else {
04190                   if (year < 1100) {
04191                      /* I'm not going to handle 1100 and prior */
04192                      /* We'll just be silent on the year, instead of bombing out. */
04193                   } else {
04194                       /* year 1100 to 1999. will anybody need this?!? */
04195                       /* say 1967 as 'neunzehn hundert sieben und sechzig' */
04196                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", (year / 100) );
04197                      res = wait_file(chan, ints, nextmsg, lang);
04198                      if (!res) {
04199                         res = wait_file(chan, ints, "digits/hundred", lang);
04200                         if (!res && year % 100 != 0) {
04201                            res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
04202                         }
04203                      }
04204                   }
04205                }
04206             }
04207             break;
04208          case 'I':
04209          case 'l':
04210             /* 12-Hour */
04211             if (tm.tm_hour == 0)
04212                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
04213             else if (tm.tm_hour > 12)
04214                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
04215             else
04216                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
04217             res = wait_file(chan, ints, nextmsg, lang);
04218             if (!res) {
04219                res = wait_file(chan, ints, "digits/oclock", lang);
04220             }
04221             break;
04222          case 'H':
04223          case 'k':
04224             /* 24-Hour */
04225             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);   
04226             if (!res) {
04227                res = wait_file(chan, ints, "digits/oclock", lang);
04228             }
04229             break;
04230          case 'M':
04231             /* Minute */
04232             if (next_item(&format[offset + 1]) == 'S') { /* zero 'digits/0' only if seconds follow */
04233                res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); /* female only if we say digits/minutes */
04234             } else if (tm.tm_min > 0) {
04235                res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
04236             }
04237 
04238             if (!res && next_item(&format[offset + 1]) == 'S') { /* minutes only if seconds follow */
04239                if (tm.tm_min == 1) {
04240                   res = wait_file(chan, ints, "digits/minute", lang);
04241                } else {
04242                   res = wait_file(chan, ints, "digits/minutes", lang);
04243                }
04244             }
04245             break;
04246          case 'P':
04247          case 'p':
04248             /* AM/PM */
04249             if (tm.tm_hour > 11)
04250                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
04251             else
04252                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
04253             res = wait_file(chan, ints, nextmsg, lang);
04254             break;
04255          case 'Q':
04256             /* Shorthand for "Today", "Yesterday", or AdBY */
04257             /* XXX As emphasized elsewhere, this should the native way in your
04258              * language to say the date, with changes in what you say, depending
04259              * upon how recent the date is. XXX */
04260             {
04261                struct timeval now = ast_tvnow();
04262                struct ast_tm tmnow;
04263                time_t beg_today;
04264 
04265                ast_localtime(&now, &tmnow, tzone);
04266                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04267                /* In any case, it saves not having to do ast_mktime() */
04268                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04269                if (beg_today < t) {
04270                   /* Today */
04271                   res = wait_file(chan, ints, "digits/today", lang);
04272                } else if (beg_today - 86400 < t) {
04273                   /* Yesterday */
04274                   res = wait_file(chan, ints, "digits/yesterday", lang);
04275                } else {
04276                   res = ast_say_date_with_format_de(chan, t, ints, lang, "AdBY", tzone);
04277                }
04278             }
04279             break;
04280          case 'q':
04281             /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */
04282             /* XXX As emphasized elsewhere, this should the native way in your
04283              * language to say the date, with changes in what you say, depending
04284              * upon how recent the date is. XXX */
04285             {
04286                struct timeval now = ast_tvnow();
04287                struct ast_tm tmnow;
04288                time_t beg_today;
04289 
04290                ast_localtime(&now, &tmnow, tzone);
04291                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04292                /* In any case, it saves not having to do ast_mktime() */
04293                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04294                if (beg_today < t) {
04295                   /* Today */
04296                } else if ((beg_today - 86400) < t) {
04297                   /* Yesterday */
04298                   res = wait_file(chan, ints, "digits/yesterday", lang);
04299                } else if (beg_today - 86400 * 6 < t) {
04300                   /* Within the last week */
04301                   res = ast_say_date_with_format_de(chan, t, ints, lang, "A", tzone);
04302                } else {
04303                   res = ast_say_date_with_format_de(chan, t, ints, lang, "AdBY", tzone);
04304                }
04305             }
04306             break;
04307          case 'R':
04308             res = ast_say_date_with_format_de(chan, t, ints, lang, "HM", tzone);
04309             break;
04310          case 'S':
04311             /* Seconds */
04312             res = wait_file(chan, ints, "digits/and", lang);
04313             if (!res) {
04314                res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");  
04315                if (!res) {
04316                   res = wait_file(chan, ints, tm.tm_sec == 1 ? "digits/second" : "digits/seconds", lang);
04317                }
04318             }
04319             break;
04320          case 'T':
04321             res = ast_say_date_with_format_de(chan, t, ints, lang, "HMS", tzone);
04322             break;
04323          case ' ':
04324          case '   ':
04325             /* Just ignore spaces and tabs */
04326             break;
04327          default:
04328             /* Unknown character */
04329             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04330       }
04331       /* Jump out on DTMF */
04332       if (res) {
04333          break;
04334       }
04335    }
04336    return res;
04337 }

int ast_say_date_with_format_en ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

English syntax.

Definition at line 3688 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_enumeration(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by ast_say_date_with_format_th(), ast_say_date_with_format_vi(), and say_date_with_format().

03689 {
03690    struct timeval when = { t, 0 };
03691    struct ast_tm tm;
03692    int res=0, offset, sndoffset;
03693    char sndfile[256], nextmsg[256];
03694 
03695    if (format == NULL)
03696       format = "ABdY 'digits/at' IMp";
03697 
03698    ast_localtime(&when, &tm, tzone);
03699 
03700    for (offset=0 ; format[offset] != '\0' ; offset++) {
03701       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
03702       switch (format[offset]) {
03703          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
03704          case '\'':
03705             /* Literal name of a sound file */
03706             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
03707                sndfile[sndoffset] = format[offset];
03708             }
03709             sndfile[sndoffset] = '\0';
03710             res = wait_file(chan, ints, sndfile, lang);
03711             break;
03712          case 'A':
03713          case 'a':
03714             /* Sunday - Saturday */
03715             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
03716             res = wait_file(chan, ints, nextmsg, lang);
03717             break;
03718          case 'B':
03719          case 'b':
03720          case 'h':
03721             /* January - December */
03722             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
03723             res = wait_file(chan, ints, nextmsg, lang);
03724             break;
03725          case 'm':
03726             /* Month enumerated */
03727             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);  
03728             break;
03729          case 'd':
03730          case 'e':
03731             /* First - Thirtyfirst */
03732             res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char *) NULL); 
03733             break;
03734          case 'Y':
03735             /* Year */
03736             if (tm.tm_year > 99) {
03737                res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03738             } else if (tm.tm_year < 1) {
03739                /* I'm not going to handle 1900 and prior */
03740                /* We'll just be silent on the year, instead of bombing out. */
03741             } else {
03742                res = wait_file(chan, ints, "digits/19", lang);
03743                if (!res) {
03744                   if (tm.tm_year <= 9) {
03745                      /* 1901 - 1909 */
03746                      res = wait_file(chan, ints, "digits/oh", lang);
03747                   }
03748 
03749                   res |= ast_say_number(chan, tm.tm_year, ints, lang, (char *) NULL);
03750                }
03751             }
03752             break;
03753          case 'I':
03754          case 'l':
03755             /* 12-Hour */
03756             if (tm.tm_hour == 0)
03757                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
03758             else if (tm.tm_hour > 12)
03759                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
03760             else
03761                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
03762             res = wait_file(chan, ints, nextmsg, lang);
03763             break;
03764          case 'H':
03765          case 'k':
03766             /* 24-Hour */
03767             if (format[offset] == 'H') {
03768                /* e.g. oh-eight */
03769                if (tm.tm_hour < 10) {
03770                   res = wait_file(chan, ints, "digits/oh", lang);
03771                }
03772             } else {
03773                /* e.g. eight */
03774                if (tm.tm_hour == 0) {
03775                   res = wait_file(chan, ints, "digits/oh", lang);
03776                }
03777             }
03778             if (!res) {
03779                if (tm.tm_hour != 0) {
03780                   int remaining = tm.tm_hour;
03781                   if (tm.tm_hour > 20) {
03782                      res = wait_file(chan, ints, "digits/20", lang);
03783                      remaining -= 20;
03784                   }
03785                   if (!res) {
03786                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", remaining);
03787                      res = wait_file(chan, ints, nextmsg, lang);
03788                   }
03789                }
03790             }
03791             break;
03792          case 'M':
03793          case 'N':
03794             /* Minute */
03795             if (tm.tm_min == 0) {
03796                if (format[offset] == 'M') {
03797                   res = wait_file(chan, ints, "digits/oclock", lang);
03798                } else {
03799                   res = wait_file(chan, ints, "digits/hundred", lang);
03800                }
03801             } else if (tm.tm_min < 10) {
03802                res = wait_file(chan, ints, "digits/oh", lang);
03803                if (!res) {
03804                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_min);
03805                   res = wait_file(chan, ints, nextmsg, lang);
03806                }
03807             } else {
03808                res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
03809             }
03810             break;
03811          case 'P':
03812          case 'p':
03813             /* AM/PM */
03814             if (tm.tm_hour > 11)
03815                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
03816             else
03817                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
03818             res = wait_file(chan, ints, nextmsg, lang);
03819             break;
03820          case 'Q':
03821             /* Shorthand for "Today", "Yesterday", or ABdY */
03822             /* XXX As emphasized elsewhere, this should the native way in your
03823              * language to say the date, with changes in what you say, depending
03824              * upon how recent the date is. XXX */
03825             {
03826                struct timeval now = ast_tvnow();
03827                struct ast_tm tmnow;
03828                time_t beg_today;
03829 
03830                gettimeofday(&now, NULL);
03831                ast_localtime(&now, &tmnow, tzone);
03832                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03833                /* In any case, it saves not having to do ast_mktime() */
03834                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03835                if (beg_today < t) {
03836                   /* Today */
03837                   res = wait_file(chan, ints, "digits/today", lang);
03838                } else if (beg_today - 86400 < t) {
03839                   /* Yesterday */
03840                   res = wait_file(chan, ints, "digits/yesterday", lang);
03841                } else if (beg_today - 86400 * 6 < t) {
03842                   /* Within the last week */
03843                   res = ast_say_date_with_format_en(chan, t, ints, lang, "A", tzone);
03844                } else if (beg_today - 2628000 < t) {
03845                   /* Less than a month ago - "Sunday, October third" */
03846                   res = ast_say_date_with_format_en(chan, t, ints, lang, "ABd", tzone);
03847                } else if (beg_today - 15768000 < t) {
03848                   /* Less than 6 months ago - "August seventh" */
03849                   res = ast_say_date_with_format_en(chan, t, ints, lang, "Bd", tzone);
03850                } else {
03851                   /* More than 6 months ago - "April nineteenth two thousand three" */
03852                   res = ast_say_date_with_format_en(chan, t, ints, lang, "BdY", tzone);
03853                }
03854             }
03855             break;
03856          case 'q':
03857             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
03858             /* XXX As emphasized elsewhere, this should the native way in your
03859              * language to say the date, with changes in what you say, depending
03860              * upon how recent the date is. XXX */
03861             {
03862                struct timeval now;
03863                struct ast_tm tmnow;
03864                time_t beg_today;
03865 
03866                now = ast_tvnow();
03867                ast_localtime(&now, &tmnow, tzone);
03868                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03869                /* In any case, it saves not having to do ast_mktime() */
03870                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03871                if (beg_today < t) {
03872                   /* Today */
03873                } else if ((beg_today - 86400) < t) {
03874                   /* Yesterday */
03875                   res = wait_file(chan, ints, "digits/yesterday", lang);
03876                } else if (beg_today - 86400 * 6 < t) {
03877                   /* Within the last week */
03878                   res = ast_say_date_with_format_en(chan, t, ints, lang, "A", tzone);
03879                } else if (beg_today - 2628000 < t) {
03880                   /* Less than a month ago - "Sunday, October third" */
03881                   res = ast_say_date_with_format_en(chan, t, ints, lang, "ABd", tzone);
03882                } else if (beg_today - 15768000 < t) {
03883                   /* Less than 6 months ago - "August seventh" */
03884                   res = ast_say_date_with_format_en(chan, t, ints, lang, "Bd", tzone);
03885                } else {
03886                   /* More than 6 months ago - "April nineteenth two thousand three" */
03887                   res = ast_say_date_with_format_en(chan, t, ints, lang, "BdY", tzone);
03888                }
03889             }
03890             break;
03891          case 'R':
03892             res = ast_say_date_with_format_en(chan, t, ints, lang, "HM", tzone);
03893             break;
03894          case 'S':
03895             /* Seconds */
03896             if (tm.tm_sec == 0) {
03897                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
03898                res = wait_file(chan, ints, nextmsg, lang);
03899             } else if (tm.tm_sec < 10) {
03900                res = wait_file(chan, ints, "digits/oh", lang);
03901                if (!res) {
03902                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
03903                   res = wait_file(chan, ints, nextmsg, lang);
03904                }
03905             } else {
03906                res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL);
03907             }
03908             break;
03909          case 'T':
03910             res = ast_say_date_with_format_en(chan, t, ints, lang, "HMS", tzone);
03911             break;
03912          case ' ':
03913          case '   ':
03914             /* Just ignore spaces and tabs */
03915             break;
03916          default:
03917             /* Unknown character */
03918             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
03919       }
03920       /* Jump out on DTMF */
03921       if (res) {
03922          break;
03923       }
03924    }
03925    return res;
03926 }

int ast_say_date_with_format_es ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Spanish syntax.

Definition at line 4672 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

04673 {
04674    struct timeval when = { t, 0 };
04675    struct ast_tm tm;
04676    int res=0, offset, sndoffset;
04677    char sndfile[256], nextmsg[256];
04678 
04679    if (format == NULL)
04680       format = "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y 'digits/at' IMp";
04681 
04682    ast_localtime(&when, &tm, tzone);
04683 
04684    for (offset=0 ; format[offset] != '\0' ; offset++) {
04685       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04686       switch (format[offset]) {
04687          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04688          case '\'':
04689             /* Literal name of a sound file */
04690             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
04691                sndfile[sndoffset] = format[offset];
04692             }
04693             sndfile[sndoffset] = '\0';
04694             snprintf(nextmsg, sizeof(nextmsg), "%s", sndfile);
04695             res = wait_file(chan, ints, nextmsg, lang);
04696             break;
04697          case 'A':
04698          case 'a':
04699             /* Sunday - Saturday */
04700             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04701             res = wait_file(chan, ints, nextmsg, lang);
04702             break;
04703          case 'B':
04704          case 'b':
04705          case 'h':
04706             /* January - December */
04707             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04708             res = wait_file(chan, ints, nextmsg, lang);
04709             break;
04710          case 'm':
04711             /* First - Twelfth */
04712             snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
04713             res = wait_file(chan, ints, nextmsg, lang);
04714             break;
04715          case 'd':
04716          case 'e':
04717             /* First - Thirtyfirst */
04718             res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
04719             break;
04720          case 'Y':
04721             /* Year */
04722             res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
04723             break;
04724          case 'I':
04725          case 'l':
04726             /* 12-Hour */
04727             if (tm.tm_hour == 0)
04728                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
04729             else if (tm.tm_hour == 1 || tm.tm_hour == 13)
04730                snprintf(nextmsg,sizeof(nextmsg), "digits/1F");
04731             else if (tm.tm_hour > 12)
04732                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
04733             else
04734                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
04735             res = wait_file(chan, ints, nextmsg, lang);
04736             break;
04737          case 'H':
04738          case 'k':
04739             /* 24-Hour */
04740             res = ast_say_number(chan, tm.tm_hour, ints, lang, NULL);
04741             break;
04742          case 'M':
04743             /* Minute */
04744             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 
04745             break;
04746          case 'P':
04747          case 'p':
04748             /* AM/PM */
04749             if (tm.tm_hour > 18)
04750                res = wait_file(chan, ints, "digits/p-m", lang);
04751             else if (tm.tm_hour > 12)
04752                res = wait_file(chan, ints, "digits/afternoon", lang);
04753             else if (tm.tm_hour)
04754                res = wait_file(chan, ints, "digits/a-m", lang);
04755             break;
04756          case 'Q':
04757             /* Shorthand for "Today", "Yesterday", or ABdY */
04758             /* XXX As emphasized elsewhere, this should the native way in your
04759              * language to say the date, with changes in what you say, depending
04760              * upon how recent the date is. XXX */
04761             {
04762                struct timeval now = ast_tvnow();
04763                struct ast_tm tmnow;
04764                time_t beg_today;
04765 
04766                ast_localtime(&now, &tmnow, tzone);
04767                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04768                /* In any case, it saves not having to do ast_mktime() */
04769                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04770                if (beg_today < t) {
04771                   /* Today */
04772                   res = wait_file(chan, ints, "digits/today", lang);
04773                } else if (beg_today - 86400 < t) {
04774                   /* Yesterday */
04775                   res = wait_file(chan, ints, "digits/yesterday", lang);
04776                } else {
04777                   res = ast_say_date_with_format_es(chan, t, ints, lang, "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y", tzone);
04778                }
04779             }
04780             break;
04781          case 'q':
04782             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
04783             /* XXX As emphasized elsewhere, this should the native way in your
04784              * language to say the date, with changes in what you say, depending
04785              * upon how recent the date is. XXX */
04786             {
04787                struct timeval now = ast_tvnow();
04788                struct ast_tm tmnow;
04789                time_t beg_today;
04790 
04791                ast_localtime(&now, &tmnow, tzone);
04792                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04793                /* In any case, it saves not having to do ast_mktime() */
04794                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04795                if (beg_today < t) {
04796                   /* Today */
04797                   res = wait_file(chan, ints, "digits/today", lang);
04798                } else if ((beg_today - 86400) < t) {
04799                   /* Yesterday */
04800                   res = wait_file(chan, ints, "digits/yesterday", lang);
04801                } else if (beg_today - 86400 * 6 < t) {
04802                   /* Within the last week */
04803                   res = ast_say_date_with_format_es(chan, t, ints, lang, "A", tzone);
04804                } else {
04805                   res = ast_say_date_with_format_es(chan, t, ints, lang, "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y", tzone);
04806                }
04807             }
04808             break;
04809          case 'R':
04810             res = ast_say_date_with_format_es(chan, t, ints, lang, "H 'digits/y' M", tzone);
04811             break;
04812          case 'S':
04813             /* Seconds */
04814             if (tm.tm_sec == 0) {
04815                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
04816                res = wait_file(chan, ints, nextmsg, lang);
04817             } else if (tm.tm_sec < 10) {
04818                res = wait_file(chan, ints, "digits/oh", lang);
04819                if (!res) {
04820                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
04821                   res = wait_file(chan, ints, nextmsg, lang);
04822                }
04823             } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
04824                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
04825                res = wait_file(chan, ints, nextmsg, lang);
04826             } else {
04827                int ten, one;
04828                ten = (tm.tm_sec / 10) * 10;
04829                one = (tm.tm_sec % 10);
04830                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", ten);
04831                res = wait_file(chan, ints, nextmsg, lang);
04832                if (!res) {
04833                   /* Fifty, not fifty-zero */
04834                   if (one != 0) {
04835                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", one);
04836                      res = wait_file(chan, ints, nextmsg, lang);
04837                   }
04838                }
04839             }
04840             break;
04841          case 'T':
04842             res = ast_say_date_with_format_es(chan, t, ints, lang, "HMS", tzone);
04843             break;
04844          case ' ':
04845          case '   ':
04846             /* Just ignore spaces and tabs */
04847             break;
04848          default:
04849             /* Unknown character */
04850             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04851       }
04852       /* Jump out on DTMF */
04853       if (res) {
04854          break;
04855       }
04856    }
04857    return res;
04858 }

int ast_say_date_with_format_fr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

French syntax oclock = heure.

Definition at line 4863 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

04864 {
04865    struct timeval when = { t, 0 };
04866    struct ast_tm tm;
04867    int res=0, offset, sndoffset;
04868    char sndfile[256], nextmsg[256];
04869 
04870    if (format == NULL)
04871       format = "AdBY 'digits/at' IMp";
04872 
04873    ast_localtime(&when, &tm, tzone);
04874 
04875    for (offset=0 ; format[offset] != '\0' ; offset++) {
04876       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04877       switch (format[offset]) {
04878          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04879          case '\'':
04880             /* Literal name of a sound file */
04881             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
04882                sndfile[sndoffset] = format[offset];
04883             }
04884             sndfile[sndoffset] = '\0';
04885             res = wait_file(chan, ints, sndfile, lang);
04886             break;
04887          case 'A':
04888          case 'a':
04889             /* Sunday - Saturday */
04890             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04891             res = wait_file(chan, ints, nextmsg, lang);
04892             break;
04893          case 'B':
04894          case 'b':
04895          case 'h':
04896             /* January - December */
04897             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04898             res = wait_file(chan, ints, nextmsg, lang);
04899             break;
04900          case 'm':
04901             /* First - Twelfth */
04902             snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
04903             res = wait_file(chan, ints, nextmsg, lang);
04904             break;
04905          case 'd':
04906          case 'e':
04907             /* First */
04908             if (tm.tm_mday == 1) {
04909                snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
04910                res = wait_file(chan, ints, nextmsg, lang);
04911             } else {
04912                res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
04913             }
04914             break;
04915          case 'Y':
04916             /* Year */
04917             if (tm.tm_year > 99) {
04918                res = wait_file(chan, ints, "digits/2", lang);
04919                if (!res) {
04920                   res = wait_file(chan, ints, "digits/thousand", lang);
04921                }
04922                if (tm.tm_year > 100) {
04923                   if (!res) {
04924                      res = ast_say_number(chan, tm.tm_year - 100, ints, lang, (char * ) NULL);
04925                   }
04926                }
04927             } else {
04928                if (tm.tm_year < 1) {
04929                   /* I'm not going to handle 1900 and prior */
04930                   /* We'll just be silent on the year, instead of bombing out. */
04931                } else {
04932                   res = wait_file(chan, ints, "digits/thousand", lang);
04933                   if (!res) {
04934                      wait_file(chan, ints, "digits/9", lang);
04935                      wait_file(chan, ints, "digits/hundred", lang);
04936                      res = ast_say_number(chan, tm.tm_year, ints, lang, (char * ) NULL);
04937                   }
04938                }
04939             }
04940             break;
04941          case 'I':
04942          case 'l':
04943             /* 12-Hour */
04944             if (tm.tm_hour == 0)
04945                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
04946             else if (tm.tm_hour > 12)
04947                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
04948             else
04949                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
04950             res = wait_file(chan, ints, nextmsg, lang);
04951             if (!res)
04952                res = wait_file(chan, ints, "digits/oclock", lang);
04953             break;
04954          case 'H':
04955          case 'k':
04956             /* 24-Hour */
04957             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char * ) NULL);
04958             if (!res)
04959                res = wait_file(chan, ints, "digits/oclock", lang);
04960             break;
04961          case 'M':
04962             /* Minute */
04963             if (tm.tm_min == 0) {
04964                break;
04965             }
04966             res = ast_say_number(chan, tm.tm_min, ints, lang, (char * ) NULL);
04967             break;
04968          case 'P':
04969          case 'p':
04970             /* AM/PM */
04971             if (tm.tm_hour > 11)
04972                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
04973             else
04974                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
04975             res = wait_file(chan, ints, nextmsg, lang);
04976             break;
04977          case 'Q':
04978             /* Shorthand for "Today", "Yesterday", or AdBY */
04979             /* XXX As emphasized elsewhere, this should the native way in your
04980              * language to say the date, with changes in what you say, depending
04981              * upon how recent the date is. XXX */
04982             {
04983                struct timeval now = ast_tvnow();
04984                struct ast_tm tmnow;
04985                time_t beg_today;
04986 
04987                ast_localtime(&now, &tmnow, tzone);
04988                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04989                /* In any case, it saves not having to do ast_mktime() */
04990                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04991                if (beg_today < t) {
04992                   /* Today */
04993                   res = wait_file(chan, ints, "digits/today", lang);
04994                } else if (beg_today - 86400 < t) {
04995                   /* Yesterday */
04996                   res = wait_file(chan, ints, "digits/yesterday", lang);
04997                } else {
04998                   res = ast_say_date_with_format_fr(chan, t, ints, lang, "AdBY", tzone);
04999                }
05000             }
05001             break;
05002          case 'q':
05003             /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */
05004             /* XXX As emphasized elsewhere, this should the native way in your
05005              * language to say the date, with changes in what you say, depending
05006              * upon how recent the date is. XXX */
05007             {
05008                struct timeval now = ast_tvnow();
05009                struct ast_tm tmnow;
05010                time_t beg_today;
05011 
05012                ast_localtime(&now, &tmnow, tzone);
05013                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05014                /* In any case, it saves not having to do ast_mktime() */
05015                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05016                if (beg_today < t) {
05017                   /* Today */
05018                } else if ((beg_today - 86400) < t) {
05019                   /* Yesterday */
05020                   res = wait_file(chan, ints, "digits/yesterday", lang);
05021                } else if (beg_today - 86400 * 6 < t) {
05022                   /* Within the last week */
05023                   res = ast_say_date_with_format_fr(chan, t, ints, lang, "A", tzone);
05024                } else {
05025                   res = ast_say_date_with_format_fr(chan, t, ints, lang, "AdBY", tzone);
05026                }
05027             }
05028             break;
05029          case 'R':
05030             res = ast_say_date_with_format_fr(chan, t, ints, lang, "HM", tzone);
05031             break;
05032          case 'S':
05033             /* Seconds */
05034             res = ast_say_number(chan, tm.tm_sec, ints, lang, (char * ) NULL);
05035             if (!res) {
05036                res = wait_file(chan, ints, "digits/second", lang);
05037             }
05038             break;
05039          case 'T':
05040             res = ast_say_date_with_format_fr(chan, t, ints, lang, "HMS", tzone);
05041             break;
05042          case ' ':
05043          case '   ':
05044             /* Just ignore spaces and tabs */
05045             break;
05046          default:
05047             /* Unknown character */
05048             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
05049       }
05050       /* Jump out on DTMF */
05051       if (res) {
05052          break;
05053       }
05054    }
05055    return res;
05056 }

static int ast_say_date_with_format_gr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Greek support.

Definition at line 7496 of file say.c.

References ast_channel_language(), ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_number_full_gr(), ast_streamfile(), ast_tvnow(), ast_waitstream(), gr_say_number_female(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

07497 {
07498    struct timeval when = { t, 0 };
07499    struct ast_tm tm;
07500    int res=0, offset, sndoffset;
07501    char sndfile[256], nextmsg[256];
07502 
07503    if (!format)
07504       format = "AdBY 'digits/at' IMp";
07505 
07506    ast_localtime(&when, &tm, tzone);
07507 
07508    for (offset=0 ; format[offset] != '\0' ; offset++) {
07509       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
07510       switch (format[offset]) {
07511          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
07512       case '\'':
07513          /* Literal name of a sound file */
07514          for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
07515             sndfile[sndoffset] = format[offset];
07516          }
07517          sndfile[sndoffset] = '\0';
07518          res = wait_file(chan, ints, sndfile, lang);
07519          break;
07520       case 'A':
07521       case 'a':
07522          /* Sunday - Saturday */
07523          snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
07524          res = wait_file(chan, ints, nextmsg, lang);
07525          break;
07526       case 'B':
07527       case 'b':
07528       case 'h':
07529          /* January - December */
07530          snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
07531          res = wait_file(chan, ints, nextmsg, lang);
07532          break;
07533       case 'd':
07534       case 'e':
07535          /* first - thirtyfirst */
07536          gr_say_number_female(tm.tm_mday, chan, ints, lang);
07537          break;
07538       case 'Y':
07539          /* Year */
07540          
07541          ast_say_number_full_gr(chan, 1900+tm.tm_year, ints, ast_channel_language(chan), -1, -1);
07542          break;
07543       case 'I':
07544       case 'l':
07545          /* 12-Hour */
07546          if (tm.tm_hour == 0)
07547             gr_say_number_female(12, chan, ints, lang);
07548          else if (tm.tm_hour > 12)
07549             gr_say_number_female(tm.tm_hour - 12, chan, ints, lang);
07550          else
07551             gr_say_number_female(tm.tm_hour, chan, ints, lang);
07552          break;
07553       case 'H':
07554       case 'k':
07555          /* 24-Hour */
07556          gr_say_number_female(tm.tm_hour, chan, ints, lang);
07557          break;
07558       case 'M':
07559          /* Minute */
07560          if (tm.tm_min) {
07561             if (!res)
07562                res = ast_streamfile(chan, "digits/kai", lang);
07563             if (!res)
07564                res = ast_waitstream(chan, ints);
07565             if (!res)
07566                res = ast_say_number_full_gr(chan, tm.tm_min, ints, lang, -1, -1);
07567          } else {
07568             if (!res)
07569                res = ast_streamfile(chan, "digits/oclock", lang);
07570             if (!res)
07571                res = ast_waitstream(chan, ints);
07572          }
07573          break;
07574       case 'P':
07575       case 'p':
07576          /* AM/PM */
07577          if (tm.tm_hour > 11)
07578             ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
07579          else
07580             ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
07581          res = wait_file(chan, ints, nextmsg, lang);
07582          break;
07583       case 'Q':
07584          /* Shorthand for "Today", "Yesterday", or ABdY */
07585             /* XXX As emphasized elsewhere, this should the native way in your
07586              * language to say the date, with changes in what you say, depending
07587              * upon how recent the date is. XXX */
07588          {
07589             struct timeval now = ast_tvnow();
07590             struct ast_tm tmnow;
07591             time_t beg_today;
07592             
07593             ast_localtime(&now, &tmnow, tzone);
07594             /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
07595             /* In any case, it saves not having to do ast_mktime() */
07596             beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
07597             if (beg_today < t) {
07598                /* Today */
07599                res = wait_file(chan, ints, "digits/today", lang);
07600             } else if (beg_today - 86400 < t) {
07601                /* Yesterday */
07602                res = wait_file(chan, ints, "digits/yesterday", lang);
07603             } else {
07604                res = ast_say_date_with_format_gr(chan, t, ints, lang, "AdBY", tzone);
07605             }
07606          }
07607          break;
07608       case 'q':
07609          /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
07610             /* XXX As emphasized elsewhere, this should the native way in your
07611              * language to say the date, with changes in what you say, depending
07612              * upon how recent the date is. XXX */
07613          {
07614             struct timeval now = ast_tvnow();
07615             struct ast_tm tmnow;
07616             time_t beg_today;
07617             
07618             ast_localtime(&now, &tmnow, tzone);
07619             /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
07620             /* In any case, it saves not having to do ast_mktime() */
07621             beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
07622             if (beg_today < t) {
07623                /* Today */
07624             } else if ((beg_today - 86400) < t) {
07625                /* Yesterday */
07626                res = wait_file(chan, ints, "digits/yesterday", lang);
07627             } else if (beg_today - 86400 * 6 < t) {
07628                /* Within the last week */
07629                res = ast_say_date_with_format_gr(chan, t, ints, lang, "A", tzone);
07630             } else {
07631                res = ast_say_date_with_format_gr(chan, t, ints, lang, "AdBY", tzone);
07632             }
07633          }
07634          break;
07635       case 'R':
07636          res = ast_say_date_with_format_gr(chan, t, ints, lang, "HM", tzone);
07637          break;
07638       case 'S':
07639          /* Seconds */
07640          ast_copy_string(nextmsg, "digits/kai", sizeof(nextmsg));
07641          res = wait_file(chan, ints, nextmsg, lang);
07642          if (!res)
07643             res = ast_say_number_full_gr(chan, tm.tm_sec, ints, lang, -1, -1);
07644          if (!res)
07645             ast_copy_string(nextmsg, "digits/seconds", sizeof(nextmsg));
07646          res = wait_file(chan, ints, nextmsg, lang);
07647          break;
07648       case 'T':
07649          res = ast_say_date_with_format_gr(chan, t, ints, lang, "HMS", tzone);
07650          break;
07651       case ' ':
07652       case '   ':
07653          /* Just ignore spaces and tabs */
07654          break;
07655       default:
07656          /* Unknown character */
07657          ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
07658       }
07659       /* Jump out on DTMF */
07660       if (res) {
07661          break;
07662       }
07663    }
07664    return res;
07665 }

int ast_say_date_with_format_he ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

ast_say_date_with_format_he Say formatted date in Hebrew

ast_say_date_with_format_en for the details of the options

Changes from the English version:

  • don't replicate in here the logic of ast_say_number_full_he

  • year is always 4-digit (because it's simpler)

  • added c, x, and X. Mainly for my tests

  • The standard "long" format used in Hebrew is AdBY, rather than ABdY

Todo:
  • A "ha" is missing in the standard date format, before the 'd'.
  • The numbers of 3000--19000 are not handled well

Definition at line 4525 of file say.c.

References ast_debug, ast_localtime(), ast_log(), ast_say_number_full_he(), ast_tvnow(), IL_DATE_STR, IL_DATE_STR_FULL, IL_TIME_STR, LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

04526 {
04527 #define IL_DATE_STR "AdBY"
04528 #define IL_TIME_STR "HM"      /* NOTE: In Hebrew we do not support 12 hours, only 24. No AM or PM exists in the Hebrew language */
04529 #define IL_DATE_STR_FULL IL_DATE_STR " 'digits/at' " IL_TIME_STR
04530    /* TODO: This whole function is cut&paste from 
04531     * ast_say_date_with_format_en . Is that considered acceptable?
04532     **/
04533    struct timeval when = { t, 0 };
04534    struct ast_tm tm;
04535    int res = 0, offset, sndoffset;
04536    char sndfile[256], nextmsg[256];
04537 
04538    if (!format) {
04539       format = IL_DATE_STR_FULL;
04540    }
04541 
04542    ast_localtime(&when, &tm, tzone);
04543 
04544    for (offset = 0; format[offset] != '\0'; offset++) {
04545       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04546       switch (format[offset]) {
04547          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04548          case '\'':
04549             /* Literal name of a sound file */
04550             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
04551                sndfile[sndoffset] = format[offset];
04552             }
04553             sndfile[sndoffset] = '\0';
04554             res = wait_file(chan, ints, sndfile, lang);
04555             break;
04556          case 'A':
04557          case 'a':
04558             /* Sunday - Saturday */
04559             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04560             res = wait_file(chan, ints, nextmsg, lang);
04561             break;
04562          case 'B':
04563          case 'b':
04564          case 'h':
04565             /* January - December */
04566             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04567             res = wait_file(chan, ints, nextmsg, lang);
04568             break;
04569          case 'd':
04570          case 'e': /* Day of the month */
04571             /* I'm not sure exactly what the parameters 
04572             * audiofd and ctrlfd to 
04573             * ast_say_number_full_he mean, but it seems
04574             * safe to pass -1 there. 
04575             *
04576             * At least in one of the pathes :-( 
04577             */
04578             res = ast_say_number_full_he(chan, tm.tm_mday, ints, lang, "m", -1, -1);
04579             break;
04580          case 'Y': /* Year */
04581             res = ast_say_number_full_he(chan, tm.tm_year + 1900, ints, lang, "f", -1, -1);
04582             break;
04583          case 'I':
04584          case 'l': /* 12-Hour -> we do not support 12 hour based langauges in Hebrew */
04585          case 'H':
04586          case 'k': /* 24-Hour */
04587             res = ast_say_number_full_he(chan, tm.tm_hour, ints, lang, "f", -1, -1);
04588             break;
04589          case 'M': /* Minute */
04590             if (tm.tm_min >= 0 && tm.tm_min <= 9)  /* say a leading zero if needed */
04591                res = ast_say_number_full_he(chan, 0, ints, lang, "f", -1, -1);
04592             res = ast_say_number_full_he(chan, tm.tm_min, ints, lang, "f", -1, -1);
04593             break;
04594          case 'P':
04595          case 'p':
04596             /* AM/PM - There is no AM/PM in Hebrew... */
04597             break;
04598          case 'Q':
04599             /* Shorthand for "Today", "Yesterday", or "date" */
04600          case 'q':
04601             /* Shorthand for "" (today), "Yesterday", A 
04602              * (weekday), or "date" */
04603             /* XXX As emphasized elsewhere, this should the native way in your
04604              * language to say the date, with changes in what you say, depending
04605              * upon how recent the date is. XXX */
04606             {
04607                struct timeval now = ast_tvnow();
04608                struct ast_tm tmnow;
04609                time_t beg_today;
04610                char todo = format[offset]; /* The letter to format*/
04611 
04612                ast_localtime(&now, &tmnow, tzone);
04613                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04614                /* In any case, it saves not having to do ast_mktime() */
04615                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04616                if (beg_today < t) {
04617                   /* Today */
04618                   if (todo == 'Q') {
04619                      res = wait_file(chan, ints, "digits/today", lang);
04620                   }
04621                } else if (beg_today - 86400 < t) {
04622                   /* Yesterday */
04623                   res = wait_file(chan, ints, "digits/yesterday", lang);
04624                } else if ((todo != 'Q') && (beg_today - 86400 * 6 < t)) {
04625                   /* Within the last week */
04626                   res = ast_say_date_with_format_he(chan, t, ints, lang, "A", tzone);
04627                } else {
04628                   res = ast_say_date_with_format_he(chan, t, ints, lang, IL_DATE_STR, tzone);
04629                }
04630             }
04631             break;
04632          case 'R':
04633             res = ast_say_date_with_format_he(chan, t, ints, lang, "HM", tzone);
04634             break;
04635          case 'S': /* Seconds */
04636             res = ast_say_number_full_he(chan, tm.tm_sec,
04637                ints, lang, "f", -1, -1
04638             );
04639             break;
04640          case 'T':
04641             res = ast_say_date_with_format_he(chan, t, ints, lang, "HMS", tzone);
04642             break;
04643          /* c, x, and X seem useful for testing. Not sure
04644           * if they're good for the general public */
04645          case 'c':
04646             res = ast_say_date_with_format_he(chan, t, ints, lang, IL_DATE_STR_FULL, tzone);
04647             break;
04648          case 'x':
04649             res = ast_say_date_with_format_he(chan, t, ints, lang, IL_DATE_STR, tzone);
04650             break;
04651          case 'X': /* Currently not locale-dependent...*/
04652             res = ast_say_date_with_format_he(chan, t, ints, lang, IL_TIME_STR, tzone);
04653             break;
04654          case ' ':
04655          case '   ':
04656             /* Just ignore spaces and tabs */
04657             break;
04658          default:
04659             /* Unknown character */
04660             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04661       }
04662       /* Jump out on DTMF */
04663       if (res) {
04664          break;
04665       }
04666    }
04667    return res;
04668 }

int ast_say_date_with_format_it ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Italian syntax.

Definition at line 5059 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

05060 {
05061    struct timeval when = { t, 0 };
05062    struct ast_tm tm;
05063    int res=0, offset, sndoffset;
05064    char sndfile[256], nextmsg[256];
05065 
05066    if (format == NULL)
05067       format = "AdB 'digits/at' IMp";
05068 
05069    ast_localtime(&when, &tm, tzone);
05070 
05071    for (offset=0 ; format[offset] != '\0' ; offset++) {
05072       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
05073       switch (format[offset]) {
05074          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
05075          case '\'':
05076             /* Literal name of a sound file */
05077             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
05078                sndfile[sndoffset] = format[offset];
05079             }
05080             sndfile[sndoffset] = '\0';
05081             res = wait_file(chan, ints, sndfile, lang);
05082             break;
05083          case 'A':
05084          case 'a':
05085             /* Sunday - Saturday */
05086             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
05087             res = wait_file(chan, ints, nextmsg, lang);
05088             break;
05089          case 'B':
05090          case 'b':
05091          case 'h':
05092             /* January - December */
05093             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
05094             res = wait_file(chan, ints, nextmsg, lang);
05095             break;
05096          case 'm':
05097             /* First - Twelfth */
05098             snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
05099             res = wait_file(chan, ints, nextmsg, lang);
05100             break;
05101          case 'd':
05102          case 'e':
05103             /* First day of the month is spelled as ordinal */
05104             if (tm.tm_mday == 1) {
05105                snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
05106                res = wait_file(chan, ints, nextmsg, lang);
05107             } else {
05108                if (!res) {
05109                   res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05110                }
05111             }
05112             break;
05113          case 'Y':
05114             /* Year */
05115             if (tm.tm_year > 99) {
05116                res = wait_file(chan, ints, "digits/ore-2000", lang);
05117                if (tm.tm_year > 100) {
05118                   if (!res) {
05119                   /* This works until the end of 2021 */
05120                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year - 100);
05121                   res = wait_file(chan, ints, nextmsg, lang);
05122                   }
05123                }
05124             } else {
05125                if (tm.tm_year < 1) {
05126                   /* I'm not going to handle 1900 and prior */
05127                   /* We'll just be silent on the year, instead of bombing out. */
05128                } else {
05129                   res = wait_file(chan, ints, "digits/ore-1900", lang);
05130                   if ((!res) && (tm.tm_year != 0)) {
05131                      if (tm.tm_year <= 21) {
05132                         /* 1910 - 1921 */
05133                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year);
05134                         res = wait_file(chan, ints, nextmsg, lang);
05135                      } else {
05136                         /* 1922 - 1999, but sounds badly in 1928, 1931, 1938, etc... */
05137                         int ten, one;
05138                         ten = tm.tm_year / 10;
05139                         one = tm.tm_year % 10;
05140                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", ten * 10);
05141                         res = wait_file(chan, ints, nextmsg, lang);
05142                         if (!res) {
05143                            if (one != 0) {
05144                               snprintf(nextmsg, sizeof(nextmsg), "digits/%d", one);
05145                               res = wait_file(chan, ints, nextmsg, lang);
05146                            }
05147                         }
05148                      }
05149                   }
05150                }
05151             }
05152             break;
05153          case 'I':
05154          case 'l':
05155             /* 12-Hour */
05156             if (tm.tm_hour == 0)
05157                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
05158             else if (tm.tm_hour > 12)
05159                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
05160             else
05161                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
05162                res = wait_file(chan, ints, nextmsg, lang);
05163             break;
05164          case 'H':
05165          case 'k':
05166             /* 24-Hour */
05167             if (tm.tm_hour == 0) {
05168                res = wait_file(chan, ints, "digits/ore-mezzanotte", lang);
05169             } else if (tm.tm_hour == 1) {
05170                res = wait_file(chan, ints, "digits/ore-una", lang);
05171             } else {
05172                res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
05173             }
05174             break;
05175          case 'M':
05176             /* Minute */
05177             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05178             break;
05179          case 'P':
05180          case 'p':
05181             /* AM/PM */
05182             if (tm.tm_hour > 11)
05183                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
05184             else
05185                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
05186                res = wait_file(chan, ints, nextmsg, lang);
05187             break;
05188          case 'Q':
05189             /* Shorthand for "Today", "Yesterday", or ABdY */
05190             /* XXX As emphasized elsewhere, this should the native way in your
05191              * language to say the date, with changes in what you say, depending
05192              * upon how recent the date is. XXX */
05193             {
05194                struct timeval now = ast_tvnow();
05195                struct ast_tm tmnow;
05196                time_t beg_today;
05197    
05198                ast_localtime(&now, &tmnow, tzone);
05199                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05200                /* In any case, it saves not having to do ast_mktime() */
05201                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05202                if (beg_today < t) {
05203                   /* Today */
05204                   res = wait_file(chan, ints, "digits/today", lang);
05205                } else if (beg_today - 86400 < t) {
05206                   /* Yesterday */
05207                   res = wait_file(chan, ints, "digits/yesterday", lang);
05208                } else {
05209                   res = ast_say_date_with_format_it(chan, t, ints, lang, "AdB", tzone);
05210                }
05211             }
05212             break;
05213          case 'q':
05214             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
05215             {
05216                struct timeval now = ast_tvnow();
05217                struct ast_tm tmnow;
05218                time_t beg_today;
05219    
05220                ast_localtime(&now, &tmnow, tzone);
05221                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05222                /* In any case, it saves not having to do ast_mktime() */
05223                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05224                if (beg_today < t) {
05225                   /* Today */
05226                } else if ((beg_today - 86400) < t) {
05227                   /* Yesterday */
05228                   res = wait_file(chan, ints, "digits/yesterday", lang);
05229                } else if (beg_today - 86400 * 6 < t) {
05230                   /* Within the last week */
05231                   res = ast_say_date_with_format_it(chan, t, ints, lang, "A", tzone);
05232                } else {
05233                   res = ast_say_date_with_format_it(chan, t, ints, lang, "AdB", tzone);
05234                }
05235             }
05236             break;
05237          case 'R':
05238             res = ast_say_date_with_format_it(chan, t, ints, lang, "HM", tzone);
05239             break;
05240          case 'S':
05241             /* Seconds */
05242             if (tm.tm_sec == 0) {
05243                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
05244                res = wait_file(chan, ints, nextmsg, lang);
05245             } else if (tm.tm_sec < 10) {
05246                res = wait_file(chan, ints, "digits/oh", lang);
05247                if (!res) {
05248                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
05249                   res = wait_file(chan, ints, nextmsg, lang);
05250                }
05251             } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
05252                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
05253                res = wait_file(chan, ints, nextmsg, lang);
05254             } else {
05255                int ten, one;
05256                ten = (tm.tm_sec / 10) * 10;
05257                one = (tm.tm_sec % 10);
05258                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", ten);
05259                res = wait_file(chan, ints, nextmsg, lang);
05260                if (!res) {
05261                   /* Fifty, not fifty-zero */
05262                   if (one != 0) {
05263                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", one);
05264                      res = wait_file(chan, ints, nextmsg, lang);
05265                   }
05266                }
05267             }
05268             break;
05269          case 'T':
05270             res = ast_say_date_with_format_it(chan, t, ints, lang, "HMS", tzone);
05271             break;
05272          case ' ':
05273          case '   ':
05274             /* Just ignore spaces and tabs */
05275             break;
05276          default:
05277             /* Unknown character */
05278             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
05279       }
05280       /* Jump out on DTMF */
05281       if (res) {
05282          break;
05283       }
05284    }
05285    return res;
05286 }

int ast_say_date_with_format_nl ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Dutch syntax.

Definition at line 5289 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

05290 {
05291    struct timeval when = { t, 0 };
05292    struct ast_tm tm;
05293    int res=0, offset, sndoffset;
05294    char sndfile[256], nextmsg[256];
05295 
05296    if (format == NULL)
05297       format = "ABdY 'digits/at' IMp";
05298 
05299    ast_localtime(&when, &tm, tzone);
05300 
05301    for (offset=0 ; format[offset] != '\0' ; offset++) {
05302       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
05303       switch (format[offset]) {
05304          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
05305          case '\'':
05306             /* Literal name of a sound file */
05307             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
05308                sndfile[sndoffset] = format[offset];
05309             }
05310             sndfile[sndoffset] = '\0';
05311             res = wait_file(chan, ints, sndfile, lang);
05312             break;
05313          case 'A':
05314          case 'a':
05315             /* Sunday - Saturday */
05316             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
05317             res = wait_file(chan, ints, nextmsg, lang);
05318             break;
05319          case 'B':
05320          case 'b':
05321          case 'h':
05322             /* January - December */
05323             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
05324             res = wait_file(chan, ints, nextmsg, lang);
05325             break;
05326          case 'm':
05327             /* First - Twelfth */
05328             snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
05329             res = wait_file(chan, ints, nextmsg, lang);
05330             break;
05331          case 'd':
05332          case 'e':
05333             /* First - Thirtyfirst */
05334             res = ast_say_number(chan, tm.tm_mday, ints, lang, NULL);
05335             break;
05336          case 'Y':
05337             /* Year */
05338             if (tm.tm_year > 99) {
05339                res = wait_file(chan, ints, "digits/2", lang);
05340                if (!res) {
05341                   res = wait_file(chan, ints, "digits/thousand", lang);
05342                }
05343                if (tm.tm_year > 100) {
05344                   if (!res) {
05345                      /* This works until the end of 2020 */
05346                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year - 100);
05347                      res = wait_file(chan, ints, nextmsg, lang);
05348                   }
05349                }
05350             } else {
05351                if (tm.tm_year < 1) {
05352                   /* I'm not going to handle 1900 and prior */
05353                   /* We'll just be silent on the year, instead of bombing out. */
05354                } else {
05355                   res = wait_file(chan, ints, "digits/19", lang);
05356                   if (!res) {
05357                      if (tm.tm_year <= 9) {
05358                         /* 1901 - 1909 */
05359                         res = wait_file(chan, ints, "digits/oh", lang);
05360                         if (!res) {
05361                            snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year);
05362                            res = wait_file(chan, ints, nextmsg, lang);
05363                         }
05364                      } else if (tm.tm_year <= 20) {
05365                         /* 1910 - 1920 */
05366                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year);
05367                         res = wait_file(chan, ints, nextmsg, lang);
05368                      } else {
05369                         /* 1921 - 1999 */
05370                         int ten, one;
05371                         ten = tm.tm_year / 10;
05372                         one = tm.tm_year % 10;
05373                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", ten * 10);
05374                         res = wait_file(chan, ints, nextmsg, lang);
05375                         if (!res) {
05376                            if (one != 0) {
05377                               snprintf(nextmsg, sizeof(nextmsg), "digits/%d", one);
05378                               res = wait_file(chan, ints, nextmsg, lang);
05379                            }
05380                         }
05381                      }
05382                   }
05383                }
05384             }
05385             break;
05386          case 'I':
05387          case 'l':
05388             /* 12-Hour */
05389             if (tm.tm_hour == 0)
05390                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
05391             else if (tm.tm_hour > 12)
05392                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
05393             else
05394                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
05395             res = wait_file(chan, ints, nextmsg, lang);
05396             break;
05397          case 'H':
05398          case 'k':
05399             /* 24-Hour */
05400             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
05401             if (!res) {
05402                res = wait_file(chan, ints, "digits/nl-uur", lang);
05403             }
05404             break;
05405          case 'M':
05406             /* Minute */
05407             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05408             break;
05409          case 'P':
05410          case 'p':
05411             /* AM/PM */
05412             if (tm.tm_hour > 11)
05413                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
05414             else
05415                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
05416             res = wait_file(chan, ints, nextmsg, lang);
05417             break;
05418          case 'Q':
05419             /* Shorthand for "Today", "Yesterday", or ABdY */
05420             /* XXX As emphasized elsewhere, this should the native way in your
05421              * language to say the date, with changes in what you say, depending
05422              * upon how recent the date is. XXX */
05423             {
05424                struct timeval now = ast_tvnow();
05425                struct ast_tm tmnow;
05426                time_t beg_today;
05427 
05428                ast_localtime(&now, &tmnow, tzone);
05429                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05430                /* In any case, it saves not having to do ast_mktime() */
05431                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05432                if (beg_today < t) {
05433                   /* Today */
05434                   res = wait_file(chan, ints, "digits/today", lang);
05435                } else if (beg_today - 86400 < t) {
05436                   /* Yesterday */
05437                   res = wait_file(chan, ints, "digits/yesterday", lang);
05438                } else {
05439                   res = ast_say_date_with_format_nl(chan, t, ints, lang, "ABdY", tzone);
05440                }
05441             }
05442             break;
05443          case 'q':
05444             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
05445             {
05446                struct timeval now = ast_tvnow();
05447                struct ast_tm tmnow;
05448                time_t beg_today;
05449 
05450                ast_localtime(&now, &tmnow, tzone);
05451                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05452                /* In any case, it saves not having to do ast_mktime() */
05453                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05454                if (beg_today < t) {
05455                   /* Today */
05456                } else if ((beg_today - 86400) < t) {
05457                   /* Yesterday */
05458                   res = wait_file(chan, ints, "digits/yesterday", lang);
05459                } else if (beg_today - 86400 * 6 < t) {
05460                   /* Within the last week */
05461                   res = ast_say_date_with_format_nl(chan, t, ints, lang, "A", tzone);
05462                } else {
05463                   res = ast_say_date_with_format_nl(chan, t, ints, lang, "ABdY", tzone);
05464                }
05465             }
05466             break;
05467          case 'R':
05468             res = ast_say_date_with_format_nl(chan, t, ints, lang, "HM", tzone);
05469             break;
05470          case 'S':
05471             /* Seconds */
05472             res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL);
05473             break;
05474          case 'T':
05475             res = ast_say_date_with_format_nl(chan, t, ints, lang, "HMS", tzone);
05476             break;
05477          case ' ':
05478          case '   ':
05479             /* Just ignore spaces and tabs */
05480             break;
05481          default:
05482             /* Unknown character */
05483             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
05484       }
05485       /* Jump out on DTMF */
05486       if (res) {
05487          break;
05488       }
05489    }
05490    return res;
05491 }

int ast_say_date_with_format_pl ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Polish syntax.

Definition at line 5494 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_date_with_format, ast_say_enumeration(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

05495 {
05496    struct timeval when = { thetime, 0 };
05497    struct ast_tm tm;
05498    int res=0, offset, sndoffset;
05499    char sndfile[256], nextmsg[256];
05500 
05501    ast_localtime(&when, &tm, tzone);
05502 
05503    for (offset = 0 ; format[offset] != '\0' ; offset++) {
05504       int remaining;
05505       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
05506       switch (format[offset]) {
05507          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
05508          case '\'':
05509             /* Literal name of a sound file */
05510             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
05511                sndfile[sndoffset] = format[offset];
05512             }
05513             sndfile[sndoffset] = '\0';
05514             res = wait_file(chan, ints, sndfile, lang);
05515             break;
05516          case 'A':
05517          case 'a':
05518             /* Sunday - Saturday */
05519             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
05520             res = wait_file(chan, ints, nextmsg, lang);
05521             break;
05522          case 'B':
05523          case 'b':
05524          case 'h':
05525             /* January - December */
05526             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
05527             res = wait_file(chan, ints, nextmsg, lang);
05528             break;
05529          case 'm':
05530             /* Month enumerated */
05531             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, NULL);
05532             break;
05533          case 'd':
05534          case 'e':
05535             /* First - Thirtyfirst */
05536             remaining = tm.tm_mday;
05537             if (tm.tm_mday > 30) {
05538                res = wait_file(chan, ints, "digits/h-30", lang);
05539                remaining -= 30;
05540             }
05541             if (tm.tm_mday > 20 && tm.tm_mday < 30) {
05542                res = wait_file(chan, ints, "digits/h-20", lang);
05543                remaining -= 20;
05544             }
05545             if (!res) {
05546                snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", remaining);
05547                res = wait_file(chan, ints, nextmsg, lang);
05548             }
05549             break;
05550          case 'Y':
05551             /* Year */
05552             if (tm.tm_year > 100) {
05553                res = wait_file(chan, ints, "digits/2", lang);
05554                if (!res)
05555                   res = wait_file(chan, ints, "digits/1000.2", lang);
05556                if (tm.tm_year > 100) {
05557                   if (!res)
05558                      res = ast_say_enumeration(chan, tm.tm_year - 100, ints, lang, NULL);
05559                }
05560             } else if (tm.tm_year == 100) {
05561                res = wait_file(chan, ints, "digits/h-2000", lang);
05562             } else {
05563                if (tm.tm_year < 1) {
05564                   /* I'm not going to handle 1900 and prior */
05565                   /* We'll just be silent on the year, instead of bombing out. */
05566                   break;
05567                } else {
05568                   res = wait_file(chan, ints, "digits/1000", lang);
05569                   if (!res) {
05570                      wait_file(chan, ints, "digits/900", lang);
05571                      res = ast_say_enumeration(chan, tm.tm_year, ints, lang, NULL);
05572                   }
05573                }
05574             }
05575             if (!res)
05576                wait_file(chan, ints, "digits/year", lang);
05577             break;
05578          case 'I':
05579          case 'l':
05580             /* 12-Hour */
05581             if (tm.tm_hour == 0)
05582                ast_copy_string(nextmsg, "digits/t-12", sizeof(nextmsg));
05583             else if (tm.tm_hour > 12)
05584                snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour - 12);
05585             else 
05586                snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour);
05587 
05588             res = wait_file(chan, ints, nextmsg, lang);
05589             break;
05590          case 'H':
05591          case 'k':
05592             /* 24-Hour */
05593             if (tm.tm_hour != 0) {
05594                snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour);
05595                res = wait_file(chan, ints, nextmsg, lang);
05596             } else 
05597                res = wait_file(chan, ints, "digits/t-24", lang);
05598             break;
05599          case 'M':
05600          case 'N':
05601             /* Minute */
05602             if (tm.tm_min == 0) {
05603                if (format[offset] == 'M') {
05604                   res = wait_file(chan, ints, "digits/oclock", lang);
05605                } else {
05606                   res = wait_file(chan, ints, "digits/100", lang);
05607                }
05608             } else
05609                res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 
05610             break;
05611          case 'P':
05612          case 'p':
05613             /* AM/PM */
05614             if (tm.tm_hour > 11)
05615                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
05616             else
05617                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
05618             res = wait_file(chan, ints, nextmsg, lang);
05619             break;
05620          case 'Q':
05621             /* Shorthand for "Today", "Yesterday", or AdBY */
05622             {
05623                struct timeval now = ast_tvnow();
05624                struct ast_tm tmnow;
05625                time_t beg_today;
05626 
05627                ast_localtime(&now, &tmnow, tzone);
05628                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05629                /* In any case, it saves not having to do ast_mktime() */
05630                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05631                if (beg_today < thetime) {
05632                   /* Today */
05633                   res = wait_file(chan, ints, "digits/today", lang);
05634                } else if (beg_today - 86400 < thetime) {
05635                   /* Yesterday */
05636                   res = wait_file(chan, ints, "digits/yesterday", lang);
05637                } else {
05638                   res = ast_say_date_with_format(chan, thetime, ints, lang, "AdBY", tzone);
05639                }
05640             }
05641             break;
05642          case 'q':
05643             /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */
05644             {
05645                struct timeval now = ast_tvnow();
05646                struct ast_tm tmnow;
05647                time_t beg_today;
05648 
05649                ast_localtime(&now, &tmnow, tzone);
05650                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05651                /* In any case, it saves not having to do ast_mktime() */
05652                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05653                if (beg_today < thetime) {
05654                   /* Today */
05655                } else if ((beg_today - 86400) < thetime) {
05656                   /* Yesterday */
05657                   res = wait_file(chan, ints, "digits/yesterday", lang);
05658                } else if (beg_today - 86400 * 6 < thetime) {
05659                   /* Within the last week */
05660                   res = ast_say_date_with_format(chan, thetime, ints, lang, "A", tzone);
05661                } else {
05662                   res = ast_say_date_with_format(chan, thetime, ints, lang, "AdBY", tzone);
05663                }
05664             }
05665             break;
05666          case 'R':
05667             res = ast_say_date_with_format(chan, thetime, ints, lang, "HM", tzone);
05668             break;
05669          case 'S':
05670             /* Seconds */
05671             res = wait_file(chan, ints, "digits/and", lang);
05672             if (!res) {
05673                if (tm.tm_sec == 1) {
05674                   res = wait_file(chan, ints, "digits/1z", lang);
05675                   if (!res)
05676                      res = wait_file(chan, ints, "digits/second-a", lang);
05677                } else {
05678                   res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
05679                   if (!res) {
05680                      int ten, one;
05681                      ten = tm.tm_sec / 10;
05682                      one = tm.tm_sec % 10;
05683                      
05684                      if (one > 1 && one < 5 && ten != 1)
05685                         res = wait_file(chan, ints, "digits/seconds", lang);
05686                      else
05687                         res = wait_file(chan, ints, "digits/second", lang);
05688                   }
05689                }
05690             }
05691             break;
05692          case 'T':
05693             res = ast_say_date_with_format(chan, thetime, ints, lang, "HMS", tzone);
05694             break;
05695          case ' ':
05696          case '   ':
05697             /* Just ignore spaces and tabs */
05698             break;
05699          default:
05700             /* Unknown character */
05701             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
05702       }
05703       /* Jump out on DTMF */
05704       if (res)
05705          break;
05706    }
05707    return res;
05708 }

int ast_say_date_with_format_pt ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Portuguese syntax.

Definition at line 5711 of file say.c.

References ast_debug, ast_localtime(), ast_log(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

05712 {
05713    struct timeval when = { t, 0 };
05714    struct ast_tm tm;
05715    int res=0, offset, sndoffset;
05716    char sndfile[256], nextmsg[256];
05717 
05718    if (format == NULL)
05719       format = "Ad 'digits/pt-de' B 'digits/pt-de' Y I 'digits/pt-e' Mp";
05720 
05721    ast_localtime(&when, &tm, tzone);
05722 
05723    for (offset=0 ; format[offset] != '\0' ; offset++) {
05724       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
05725       switch (format[offset]) {
05726          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
05727          case '\'':
05728             /* Literal name of a sound file */
05729             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
05730                sndfile[sndoffset] = format[offset];
05731             }
05732             sndfile[sndoffset] = '\0';
05733             snprintf(nextmsg, sizeof(nextmsg), "%s", sndfile);
05734             res = wait_file(chan, ints, nextmsg, lang);
05735             break;
05736          case 'A':
05737          case 'a':
05738             /* Sunday - Saturday */
05739             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
05740             res = wait_file(chan, ints, nextmsg, lang);
05741             break;
05742          case 'B':
05743          case 'b':
05744          case 'h':
05745             /* January - December */
05746             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
05747             res = wait_file(chan, ints, nextmsg, lang);
05748             break;
05749          case 'm':
05750             /* First - Twelfth */
05751             if (!strcasecmp(lang, "pt_BR")) {
05752                res = ast_say_number(chan, tm.tm_mon+1, ints, lang, (char *) NULL);
05753             } else {
05754                snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
05755                res = wait_file(chan, ints, nextmsg, lang);
05756             }
05757             break;
05758          case 'd':
05759          case 'e':
05760             /* First - Thirtyfirst */
05761             res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05762             break;
05763          case 'Y':
05764             /* Year */
05765             res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
05766             break;
05767          case 'I':
05768          case 'l':
05769             /* 12-Hour */
05770             if (!strcasecmp(lang, "pt_BR")) {
05771                if (tm.tm_hour == 0) {
05772                   if (format[offset] == 'I')
05773                      res = wait_file(chan, ints, "digits/pt-a", lang);
05774                   if (!res)
05775                      res = wait_file(chan, ints, "digits/pt-meianoite", lang);
05776                } else if (tm.tm_hour == 12) {
05777                   if (format[offset] == 'I')
05778                      res = wait_file(chan, ints, "digits/pt-ao", lang);
05779                   if (!res)
05780                      res = wait_file(chan, ints, "digits/pt-meiodia", lang);
05781                   } else {
05782                   if (format[offset] == 'I') {
05783                      if ((tm.tm_hour % 12) != 1)
05784                         res = wait_file(chan, ints, "digits/pt-as", lang);
05785                      else
05786                         res = wait_file(chan, ints, "digits/pt-a", lang);
05787                   }
05788                   if (!res)
05789                      res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
05790                }
05791             } else {
05792                if (tm.tm_hour == 0) {
05793                   if (format[offset] == 'I')
05794                      res = wait_file(chan, ints, "digits/pt-ah", lang);
05795                   if (!res)
05796                      res = wait_file(chan, ints, "digits/pt-meianoite", lang);
05797                   }
05798                else if (tm.tm_hour == 12) {
05799                   if (format[offset] == 'I')
05800                      res = wait_file(chan, ints, "digits/pt-ao", lang);
05801                   if (!res)
05802                      res = wait_file(chan, ints, "digits/pt-meiodia", lang);
05803                }
05804                else {
05805                   if (format[offset] == 'I') {
05806                      res = wait_file(chan, ints, "digits/pt-ah", lang);
05807                      if ((tm.tm_hour % 12) != 1)
05808                         if (!res)
05809                            res = wait_file(chan, ints, "digits/pt-sss", lang);
05810                   }
05811                   if (!res)
05812                      res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
05813                }
05814             }
05815             break;
05816          case 'H':
05817          case 'k':
05818             /* 24-Hour */
05819             if (!strcasecmp(lang, "pt_BR")) {
05820                res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
05821                if ((!res) && (format[offset] == 'H')) {
05822                   if (tm.tm_hour > 1) {
05823                      res = wait_file(chan, ints, "digits/hours", lang);
05824                   } else {
05825                      res = wait_file(chan, ints, "digits/hour", lang);
05826                   }
05827                }
05828             } else {
05829                res = ast_say_number(chan, -tm.tm_hour, ints, lang, NULL);
05830                if (!res) {
05831                   if (tm.tm_hour != 0) {
05832                      int remaining = tm.tm_hour;
05833                      if (tm.tm_hour > 20) {
05834                         res = wait_file(chan, ints, "digits/20", lang);
05835                         remaining -= 20;
05836                      }
05837                      if (!res) {
05838                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", remaining);
05839                         res = wait_file(chan, ints, nextmsg, lang);
05840                      }
05841                   }
05842                }
05843             }
05844             break;
05845          case 'M':
05846             /* Minute */
05847             if (!strcasecmp(lang, "pt_BR")) {
05848                res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
05849                if (!res) {
05850                   if (tm.tm_min > 1) {
05851                      res = wait_file(chan, ints, "digits/minutes", lang);
05852                   } else {
05853                      res = wait_file(chan, ints, "digits/minute", lang);
05854                   }
05855                }
05856             } else {
05857                if (tm.tm_min == 0) {
05858                   res = wait_file(chan, ints, "digits/pt-hora", lang);
05859                   if (tm.tm_hour != 1)
05860                      if (!res)
05861                         res = wait_file(chan, ints, "digits/pt-sss", lang);         
05862                } else {
05863                   res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 
05864                }
05865             }
05866             break;
05867          case 'P':
05868          case 'p':
05869             /* AM/PM */
05870             if (!strcasecmp(lang, "pt_BR")) {
05871                if ((tm.tm_hour != 0) && (tm.tm_hour != 12)) {
05872                   res = wait_file(chan, ints, "digits/pt-da", lang);
05873                   if (!res) {
05874                      if ((tm.tm_hour >= 0) && (tm.tm_hour < 12))
05875                         res = wait_file(chan, ints, "digits/morning", lang);
05876                      else if ((tm.tm_hour >= 12) && (tm.tm_hour < 18))
05877                         res = wait_file(chan, ints, "digits/afternoon", lang);
05878                      else res = wait_file(chan, ints, "digits/night", lang);
05879                   }
05880                }
05881             } else {
05882                if (tm.tm_hour > 12)
05883                   res = wait_file(chan, ints, "digits/p-m", lang);
05884                else if (tm.tm_hour  && tm.tm_hour < 12)
05885                   res = wait_file(chan, ints, "digits/a-m", lang);
05886             }
05887             break;
05888          case 'Q':
05889             /* Shorthand for "Today", "Yesterday", or ABdY */
05890             /* XXX As emphasized elsewhere, this should the native way in your
05891              * language to say the date, with changes in what you say, depending
05892              * upon how recent the date is. XXX */
05893             {
05894                struct timeval now = ast_tvnow();
05895                struct ast_tm tmnow;
05896                time_t beg_today;
05897 
05898                ast_localtime(&now, &tmnow, tzone);
05899                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05900                /* In any case, it saves not having to do ast_mktime() */
05901                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05902                if (beg_today < t) {
05903                   /* Today */
05904                   res = wait_file(chan, ints, "digits/today", lang);
05905                } else if (beg_today - 86400 < t) {
05906                   /* Yesterday */
05907                   res = wait_file(chan, ints, "digits/yesterday", lang);
05908                } else {
05909                   res = ast_say_date_with_format_pt(chan, t, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", tzone);
05910                }
05911             }
05912             break;
05913          case 'q':
05914             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
05915             /* XXX As emphasized elsewhere, this should the native way in your
05916              * language to say the date, with changes in what you say, depending
05917              * upon how recent the date is. XXX */
05918             {
05919                struct timeval now = ast_tvnow();
05920                struct ast_tm tmnow;
05921                time_t beg_today;
05922 
05923                ast_localtime(&now, &tmnow, tzone);
05924                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05925                /* In any case, it saves not having to do ast_mktime() */
05926                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05927                if (beg_today < t) {
05928                   /* Today */
05929                } else if ((beg_today - 86400) < t) {
05930                   /* Yesterday */
05931                   res = wait_file(chan, ints, "digits/yesterday", lang);
05932                } else if (beg_today - 86400 * 6 < t) {
05933                   /* Within the last week */
05934                   res = ast_say_date_with_format_pt(chan, t, ints, lang, "A", tzone);
05935                } else {
05936                   res = ast_say_date_with_format_pt(chan, t, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", tzone);
05937                }
05938             }
05939             break;
05940          case 'R':
05941             res = ast_say_date_with_format_pt(chan, t, ints, lang, "H 'digits/pt-e' M", tzone);
05942             break;
05943          case 'S':
05944             /* Seconds */
05945             if (!strcasecmp(lang, "pt_BR")) {
05946                res = ast_say_number(chan, tm.tm_sec, ints, lang, NULL);
05947                if (!res) {
05948                   if (tm.tm_sec > 1) {
05949                      res = wait_file(chan, ints, "digits/seconds", lang);
05950                   } else {
05951                      res = wait_file(chan, ints, "digits/second", lang);
05952                   }
05953                }
05954             } else {
05955                if (tm.tm_sec == 0) {
05956                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
05957                   res = wait_file(chan, ints, nextmsg, lang);
05958                } else if (tm.tm_sec < 10) {
05959                   res = wait_file(chan, ints, "digits/oh", lang);
05960                   if (!res) {
05961                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
05962                      res = wait_file(chan, ints, nextmsg, lang);
05963                   }
05964                } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
05965                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
05966                   res = wait_file(chan, ints, nextmsg, lang);
05967                } else {
05968                   int ten, one;
05969                   ten = (tm.tm_sec / 10) * 10;
05970                   one = (tm.tm_sec % 10);
05971                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", ten);
05972                   res = wait_file(chan, ints, nextmsg, lang);
05973                   if (!res) {
05974                      /* Fifty, not fifty-zero */
05975                      if (one != 0) {
05976                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", one);
05977                         res = wait_file(chan, ints, nextmsg, lang);
05978                      }
05979                   }
05980                }
05981             }
05982             break;
05983          case 'T':
05984             res = ast_say_date_with_format_pt(chan, t, ints, lang, "HMS", tzone);
05985             break;
05986          case ' ':
05987          case '   ':
05988             /* Just ignore spaces and tabs */
05989             break;
05990          default:
05991             /* Unknown character */
05992             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
05993       }
05994       /* Jump out on DTMF */
05995       if (res) {
05996          break;
05997       }
05998    }
05999    return res;
06000 }

int ast_say_date_with_format_th ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Thai syntax.

Definition at line 4340 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_date_with_format_en(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

04341 {
04342    struct timeval when = { t, 0 };
04343    struct ast_tm tm;
04344    int res=0, offset, sndoffset;
04345    char sndfile[256], nextmsg[256];
04346 
04347    if (format == NULL)
04348       format = "a 'digits/tee' e 'digits/duan' hY  I 'digits/naliga' M 'digits/natee'";
04349 
04350    ast_localtime(&when, &tm, tzone);
04351 
04352    for (offset=0 ; format[offset] != '\0' ; offset++) {
04353       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04354       switch (format[offset]) {
04355          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04356          case '\'':
04357             /* Literal name of a sound file */
04358             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
04359                sndfile[sndoffset] = format[offset];
04360             }
04361             sndfile[sndoffset] = '\0';
04362             res = wait_file(chan, ints, sndfile, lang);
04363             break;
04364          case 'A':
04365          case 'a':
04366             /* Sunday - Saturday */
04367             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04368             res = wait_file(chan, ints, nextmsg, lang);
04369             break;
04370          case 'B':
04371          case 'b':
04372          case 'h':
04373             /* January - December */
04374             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04375             res = wait_file(chan, ints, nextmsg, lang);
04376             break;
04377          case 'm':
04378             /* Month enumerated */
04379             res = ast_say_number(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL); 
04380             break;
04381          case 'd':
04382          case 'e':
04383             /* First - Thirtyfirst */
04384             res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);   
04385             break;
04386          case 'Y':
04387             /* Year */
04388             res = ast_say_number(chan, tm.tm_year + 1900 + 543, ints, lang, (char *) NULL);
04389             break;
04390          case 'I':
04391          case 'l':
04392             /* 12-Hour */
04393             if (tm.tm_hour == 0)
04394                ast_copy_string(nextmsg, "digits/24", sizeof(nextmsg));
04395             snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
04396             res = wait_file(chan, ints, nextmsg, lang);
04397             break;
04398          case 'H':
04399          case 'k':
04400             /* 24-Hour */
04401             if (tm.tm_hour == 0)
04402                ast_copy_string(nextmsg, "digits/24", sizeof(nextmsg));
04403             snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
04404             res = wait_file(chan, ints, nextmsg, lang);
04405             break;
04406          case 'M':
04407          case 'N':
04408             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
04409             break;
04410          case 'P':
04411          case 'p':
04412             break;
04413          case 'Q':
04414             /* Shorthand for "Today", "Yesterday", or ABdY */
04415             /* XXX As emphasized elsewhere, this should the native way in your
04416              * language to say the date, with changes in what you say, depending
04417              * upon how recent the date is. XXX */
04418             {
04419                struct timeval now = ast_tvnow();
04420                struct ast_tm tmnow;
04421                time_t beg_today;
04422 
04423                ast_localtime(&now, &tmnow, tzone);
04424                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04425                /* In any case, it saves not having to do ast_mktime() */
04426                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04427                if (beg_today < t) {
04428                   /* Today */
04429                   res = wait_file(chan, ints, "digits/today", lang);
04430                } else if (beg_today - 86400 < t) {
04431                   /* Yesterday */
04432                   res = wait_file(chan, ints, "digits/yesterday", lang);
04433                } else if (beg_today - 86400 * 6 < t) {
04434                   /* Within the last week */
04435                   res = ast_say_date_with_format_en(chan, t, ints, lang, "A", tzone);
04436                } else if (beg_today - 2628000 < t) {
04437                   /* Less than a month ago - "Sunday, October third" */
04438                   res = ast_say_date_with_format_en(chan, t, ints, lang, "ABd", tzone);
04439                } else if (beg_today - 15768000 < t) {
04440                   /* Less than 6 months ago - "August seventh" */
04441                   res = ast_say_date_with_format_en(chan, t, ints, lang, "Bd", tzone);
04442                } else {
04443                   /* More than 6 months ago - "April nineteenth two thousand three" */
04444                   res = ast_say_date_with_format_en(chan, t, ints, lang, "BdY", tzone);
04445                }
04446             }
04447             break;
04448          case 'q':
04449             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
04450             /* XXX As emphasized elsewhere, this should the native way in your
04451              * language to say the date, with changes in what you say, depending
04452              * upon how recent the date is. XXX */
04453             {
04454                struct timeval now = ast_tvnow();
04455                struct ast_tm tmnow;
04456                time_t beg_today;
04457 
04458                ast_localtime(&now, &tmnow, tzone);
04459                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04460                /* In any case, it saves not having to do ast_mktime() */
04461                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04462                if (beg_today < t) {
04463                   /* Today */
04464                } else if ((beg_today - 86400) < t) {
04465                   /* Yesterday */
04466                   res = wait_file(chan, ints, "digits/yesterday", lang);
04467                } else if (beg_today - 86400 * 6 < t) {
04468                   /* Within the last week */
04469                   res = ast_say_date_with_format_en(chan, t, ints, lang, "A", tzone);
04470                } else if (beg_today - 2628000 < t) {
04471                   /* Less than a month ago - "Sunday, October third" */
04472                   res = ast_say_date_with_format_en(chan, t, ints, lang, "ABd", tzone);
04473                } else if (beg_today - 15768000 < t) {
04474                   /* Less than 6 months ago - "August seventh" */
04475                   res = ast_say_date_with_format_en(chan, t, ints, lang, "Bd", tzone);
04476                } else {
04477                   /* More than 6 months ago - "April nineteenth two thousand three" */
04478                   res = ast_say_date_with_format_en(chan, t, ints, lang, "BdY", tzone);
04479                }
04480             }
04481             break;
04482          case 'R':
04483             res = ast_say_date_with_format_en(chan, t, ints, lang, "HM", tzone);
04484             break;
04485          case 'S':
04486             res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL);
04487             break;
04488          case 'T':
04489             res = ast_say_date_with_format_en(chan, t, ints, lang, "HMS", tzone);
04490             break;
04491          case ' ':
04492          case '   ':
04493             /* Just ignore spaces and tabs */
04494             break;
04495          default:
04496             /* Unknown character */
04497             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04498       }
04499       /* Jump out on DTMF */
04500       if (res) {
04501          break;
04502       }
04503    }
04504    return res;
04505 }

int ast_say_date_with_format_vi ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Vietnamese syntax.

Definition at line 7668 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_say_date_with_format_en(), ast_say_enumeration(), ast_say_number(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

07669 {
07670    struct timeval when = { t, 0 };
07671    struct ast_tm tm;
07672    int res = 0, offset, sndoffset;
07673    char sndfile[256], nextmsg[256];
07674 
07675    if (format == NULL)
07676       format = "A 'digits/day' eB 'digits/year' Y 'digits/at' k 'hours' M 'minutes' p";
07677 
07678    ast_localtime(&when, &tm, tzone);
07679 
07680    for (offset=0 ; format[offset] != '\0' ; offset++) {
07681       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
07682       switch (format[offset]) {
07683          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
07684          case '\'':
07685             /* Literal name of a sound file */
07686             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
07687                sndfile[sndoffset] = format[offset];
07688             }
07689             sndfile[sndoffset] = '\0';
07690             res = wait_file(chan, ints, sndfile, lang);
07691             break;
07692          case 'A':
07693          case 'a':
07694             /* Sunday - Saturday */
07695             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
07696             res = wait_file(chan, ints, nextmsg, lang);
07697             break;
07698          case 'B':
07699          case 'b':
07700          case 'h':
07701             /* January - December */
07702             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
07703             res = wait_file(chan, ints, nextmsg, lang);
07704             break;
07705          case 'm':
07706             /* Month enumerated */
07707             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);  
07708             break;
07709          case 'd':
07710          case 'e':
07711             /* 1 - 31 */
07712             res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);   
07713             break;
07714          case 'Y':
07715             /* Year */
07716             if (tm.tm_year > 99) {
07717                res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
07718             } else if (tm.tm_year < 1) {
07719                /* I'm not going to handle 1900 and prior */
07720                /* We'll just be silent on the year, instead of bombing out. */
07721             } else {
07722                res = wait_file(chan, ints, "digits/19", lang);
07723                if (!res) {
07724                   if (tm.tm_year <= 9) {
07725                      /* 1901 - 1909 */
07726                      res = wait_file(chan, ints, "digits/odd", lang);
07727                   }
07728 
07729                   res |= ast_say_number(chan, tm.tm_year, ints, lang, (char *) NULL);
07730                }
07731             }
07732             break;
07733          case 'I':
07734          case 'l':
07735             /* 12-Hour */
07736             if (tm.tm_hour == 0)
07737                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
07738             else if (tm.tm_hour > 12)
07739                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
07740             else
07741                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
07742             res = wait_file(chan, ints, nextmsg, lang);
07743             break;
07744          case 'H':
07745          case 'k':
07746             /* 24-Hour */
07747             if (format[offset] == 'H') {
07748                /* e.g. oh-eight */
07749                if (tm.tm_hour < 10) {
07750                   res = wait_file(chan, ints, "digits/0", lang);
07751                }
07752             } else {
07753                /* e.g. eight */
07754                if (tm.tm_hour == 0) {
07755                   res = wait_file(chan, ints, "digits/0", lang);
07756                }
07757             }
07758             if (!res) {
07759                if (tm.tm_hour != 0) {
07760                   int remaining = tm.tm_hour;
07761                   if (tm.tm_hour > 20) {
07762                      res = wait_file(chan, ints, "digits/20", lang);
07763                      remaining -= 20;
07764                   }
07765                   if (!res) {
07766                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", remaining);
07767                      res = wait_file(chan, ints, nextmsg, lang);
07768                   }
07769                }
07770             }
07771             break;
07772          case 'M':
07773          case 'N':
07774             /* Minute */
07775             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
07776             break;
07777          case 'P':
07778          case 'p':
07779             /* AM/PM */
07780             if (tm.tm_hour > 11)
07781                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
07782             else
07783                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
07784             res = wait_file(chan, ints, nextmsg, lang);
07785             break;
07786          case 'Q':
07787             /* Shorthand for "Today", "Yesterday", or ABdY */
07788             /* XXX As emphasized elsewhere, this should the native way in your
07789              * language to say the date, with changes in what you say, depending
07790              * upon how recent the date is. XXX */
07791             {
07792                struct timeval now = ast_tvnow();
07793                struct ast_tm tmnow;
07794                time_t beg_today;
07795 
07796                gettimeofday(&now, NULL);
07797                ast_localtime(&now, &tmnow, tzone);
07798                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
07799                /* In any case, it saves not having to do ast_mktime() */
07800                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
07801                if (beg_today < t) {
07802                   /* Today */
07803                   res = wait_file(chan, ints, "digits/today", lang);
07804                } else if (beg_today - 86400 < t) {
07805                   /* Yesterday */
07806                   res = wait_file(chan, ints, "digits/yesterday", lang);
07807                } else if (beg_today - 86400 * 6 < t) {
07808                   /* Within the last week */
07809                   res = ast_say_date_with_format_vi(chan, t, ints, lang, "A", tzone);
07810                } else if (beg_today - 2628000 < t) {
07811                   /* Less than a month ago - "Chu nhat ngay 13 thang 2" */
07812                   res = ast_say_date_with_format_vi(chan, t, ints, lang, "A 'digits/day' dB", tzone);
07813                } else if (beg_today - 15768000 < t) {
07814                   /* Less than 6 months ago - "August seventh" */
07815                   res = ast_say_date_with_format_vi(chan, t, ints, lang, "'digits/day' dB", tzone);
07816                } else {
07817                   /* More than 6 months ago - "April nineteenth two thousand three" */
07818                   res = ast_say_date_with_format_vi(chan, t, ints, lang, "'digits/day' dB 'digits/year' Y", tzone);
07819                }
07820             }
07821             break;
07822          case 'q':
07823             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
07824             /* XXX As emphasized elsewhere, this should the native way in your
07825              * language to say the date, with changes in what you say, depending
07826              * upon how recent the date is. XXX */
07827             {
07828                struct timeval now;
07829                struct ast_tm tmnow;
07830                time_t beg_today;
07831 
07832                now = ast_tvnow();
07833                ast_localtime(&now, &tmnow, tzone);
07834                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
07835                /* In any case, it saves not having to do ast_mktime() */
07836                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
07837                if (beg_today < t) {
07838                   /* Today */
07839                } else if ((beg_today - 86400) < t) {
07840                   /* Yesterday */
07841                   res = wait_file(chan, ints, "digits/yesterday", lang);
07842                } else if (beg_today - 86400 * 6 < t) {
07843                   /* Within the last week */
07844                   res = ast_say_date_with_format_en(chan, t, ints, lang, "A", tzone);
07845                } else if (beg_today - 2628000 < t) {
07846                   /* Less than a month ago - "Chu nhat ngay 13 thang 2" */
07847                   res = ast_say_date_with_format_vi(chan, t, ints, lang, "A 'digits/day' dB", tzone);
07848                } else if (beg_today - 15768000 < t) {
07849                   /* Less than 6 months ago - "August seventh" */
07850                   res = ast_say_date_with_format_vi(chan, t, ints, lang, "'digits/day' dB", tzone);
07851                } else {
07852                   /* More than 6 months ago - "April nineteenth two thousand three" */
07853                   res = ast_say_date_with_format_vi(chan, t, ints, lang, "'digits/day' dB 'digits/year' Y", tzone);
07854                }
07855             }
07856             break;
07857          case 'R':
07858             res = ast_say_date_with_format_vi(chan, t, ints, lang, "HM", tzone);
07859             break;
07860          case 'S':
07861             /* Seconds */
07862             res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL);
07863             break;
07864          case 'T':
07865             res = ast_say_date_with_format_vi(chan, t, ints, lang, "H 'hours' M 'minutes' S 'seconds'", tzone);
07866             break;
07867          case ' ':
07868          case '   ':
07869             /* Just ignore spaces and tabs */
07870             break;
07871          default:
07872             /* Unknown character */
07873             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
07874       }
07875       /* Jump out on DTMF */
07876       if (res) {
07877          break;
07878       }
07879    }
07880    return res;
07881 }

int ast_say_date_with_format_zh ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Taiwanese / Chinese syntax.

Definition at line 6003 of file say.c.

References ast_copy_string(), ast_debug, ast_localtime(), ast_log(), ast_tvnow(), LOG_WARNING, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_wday, ast_tm::tm_year, and wait_file().

Referenced by say_date_with_format().

06004 {
06005    struct timeval when = { t, 0 };
06006    struct ast_tm tm;
06007    int res=0, offset, sndoffset;
06008    char sndfile[256], nextmsg[256];
06009 
06010    if (format == NULL)
06011       format = "YBdAkM";
06012 
06013    ast_localtime(&when, &tm, tzone);
06014 
06015    for (offset=0 ; format[offset] != '\0' ; offset++) {
06016       ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
06017       switch (format[offset]) {
06018          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
06019          case '\'':
06020             /* Literal name of a sound file */
06021             for (sndoffset = 0; !strchr("\'\0", format[++offset]) && (sndoffset < sizeof(sndfile) - 1) ; sndoffset++) {
06022                sndfile[sndoffset] = format[offset];
06023             }
06024             sndfile[sndoffset] = '\0';
06025             res = wait_file(chan, ints, sndfile, lang);
06026             break;
06027          case 'A':
06028          case 'a':
06029             /* Sunday - Saturday */
06030             snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
06031             res = wait_file(chan, ints, nextmsg, lang);
06032             break;
06033          case 'B':
06034          case 'b':
06035          case 'h':
06036          case 'm':
06037             /* January - December */
06038             snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
06039             res = wait_file(chan, ints, nextmsg, lang);
06040             break;
06041          case 'd':
06042          case 'e':
06043             /* First - Thirtyfirst */
06044             if (!(tm.tm_mday % 10) || (tm.tm_mday < 10)) {
06045                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_mday);
06046                res = wait_file(chan, ints, nextmsg, lang);
06047             } else {
06048                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_mday - (tm.tm_mday % 10));
06049                res = wait_file(chan, ints, nextmsg, lang);
06050                if (!res) {
06051                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_mday % 10);
06052                   res = wait_file(chan, ints, nextmsg, lang);
06053                }
06054             }
06055             if (!res) res = wait_file(chan, ints, "digits/day", lang);
06056             break;
06057          case 'Y':
06058             /* Year */
06059             if (tm.tm_year > 99) {
06060                res = wait_file(chan, ints, "digits/2", lang);
06061                if (!res) {
06062                   res = wait_file(chan, ints, "digits/thousand", lang);
06063                }
06064                if (tm.tm_year > 100) {
06065                   if (!res) {
06066                      snprintf(nextmsg, sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) / 10);
06067                      res = wait_file(chan, ints, nextmsg, lang);
06068                      if (!res) {
06069                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) % 10);
06070                         res = wait_file(chan, ints, nextmsg, lang);
06071                      }
06072                   }
06073                }
06074                if (!res) {
06075                   res = wait_file(chan, ints, "digits/year", lang);
06076                }
06077             } else {
06078                if (tm.tm_year < 1) {
06079                   /* I'm not going to handle 1900 and prior */
06080                   /* We'll just be silent on the year, instead of bombing out. */
06081                } else {
06082                   res = wait_file(chan, ints, "digits/1", lang);
06083                   if (!res) {
06084                      res = wait_file(chan, ints, "digits/9", lang);
06085                   }
06086                   if (!res) {
06087                      if (tm.tm_year <= 9) {
06088                         /* 1901 - 1909 */
06089                         res = wait_file(chan, ints, "digits/0", lang);
06090                         if (!res) {
06091                            snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year);
06092                            res = wait_file(chan, ints, nextmsg, lang);
06093                         }
06094                      } else {
06095                         /* 1910 - 1999 */
06096                         snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year / 10);
06097                         res = wait_file(chan, ints, nextmsg, lang);
06098                         if (!res) {
06099                            snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_year % 10);
06100                            res = wait_file(chan, ints, nextmsg, lang);
06101                         }
06102                      }
06103                   }
06104                }
06105                if (!res) {
06106                   res = wait_file(chan, ints, "digits/year", lang);
06107                }
06108             }
06109             break;
06110          case 'I':
06111          case 'l':
06112             /* 12-Hour */
06113             if (tm.tm_hour == 0)
06114                ast_copy_string(nextmsg, "digits/12", sizeof(nextmsg));
06115             else if (tm.tm_hour > 12)
06116                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
06117             else
06118                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
06119             res = wait_file(chan, ints, nextmsg, lang);
06120             if (!res) {
06121                res = wait_file(chan, ints, "digits/oclock", lang);
06122             }
06123             break;
06124          case 'H':
06125             if (tm.tm_hour < 10) {
06126                res = wait_file(chan, ints, "digits/0", lang);
06127             }
06128          case 'k':
06129             /* 24-Hour */
06130             if (!(tm.tm_hour % 10) || tm.tm_hour < 10) {
06131                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour);
06132                res = wait_file(chan, ints, nextmsg, lang);
06133             } else {
06134                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour - (tm.tm_hour % 10));
06135                res = wait_file(chan, ints, nextmsg, lang);
06136                if (!res) {
06137                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_hour % 10);
06138                   res = wait_file(chan, ints, nextmsg, lang);
06139                }
06140             }
06141             if (!res) {
06142                res = wait_file(chan, ints, "digits/oclock", lang);
06143             }
06144             break;
06145          case 'M':
06146             /* Minute */
06147             if (!(tm.tm_min % 10) || tm.tm_min < 10) {
06148                if (tm.tm_min < 10) {
06149                   res = wait_file(chan, ints, "digits/0", lang);
06150                }
06151                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_min);
06152                res = wait_file(chan, ints, nextmsg, lang);
06153             } else {
06154                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_min - (tm.tm_min % 10));
06155                res = wait_file(chan, ints, nextmsg, lang);
06156                if (!res) {
06157                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_min % 10);
06158                   res = wait_file(chan, ints, nextmsg, lang);
06159                }
06160             }
06161             if (!res) {
06162                res = wait_file(chan, ints, "digits/minute", lang);
06163             }
06164             break;
06165          case 'P':
06166          case 'p':
06167             /* AM/PM */
06168             if (tm.tm_hour > 11)
06169                ast_copy_string(nextmsg, "digits/p-m", sizeof(nextmsg));
06170             else
06171                ast_copy_string(nextmsg, "digits/a-m", sizeof(nextmsg));
06172             res = wait_file(chan, ints, nextmsg, lang);
06173             break;
06174          case 'Q':
06175             /* Shorthand for "Today", "Yesterday", or ABdY */
06176             /* XXX As emphasized elsewhere, this should the native way in your
06177              * language to say the date, with changes in what you say, depending
06178              * upon how recent the date is. XXX */
06179             {
06180                struct timeval now = ast_tvnow();
06181                struct ast_tm tmnow;
06182                time_t beg_today;
06183 
06184                ast_localtime(&now, &tmnow, tzone);
06185                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
06186                /* In any case, it saves not having to do ast_mktime() */
06187                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
06188                if (beg_today < t) {
06189                   /* Today */
06190                   res = wait_file(chan, ints, "digits/today", lang);
06191                } else if (beg_today - 86400 < t) {
06192                   /* Yesterday */
06193                   res = wait_file(chan, ints, "digits/yesterday", lang);
06194                } else {
06195                   res = ast_say_date_with_format_zh(chan, t, ints, lang, "YBdA", tzone);
06196                }
06197             }
06198             break;
06199          case 'q':
06200             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
06201             /* XXX As emphasized elsewhere, this should the native way in your
06202              * language to say the date, with changes in what you say, depending
06203              * upon how recent the date is. XXX */
06204             {
06205                struct timeval now = ast_tvnow();
06206                struct ast_tm tmnow;
06207                time_t beg_today;
06208 
06209                ast_localtime(&now, &tmnow, tzone);
06210                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
06211                /* In any case, it saves not having to do ast_mktime() */
06212                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
06213                if (beg_today < t) {
06214                   /* Today */
06215                } else if ((beg_today - 86400) < t) {
06216                   /* Yesterday */
06217                   res = wait_file(chan, ints, "digits/yesterday", lang);
06218                } else if (beg_today - 86400 * 6 < t) {
06219                   /* Within the last week */
06220                   res = ast_say_date_with_format_zh(chan, t, ints, lang, "A", tzone);
06221                } else {
06222                   res = ast_say_date_with_format_zh(chan, t, ints, lang, "YBdA", tzone);
06223                }
06224             }
06225             break;
06226          case 'R':
06227             res = ast_say_date_with_format_zh(chan, t, ints, lang, "kM", tzone);
06228             break;
06229          case 'S':
06230             /* Seconds */
06231             if (!(tm.tm_sec % 10) || tm.tm_sec < 10) {
06232                if (tm.tm_sec < 10) {
06233                   res = wait_file(chan, ints, "digits/0", lang);
06234                }
06235                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec);
06236                res = wait_file(chan, ints, nextmsg, lang);
06237             } else {
06238                snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec - (tm.tm_sec % 10));
06239                res = wait_file(chan, ints, nextmsg, lang);
06240                if (!res) {
06241                   snprintf(nextmsg, sizeof(nextmsg), "digits/%d", tm.tm_sec % 10);
06242                   res = wait_file(chan, ints, nextmsg, lang);
06243                }
06244             }
06245             if (!res) {
06246                res = wait_file(chan, ints, "digits/second", lang);
06247             }
06248             break;
06249          case 'T':
06250             res = ast_say_date_with_format_zh(chan, t, ints, lang, "HMS", tzone);
06251             break;
06252          case ' ':
06253          case '   ':
06254             /* Just ignore spaces and tabs */
06255          break;
06256          default:
06257             /* Unknown character */
06258             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
06259       }
06260       /* Jump out on DTMF */
06261       if (res) {
06262          break;
06263       }
06264    }
06265    return res;
06266 }

int ast_say_datetime_de ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

German syntax.

Definition at line 6711 of file say.c.

References ast_localtime(), ast_say_date, and ast_say_time.

Referenced by say_datetime().

06712 {
06713    struct timeval when = { t, 0 };
06714    struct ast_tm tm;
06715    int res = 0;
06716 
06717    ast_localtime(&when, &tm, NULL);
06718    res = ast_say_date(chan, t, ints, lang);
06719    if (!res) 
06720       ast_say_time(chan, t, ints, lang);
06721    return res;
06722 
06723 }

int ast_say_datetime_en ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

English syntax.

Definition at line 6644 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_datetime().

06645 {
06646    struct timeval when = { t, 0 };
06647    struct ast_tm tm;
06648    char fn[256];
06649    int res = 0;
06650    int hour, pm=0;
06651 
06652    ast_localtime(&when, &tm, NULL);
06653    if (!res) {
06654       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
06655       res = ast_streamfile(chan, fn, lang);
06656       if (!res)
06657          res = ast_waitstream(chan, ints);
06658    }
06659    if (!res) {
06660       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
06661       res = ast_streamfile(chan, fn, lang);
06662       if (!res)
06663          res = ast_waitstream(chan, ints);
06664    }
06665    if (!res)
06666       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
06667 
06668    hour = tm.tm_hour;
06669    if (!hour)
06670       hour = 12;
06671    else if (hour == 12)
06672       pm = 1;
06673    else if (hour > 12) {
06674       hour -= 12;
06675       pm = 1;
06676    }
06677    if (!res)
06678       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06679 
06680    if (tm.tm_min > 9) {
06681       if (!res)
06682          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06683    } else if (tm.tm_min) {
06684       if (!res)
06685          res = ast_streamfile(chan, "digits/oh", lang);
06686       if (!res)
06687          res = ast_waitstream(chan, ints);
06688       if (!res)
06689          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06690    } else {
06691       if (!res)
06692          res = ast_streamfile(chan, "digits/oclock", lang);
06693       if (!res)
06694          res = ast_waitstream(chan, ints);
06695    }
06696    if (pm) {
06697       if (!res)
06698          res = ast_streamfile(chan, "digits/p-m", lang);
06699    } else {
06700       if (!res)
06701          res = ast_streamfile(chan, "digits/a-m", lang);
06702    }
06703    if (!res)
06704       res = ast_waitstream(chan, ints);
06705    if (!res)
06706       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
06707    return res;
06708 }

int ast_say_datetime_fr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

French syntax.

Definition at line 6740 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_datetime().

06741 {
06742    struct timeval when = { t, 0 };
06743    struct ast_tm tm;
06744    char fn[256];
06745    int res = 0;
06746 
06747    ast_localtime(&when, &tm, NULL);
06748 
06749    if (!res)
06750       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
06751 
06752    if (!res) {
06753       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
06754       res = ast_streamfile(chan, fn, lang);
06755       if (!res)
06756          res = ast_waitstream(chan, ints);
06757    }
06758    if (!res) {
06759       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
06760       res = ast_streamfile(chan, fn, lang);
06761       if (!res)
06762          res = ast_waitstream(chan, ints);
06763    }
06764 
06765    if (!res)
06766       res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
06767    if (!res)
06768          res = ast_streamfile(chan, "digits/oclock", lang);
06769    if (tm.tm_min > 0) {
06770       if (!res)
06771          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06772    } 
06773    if (!res)
06774       res = ast_waitstream(chan, ints);
06775    if (!res)
06776       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
06777    return res;
06778 }

int ast_say_datetime_from_now_en ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

English syntax.

Definition at line 7074 of file say.c.

References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), ast_tvnow(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_yday.

Referenced by say_datetime_from_now().

07075 {
07076    int res=0;
07077    struct timeval nowtv = ast_tvnow(), when = { t, 0 };
07078    int daydiff;
07079    struct ast_tm tm;
07080    struct ast_tm now;
07081    char fn[256];
07082 
07083    ast_localtime(&when, &tm, NULL);
07084    ast_localtime(&nowtv, &now, NULL);
07085    daydiff = now.tm_yday - tm.tm_yday;
07086    if ((daydiff < 0) || (daydiff > 6)) {
07087       /* Day of month and month */
07088       if (!res) {
07089          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
07090          res = ast_streamfile(chan, fn, lang);
07091          if (!res)
07092             res = ast_waitstream(chan, ints);
07093       }
07094       if (!res)
07095          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
07096 
07097    } else if (daydiff) {
07098       /* Just what day of the week */
07099       if (!res) {
07100          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
07101          res = ast_streamfile(chan, fn, lang);
07102          if (!res)
07103             res = ast_waitstream(chan, ints);
07104       }
07105    } /* Otherwise, it was today */
07106    if (!res)
07107       res = ast_say_time(chan, t, ints, lang);
07108    return res;
07109 }

int ast_say_datetime_from_now_fr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

French syntax.

Definition at line 7112 of file say.c.

References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), ast_tvnow(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_yday.

Referenced by say_datetime_from_now().

07113 {
07114    int res=0;
07115    struct timeval nowtv = ast_tvnow(), when = { t, 0 };
07116    int daydiff;
07117    struct ast_tm tm;
07118    struct ast_tm now;
07119    char fn[256];
07120 
07121    ast_localtime(&when, &tm, NULL);
07122    ast_localtime(&nowtv, &now, NULL);
07123    daydiff = now.tm_yday - tm.tm_yday;
07124    if ((daydiff < 0) || (daydiff > 6)) {
07125       /* Day of month and month */
07126       if (!res) {
07127          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
07128          res = ast_streamfile(chan, fn, lang);
07129          if (!res)
07130             res = ast_waitstream(chan, ints);
07131       }
07132       if (!res)
07133          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
07134 
07135    } else if (daydiff) {
07136       /* Just what day of the week */
07137       if (!res) {
07138          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
07139          res = ast_streamfile(chan, fn, lang);
07140          if (!res)
07141             res = ast_waitstream(chan, ints);
07142       }
07143    } /* Otherwise, it was today */
07144    if (!res)
07145       res = ast_say_time(chan, t, ints, lang);
07146    return res;
07147 }

int ast_say_datetime_from_now_he ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Hebrew syntax.

Definition at line 7200 of file say.c.

References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), ast_tvnow(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_yday.

Referenced by say_datetime_from_now().

07201 {
07202    int res = 0;
07203    struct timeval nowt = ast_tvnow(), when = { t, 0 };
07204    int daydiff;
07205    struct ast_tm tm;
07206    struct ast_tm now;
07207    char fn[256];
07208 
07209    ast_localtime(&when, &tm, NULL);
07210    ast_localtime(&nowt, &now, NULL);
07211    daydiff = now.tm_yday - tm.tm_yday;
07212    if ((daydiff < 0) || (daydiff > 6)) {
07213       /* Day of month and month */
07214       if (!res) {
07215          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
07216          res = ast_streamfile(chan, fn, lang);
07217          if (!res)
07218             res = ast_waitstream(chan, ints);
07219       }
07220       if (!res) {
07221          res = ast_say_number(chan, tm.tm_mday, ints, lang, "f");
07222       }
07223    } else if (daydiff) {
07224       /* Just what day of the week */
07225       if (!res) {
07226          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
07227          res = ast_streamfile(chan, fn, lang);
07228          if (!res) {
07229             res = ast_waitstream(chan, ints);
07230          }
07231       }
07232    }                    /* Otherwise, it was today */
07233    if (!res) {
07234       res = ast_say_time(chan, t, ints, lang);
07235    }
07236    return res;
07237 }

static int ast_say_datetime_from_now_ka ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Georgian syntax.

Definition at line 8207 of file say.c.

References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), ast_tvnow(), ast_waitstream(), ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_yday.

Referenced by say_datetime_from_now().

08208 {
08209    int res=0;
08210    int daydiff;
08211    struct ast_tm tm;
08212    struct ast_tm now;
08213    struct timeval when = { t, 0 }, nowt = ast_tvnow();
08214    char fn[256];
08215 
08216    ast_localtime(&when, &tm, NULL);
08217    ast_localtime(&nowt, &now, NULL);
08218    daydiff = now.tm_yday - tm.tm_yday;
08219    if ((daydiff < 0) || (daydiff > 6)) {
08220       /* Day of month and month */
08221       if (!res)
08222          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
08223       if (!res) {
08224          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
08225          res = ast_streamfile(chan, fn, lang);
08226          if (!res)
08227             res = ast_waitstream(chan, ints);
08228       }
08229 
08230    } else if (daydiff) {
08231       /* Just what day of the week */
08232       if (!res) {
08233          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
08234          res = ast_streamfile(chan, fn, lang);
08235          if (!res)
08236             res = ast_waitstream(chan, ints);
08237       }
08238    } /* Otherwise, it was today */
08239    if (!res)
08240       res = ast_say_time(chan, t, ints, lang);
08241 
08242    return res;
08243 }

int ast_say_datetime_from_now_pt ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Portuguese syntax.

Definition at line 7150 of file say.c.

References ast_copy_string(), ast_localtime(), ast_say_number(), ast_say_time, ast_tvnow(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_mon, ast_tm::tm_wday, ast_tm::tm_yday, and wait_file().

Referenced by say_datetime_from_now().

07151 {
07152    int res=0;
07153    int daydiff;
07154    struct ast_tm tm;
07155    struct ast_tm now;
07156    struct timeval nowtv = ast_tvnow(), when = { t, 0 };
07157    char fn[256];
07158 
07159    ast_localtime(&when, &tm, NULL);
07160    ast_localtime(&nowtv, &now, NULL);
07161    daydiff = now.tm_yday - tm.tm_yday;
07162    if ((daydiff < 0) || (daydiff > 6)) {
07163       /* Day of month and month */
07164       if (!res)
07165          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
07166       if (!res)
07167          res = wait_file(chan, ints, "digits/pt-de", lang);
07168       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
07169       if (!res)
07170          res = wait_file(chan, ints, fn, lang);
07171    
07172    } else if (daydiff) {
07173       /* Just what day of the week */
07174       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
07175       if (!res)
07176          res = wait_file(chan, ints, fn, lang);
07177    }  /* Otherwise, it was today */
07178    if (!strcasecmp(lang, "pt_BR")) {
07179       if (tm.tm_hour > 1) {
07180          ast_copy_string(fn, "digits/pt-as", sizeof(fn));
07181       } else {
07182          ast_copy_string(fn, "digits/pt-a", sizeof(fn));
07183       }
07184       if (!res)
07185          res = wait_file(chan, ints, fn, lang);
07186    } else {
07187       ast_copy_string(fn, "digits/pt-ah", sizeof(fn));
07188       if (!res)
07189          res = wait_file(chan, ints, fn, lang);
07190       if (tm.tm_hour != 1)
07191       if (!res)
07192          res = wait_file(chan, ints, "digits/pt-sss", lang);
07193       if (!res)
07194          res = ast_say_time(chan, t, ints, lang);
07195    }
07196    return res;
07197 }

static int ast_say_datetime_gr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Greek support.

Definition at line 7462 of file say.c.

References ast_localtime(), ast_say_time_gr(), ast_streamfile(), ast_waitstream(), gr_say_number_female(), ast_tm::tm_mday, ast_tm::tm_mon, and ast_tm::tm_wday.

Referenced by say_datetime().

07463 {
07464    struct timeval when = { t, 0 };
07465    struct ast_tm tm;
07466    char fn[256];
07467    int res = 0;
07468 
07469    ast_localtime(&when, &tm, NULL);
07470 
07471    /* W E E K - D A Y */
07472    if (!res) {
07473       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
07474       res = ast_streamfile(chan, fn, lang);
07475       if (!res)
07476          res = ast_waitstream(chan, ints);
07477    }
07478    /* D A Y */
07479    if (!res) {
07480       gr_say_number_female(tm.tm_mday, chan, ints, lang);
07481    }
07482    /* M O N T H */
07483    if (!res) {
07484       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
07485       res = ast_streamfile(chan, fn, lang);
07486       if (!res)
07487          res = ast_waitstream(chan, ints);
07488    }
07489 
07490    res = ast_say_time_gr(chan, t, ints, lang);
07491    return res;
07492 }

int ast_say_datetime_he ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Hebrew syntax.

Definition at line 6984 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_datetime().

06985 {
06986    struct timeval when = { t, 0 };
06987    struct ast_tm tm;
06988    char fn[256];
06989    int res = 0;
06990    int hour;
06991 
06992    ast_localtime(&when, &tm, NULL);
06993    if (!res) {
06994       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
06995       res = ast_streamfile(chan, fn, lang);
06996       if (!res) {
06997          res = ast_waitstream(chan, ints);
06998       }
06999    }
07000    if (!res) {
07001       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
07002       res = ast_streamfile(chan, fn, lang);
07003       if (!res) {
07004          res = ast_waitstream(chan, ints);
07005       }
07006    }
07007    if (!res) {
07008       res = ast_say_number(chan, tm.tm_mday, ints, lang, "f");
07009    }
07010 
07011    hour = tm.tm_hour;
07012    if (!hour) {
07013       hour = 12;
07014    }
07015 
07016    if (!res) {
07017       res = ast_say_number(chan, hour, ints, lang, "f");
07018    }
07019 
07020    if (tm.tm_min > 9) {
07021       if (!res) {
07022          res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
07023       }
07024    } else if (tm.tm_min) {
07025       if (!res) {
07026          /* say a leading zero if needed */
07027          res = ast_say_number(chan, 0, ints, lang, "f");
07028       }
07029       if (!res) {
07030          res = ast_waitstream(chan, ints);
07031       }
07032       if (!res) {
07033          res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
07034       }
07035    } else {
07036       if (!res) {
07037          res = ast_waitstream(chan, ints);
07038       }
07039    }
07040    if (!res) {
07041       res = ast_waitstream(chan, ints);
07042    }
07043    if (!res) {
07044       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, "f");
07045    }
07046    return res;
07047 }

int ast_say_datetime_hu ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Hungarian syntax.

Definition at line 6726 of file say.c.

References ast_localtime(), ast_say_date, and ast_say_time.

Referenced by say_datetime().

06727 {
06728    struct timeval when = { t, 0 };
06729    struct ast_tm tm;
06730    int res = 0;
06731 
06732    ast_localtime(&when, &tm, NULL);
06733    res = ast_say_date(chan, t, ints, lang);
06734    if (!res) 
06735       ast_say_time(chan, t, ints, lang);
06736    return res;
06737 }

static int ast_say_datetime_ka ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Georgian syntax. Say date, then say time.

Definition at line 8189 of file say.c.

References ast_localtime(), ast_say_date, and ast_say_time.

Referenced by say_datetime().

08190 {
08191    struct timeval when = { t, 0 };
08192    struct ast_tm tm;
08193    int res = 0;
08194 
08195    ast_localtime(&when, &tm, NULL);
08196    res = ast_say_date(chan, t, ints, lang);
08197    if (!res)
08198       ast_say_time(chan, t, ints, lang);
08199    return res;
08200 
08201 }

int ast_say_datetime_nl ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Dutch syntax.

Definition at line 6781 of file say.c.

References ast_localtime(), ast_say_date, ast_say_time, ast_streamfile(), and ast_waitstream().

Referenced by say_datetime().

06782 {
06783    struct timeval when = { t, 0 };
06784    struct ast_tm tm;
06785    int res = 0;
06786 
06787    ast_localtime(&when, &tm, NULL);
06788    res = ast_say_date(chan, t, ints, lang);
06789    if (!res) {
06790       res = ast_streamfile(chan, "digits/nl-om", lang);
06791       if (!res)
06792          res = ast_waitstream(chan, ints);
06793    }
06794    if (!res) 
06795       ast_say_time(chan, t, ints, lang);
06796    return res;
06797 }

int ast_say_datetime_pt ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Portuguese syntax.

Definition at line 6800 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_datetime().

06801 {
06802    struct timeval when = { t, 0 };
06803    struct ast_tm tm;
06804    char fn[256];
06805    int res = 0;
06806    int hour, pm=0;
06807 
06808    ast_localtime(&when, &tm, NULL);
06809    if (!res) {
06810       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
06811       res = ast_streamfile(chan, fn, lang);
06812       if (!res)
06813          res = ast_waitstream(chan, ints);
06814    }
06815    if (!res) {
06816       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
06817       res = ast_streamfile(chan, fn, lang);
06818       if (!res)
06819          res = ast_waitstream(chan, ints);
06820    }
06821    if (!res)
06822       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
06823 
06824    hour = tm.tm_hour;
06825    if (!hour)
06826       hour = 12;
06827    else if (hour == 12)
06828       pm = 1;
06829    else if (hour > 12) {
06830       hour -= 12;
06831       pm = 1;
06832    }
06833    if (!res)
06834       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06835 
06836    if (tm.tm_min > 9) {
06837       if (!res)
06838          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06839    } else if (tm.tm_min) {
06840       if (!res)
06841          res = ast_streamfile(chan, "digits/oh", lang);
06842       if (!res)
06843          res = ast_waitstream(chan, ints);
06844       if (!res)
06845          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06846    } else {
06847       if (!res)
06848          res = ast_streamfile(chan, "digits/oclock", lang);
06849       if (!res)
06850          res = ast_waitstream(chan, ints);
06851    }
06852    if (pm) {
06853       if (!res)
06854          res = ast_streamfile(chan, "digits/p-m", lang);
06855    } else {
06856       if (!res)
06857          res = ast_streamfile(chan, "digits/a-m", lang);
06858    }
06859    if (!res)
06860       res = ast_waitstream(chan, ints);
06861    if (!res)
06862       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
06863    return res;
06864 }

int ast_say_datetime_pt_BR ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Brazilian Portuguese syntax.

Definition at line 6867 of file say.c.

References ast_localtime(), ast_say_date, and ast_say_time.

Referenced by say_datetime().

06868 {
06869    struct timeval when = { t, 0 };
06870    struct ast_tm tm;
06871    int res = 0;
06872 
06873    ast_localtime(&when, &tm, NULL);
06874    res = ast_say_date(chan, t, ints, lang);
06875    if (!res)
06876       res = ast_say_time(chan, t, ints, lang);
06877    return res;
06878 }

int ast_say_datetime_th ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Thai syntax.

Definition at line 6881 of file say.c.

References ast_copy_string(), ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_datetime().

06882 {
06883    struct timeval when = { t, 0 };
06884    struct ast_tm tm;
06885    char fn[256];
06886    int res = 0;
06887    int hour;
06888    ast_localtime(&when, &tm, NULL);
06889    if (!res) {
06890       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
06891       res = ast_streamfile(chan, fn, lang);
06892       if (!res)
06893          res = ast_waitstream(chan, ints);
06894    }
06895    if (!res) {
06896       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
06897       res = ast_streamfile(chan, fn, lang);
06898       if (!res)
06899          res = ast_waitstream(chan, ints);
06900    }
06901    if (!res){
06902       ast_copy_string(fn, "digits/posor", sizeof(fn));
06903       res = ast_streamfile(chan, fn, lang);
06904       res = ast_say_number(chan, tm.tm_year + 1900 + 543, ints, lang, (char *) NULL);
06905    }  
06906    if (!res)
06907       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
06908 
06909    hour = tm.tm_hour;
06910    if (!hour)
06911       hour = 24;
06912    if (!res){
06913       ast_copy_string(fn, "digits/wela", sizeof(fn));
06914       res = ast_streamfile(chan, fn, lang);
06915    }  
06916    if (!res)
06917       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06918    if (!res)
06919       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06920    return res;
06921 }

int ast_say_datetime_zh ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Taiwanese / Chinese syntax.

Definition at line 6924 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_wday, and ast_tm::tm_year.

Referenced by say_datetime().

06925 {
06926    struct timeval when = { t, 0 };
06927    struct ast_tm tm;
06928    char fn[256];
06929    int res = 0;
06930    int hour, pm=0;
06931 
06932    ast_localtime(&when, &tm, NULL);
06933    if (!res)
06934       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
06935    if (!res) {
06936       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
06937       res = ast_streamfile(chan, fn, lang);
06938       if (!res)
06939          res = ast_waitstream(chan, ints);
06940    }
06941    if (!res)
06942       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
06943    if (!res) {
06944       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
06945       res = ast_streamfile(chan, fn, lang);
06946       if (!res)
06947          res = ast_waitstream(chan, ints);
06948    }
06949 
06950    hour = tm.tm_hour;
06951    if (!hour)
06952       hour = 12;
06953    else if (hour == 12)
06954       pm = 1;
06955    else if (hour > 12) {
06956       hour -= 12;
06957       pm = 1;
06958    }
06959    if (pm) {
06960       if (!res)
06961          res = ast_streamfile(chan, "digits/p-m", lang);
06962    } else {
06963       if (!res)
06964          res = ast_streamfile(chan, "digits/a-m", lang);
06965    }
06966    if (!res)
06967       res = ast_waitstream(chan, ints);
06968    if (!res)
06969       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06970    if (!res)
06971       res = ast_streamfile(chan, "digits/oclock", lang);
06972    if (!res)
06973       res = ast_waitstream(chan, ints);
06974    if (!res)
06975       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06976    if (!res)
06977       res = ast_streamfile(chan, "digits/minute", lang);
06978    if (!res)
06979       res = ast_waitstream(chan, ints);
06980    return res;
06981 }

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 
) [static]

ast_say_enumeration_full_da: Danish syntax

Definition at line 2875 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_say_number_full_de(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_enumeration_full().

02876 {
02877    /* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */
02878    int res = 0, t = 0;
02879    char fn[256] = "", fna[256] = "";
02880    char *gender;
02881 
02882    if (options && !strncasecmp(options, "f", 1)) {
02883       gender = "F";
02884    } else if (options && !strncasecmp(options, "n", 1)) {
02885       gender = "N";
02886    } else {
02887       gender = "";
02888    }
02889 
02890    if (!num) 
02891       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02892 
02893    while (!res && num) {
02894       if (num < 0) {
02895          ast_copy_string(fn, "digits/minus", sizeof(fn)); /* kind of senseless for enumerations, but our best effort for error checking */
02896          if ( num > INT_MIN ) {
02897             num = -num;
02898          } else {
02899             num = 0;
02900          }  
02901       } else if (num < 100 && t) {
02902          ast_copy_string(fn, "digits/and", sizeof(fn));
02903          t = 0;
02904       } else if (num < 20) {
02905          snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
02906          num = 0;
02907       } else if (num < 100) {
02908          int ones = num % 10;
02909          if (ones) {
02910             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
02911             num -= ones;
02912          } else {
02913             snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
02914             num = 0;
02915          }
02916       } else if (num == 100 && t == 0) {
02917          snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender);
02918          num = 0;
02919       } else if (num < 1000) {
02920          int hundreds = num / 100;
02921          num = num % 100;
02922          if (hundreds == 1) {
02923             ast_copy_string(fn, "digits/1N", sizeof(fn));
02924          } else {
02925             snprintf(fn, sizeof(fn), "digits/%d", hundreds);
02926          }
02927          if (num) {              
02928             ast_copy_string(fna, "digits/hundred", sizeof(fna));
02929          } else {
02930             snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
02931          }
02932          t = 1;
02933       } else   if (num < 1000000) {
02934          int thousands = num / 1000;
02935          num = num % 1000;
02936          if (thousands == 1) {
02937             if (num) {              
02938                ast_copy_string(fn, "digits/1N", sizeof(fn));
02939                ast_copy_string(fna, "digits/thousand", sizeof(fna));
02940             } else {
02941                if (t) {
02942                   ast_copy_string(fn, "digits/1N", sizeof(fn));
02943                   snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender);
02944                } else {
02945                   snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
02946                }
02947             }
02948          } else {
02949             res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
02950             if (res) {
02951                return res;
02952             }
02953             if (num) {              
02954                ast_copy_string(fn, "digits/thousand", sizeof(fn));
02955             } else {
02956                snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
02957             }
02958          }
02959          t = 1;
02960       } else if (num < 1000000000) {
02961          int millions = num / 1000000;
02962          num = num % 1000000;
02963          if (millions == 1) {
02964             if (num) {              
02965                ast_copy_string(fn, "digits/1F", sizeof(fn));
02966                ast_copy_string(fna, "digits/million", sizeof(fna));
02967             } else {
02968                ast_copy_string(fn, "digits/1N", sizeof(fn));
02969                snprintf(fna, sizeof(fna), "digits/h-million%s", gender);
02970             }
02971          } else {
02972             res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
02973             if (res) {
02974                return res;
02975             }
02976             if (num) {              
02977                ast_copy_string(fn, "digits/millions", sizeof(fn));
02978             } else {
02979                snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
02980             }
02981          }
02982          t = 1;
02983       } else if (num < INT_MAX) {
02984          int billions = num / 1000000000;
02985          num = num % 1000000000;
02986          if (billions == 1) {
02987             if (num) {              
02988                ast_copy_string(fn, "digits/1F", sizeof(fn));
02989                ast_copy_string(fna, "digits/milliard", sizeof(fna));
02990             } else {
02991                ast_copy_string(fn, "digits/1N", sizeof(fn));
02992                snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender);
02993             }
02994          } else {
02995             res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
02996             if (res)
02997                return res;
02998             if (num) {
02999                ast_copy_string(fn, "digits/milliards", sizeof(fna));
03000             } else {
03001                snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender);
03002             }
03003          }
03004          t = 1;
03005       } else if (num == INT_MAX) {
03006          snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
03007          num = 0;
03008       } else {
03009          ast_debug(1, "Number '%d' is too big for me\n", num);
03010          res = -1;
03011       }
03012 
03013       if (!res) {
03014          if (!ast_streamfile(chan, fn, language)) {
03015             if ((audiofd > -1) && (ctrlfd > -1))
03016                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
03017             else
03018                res = ast_waitstream(chan, ints);
03019          }
03020          ast_stopstream(chan);
03021          if (!res) {
03022             if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
03023                if ((audiofd > -1) && (ctrlfd > -1)) {
03024                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
03025                } else {
03026                   res = ast_waitstream(chan, ints);
03027                }
03028             }
03029             ast_stopstream(chan);
03030             strcpy(fna, "");
03031          }
03032       }
03033    }
03034    return res;
03035 }

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 
) [static]

ast_say_enumeration_full_de: German syntax

Definition at line 3038 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_say_number_full_de(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_enumeration_full().

03039 {
03040    /* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */
03041    int res = 0, t = 0;
03042    char fn[256] = "", fna[256] = "";
03043    char *gender;
03044 
03045    if (options && !strncasecmp(options, "f", 1)) {
03046       gender = "F";
03047    } else if (options && !strncasecmp(options, "n", 1)) {
03048       gender = "N";
03049    } else {
03050       gender = "";
03051    }
03052 
03053    if (!num) 
03054       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
03055 
03056    while (!res && num) {
03057       if (num < 0) {
03058          ast_copy_string(fn, "digits/minus", sizeof(fn)); /* kind of senseless for enumerations, but our best effort for error checking */
03059          if ( num > INT_MIN ) {
03060             num = -num;
03061          } else {
03062             num = 0;
03063          }  
03064       } else if (num < 100 && t) {
03065          ast_copy_string(fn, "digits/and", sizeof(fn));
03066          t = 0;
03067       } else if (num < 20) {
03068          snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
03069          num = 0;
03070       } else if (num < 100) {
03071          int ones = num % 10;
03072          if (ones) {
03073             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
03074             num -= ones;
03075          } else {
03076             snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
03077             num = 0;
03078          }
03079       } else if (num == 100 && t == 0) {
03080          snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender);
03081          num = 0;
03082       } else if (num < 1000) {
03083          int hundreds = num / 100;
03084          num = num % 100;
03085          if (hundreds == 1) {
03086             ast_copy_string(fn, "digits/1N", sizeof(fn));
03087          } else {
03088             snprintf(fn, sizeof(fn), "digits/%d", hundreds);
03089          }
03090          if (num) {              
03091             ast_copy_string(fna, "digits/hundred", sizeof(fna));
03092          } else {
03093             snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
03094          }
03095          t = 1;
03096       } else   if (num < 1000000) {
03097          int thousands = num / 1000;
03098          num = num % 1000;
03099          if (thousands == 1) {
03100             if (num) {              
03101                ast_copy_string(fn, "digits/1N", sizeof(fn));
03102                ast_copy_string(fna, "digits/thousand", sizeof(fna));
03103             } else {
03104                if (t) {
03105                   ast_copy_string(fn, "digits/1N", sizeof(fn));
03106                   snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender);
03107                } else {
03108                   snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
03109                }
03110             }
03111          } else {
03112             res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
03113             if (res) {
03114                return res;
03115             }
03116             if (num) {              
03117                ast_copy_string(fn, "digits/thousand", sizeof(fn));
03118             } else {
03119                snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
03120             }
03121          }
03122          t = 1;
03123       } else if (num < 1000000000) {
03124          int millions = num / 1000000;
03125          num = num % 1000000;
03126          if (millions == 1) {
03127             if (num) {              
03128                ast_copy_string(fn, "digits/1F", sizeof(fn));
03129                ast_copy_string(fna, "digits/million", sizeof(fna));
03130             } else {
03131                ast_copy_string(fn, "digits/1N", sizeof(fn));
03132                snprintf(fna, sizeof(fna), "digits/h-million%s", gender);
03133             }
03134          } else {
03135             res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
03136             if (res) {
03137                return res;
03138             }
03139             if (num) {              
03140                ast_copy_string(fn, "digits/millions", sizeof(fn));
03141             } else {
03142                snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
03143             }
03144          }
03145          t = 1;
03146       } else if (num < INT_MAX) {
03147          int billions = num / 1000000000;
03148          num = num % 1000000000;
03149          if (billions == 1) {
03150             if (num) {              
03151                ast_copy_string(fn, "digits/1F", sizeof(fn));
03152                ast_copy_string(fna, "digits/milliard", sizeof(fna));
03153             } else {
03154                ast_copy_string(fn, "digits/1N", sizeof(fn));
03155                snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender);
03156             }
03157          } else {
03158             res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
03159             if (res)
03160                return res;
03161             if (num) {
03162                ast_copy_string(fn, "digits/milliards", sizeof(fna));
03163             } else {
03164                snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender);
03165             }
03166          }
03167          t = 1;
03168       } else if (num == INT_MAX) {
03169          snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
03170          num = 0;
03171       } else {
03172          ast_debug(1, "Number '%d' is too big for me\n", num);
03173          res = -1;
03174       }
03175 
03176       if (!res) {
03177          if (!ast_streamfile(chan, fn, language)) {
03178             if ((audiofd > -1) && (ctrlfd > -1))
03179                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
03180             else
03181                res = ast_waitstream(chan, ints);
03182          }
03183          ast_stopstream(chan);
03184          if (!res) {
03185             if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
03186                if ((audiofd > -1) && (ctrlfd > -1)) {
03187                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
03188                } else {
03189                   res = ast_waitstream(chan, ints);
03190                }
03191             }
03192             ast_stopstream(chan);
03193             strcpy(fna, "");
03194          }
03195       }
03196    }
03197    return res;
03198 }

static int ast_say_enumeration_full_en ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_enumeration_full_en: English syntax

Note:
This is the default syntax, if no other syntax defined in this file is used

Definition at line 2758 of file say.c.

References ast_copy_string(), ast_debug, ast_say_number_full_en(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_enumeration_full().

02759 {
02760    int res = 0, t = 0;
02761    char fn[256] = "";
02762    
02763    while (!res && num) {
02764       if (num < 0) {
02765          ast_copy_string(fn, "digits/minus", sizeof(fn)); /* kind of senseless for enumerations, but our best effort for error checking */
02766          if ( num > INT_MIN ) {
02767             num = -num;
02768          } else {
02769             num = 0;
02770          }  
02771       } else if (num < 20) {
02772          snprintf(fn, sizeof(fn), "digits/h-%d", num);
02773          num = 0;
02774       } else if (num < 100) { 
02775          int tens = num / 10;
02776          num = num % 10;
02777          if (num == 0) {
02778             snprintf(fn, sizeof(fn), "digits/h-%d", (tens * 10));
02779          } else {
02780             snprintf(fn, sizeof(fn), "digits/%d", (tens * 10));
02781          }
02782       } else if (num < 1000) {
02783          int hundreds = num / 100;
02784          num = num % 100;
02785          if (hundreds > 1 || t == 1) {
02786             res = ast_say_number_full_en(chan, hundreds, ints, language, audiofd, ctrlfd);
02787          }        
02788          if (res)
02789             return res;
02790          if (num) {
02791             ast_copy_string(fn, "digits/hundred", sizeof(fn));
02792          } else {
02793             ast_copy_string(fn, "digits/h-hundred", sizeof(fn));
02794          }
02795       } else if (num < 1000000) {
02796          int thousands = num / 1000;
02797          num = num % 1000;
02798          if (thousands > 1 || t == 1) {
02799             res = ast_say_number_full_en(chan, thousands, ints, language, audiofd, ctrlfd);
02800          }
02801          if (res)
02802             return res;
02803          if (num) {              
02804             ast_copy_string(fn, "digits/thousand", sizeof(fn));
02805          } else {
02806             ast_copy_string(fn, "digits/h-thousand", sizeof(fn));
02807          }
02808          t = 1;
02809       } else if (num < 1000000000) {
02810          int millions = num / 1000000;
02811          num = num % 1000000;
02812          t = 1;
02813          res = ast_say_number_full_en(chan, millions, ints, language, audiofd, ctrlfd);
02814          if (res)
02815             return res;
02816          if (num) {              
02817             ast_copy_string(fn, "digits/million", sizeof(fn));
02818          } else {
02819             ast_copy_string(fn, "digits/h-million", sizeof(fn));
02820          }
02821       } else if (num < INT_MAX) {
02822          int billions = num / 1000000000;
02823          num = num % 1000000000;
02824          t = 1;
02825          res = ast_say_number_full_en(chan, billions, ints, language, audiofd, ctrlfd);
02826          if (res)
02827             return res;
02828          if (num) {
02829             ast_copy_string(fn, "digits/billion", sizeof(fn));
02830          } else {
02831             ast_copy_string(fn, "digits/h-billion", sizeof(fn));
02832          }
02833       } else if (num == INT_MAX) {
02834          ast_copy_string(fn, "digits/h-last", sizeof(fn));
02835          num = 0;
02836       } else {
02837          ast_debug(1, "Number '%d' is too big for me\n", num);
02838          res = -1;
02839       }
02840 
02841       if (!res) {
02842          if (!ast_streamfile(chan, fn, language)) {
02843             if ((audiofd > -1) && (ctrlfd > -1)) {
02844                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02845             } else {
02846                res = ast_waitstream(chan, ints);
02847             }
02848          }
02849          ast_stopstream(chan);
02850       }
02851    }
02852    return res;
02853 }

static int ast_say_enumeration_full_he ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 3200 of file say.c.

References ast_debug, ast_say_number_full_he(), ast_stopstream(), ast_streamfile(), ast_verb, ast_waitstream(), and ast_waitstream_full().

Referenced by say_enumeration_full().

03201 {
03202    int res = 0;
03203    char fn[256] = "";
03204    int mf = -1;            /* +1 = Masculin; -1 = Feminin */
03205    ast_verb(3, "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options);
03206 
03207    if (options && !strncasecmp(options, "m", 1)) {
03208       mf = -1;
03209    }
03210 
03211    ast_verb(3, "ast_say_digits_full: num: %d, options=\"%s\", mf=%d\n", num, options, mf);
03212 
03213    while (!res && num) {
03214       if (num < 0) {
03215          snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
03216          if (num > INT_MIN) {
03217             num = -num;
03218          } else {
03219             num = 0;
03220          }
03221       } else if (num < 21) {
03222          if (mf < 0) {
03223             if (num < 10) {
03224                snprintf(fn, sizeof(fn), "digits/f-0%d", num);
03225             } else {
03226                snprintf(fn, sizeof(fn), "digits/f-%d", num);
03227             }
03228          } else {
03229             if (num < 10) {
03230                snprintf(fn, sizeof(fn), "digits/m-0%d", num);
03231             } else {
03232                snprintf(fn, sizeof(fn), "digits/m-%d", num);
03233             }
03234          }
03235          num = 0;
03236       } else if ((num < 100) && num >= 20) {
03237          snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10);
03238          num = num % 10;
03239       } else if ((num >= 100) && (num < 1000)) {
03240          int tmpnum = num / 100;
03241          snprintf(fn, sizeof(fn), "digits/%d00", tmpnum);
03242          num = num - (tmpnum * 100);
03243       } else if ((num >= 1000) && (num < 10000)) {
03244          int tmpnum = num / 1000;
03245          snprintf(fn, sizeof(fn), "digits/%dk", tmpnum);
03246          num = num - (tmpnum * 1000);
03247       } else if (num < 20000) {
03248          snprintf(fn, sizeof(fn), "digits/m-%d", (num / 1000));
03249          num = num % 1000;
03250       } else if (num < 1000000) {
03251          res = ast_say_number_full_he(chan, num / 1000, ints, language, "m", audiofd, ctrlfd);
03252          if (res) {
03253             return res;
03254          }
03255          snprintf(fn, sizeof(fn), "digits/1k");
03256          num = num % 1000;
03257       } else if (num < 2000000) {
03258          snprintf(fn, sizeof(fn), "digits/1m");
03259          num = num % 1000000;
03260       } else if (num < 3000000) {
03261          snprintf(fn, sizeof(fn), "digits/2m");
03262          num = num - 2000000;
03263       } else if (num < 1000000000) {
03264          res = ast_say_number_full_he(chan, num / 1000000, ints, language, "m", audiofd, ctrlfd);
03265          if (res) {
03266             return res;
03267          }
03268          snprintf(fn, sizeof(fn), "digits/1m");
03269          num = num % 1000000;
03270       } else {
03271          ast_debug(1, "Number '%d' is too big for me\n", num);
03272          res = -1;
03273       }
03274       if (!res) {
03275          if (!ast_streamfile(chan, fn, language)) {
03276             if ((audiofd > -1) && (ctrlfd > -1)) {
03277                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
03278             } else {
03279                res = ast_waitstream(chan, ints);
03280             }
03281          }
03282          ast_stopstream(chan);
03283       }
03284    }
03285    return res;
03286 }

static int ast_say_enumeration_full_vi ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 2855 of file say.c.

References ast_copy_string(), ast_say_number_full_vi(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_enumeration_full().

02856 {
02857    int res = 0;
02858    char fn[256] = "";
02859    ast_copy_string(fn, "digits/h", sizeof(fn));
02860    if (!res) {
02861       if (!ast_streamfile(chan, fn, language)) {
02862          if ((audiofd > -1) && (ctrlfd > -1)) {
02863             res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02864          } else {
02865             res = ast_waitstream(chan, ints);
02866          }
02867       }
02868       ast_stopstream(chan);
02869    }
02870 
02871    return ast_say_number_full_vi(chan, num, ints, language, audiofd, ctrlfd);
02872 }

static int ast_say_number_full_cs ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_cs: Czech syntax

files needed:

  • 1m,2m - gender male
  • 1w,2w - gender female
  • 3,4,...,20
  • 30,40,...,90

  • hundereds - 100 - sto, 200 - 2ste, 300,400 3,4sta, 500,600,...,900 5,6,...9set

for each number 10^(3n + 3) exist 3 files represented as: 1 tousand = jeden tisic = 1_E3 2,3,4 tousands = dva,tri,ctyri tisice = 2-3_E3 5,6,... tousands = pet,sest,... tisic = 5_E3

million = _E6 miliard = _E9 etc...

tousand, milion are gender male, so 1 and 2 is 1m 2m miliard is gender female, so 1 and 2 is 1w 2w

Definition at line 608 of file say.c.

References ast_copy_string(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and exp10_int().

Referenced by say_number_full().

00609 {
00610    int res = 0;
00611    int playh = 0;
00612    char fn[256] = "";
00613    
00614    int hundered = 0;
00615    int left = 0;
00616    int length = 0;
00617    
00618    /* options - w = woman, m = man, n = neutral. Defaultl is woman */
00619    if (!options)
00620       options = "w";
00621    
00622    if (!num) 
00623       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
00624    
00625    while (!res && (num || playh)) {
00626       if (num < 0) {
00627          ast_copy_string(fn, "digits/minus", sizeof(fn));
00628          if ( num > INT_MIN ) {
00629             num = -num;
00630          } else {
00631             num = 0;
00632          }  
00633       } else if (num < 3 ) {
00634          snprintf(fn, sizeof(fn), "digits/%d%c", num, options[0]);
00635          playh = 0;
00636          num = 0;
00637       } else if (num < 20) {
00638          snprintf(fn, sizeof(fn), "digits/%d", num);
00639          playh = 0;
00640          num = 0;
00641       } else if (num < 100) {
00642          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
00643          num %= 10;
00644       } else if (num < 1000) {
00645          hundered = num / 100;
00646          if ( hundered == 1 ) {
00647             ast_copy_string(fn, "digits/1sto", sizeof(fn));
00648          } else if ( hundered == 2 ) {
00649             ast_copy_string(fn, "digits/2ste", sizeof(fn));
00650          } else {
00651             res = ast_say_number_full_cs(chan, hundered, ints, language, options, audiofd, ctrlfd);
00652             if (res)
00653                return res;
00654             if (hundered == 3 || hundered == 4) {  
00655                ast_copy_string(fn, "digits/sta", sizeof(fn));
00656             } else if ( hundered > 4 ) {
00657                ast_copy_string(fn, "digits/set", sizeof(fn));
00658             }
00659          }
00660          num -= (hundered * 100);
00661       } else { /* num > 1000 */
00662          length = (int)log10(num)+1;  
00663          while ( (length % 3 ) != 1 ) {
00664             length--;      
00665          }
00666          left = num / (exp10_int(length-1));
00667          if ( left == 2 ) {  
00668             switch (length-1) {
00669                case 9: options = "w";  /* 1,000,000,000 gender female */
00670                   break;
00671                default : options = "m"; /* others are male */
00672             }
00673          }
00674          if ( left > 1 )   { /* we don't say "one thousand" but only thousand */
00675             res = ast_say_number_full_cs(chan, left, ints, language, options, audiofd, ctrlfd);
00676             if (res) 
00677                return res;
00678          }
00679          if ( left >= 5 ) { /* >= 5 have the same declesion */
00680             snprintf(fn, sizeof(fn), "digits/5_E%d", length - 1); 
00681          } else if ( left >= 2 && left <= 4 ) {
00682             snprintf(fn, sizeof(fn), "digits/2-4_E%d", length - 1);
00683          } else { /* left == 1 */
00684             snprintf(fn, sizeof(fn), "digits/1_E%d", length - 1);
00685          }
00686          num -= left * (exp10_int(length-1));
00687       }
00688       if (!res) {
00689          if (!ast_streamfile(chan, fn, language)) {
00690             if ((audiofd > -1) && (ctrlfd > -1)) {
00691                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00692             } else {
00693                res = ast_waitstream(chan, ints);
00694             }
00695          }
00696          ast_stopstream(chan);
00697       }
00698    }
00699    return res; 
00700 }

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 
) [static]

ast_say_number_full_da: Danish syntax New files:

  • In addition to English, the following sounds are required: "1N", "millions", "and" and "1-and" through "9-and"

Definition at line 706 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

00707 {
00708    int res = 0;
00709    int playh = 0;
00710    int playa = 0;
00711    int cn = 1;    /* +1 = commune; -1 = neuter */
00712    char fn[256] = "";
00713    if (!num) 
00714       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
00715 
00716    if (options && !strncasecmp(options, "n", 1)) cn = -1;
00717 
00718    while (!res && (num || playh || playa )) {
00719       /* The grammar for Danish numbers is the same as for English except
00720       * for the following:
00721       * - 1 exists in both commune ("en", file "1N") and neuter ("et", file "1")
00722       * - numbers 20 through 99 are said in reverse order, i.e. 21 is
00723       *   "one-and twenty" and 68 is "eight-and sixty".
00724       * - "million" is different in singular and plural form
00725       * - numbers > 1000 with zero as the third digit from last have an
00726       *   "and" before the last two digits, i.e. 2034 is "two thousand and
00727       *   four-and thirty" and 1000012 is "one million and twelve".
00728       */
00729       if (num < 0) {
00730          ast_copy_string(fn, "digits/minus", sizeof(fn));
00731          if ( num > INT_MIN ) {
00732             num = -num;
00733          } else {
00734             num = 0;
00735          }  
00736       } else if (playh) {
00737          ast_copy_string(fn, "digits/hundred", sizeof(fn));
00738          playh = 0;
00739       } else if (playa) {
00740          ast_copy_string(fn, "digits/and", sizeof(fn));
00741          playa = 0;
00742       } else if (num == 1 && cn == -1) {
00743          ast_copy_string(fn, "digits/1N", sizeof(fn));
00744          num = 0;
00745       } else if (num < 20) {
00746          snprintf(fn, sizeof(fn), "digits/%d", num);
00747          num = 0;
00748       } else if (num < 100) {
00749          int ones = num % 10;
00750          if (ones) {
00751             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
00752             num -= ones;
00753          } else {
00754             snprintf(fn, sizeof(fn), "digits/%d", num);
00755             num = 0;
00756          }
00757       } else {
00758          if (num < 1000) {
00759             int hundreds = num / 100;
00760             if (hundreds == 1)
00761                ast_copy_string(fn, "digits/1N", sizeof(fn));
00762             else
00763                snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
00764 
00765             playh++;
00766             num -= 100 * hundreds;
00767             if (num)
00768                playa++;
00769 
00770          } else {
00771             if (num < 1000000) {
00772                res = ast_say_number_full_da(chan, num / 1000, ints, language, "n", audiofd, ctrlfd);
00773                if (res)
00774                   return res;
00775                num = num % 1000;
00776                ast_copy_string(fn, "digits/thousand", sizeof(fn));
00777             } else {
00778                if (num < 1000000000) {
00779                   int millions = num / 1000000;
00780                   res = ast_say_number_full_da(chan, millions, ints, language, "c", audiofd, ctrlfd);
00781                   if (res)
00782                      return res;
00783                   if (millions == 1)
00784                      ast_copy_string(fn, "digits/million", sizeof(fn));
00785                   else
00786                      ast_copy_string(fn, "digits/millions", sizeof(fn));
00787                   num = num % 1000000;
00788                } else {
00789                   ast_debug(1, "Number '%d' is too big for me\n", num);
00790                   res = -1;
00791                }
00792             }
00793             if (num && num < 100)
00794                playa++;
00795          }
00796       }
00797       if (!res) {
00798          if (!ast_streamfile(chan, fn, language)) {
00799             if ((audiofd > -1) && (ctrlfd > -1))
00800                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00801             else
00802                res = ast_waitstream(chan, ints);
00803          }
00804          ast_stopstream(chan);
00805       }
00806    }
00807    return res;
00808 }

static int ast_say_number_full_de ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_de: German syntax

New files: In addition to English, the following sounds are required:

  • "millions"
  • "1-and" through "9-and"
  • "1F" (eine)
  • "1N" (ein)
  • NB "1" is recorded as 'eins'

Definition at line 820 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), and say_number_full().

00821 {
00822    int res = 0, t = 0;
00823    int mf = 1;                            /* +1 = male and neuter; -1 = female */
00824    char fn[256] = "";
00825    char fna[256] = "";
00826    if (!num) 
00827       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
00828 
00829    if (options && (!strncasecmp(options, "f", 1)))
00830       mf = -1;
00831 
00832    while (!res && num) {
00833       /* The grammar for German numbers is the same as for English except
00834       * for the following:
00835       * - numbers 20 through 99 are said in reverse order, i.e. 21 is
00836       *   "one-and twenty" and 68 is "eight-and sixty".
00837       * - "one" varies according to gender
00838       * - 100 is 'hundert', however all other instances are 'ein hundert'
00839       * - 1000 is 'tausend', however all other instances are 'ein tausend'
00840       * - 1000000 is always 'eine million'
00841       * - "million" is different in singular and plural form
00842       * - 'and' should not go between a hundreds place value and any
00843       *   tens/ones place values that follows it. i.e 136 is ein hundert
00844       *   sechs und dreizig, not ein hundert und sechs und dreizig.
00845       */
00846       if (num < 0) {
00847          ast_copy_string(fn, "digits/minus", sizeof(fn));
00848          if ( num > INT_MIN ) {
00849             num = -num;
00850          } else {
00851             num = 0;
00852          }
00853       } else if (num == 1 && mf == -1) {
00854          snprintf(fn, sizeof(fn), "digits/%dF", num);
00855          num = 0;
00856       } else if (num < 20) {
00857          snprintf(fn, sizeof(fn), "digits/%d", num);
00858          num = 0;
00859       } else if (num < 100) {
00860          int ones = num % 10;
00861          if (ones) {
00862             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
00863             num -= ones;
00864          } else {
00865             snprintf(fn, sizeof(fn), "digits/%d", num);
00866             num = 0;
00867          }
00868       } else if (num == 100 && t == 0) {
00869          ast_copy_string(fn, "digits/hundred", sizeof(fn));
00870          num = 0;
00871       } else if (num < 1000) {
00872          int hundreds = num / 100;
00873          num = num % 100;
00874          if (hundreds == 1) {
00875             ast_copy_string(fn, "digits/1N", sizeof(fn));
00876          } else {
00877             snprintf(fn, sizeof(fn), "digits/%d", hundreds);
00878          }
00879          ast_copy_string(fna, "digits/hundred", sizeof(fna));
00880       } else if (num == 1000 && t == 0) {
00881          ast_copy_string(fn, "digits/thousand", sizeof(fn));
00882          num = 0;
00883       } else   if (num < 1000000) {
00884          int thousands = num / 1000;
00885          num = num % 1000;
00886          t = 1;
00887          if (thousands == 1) {
00888             ast_copy_string(fn, "digits/1N", sizeof(fn));
00889             ast_copy_string(fna, "digits/thousand", sizeof(fna));
00890          } else {
00891             res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
00892             if (res)
00893                return res;
00894             ast_copy_string(fn, "digits/thousand", sizeof(fn));
00895          }
00896       } else if (num < 1000000000) {
00897          int millions = num / 1000000;
00898          num = num % 1000000;
00899          t = 1;
00900          if (millions == 1) {
00901             ast_copy_string(fn, "digits/1F", sizeof(fn));
00902             ast_copy_string(fna, "digits/million", sizeof(fna));
00903          } else {
00904             res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
00905             if (res)
00906                return res;
00907             ast_copy_string(fn, "digits/millions", sizeof(fn));
00908          }
00909       } else if (num <= INT_MAX) {
00910          int billions = num / 1000000000;
00911          num = num % 1000000000;
00912          t = 1;
00913          if (billions == 1) {
00914             ast_copy_string(fn, "digits/1F", sizeof(fn));
00915             ast_copy_string(fna, "digits/milliard", sizeof(fna));
00916          } else {
00917             res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
00918             if (res) {
00919                return res;
00920             }
00921             ast_copy_string(fn, "digits/milliards", sizeof(fn));
00922          }
00923       } else {
00924          ast_debug(1, "Number '%d' is too big for me\n", num);
00925          res = -1;
00926       }
00927       if (!res) {
00928          if (!ast_streamfile(chan, fn, language)) {
00929             if ((audiofd > -1) && (ctrlfd > -1))
00930                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00931             else
00932                res = ast_waitstream(chan, ints);
00933          }
00934          ast_stopstream(chan);
00935          if (!res) {
00936             if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
00937                if ((audiofd > -1) && (ctrlfd > -1))
00938                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00939                else
00940                   res = ast_waitstream(chan, ints);
00941             }
00942             ast_stopstream(chan);
00943             strcpy(fna, "");
00944          }
00945       }
00946    }
00947    return res;
00948 }

static int ast_say_number_full_en ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_en: English syntax

Note:
This is the default syntax, if no other syntax defined in this file is used

Definition at line 514 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by ast_say_enumeration_full_en(), and say_number_full().

00515 {
00516    int res = 0;
00517    int playh = 0;
00518    char fn[256] = "";
00519    if (!num) 
00520       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
00521 
00522    while (!res && (num || playh)) {
00523       if (num < 0) {
00524          ast_copy_string(fn, "digits/minus", sizeof(fn));
00525          if ( num > INT_MIN ) {
00526             num = -num;
00527          } else {
00528             num = 0;
00529          }  
00530       } else if (playh) {
00531          ast_copy_string(fn, "digits/hundred", sizeof(fn));
00532          playh = 0;
00533       } else   if (num < 20) {
00534          snprintf(fn, sizeof(fn), "digits/%d", num);
00535          num = 0;
00536       } else   if (num < 100) {
00537          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
00538          num %= 10;
00539       } else {
00540          if (num < 1000){
00541             snprintf(fn, sizeof(fn), "digits/%d", (num/100));
00542             playh++;
00543             num %= 100;
00544          } else {
00545             if (num < 1000000) { /* 1,000,000 */
00546                res = ast_say_number_full_en(chan, num / 1000, ints, language, audiofd, ctrlfd);
00547                if (res)
00548                   return res;
00549                num %= 1000;
00550                snprintf(fn, sizeof(fn), "digits/thousand");
00551             } else {
00552                if (num < 1000000000) { /* 1,000,000,000 */
00553                   res = ast_say_number_full_en(chan, num / 1000000, ints, language, audiofd, ctrlfd);
00554                   if (res)
00555                      return res;
00556                   num %= 1000000;
00557                   ast_copy_string(fn, "digits/million", sizeof(fn));
00558                } else {
00559                   ast_debug(1, "Number '%d' is too big for me\n", num);
00560                   res = -1;
00561                }
00562             }
00563          }
00564       }
00565       if (!res) {
00566          if (!ast_streamfile(chan, fn, language)) {
00567             if ((audiofd  > -1) && (ctrlfd > -1))
00568                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00569             else
00570                res = ast_waitstream(chan, ints);
00571          }
00572          ast_stopstream(chan);
00573       }
00574    }
00575    return res;
00576 }

static int ast_say_number_full_en_GB ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_en_GB: British syntax New files:

  • In addition to American English, the following sounds are required: "and"

Definition at line 954 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

00955 {
00956    int res = 0;
00957    int playh = 0;
00958    int playa = 0;
00959    char fn[256] = "";
00960    if (!num) 
00961       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
00962 
00963    while (!res && (num || playh || playa )) {
00964       if (num < 0) {
00965          ast_copy_string(fn, "digits/minus", sizeof(fn));
00966          if ( num > INT_MIN ) {
00967             num = -num;
00968          } else {
00969             num = 0;
00970          }  
00971       } else if (playh) {
00972          ast_copy_string(fn, "digits/hundred", sizeof(fn));
00973          playh = 0;
00974       } else if (playa) {
00975          ast_copy_string(fn, "digits/and", sizeof(fn));
00976          playa = 0;
00977       } else if (num < 20) {
00978          snprintf(fn, sizeof(fn), "digits/%d", num);
00979          num = 0;
00980       } else if (num < 100) {
00981          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
00982          num %= 10;
00983       } else if (num < 1000) {
00984          int hundreds = num / 100;
00985          snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
00986 
00987          playh++;
00988          num -= 100 * hundreds;
00989          if (num)
00990             playa++;
00991       } else if (num < 1000000) {
00992          res = ast_say_number_full_en_GB(chan, num / 1000, ints, language, audiofd, ctrlfd);
00993          if (res)
00994             return res;
00995          ast_copy_string(fn, "digits/thousand", sizeof(fn));
00996          num %= 1000;
00997          if (num && num < 100)
00998             playa++;
00999       } else if (num < 1000000000) {
01000             int millions = num / 1000000;
01001             res = ast_say_number_full_en_GB(chan, millions, ints, language, audiofd, ctrlfd);
01002             if (res)
01003                return res;
01004             ast_copy_string(fn, "digits/million", sizeof(fn));
01005             num %= 1000000;
01006             if (num && num < 100)
01007                playa++;
01008       } else {
01009             ast_debug(1, "Number '%d' is too big for me\n", num);
01010             res = -1;
01011       }
01012 
01013       if (!res) {
01014          if (!ast_streamfile(chan, fn, language)) {
01015             if ((audiofd > -1) && (ctrlfd > -1))
01016                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01017             else
01018                res = ast_waitstream(chan, ints);
01019          }
01020          ast_stopstream(chan);
01021       }
01022    }
01023    return res;
01024 }

static int ast_say_number_full_es ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_es: Spanish syntax

New files: Requires a few new audios: 1F.gsm: feminine 'una' 21.gsm thru 29.gsm, cien.gsm, mil.gsm, millon.gsm, millones.gsm, 100.gsm, 200.gsm, 300.gsm, 400.gsm, 500.gsm, 600.gsm, 700.gsm, 800.gsm, 900.gsm, y.gsm

Definition at line 1033 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

01034 {
01035    int res = 0;
01036    int playa = 0;
01037    int mf = 0;                            /* +1 = male; -1 = female */
01038    char fn[256] = "";
01039    if (!num) 
01040       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
01041 
01042    if (options) {
01043       if (!strncasecmp(options, "f", 1))
01044          mf = -1;
01045       else if (!strncasecmp(options, "m", 1))
01046          mf = 1;
01047    }
01048 
01049    while (!res && num) {
01050       if (num < 0) {
01051          ast_copy_string(fn, "digits/minus", sizeof(fn));
01052          if ( num > INT_MIN ) {
01053             num = -num;
01054          } else {
01055             num = 0;
01056          }  
01057       } else if (playa) {
01058          ast_copy_string(fn, "digits/and", sizeof(fn));
01059          playa = 0;
01060       } else if (num == 1) {
01061          if (mf < 0)
01062             snprintf(fn, sizeof(fn), "digits/%dF", num);
01063          else if (mf > 0)
01064             snprintf(fn, sizeof(fn), "digits/%dM", num);
01065          else 
01066             snprintf(fn, sizeof(fn), "digits/%d", num);
01067          num = 0;
01068       } else if (num < 31) {
01069          snprintf(fn, sizeof(fn), "digits/%d", num);
01070          num = 0;
01071       } else if (num < 100) {
01072          snprintf(fn, sizeof(fn), "digits/%d", (num/10)*10);
01073          num %= 10;
01074          if (num)
01075             playa++;
01076       } else if (num == 100) {
01077          ast_copy_string(fn, "digits/100", sizeof(fn));
01078          num = 0;
01079       } else if (num < 200) {
01080          ast_copy_string(fn, "digits/100-and", sizeof(fn));
01081          num -= 100;
01082       } else {
01083          if (num < 1000) {
01084             snprintf(fn, sizeof(fn), "digits/%d", (num/100)*100);
01085             num %= 100;
01086          } else if (num < 2000) {
01087             num %= 1000;
01088             ast_copy_string(fn, "digits/thousand", sizeof(fn));
01089          } else {
01090             if (num < 1000000) {
01091                res = ast_say_number_full_es(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
01092                if (res)
01093                   return res;
01094                num %= 1000;
01095                ast_copy_string(fn, "digits/thousand", sizeof(fn));
01096             } else {
01097                if (num < 2147483640) {
01098                   if ((num/1000000) == 1) {
01099                      res = ast_say_number_full_es(chan, num / 1000000, ints, language, "M", audiofd, ctrlfd);
01100                      if (res)
01101                         return res;
01102                      ast_copy_string(fn, "digits/million", sizeof(fn));
01103                   } else {
01104                      res = ast_say_number_full_es(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);
01105                      if (res)
01106                         return res;
01107                      ast_copy_string(fn, "digits/millions", sizeof(fn));
01108                   }
01109                   num %= 1000000;
01110                } else {
01111                   ast_debug(1, "Number '%d' is too big for me\n", num);
01112                   res = -1;
01113                }
01114             }
01115          }
01116       }
01117 
01118       if (!res) {
01119          if (!ast_streamfile(chan, fn, language)) {
01120             if ((audiofd > -1) && (ctrlfd > -1))
01121                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01122             else
01123                res = ast_waitstream(chan, ints);
01124          }
01125          ast_stopstream(chan);
01126 
01127       }
01128 
01129    }
01130    return res;
01131 }

static int ast_say_number_full_fr ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_fr: French syntax Extra sounds needed: 1F: feminin 'une' et: 'and'

Definition at line 1137 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

01138 {
01139    int res = 0;
01140    int playh = 0;
01141    int playa = 0;
01142    int mf = 1;                            /* +1 = male; -1 = female */
01143    char fn[256] = "";
01144    if (!num) 
01145       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
01146    
01147    if (options && !strncasecmp(options, "f", 1))
01148       mf = -1;
01149 
01150    while (!res && (num || playh || playa)) {
01151       if (num < 0) {
01152          ast_copy_string(fn, "digits/minus", sizeof(fn));
01153          if ( num > INT_MIN ) {
01154             num = -num;
01155          } else {
01156             num = 0;
01157          }  
01158       } else if (playh) {
01159          ast_copy_string(fn, "digits/hundred", sizeof(fn));
01160          playh = 0;
01161       } else if (playa) {
01162          ast_copy_string(fn, "digits/et", sizeof(fn));
01163          playa = 0;
01164       } else if (num == 1) {
01165          if (mf < 0)
01166             snprintf(fn, sizeof(fn), "digits/%dF", num);
01167          else
01168             snprintf(fn, sizeof(fn), "digits/%d", num);
01169          num = 0;
01170       } else if (num < 21) {
01171          snprintf(fn, sizeof(fn), "digits/%d", num);
01172          num = 0;
01173       } else if (num < 70) {
01174          snprintf(fn, sizeof(fn), "digits/%d", (num/10)*10);
01175          if ((num % 10) == 1) playa++;
01176          num = num % 10;
01177       } else if (num < 80) {
01178          ast_copy_string(fn, "digits/60", sizeof(fn));
01179          if ((num % 10) == 1) playa++;
01180          num -= 60;
01181       } else if (num < 100) {
01182          ast_copy_string(fn, "digits/80", sizeof(fn));
01183          num = num - 80;
01184       } else if (num < 200) {
01185          ast_copy_string(fn, "digits/hundred", sizeof(fn));
01186          num = num - 100;
01187       } else if (num < 1000) {
01188          snprintf(fn, sizeof(fn), "digits/%d", (num/100));
01189          playh++;
01190          num = num % 100;
01191       } else if (num < 2000) {
01192          ast_copy_string(fn, "digits/thousand", sizeof(fn));
01193          num = num - 1000;
01194       } else if (num < 1000000) {
01195          res = ast_say_number_full_fr(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
01196          if (res)
01197             return res;
01198          ast_copy_string(fn, "digits/thousand", sizeof(fn));
01199          num = num % 1000;
01200       } else   if (num < 1000000000) {
01201          res = ast_say_number_full_fr(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);
01202          if (res)
01203             return res;
01204          ast_copy_string(fn, "digits/million", sizeof(fn));
01205          num = num % 1000000;
01206       } else {
01207          ast_debug(1, "Number '%d' is too big for me\n", num);
01208          res = -1;
01209       }
01210       if (!res) {
01211          if (!ast_streamfile(chan, fn, language)) {
01212             if ((audiofd > -1) && (ctrlfd > -1))
01213                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01214             else
01215                res = ast_waitstream(chan, ints);
01216          }
01217          ast_stopstream(chan);
01218       }
01219    }
01220    return res;
01221 }

static int ast_say_number_full_gr ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

Greek support A list of the files that you need to create -> digits/xilia = "xilia" -> digits/myrio = "ekatomyrio" -> digits/thousands = "xiliades" -> digits/millions = "ektatomyria" -> digits/[1..12] :: A pronunciation of th digits form 1 to 12 e.g. "tria" -> digits/[10..100] :: A pronunciation of the tens from 10 to 90 e.g. 80 = "ogdonta" Here we must note that we use digits/tens/100 to utter "ekato" and digits/hundred-100 to utter "ekaton" -> digits/hundred-[100...1000] :: A pronunciation of hundreds from 100 to 1000 e.g 400 = "terakosia". Here again we use hundreds/1000 for "xilia" and digits/thousnds for "xiliades".

Definition at line 7289 of file say.c.

References ast_channel_language(), ast_copy_string(), ast_debug, ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by ast_say_date_with_format_gr(), and say_number_full().

07290 {
07291    int res = 0;
07292    char fn[256] = "";
07293    int i=0;
07294 
07295  
07296    if (!num) {
07297       ast_copy_string(fn, "digits/0", sizeof(fn));
07298       res = ast_streamfile(chan, fn, ast_channel_language(chan));
07299       if (!res)
07300          return  ast_waitstream(chan, ints);
07301    }
07302 
07303    while (!res && num ) {
07304       i++;
07305       if (num < 13) {
07306          snprintf(fn, sizeof(fn), "digits/%d", num);
07307          num = 0;
07308       } else if (num <= 100) {
07309          /* 13 < num <= 100  */
07310          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
07311          num %= 10; 
07312       } else if (num < 200) {
07313          /* 100 < num < 200 */
07314          snprintf(fn, sizeof(fn), "digits/hundred-100");
07315          num %= 100;
07316       } else if (num < 1000) {
07317          /* 200 < num < 1000 */
07318          snprintf(fn, sizeof(fn), "digits/hundred-%d", (num/100)*100);
07319          num %= 100;
07320       } else if (num < 2000){
07321          snprintf(fn, sizeof(fn), "digits/xilia");
07322          num %= 1000;
07323       } else {
07324          /* num >  1000 */
07325          if (num < 1000000) {
07326             res = ast_say_number_full_gr(chan, (num / 1000), ints, ast_channel_language(chan), audiofd, ctrlfd);
07327             if (res)
07328                return res;
07329             num %= 1000;
07330             snprintf(fn, sizeof(fn), "digits/thousands");
07331          }  else {
07332             if (num < 1000000000) { /* 1,000,000,000 */
07333                res = ast_say_number_full_gr(chan, (num / 1000000), ints, ast_channel_language(chan), audiofd, ctrlfd);
07334                if (res)
07335                   return res;
07336                num %= 1000000;
07337                snprintf(fn, sizeof(fn), "digits/millions");
07338             } else {
07339                ast_debug(1, "Number '%d' is too big for me\n", num);
07340                res = -1;
07341             }
07342          }
07343       }
07344       if (!res) {
07345          if (!ast_streamfile(chan, fn, language)) {
07346             if ((audiofd > -1) && (ctrlfd > -1))
07347                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
07348             else
07349                res = ast_waitstream(chan, ints);
07350          }
07351          ast_stopstream(chan);
07352       }
07353    }
07354    return res;
07355 }

static int ast_say_number_full_he ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 1229 of file say.c.

References ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_verb, ast_waitstream(), ast_waitstream_full(), and SAY_NUM_BUF_SIZE.

Referenced by ast_say_date_with_format_he(), ast_say_enumeration_full_he(), ast_say_time_he(), and say_number_full().

01230 {
01231    int res = 0;
01232    int state = 0;          /* no need to save anything */
01233    int mf = -1;            /* +1 = Masculin; -1 = Feminin */
01234    int tmpnum = 0;
01235 
01236    char fn[SAY_NUM_BUF_SIZE] = "";
01237 
01238    ast_verb(3, "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options);
01239 
01240    if (!num) {
01241       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
01242    }
01243    if (options && !strncasecmp(options, "m", 1)) {
01244       mf = 1;
01245    }
01246    ast_verb(3, "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d\n", num, state, options, mf);
01247 
01248    /* Do we have work to do? */
01249    while (!res && (num || (state > 0))) {
01250       /* first type of work: play a second sound. In this loop
01251        * we can only play one sound file at a time. Thus playing
01252        * a second one requires repeating the loop just for the
01253        * second file. The variable 'state' remembers where we were.
01254        * state==0 is the normal mode and it means that we continue
01255        * to check if the number num has yet anything left.
01256        */
01257       ast_verb(3, "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d, tmpnum=%d\n", num, state, options, mf, tmpnum);
01258 
01259       if (state == 1) {
01260          state = 0;
01261       } else if (state == 2) {
01262          if ((num >= 11) && (num < 21)) {
01263             if (mf < 0) {
01264                snprintf(fn, sizeof(fn), "digits/ve");
01265             } else {
01266                snprintf(fn, sizeof(fn), "digits/uu");
01267             }
01268          } else {
01269             switch (num) {
01270             case 1:
01271                snprintf(fn, sizeof(fn), "digits/ve");
01272                break;
01273             case 2:
01274                snprintf(fn, sizeof(fn), "digits/uu");
01275                break;
01276             case 3:
01277                if (mf < 0) {
01278                   snprintf(fn, sizeof(fn), "digits/ve");
01279                } else {
01280                   snprintf(fn, sizeof(fn), "digits/uu");
01281                }
01282                break;
01283             case 4:
01284                snprintf(fn, sizeof(fn), "digits/ve");
01285                break;
01286             case 5:
01287                snprintf(fn, sizeof(fn), "digits/ve");
01288                break;
01289             case 6:
01290                snprintf(fn, sizeof(fn), "digits/ve");
01291                break;
01292             case 7:
01293                snprintf(fn, sizeof(fn), "digits/ve");
01294                break;
01295             case 8:
01296                snprintf(fn, sizeof(fn), "digits/uu");
01297                break;
01298             case 9:
01299                snprintf(fn, sizeof(fn), "digits/ve");
01300                break;
01301             case 10:
01302                snprintf(fn, sizeof(fn), "digits/ve");
01303                break;
01304             }
01305          }
01306          state = 0;
01307       } else if (state == 3) {
01308          snprintf(fn, sizeof(fn), "digits/1k");
01309          state = 0;
01310       } else if (num < 0) {
01311          snprintf(fn, sizeof(fn), "digits/minus");
01312          num = (-1) * num;
01313       } else if (num < 20) {
01314          if (mf < 0) {
01315             snprintf(fn, sizeof(fn), "digits/%d", num);
01316          } else {
01317             snprintf(fn, sizeof(fn), "digits/%dm", num);
01318          }
01319          num = 0;
01320       } else if ((num < 100) && (num >= 20)) {
01321          snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10);
01322          num = num % 10;
01323          if (num > 0) {
01324             state = 2;
01325          }
01326       } else if ((num >= 100) && (num < 1000)) {
01327          tmpnum = num / 100;
01328          snprintf(fn, sizeof(fn), "digits/%d00", tmpnum);
01329          num = num - (tmpnum * 100);
01330          if ((num > 0) && (num < 11)) {
01331             state = 2;
01332          }
01333       } else if ((num >= 1000) && (num < 10000)) {
01334          tmpnum = num / 1000;
01335          snprintf(fn, sizeof(fn), "digits/%dk", tmpnum);
01336          num = num - (tmpnum * 1000);
01337          if ((num > 0) && (num < 11)) {
01338             state = 2;
01339          }
01340       } else if (num < 20000) {
01341          snprintf(fn, sizeof(fn), "digits/%dm", (num / 1000));
01342          num = num % 1000;
01343          state = 3;
01344       } else if (num < 1000000) {
01345          res = ast_say_number_full_he(chan, num / 1000, ints, language, "m", audiofd, ctrlfd);
01346          if (res) {
01347             return res;
01348          }
01349          snprintf(fn, sizeof(fn), "digits/1k");
01350          num = num % 1000;
01351          if ((num > 0) && (num < 11)) {
01352             state = 2;
01353          }
01354       } else if (num < 2000000) {
01355          snprintf(fn, sizeof(fn), "digits/million");
01356          num = num % 1000000;
01357          if ((num > 0) && (num < 11)) {
01358             state = 2;
01359          }
01360       } else if (num < 3000000) {
01361          snprintf(fn, sizeof(fn), "digits/twomillion");
01362          num = num - 2000000;
01363          if ((num > 0) && (num < 11)) {
01364             state = 2;
01365          }
01366       } else if (num < 1000000000) {
01367          res = ast_say_number_full_he(chan, num / 1000000, ints, language, "m", audiofd, ctrlfd);
01368          if (res) {
01369             return res;
01370          }
01371          snprintf(fn, sizeof(fn), "digits/million");
01372          num = num % 1000000;
01373          if ((num > 0) && (num < 11)) {
01374             state = 2;
01375          }
01376       } else {
01377          ast_debug(1, "Number '%d' is too big for me\n", num);
01378          res = -1;
01379       }
01380       tmpnum = 0;
01381       if (!res) {
01382          if (!ast_streamfile(chan, fn, language)) {
01383             if ((audiofd > -1) && (ctrlfd > -1)) {
01384                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01385             } else {
01386                res = ast_waitstream(chan, ints);
01387             }
01388          }
01389          ast_stopstream(chan);
01390       }
01391    }
01392    return res;
01393 }

static int ast_say_number_full_hu ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_hu: Hungarian syntax

Extra sounds needed: 10en: "tizen" 20on: "huszon"

Definition at line 1401 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

01402 {
01403    int res = 0;
01404    int playh = 0;
01405    char fn[256] = "";
01406    if (!num) 
01407       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
01408 
01409    /*
01410    Hungarian support
01411    like english, except numbers up to 29 are from 2 words.
01412    10 and first word of 1[1-9] and 20 and first word of 2[1-9] are different.
01413    */
01414 
01415    while(!res && (num || playh)) {
01416       if (num < 0) {
01417          ast_copy_string(fn, "digits/minus", sizeof(fn));
01418          if ( num > INT_MIN ) {
01419             num = -num;
01420          } else {
01421             num = 0;
01422          }  
01423       } else if (playh) {
01424          ast_copy_string(fn, "digits/hundred", sizeof(fn));
01425          playh = 0;
01426       } else if (num < 11 || num == 20) {
01427          snprintf(fn, sizeof(fn), "digits/%d", num);
01428          num = 0;
01429       } else if (num < 20) {
01430          ast_copy_string(fn, "digits/10en", sizeof(fn));
01431          num -= 10;
01432       } else if (num < 30) {
01433          ast_copy_string(fn, "digits/20on", sizeof(fn));
01434          num -= 20;
01435       } else   if (num < 100) {
01436          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
01437          num %= 10;
01438       } else {
01439          if (num < 1000){
01440             snprintf(fn, sizeof(fn), "digits/%d", (num/100));
01441             playh++;
01442             num %= 100;
01443          } else {
01444             if (num < 1000000) { /* 1,000,000 */
01445                res = ast_say_number_full_hu(chan, num / 1000, ints, language, audiofd, ctrlfd);
01446                if (res)
01447                   return res;
01448                num %= 1000;
01449                ast_copy_string(fn, "digits/thousand", sizeof(fn));
01450             } else {
01451                if (num < 1000000000) { /* 1,000,000,000 */
01452                   res = ast_say_number_full_hu(chan, num / 1000000, ints, language, audiofd, ctrlfd);
01453                   if (res)
01454                      return res;
01455                   num %= 1000000;
01456                   ast_copy_string(fn, "digits/million", sizeof(fn));
01457                } else {
01458                   ast_debug(1, "Number '%d' is too big for me\n", num);
01459                   res = -1;
01460                }
01461             }
01462          }
01463       }
01464       if (!res) {
01465          if(!ast_streamfile(chan, fn, language)) {
01466             if ((audiofd  > -1) && (ctrlfd > -1))
01467                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01468             else
01469                res = ast_waitstream(chan, ints);
01470          }
01471          ast_stopstream(chan);
01472       }
01473    }
01474    return res;
01475 }

static int ast_say_number_full_it ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_it: Italian

Definition at line 1478 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

01479 {
01480    int res = 0;
01481    int playh = 0;
01482    int tempnum = 0;
01483    char fn[256] = "";
01484 
01485    if (!num)
01486       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
01487 
01488       /*
01489       Italian support
01490 
01491       Like english, numbers up to 20 are a single 'word', and others
01492       compound, but with exceptions.
01493       For example 21 is not twenty-one, but there is a single word in 'it'.
01494       Idem for 28 (ie when a the 2nd part of a compund number
01495       starts with a vowel)
01496 
01497       There are exceptions also for hundred, thousand and million.
01498       In english 100 = one hundred, 200 is two hundred.
01499       In italian 100 = cento , like to say hundred (without one),
01500       200 and more are like english.
01501       
01502       Same applies for thousand:
01503       1000 is one thousand in en, 2000 is two thousand.
01504       In it we have 1000 = mille , 2000 = 2 mila 
01505 
01506       For million(s) we use the plural, if more than one
01507       Also, one million is abbreviated in it, like on-million,
01508       or 'un milione', not 'uno milione'.
01509       So the right file is provided.
01510       */
01511 
01512    while (!res && (num || playh)) {
01513          if (num < 0) {
01514             ast_copy_string(fn, "digits/minus", sizeof(fn));
01515             if ( num > INT_MIN ) {
01516                num = -num;
01517             } else {
01518                num = 0;
01519             }  
01520          } else if (playh) {
01521             ast_copy_string(fn, "digits/hundred", sizeof(fn));
01522             playh = 0;
01523          } else if (num < 20) {
01524             snprintf(fn, sizeof(fn), "digits/%d", num);
01525             num = 0;
01526          } else if (num == 21) {
01527             snprintf(fn, sizeof(fn), "digits/%d", num);
01528             num = 0;
01529          } else if (num == 28) {
01530             snprintf(fn, sizeof(fn), "digits/%d", num);
01531             num = 0;
01532          } else if (num == 31) {
01533             snprintf(fn, sizeof(fn), "digits/%d", num);
01534             num = 0;
01535          } else if (num == 38) {
01536             snprintf(fn, sizeof(fn), "digits/%d", num);
01537             num = 0;
01538          } else if (num == 41) {
01539             snprintf(fn, sizeof(fn), "digits/%d", num);
01540             num = 0;
01541          } else if (num == 48) {
01542             snprintf(fn, sizeof(fn), "digits/%d", num);
01543             num = 0;
01544          } else if (num == 51) {
01545             snprintf(fn, sizeof(fn), "digits/%d", num);
01546             num = 0;
01547          } else if (num == 58) {
01548             snprintf(fn, sizeof(fn), "digits/%d", num);
01549             num = 0;
01550          } else if (num == 61) {
01551             snprintf(fn, sizeof(fn), "digits/%d", num);
01552             num = 0;
01553          } else if (num == 68) {
01554             snprintf(fn, sizeof(fn), "digits/%d", num);
01555             num = 0;
01556          } else if (num == 71) {
01557             snprintf(fn, sizeof(fn), "digits/%d", num);
01558             num = 0;
01559          } else if (num == 78) {
01560             snprintf(fn, sizeof(fn), "digits/%d", num);
01561             num = 0;
01562          } else if (num == 81) {
01563             snprintf(fn, sizeof(fn), "digits/%d", num);
01564             num = 0;
01565          } else if (num == 88) {
01566             snprintf(fn, sizeof(fn), "digits/%d", num);
01567             num = 0;
01568          } else if (num == 91) {
01569             snprintf(fn, sizeof(fn), "digits/%d", num);
01570             num = 0;
01571          } else if (num == 98) {
01572             snprintf(fn, sizeof(fn), "digits/%d", num);
01573             num = 0;
01574          } else if (num < 100) {
01575             snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
01576             num %= 10;
01577          } else {
01578             if (num < 1000) {
01579                if ((num / 100) > 1) {
01580                   snprintf(fn, sizeof(fn), "digits/%d", (num/100));
01581                   playh++;
01582                } else {
01583                   ast_copy_string(fn, "digits/hundred", sizeof(fn));
01584                }
01585                num %= 100;
01586             } else {
01587                if (num < 1000000) { /* 1,000,000 */
01588                   if ((num/1000) > 1)
01589                      res = ast_say_number_full_it(chan, num / 1000, ints, language, audiofd, ctrlfd);
01590                   if (res)
01591                      return res;
01592                   tempnum = num;
01593                   num %= 1000;
01594                   if ((tempnum / 1000) < 2)
01595                      ast_copy_string(fn, "digits/thousand", sizeof(fn));
01596                   else /* for 1000 it says mille, for >1000 (eg 2000) says mila */
01597                      ast_copy_string(fn, "digits/thousands", sizeof(fn));
01598                } else {
01599                   if (num < 1000000000) { /* 1,000,000,000 */
01600                      if ((num / 1000000) > 1)
01601                         res = ast_say_number_full_it(chan, num / 1000000, ints, language, audiofd, ctrlfd);
01602                      if (res)
01603                         return res;
01604                      tempnum = num;
01605                      num %= 1000000;
01606                      if ((tempnum / 1000000) < 2)
01607                         ast_copy_string(fn, "digits/million", sizeof(fn));
01608                      else
01609                         ast_copy_string(fn, "digits/millions", sizeof(fn));
01610                   } else {
01611                      ast_debug(1, "Number '%d' is too big for me\n", num);
01612                      res = -1;
01613                   }
01614                }
01615             }
01616          }
01617          if (!res) {
01618             if (!ast_streamfile(chan, fn, language)) {
01619                if ((audiofd > -1) && (ctrlfd > -1))
01620                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01621                else
01622                   res = ast_waitstream(chan, ints);
01623             }
01624             ast_stopstream(chan);
01625          }
01626       }
01627    return res;
01628 }

static int ast_say_number_full_ka ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_ka: Georgian syntax

Definition at line 8043 of file say.c.

References ast_free, ast_malloc, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_translate_number_ka(), ast_waitstream(), ast_waitstream_full(), and len().

Referenced by say_number_full().

08044 {
08045    int res = 0;
08046    char fn[512] = "";
08047    char* s = 0;
08048    const char* remaining = fn;
08049 
08050    if (!num)
08051       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
08052 
08053 
08054    ast_translate_number_ka(num, fn, 512);
08055 
08056 
08057 
08058    while (res == 0 && (s = strstr(remaining, " "))) {
08059       size_t len = s - remaining;
08060       char* new_string = ast_malloc(len + 1 + strlen("digits/"));
08061 
08062       sprintf(new_string, "digits/");
08063       strncat(new_string, remaining, len);  /* we can't sprintf() it, it's not null-terminated. */
08064 /*       new_string[len + strlen("digits/")] = '\0'; */
08065 
08066       if (!ast_streamfile(chan, new_string, language)) {
08067          if ((audiofd  > -1) && (ctrlfd > -1))
08068             res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
08069          else
08070             res = ast_waitstream(chan, ints);
08071       }
08072       ast_stopstream(chan);
08073 
08074       ast_free(new_string);
08075 
08076       remaining = s + 1;  /* position just after the found space char. */
08077       while (*remaining == ' ')  /* skip multiple spaces */
08078          remaining++;
08079    }
08080 
08081 
08082    /* the last chunk. */
08083    if (res == 0 && *remaining) {
08084 
08085       char* new_string = ast_malloc(strlen(remaining) + 1 + strlen("digits/"));
08086       sprintf(new_string, "digits/%s", remaining);
08087 
08088       if (!ast_streamfile(chan, new_string, language)) {
08089          if ((audiofd  > -1) && (ctrlfd > -1))
08090             res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
08091          else
08092             res = ast_waitstream(chan, ints);
08093       }
08094       ast_stopstream(chan);
08095 
08096       ast_free(new_string);
08097 
08098    }
08099 
08100 
08101    return res;
08102 
08103 }

static int ast_say_number_full_nl ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_nl: dutch syntax New files: digits/nl-en

Definition at line 1633 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

01634 {
01635    int res = 0;
01636    int playh = 0;
01637    int units = 0;
01638    char fn[256] = "";
01639    if (!num) 
01640       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
01641    while (!res && (num || playh )) {
01642       if (num < 0) {
01643          ast_copy_string(fn, "digits/minus", sizeof(fn));
01644          if ( num > INT_MIN ) {
01645             num = -num;
01646          } else {
01647             num = 0;
01648          }  
01649       } else if (playh) {
01650          ast_copy_string(fn, "digits/hundred", sizeof(fn));
01651          playh = 0;
01652       } else if (num < 20) {
01653          snprintf(fn, sizeof(fn), "digits/%d", num);
01654          num = 0;
01655       } else if (num < 100) {
01656          units = num % 10;
01657          if (units > 0) {
01658             res = ast_say_number_full_nl(chan, units, ints, language, audiofd, ctrlfd);
01659             if (res)
01660                return res;
01661             num = num - units;
01662             ast_copy_string(fn, "digits/nl-en", sizeof(fn));
01663          } else {
01664             snprintf(fn, sizeof(fn), "digits/%d", num - units);
01665             num = 0;
01666          }
01667       } else if (num < 200) {
01668          /* hundred, not one-hundred */
01669          ast_copy_string(fn, "digits/hundred", sizeof(fn));
01670          num %= 100;
01671       } else if (num < 1000) {
01672          snprintf(fn, sizeof(fn), "digits/%d", num / 100);
01673          playh++;
01674          num %= 100;
01675       } else {
01676          if (num < 1100) {
01677             /* thousand, not one-thousand */
01678             num %= 1000;
01679             ast_copy_string(fn, "digits/thousand", sizeof(fn));
01680          } else if (num < 10000) { /* 1,100 to 9,9999 */
01681             res = ast_say_number_full_nl(chan, num / 100, ints, language, audiofd, ctrlfd);
01682             if (res)
01683                return res;
01684             num %= 100;
01685             ast_copy_string(fn, "digits/hundred", sizeof(fn));
01686          } else {
01687             if (num < 1000000) { /* 1,000,000 */
01688                res = ast_say_number_full_nl(chan, num / 1000, ints, language, audiofd, ctrlfd);
01689                if (res)
01690                   return res;
01691                num %= 1000;
01692                ast_copy_string(fn, "digits/thousand", sizeof(fn));
01693             } else {
01694                if (num < 1000000000) { /* 1,000,000,000 */
01695                   res = ast_say_number_full_nl(chan, num / 1000000, ints, language, audiofd, ctrlfd);
01696                   if (res)
01697                      return res;
01698                   num %= 1000000;
01699                   ast_copy_string(fn, "digits/million", sizeof(fn));
01700                } else {
01701                   ast_debug(1, "Number '%d' is too big for me\n", num);
01702                   res = -1;
01703                }
01704             }
01705          }
01706       }
01707 
01708       if (!res) {
01709          if (!ast_streamfile(chan, fn, language)) {
01710             if ((audiofd > -1) && (ctrlfd > -1))
01711                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01712             else
01713                res = ast_waitstream(chan, ints);
01714          }
01715          ast_stopstream(chan);
01716       }
01717    }
01718    return res;
01719 }

static int ast_say_number_full_no ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_no: Norwegian syntax New files: In addition to American English, the following sounds are required: "and", "1N"

The grammar for Norwegian numbers is the same as for English except for the following:

  • 1 exists in both commune ("en", file "1") and neuter ("ett", file "1N") "and" before the last two digits, i.e. 2034 is "two thousand and thirty-four" and 1000012 is "one million and twelve".

Definition at line 1731 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

01732 {
01733    int res = 0;
01734    int playh = 0;
01735    int playa = 0;
01736    int cn = 1;    /* +1 = commune; -1 = neuter */
01737    char fn[256] = "";
01738    
01739    if (!num) 
01740       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
01741    
01742    if (options && !strncasecmp(options, "n", 1)) cn = -1;
01743 
01744    while (!res && (num || playh || playa )) {
01745       if (num < 0) {
01746          ast_copy_string(fn, "digits/minus", sizeof(fn));
01747          if ( num > INT_MIN ) {
01748             num = -num;
01749          } else {
01750             num = 0;
01751          }  
01752       } else if (playh) {
01753          ast_copy_string(fn, "digits/hundred", sizeof(fn));
01754          playh = 0;
01755       } else if (playa) {
01756          ast_copy_string(fn, "digits/and", sizeof(fn));
01757          playa = 0;
01758       } else if (num == 1 && cn == -1) {
01759          ast_copy_string(fn, "digits/1N", sizeof(fn));
01760          num = 0;
01761       } else if (num < 20) {
01762          snprintf(fn, sizeof(fn), "digits/%d", num);
01763          num = 0;
01764       } else if (num < 100) {
01765          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
01766          num %= 10;
01767       } else if (num < 1000) {
01768          int hundreds = num / 100;
01769          if (hundreds == 1)
01770             ast_copy_string(fn, "digits/1N", sizeof(fn));
01771          else
01772             snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
01773 
01774          playh++;
01775          num -= 100 * hundreds;
01776          if (num)
01777             playa++;
01778       } else if (num < 1000000) {
01779          res = ast_say_number_full_no(chan, num / 1000, ints, language, "n", audiofd, ctrlfd);
01780          if (res)
01781             return res;
01782          ast_copy_string(fn, "digits/thousand", sizeof(fn));
01783          num %= 1000;
01784          if (num && num < 100)
01785             playa++;
01786       } else if (num < 1000000000) {
01787             int millions = num / 1000000;
01788             res = ast_say_number_full_no(chan, millions, ints, language, "c", audiofd, ctrlfd);
01789             if (res)
01790                return res;
01791             ast_copy_string(fn, "digits/million", sizeof(fn));
01792             num %= 1000000;
01793             if (num && num < 100)
01794                playa++;
01795       } else {
01796             ast_debug(1, "Number '%d' is too big for me\n", num);
01797             res = -1;
01798       }
01799 
01800       if (!res) {
01801          if (!ast_streamfile(chan, fn, language)) {
01802             if ((audiofd > -1) && (ctrlfd > -1))
01803                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01804             else
01805                res = ast_waitstream(chan, ints);
01806          }
01807          ast_stopstream(chan);
01808       }
01809    }
01810    return res;
01811 }

static int ast_say_number_full_pl ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 2018 of file say.c.

References ast_malloc, odmiana::cyfry, odmiana::cyfry2, odmiana::dziesiatki, odmiana::nastki, powiedz(), odmiana::rzedy, odmiana::separator_dziesiatek, and odmiana::setki.

Referenced by say_number_full().

02019 {
02020    char *zenski_cyfry[] = {"0", "1z", "2z", "3", "4", "5", "6", "7", "8", "9"};
02021 
02022    char *zenski_cyfry2[] = {"0", "1", "2z", "3", "4", "5", "6", "7", "8", "9"};
02023 
02024    char *meski_cyfry[] = {"0", "1", "2-1m", "3-1m", "4-1m", "5m",  /*"2-1mdwaj"*/ "6m", "7m", "8m", "9m"};
02025 
02026    char *meski_cyfry2[] = {"0", "1", "2-2m", "3-2m", "4-2m", "5m", "6m", "7m", "8m", "9m"};
02027 
02028    char *meski_setki[] = {"", "100m", "200m", "300m", "400m", "500m", "600m", "700m", "800m", "900m"};
02029 
02030    char *meski_dziesiatki[] = {"", "10m", "20m", "30m", "40m", "50m", "60m", "70m", "80m", "90m"};
02031 
02032    char *meski_nastki[] = {"", "11m", "12m", "13m", "14m", "15m", "16m", "17m", "18m", "19m"};
02033 
02034    char *nijaki_cyfry[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
02035 
02036    char *nijaki_cyfry2[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
02037 
02038    char *nijaki_setki[] = {"", "100", "200", "300", "400", "500", "600", "700", "800", "900"};
02039 
02040    char *nijaki_dziesiatki[] = {"", "10", "20", "30", "40", "50", "60", "70", "80", "90"};
02041 
02042    char *nijaki_nastki[] = {"", "11", "12", "13", "14", "15", "16", "17", "18", "19"};
02043 
02044    char *rzedy[][3] = { {"1000", "1000.2", "1000.5"}, {"1000000", "1000000.2", "1000000.5"}, {"1000000000", "1000000000.2", "1000000000.5"}}; 
02045 
02046    /* Initialise variables to allow compilation on Debian-stable, etc */
02047    odmiana *o;
02048 
02049    static odmiana *odmiana_nieosobowa = NULL; 
02050    static odmiana *odmiana_meska = NULL; 
02051    static odmiana *odmiana_zenska = NULL; 
02052 
02053    if (odmiana_nieosobowa == NULL) {
02054       odmiana_nieosobowa = ast_malloc(sizeof(*odmiana_nieosobowa));
02055 
02056       odmiana_nieosobowa->separator_dziesiatek = " ";
02057 
02058       memcpy(odmiana_nieosobowa->cyfry, nijaki_cyfry, sizeof(odmiana_nieosobowa->cyfry));
02059       memcpy(odmiana_nieosobowa->cyfry2, nijaki_cyfry2, sizeof(odmiana_nieosobowa->cyfry));
02060       memcpy(odmiana_nieosobowa->setki, nijaki_setki, sizeof(odmiana_nieosobowa->setki));
02061       memcpy(odmiana_nieosobowa->dziesiatki, nijaki_dziesiatki, sizeof(odmiana_nieosobowa->dziesiatki));
02062       memcpy(odmiana_nieosobowa->nastki, nijaki_nastki, sizeof(odmiana_nieosobowa->nastki));
02063       memcpy(odmiana_nieosobowa->rzedy, rzedy, sizeof(odmiana_nieosobowa->rzedy));
02064    }
02065 
02066    if (odmiana_zenska == NULL) {
02067       odmiana_zenska = ast_malloc(sizeof(*odmiana_zenska));
02068 
02069       odmiana_zenska->separator_dziesiatek = " ";
02070 
02071       memcpy(odmiana_zenska->cyfry, zenski_cyfry, sizeof(odmiana_zenska->cyfry));
02072       memcpy(odmiana_zenska->cyfry2, zenski_cyfry2, sizeof(odmiana_zenska->cyfry));
02073       memcpy(odmiana_zenska->setki, nijaki_setki, sizeof(odmiana_zenska->setki));
02074       memcpy(odmiana_zenska->dziesiatki, nijaki_dziesiatki, sizeof(odmiana_zenska->dziesiatki));
02075       memcpy(odmiana_zenska->nastki, nijaki_nastki, sizeof(odmiana_zenska->nastki));
02076       memcpy(odmiana_zenska->rzedy, rzedy, sizeof(odmiana_zenska->rzedy));
02077    }
02078 
02079    if (odmiana_meska == NULL) {
02080       odmiana_meska = ast_malloc(sizeof(*odmiana_meska));
02081 
02082       odmiana_meska->separator_dziesiatek = " ";
02083 
02084       memcpy(odmiana_meska->cyfry, meski_cyfry, sizeof(odmiana_meska->cyfry));
02085       memcpy(odmiana_meska->cyfry2, meski_cyfry2, sizeof(odmiana_meska->cyfry));
02086       memcpy(odmiana_meska->setki, meski_setki, sizeof(odmiana_meska->setki));
02087       memcpy(odmiana_meska->dziesiatki, meski_dziesiatki, sizeof(odmiana_meska->dziesiatki));
02088       memcpy(odmiana_meska->nastki, meski_nastki, sizeof(odmiana_meska->nastki));
02089       memcpy(odmiana_meska->rzedy, rzedy, sizeof(odmiana_meska->rzedy));
02090    }
02091 
02092    if (options) {
02093       if (strncasecmp(options, "f", 1) == 0)
02094          o = odmiana_zenska;
02095       else if (strncasecmp(options, "m", 1) == 0)
02096          o = odmiana_meska;
02097       else
02098          o = odmiana_nieosobowa;
02099    } else
02100       o = odmiana_nieosobowa;
02101 
02102    powiedz(chan, language, audiofd, ctrlfd, ints, o, 0, num);
02103    return 0;
02104 }

static int ast_say_number_full_pt ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 2114 of file say.c.

References ast_copy_string(), ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_WARNING, and wait_file().

Referenced by say_number_full().

02115 {
02116    int res = 0;
02117    int playh = 0;
02118    int mf = 1;                            /* +1 = male; -1 = female */
02119    char fn[256] = "";
02120 
02121    if (!num) 
02122       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02123 
02124    if (options && !strncasecmp(options, "f", 1))
02125       mf = -1;
02126 
02127    while (!res && num ) {
02128       if (num < 0) {
02129          ast_copy_string(fn, "digits/minus", sizeof(fn));
02130          if ( num > INT_MIN ) {
02131             num = -num;
02132          } else {
02133             num = 0;
02134          }  
02135       } else if (num < 20) {
02136          if ((num == 1 || num == 2) && (mf < 0))
02137             snprintf(fn, sizeof(fn), "digits/%dF", num);
02138          else
02139             snprintf(fn, sizeof(fn), "digits/%d", num);
02140          num = 0;
02141       } else if (num < 100) {
02142          snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10);
02143          if (num % 10)
02144             playh = 1;
02145          num = num % 10;
02146       } else if (num < 1000) {
02147          if (num == 100)
02148             ast_copy_string(fn, "digits/100", sizeof(fn));
02149          else if (num < 200)
02150             ast_copy_string(fn, "digits/100E", sizeof(fn));
02151          else {
02152             if (mf < 0 && num > 199)
02153                snprintf(fn, sizeof(fn), "digits/%dF", (num / 100) * 100);
02154             else
02155                snprintf(fn, sizeof(fn), "digits/%d", (num / 100) * 100);
02156             if (num % 100)
02157                playh = 1;
02158          }
02159          num = num % 100;
02160       } else if (num < 1000000) {
02161          if (num > 1999) {
02162             res = ast_say_number_full_pt(chan, (num / 1000) * mf, ints, language, options, audiofd, ctrlfd);
02163             if (res)
02164                return res;
02165          }
02166          ast_copy_string(fn, "digits/1000", sizeof(fn));
02167          if ((num % 1000) && ((num % 1000) < 100  || !(num % 100)))
02168             playh = 1;
02169          num = num % 1000;
02170       } else if (num < 1000000000) {
02171          res = ast_say_number_full_pt(chan, (num / 1000000), ints, language, options, audiofd, ctrlfd );
02172          if (res)
02173             return res;
02174          if (num < 2000000)
02175             ast_copy_string(fn, "digits/1000000", sizeof(fn));
02176          else
02177             ast_copy_string(fn, "digits/1000000S", sizeof(fn));
02178  
02179          if ((num % 1000000) &&
02180             /* no thousands */
02181             ((!((num / 1000) % 1000) && ((num % 1000) < 100 || !(num % 100))) ||
02182             /* no hundreds and below */
02183             (!(num % 1000) && (((num / 1000) % 1000) < 100 || !((num / 1000) % 100))) ) )
02184             playh = 1;
02185          num = num % 1000000;
02186       } else {
02187          /* number is too big */
02188          ast_log(LOG_WARNING, "Number '%d' is too big to say.", num);
02189          res = -1;
02190       }
02191       if (!res) {
02192          if (!ast_streamfile(chan, fn, language)) {
02193             if ((audiofd > -1) && (ctrlfd > -1))
02194                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);  
02195             else
02196                res = ast_waitstream(chan, ints);
02197          }
02198          ast_stopstream(chan);
02199       }
02200       if (!res && playh) {
02201          res = wait_file(chan, ints, "digits/pt-e", language);
02202          ast_stopstream(chan);
02203          playh = 0;
02204       }
02205    }
02206    return res;
02207 }

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 
) [static]

ast_say_number_full_ru: Russian syntax

additional files: 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

Definition at line 2493 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and get_lastdigits_ru().

Referenced by say_number_full().

02494 {
02495    int res = 0;
02496    int lastdigits = 0;
02497    char fn[256] = "";
02498    if (!num) 
02499       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02500 
02501    while (!res && (num)) {
02502       if (num < 0) {
02503          ast_copy_string(fn, "digits/minus", sizeof(fn));
02504          if ( num > INT_MIN ) {
02505             num = -num;
02506          } else {
02507             num = 0;
02508          }  
02509       } else   if (num < 20) {
02510          if (options && strlen(options) == 1 && num < 3) {
02511              snprintf(fn, sizeof(fn), "digits/%d%s", num, options);
02512          } else {
02513             snprintf(fn, sizeof(fn), "digits/%d", num);
02514          }
02515          num = 0;
02516       } else if (num < 100) {
02517          snprintf(fn, sizeof(fn), "digits/%d", num - (num % 10));
02518          num %= 10;
02519       } else if (num < 1000){
02520          snprintf(fn, sizeof(fn), "digits/%d", num - (num % 100));
02521          num %= 100;
02522       } else if (num < 1000000) { /* 1,000,000 */
02523          lastdigits = get_lastdigits_ru(num / 1000);
02524          /* say thousands */
02525          if (lastdigits < 3) {
02526             res = ast_say_number_full_ru(chan, num / 1000, ints, language, "f", audiofd, ctrlfd);
02527          } else {
02528             res = ast_say_number_full_ru(chan, num / 1000, ints, language, NULL, audiofd, ctrlfd);
02529          }
02530          if (res)
02531             return res;
02532          if (lastdigits == 1) {
02533             ast_copy_string(fn, "digits/thousand", sizeof(fn));
02534          } else if (lastdigits > 1 && lastdigits < 5) {
02535             ast_copy_string(fn, "digits/thousands-i", sizeof(fn));
02536          } else {
02537             ast_copy_string(fn, "digits/thousands", sizeof(fn));
02538          }
02539          num %= 1000;
02540       } else if (num < 1000000000) {   /* 1,000,000,000 */
02541          lastdigits = get_lastdigits_ru(num / 1000000);
02542          /* say millions */
02543          res = ast_say_number_full_ru(chan, num / 1000000, ints, language, NULL, audiofd, ctrlfd);
02544          if (res)
02545             return res;
02546          if (lastdigits == 1) {
02547             ast_copy_string(fn, "digits/million", sizeof(fn));
02548          } else if (lastdigits > 1 && lastdigits < 5) {
02549             ast_copy_string(fn, "digits/million-a", sizeof(fn));
02550          } else {
02551             ast_copy_string(fn, "digits/millions", sizeof(fn));
02552          }
02553          num %= 1000000;
02554       } else {
02555          ast_debug(1, "Number '%d' is too big for me\n", num);
02556          res = -1;
02557       }
02558       if (!res) {
02559          if (!ast_streamfile(chan, fn, language)) {
02560             if ((audiofd  > -1) && (ctrlfd > -1))
02561                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02562             else
02563                res = ast_waitstream(chan, ints);
02564          }
02565          ast_stopstream(chan);
02566       }
02567    }
02568    return res;
02569 }

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 
) [static]

ast_say_number_full_se: Swedish syntax

Sound files needed

  • 1N

Definition at line 2214 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

02215 {
02216    int playh = 0;
02217    int start = 1;
02218    char fn[256] = "";
02219    int cn = 1;    /* +1 = commune; -1 = neuter */
02220    int res = 0;
02221 
02222    if (!num) {
02223       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02224    }
02225    if (options && !strncasecmp(options, "n", 1)) cn = -1;
02226 
02227    while (num || playh) {
02228       if (num < 0) {
02229          ast_copy_string(fn, "digits/minus", sizeof(fn));
02230          if ( num > INT_MIN ) {
02231             num = -num;
02232          } else {
02233             num = 0;
02234          }
02235       } else if (playh) {
02236          ast_copy_string(fn, "digits/hundred", sizeof(fn));
02237          playh = 0;
02238       } else if (start  && num < 200 && num > 99 && cn == -1) {
02239          /* Don't say "en hundra" just say "hundra". */
02240          snprintf(fn, sizeof(fn), "digits/hundred");
02241          num -= 100;
02242       } else if (num == 1 && cn == -1) {  /* En eller ett? */
02243          ast_copy_string(fn, "digits/1N", sizeof(fn));
02244          num = 0;
02245       } else if (num < 20) {
02246          snprintf(fn, sizeof(fn), "digits/%d", num);
02247          num = 0;
02248       } else if (num < 100) { /* Below hundreds - teens and tens */
02249          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
02250          num %= 10;
02251       } else if (num < 1000) {
02252          /* Hundreds */
02253          snprintf(fn, sizeof(fn), "digits/%d", (num/100));
02254          playh++;
02255          num %= 100;
02256       } else if (num < 1000000) { /* 1,000,000 */
02257          /* Always say "ett hundra tusen", not "en hundra tusen" */
02258          res = ast_say_number_full_se(chan, num / 1000, ints, language, "c", audiofd, ctrlfd);
02259          if (res) {
02260             return res;
02261          }
02262          num %= 1000;
02263          ast_copy_string(fn, "digits/thousand", sizeof(fn));
02264       } else if (num < 1000000000) {   /* 1,000,000,000 */
02265          /* Always say "en miljon", not "ett miljon" */
02266          res = ast_say_number_full_se(chan, num / 1000000, ints, language, "n", audiofd, ctrlfd);
02267          if (res) {
02268             return res;
02269          }
02270          num %= 1000000;
02271          ast_copy_string(fn, "digits/million", sizeof(fn));
02272       } else { /* Miljarder - Billions */
02273          ast_debug(1, "Number '%d' is too big for me\n", num);
02274          return -1;
02275       }
02276 
02277       if (!ast_streamfile(chan, fn, language)) {
02278          if ((audiofd > -1) && (ctrlfd > -1)) {
02279             res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02280          } else {
02281             res = ast_waitstream(chan, ints);
02282          }
02283          ast_stopstream(chan);
02284          if (res) {
02285             return res;
02286          }
02287       }
02288       start = 0;
02289    }
02290    return 0;
02291 }

static int ast_say_number_full_th ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

Thai syntax.

Definition at line 2572 of file say.c.

References ast_copy_string(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

02573 {
02574    int res = 0;
02575    int playh = 0;
02576    char fn[256] = "";
02577    if (!num) 
02578       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02579 
02580    while(!res && (num || playh)) {
02581       if (num < 0) {
02582          ast_copy_string(fn, "digits/lop", sizeof(fn));
02583          if ( num > INT_MIN ) {
02584             num = -num;
02585          } else {
02586             num = 0;
02587          }  
02588       } else if (playh) {
02589          ast_copy_string(fn, "digits/roi", sizeof(fn));
02590          playh = 0;
02591       } else if (num < 100) {
02592          if ((num <= 20) || ((num % 10) == 1)) {
02593             snprintf(fn, sizeof(fn), "digits/%d", num);
02594             num = 0;
02595          } else {
02596             snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10);
02597             num %= 10;
02598          }
02599       } else if (num < 1000) {
02600          snprintf(fn, sizeof(fn), "digits/%d", (num/100));
02601          playh++;
02602          num %= 100;
02603       } else if (num < 10000) { /* 10,000 */
02604          res = ast_say_number_full_th(chan, num / 1000, ints, language, audiofd, ctrlfd);
02605          if (res)
02606             return res;
02607          num %= 1000;
02608          ast_copy_string(fn, "digits/pan", sizeof(fn));
02609       } else if (num < 100000) { /* 100,000 */
02610          res = ast_say_number_full_th(chan, num / 10000, ints, language, audiofd, ctrlfd);
02611          if (res)
02612             return res;
02613          num %= 10000;
02614          ast_copy_string(fn, "digits/muan", sizeof(fn));
02615       } else if (num < 1000000) { /* 1,000,000 */
02616          res = ast_say_number_full_th(chan, num / 100000, ints, language, audiofd, ctrlfd);
02617          if (res)
02618             return res;
02619          num %= 100000;
02620          ast_copy_string(fn, "digits/san", sizeof(fn));
02621       } else {
02622          res = ast_say_number_full_th(chan, num / 1000000, ints, language, audiofd, ctrlfd);
02623          if (res)
02624             return res;
02625          num %= 1000000;
02626          ast_copy_string(fn, "digits/larn", sizeof(fn));
02627       }
02628       if (!res) {
02629          if(!ast_streamfile(chan, fn, language)) {
02630             if ((audiofd  > -1) && (ctrlfd > -1))
02631                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02632             else
02633                res = ast_waitstream(chan, ints);
02634          }
02635          ast_stopstream(chan);
02636       }
02637    }
02638    return res;
02639 }

static int ast_say_number_full_ur ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 2407 of file say.c.

References ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

02408 {
02409    int res = 0;
02410    int playh = 0;
02411    char fn[256] = "";
02412 
02413    if (!num) {
02414       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02415    }
02416 
02417    while (!res && (num || playh)) {
02418       if (playh) {
02419          snprintf(fn, sizeof(fn), "digits/hundred");
02420          playh = 0;
02421       } else if (num < 100) {
02422          snprintf(fn, sizeof(fn), "digits/%d", num);
02423          num = 0;
02424       } else if (num < 1000) {
02425          snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
02426          playh++;
02427          num -= ((num / 100) * 100);
02428       } else if (num < 100000) { /* 1,00,000 */
02429          if ((res = ast_say_number_full_ur(chan, num / 1000, ints, language, options, audiofd, ctrlfd))) {
02430             return res;
02431          }
02432          num = num % 1000;
02433          snprintf(fn, sizeof(fn), "digits/thousand");
02434       } else if (num < 10000000) { /* 1,00,00,000 */
02435          if ((res = ast_say_number_full_ur(chan, num / 100000, ints, language, options, audiofd, ctrlfd))) {
02436             return res;
02437          }
02438          num = num % 100000;
02439          snprintf(fn, sizeof(fn), "digits/lac");
02440       } else if (num < 1000000000) { /* 1,00,00,00,000 */
02441          if ((res = ast_say_number_full_ur(chan, num / 10000000, ints, language, options, audiofd, ctrlfd))) {
02442             return res;
02443          }
02444          num = num % 10000000;
02445          snprintf(fn, sizeof(fn), "digits/crore");
02446       } else {
02447          ast_debug(1, "Number '%d' is too big for me\n", num);
02448          res = -1;
02449       }
02450 
02451       if (!res) {
02452          if (!ast_streamfile(chan, fn, language)) {
02453             if ((audiofd > -1) && (ctrlfd > -1)) {
02454                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02455             } else {
02456                res = ast_waitstream(chan, ints);
02457             }
02458          }
02459          ast_stopstream(chan);
02460       }
02461    }
02462    return res;
02463 }

static int ast_say_number_full_vi ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_vi: Vietnamese syntax

Definition at line 2642 of file say.c.

References ast_copy_string(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by ast_say_enumeration_full_vi(), and say_number_full().

02643 {
02644    int res = 0;
02645    int playh = 0;
02646    int playoh = 0;
02647    int playohz = 0;
02648    int playz = 0;
02649    int playl = 0;
02650    char fn[256] = "";
02651    if (!num) 
02652       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02653    while (!res && (num || playh)) {
02654       if (num < 0) {
02655          ast_copy_string(fn, "digits/minus", sizeof(fn));
02656          if ( num > INT_MIN ) {
02657             num = -num;
02658          } else {
02659             num = 0;
02660          }  
02661       } else if (playl) {
02662          snprintf(fn, sizeof(fn), "digits/%da", num);
02663          playl = 0;
02664          num = 0;
02665       } else if (playh) {
02666          ast_copy_string(fn, "digits/hundred", sizeof(fn));
02667          playh = 0;
02668       } else if (playz) {
02669          ast_copy_string(fn, "digits/odd", sizeof(fn));
02670          playz = 0;        
02671       } else if (playoh) {
02672          ast_copy_string(fn, "digits/0-hundred", sizeof(fn));
02673          playoh = 0;
02674       } else if (playohz) {
02675          ast_copy_string(fn, "digits/0-hundred-odd", sizeof(fn));
02676          playohz = 0;
02677       } else   if (num < 20) {
02678          snprintf(fn, sizeof(fn), "digits/%d", num);
02679          num = 0;
02680       } else   if (num < 100) {
02681          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
02682          num %= 10;
02683          if ((num == 5) || (num == 4) || (num == 1)) playl++;
02684       } else {
02685          if (num < 1000) {
02686             snprintf(fn, sizeof(fn), "digits/%d", (num/100));           
02687             num %= 100;
02688             if (num && (num < 10)) {
02689                playz++;
02690                playh++;
02691             } else {
02692                playh++;
02693             }
02694          } else {
02695             if (num < 1000000) { /* 1,000,000 */
02696                res = ast_say_number_full_vi(chan, num / 1000, ints, language, audiofd, ctrlfd);
02697                if (res)
02698                   return res;
02699                num %= 1000;
02700                snprintf(fn, sizeof(fn), "digits/thousand");
02701                if (num && (num < 10)) {
02702                   playohz++;
02703                } else if (num && (num < 100)){
02704                   playoh++;
02705                } else {
02706                   playh = 0;
02707                   playohz = 0;
02708                   playoh = 0;
02709                }
02710             } else {
02711                if (num < 1000000000) { /* 1,000,000,000 */
02712                   res = ast_say_number_full_vi(chan, num / 1000000, ints, language, audiofd, ctrlfd);
02713                   if (res)
02714                      return res;
02715                   num %= 1000000;
02716                   ast_copy_string(fn, "digits/million", sizeof(fn));
02717                } else {
02718                   res = -1;
02719                }
02720             }
02721          }
02722       }
02723       if (!res) {
02724          if (!ast_streamfile(chan, fn, language)) {
02725             if ((audiofd  > -1) && (ctrlfd > -1))
02726                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02727             else
02728                res = ast_waitstream(chan, ints);
02729          }
02730          ast_stopstream(chan);
02731       }
02732    }
02733    return res;
02734 }

static int ast_say_number_full_zh ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full_zh: Taiwanese / Chinese syntax

Definition at line 2294 of file say.c.

References ast_copy_string(), ast_debug, ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by say_number_full().

02295 {
02296    int res = 0;
02297    int playh = 0;
02298    int playt = 0;
02299    int playz = 0;
02300    int last_length = 0;
02301    char buf[20] = "";
02302    char fn[256] = "";
02303    if (!num)
02304       return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
02305 
02306    while (!res && (num || playh || playt || playz)) {
02307          if (num < 0) {
02308             ast_copy_string(fn, "digits/minus", sizeof(fn));
02309             if ( num > INT_MIN ) {
02310                num = -num;
02311             } else {
02312                num = 0;
02313             }  
02314          } else if (playz) {
02315             snprintf(fn, sizeof(fn), "digits/0");
02316             last_length = 0;
02317             playz = 0;
02318          } else if (playh) {
02319             ast_copy_string(fn, "digits/hundred", sizeof(fn));
02320             playh = 0;
02321          } else if (playt) {
02322             snprintf(fn, sizeof(fn), "digits/thousand");
02323             playt = 0;
02324          } else   if (num < 10) {
02325             snprintf(buf, 10, "%d", num);
02326             if (last_length - strlen(buf) > 1 && last_length != 0) {
02327                last_length = strlen(buf);
02328                playz++;
02329                continue;
02330             }
02331             snprintf(fn, sizeof(fn), "digits/%d", num);
02332             num = 0;
02333          } else   if (num < 100) {
02334             snprintf(buf, 10, "%d", num);
02335             if (last_length - strlen(buf) > 1 && last_length != 0) {
02336                last_length = strlen(buf);
02337                playz++;
02338                continue;
02339             }
02340             last_length = strlen(buf);
02341             snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10);
02342             num %= 10;
02343          } else {
02344             if (num < 1000){
02345                snprintf(buf, 10, "%d", num);
02346                if (last_length - strlen(buf) > 1 && last_length != 0) {
02347                   last_length = strlen(buf);
02348                   playz++;
02349                   continue;
02350                }
02351                snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
02352                playh++;
02353                snprintf(buf, 10, "%d", num);
02354                ast_debug(1, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
02355                last_length = strlen(buf);
02356                num -= ((num / 100) * 100);
02357             } else if (num < 10000){
02358                snprintf(buf, 10, "%d", num);
02359                snprintf(fn, sizeof(fn), "digits/%d", (num / 1000));
02360                playt++;
02361                snprintf(buf, 10, "%d", num);
02362                ast_debug(1, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
02363                last_length = strlen(buf);
02364                num -= ((num / 1000) * 1000);
02365             } else if (num < 100000000) { /* 100,000,000 */
02366                   res = ast_say_number_full_zh(chan, num / 10000, ints, language, audiofd, ctrlfd);
02367                   if (res)
02368                      return res;
02369                   snprintf(buf, 10, "%d", num);
02370                   ast_debug(1, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
02371                   num -= ((num / 10000) * 10000);
02372                   last_length = strlen(buf);
02373                   snprintf(fn, sizeof(fn), "digits/wan");
02374             } else {
02375                if (num < 1000000000) { /* 1,000,000,000 */
02376                   res = ast_say_number_full_zh(chan, num / 100000000, ints, language, audiofd, ctrlfd);
02377                   if (res)
02378                      return res;
02379                   snprintf(buf, 10, "%d", num);
02380                   ast_debug(1, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
02381                   last_length = strlen(buf);
02382                   num -= ((num / 100000000) * 100000000);
02383                   snprintf(fn, sizeof(fn), "digits/yi");
02384                } else {
02385                   ast_debug(1, "Number '%d' is too big for me\n", num);
02386                   res = -1;
02387                }
02388             }
02389          }
02390          if (!res) {
02391             if (!ast_streamfile(chan, fn, language)) {
02392                if ((audiofd > -1) && (ctrlfd > -1))
02393                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02394                else
02395                   res = ast_waitstream(chan, ints);
02396             }
02397             ast_stopstream(chan);
02398          }
02399    }
02400    return res;
02401 }

int ast_say_time_de ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

German syntax.

Definition at line 6362 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06363 {
06364    struct timeval when = { t, 0 };
06365    struct ast_tm tm;
06366    int res = 0;
06367 
06368    ast_localtime(&when, &tm, NULL);
06369    if (!res)
06370       res = ast_say_number(chan, tm.tm_hour, ints, lang, "n");
06371    if (!res)
06372       res = ast_streamfile(chan, "digits/oclock", lang);
06373    if (!res)
06374       res = ast_waitstream(chan, ints);
06375    if (!res)
06376        if (tm.tm_min > 0) 
06377       res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
06378    return res;
06379 }

int ast_say_time_en ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

English syntax.

Definition at line 6313 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06314 {
06315    struct timeval when = { t, 0 };
06316    struct ast_tm tm;
06317    int res = 0;
06318    int hour, pm=0;
06319 
06320    ast_localtime(&when, &tm, NULL);
06321    hour = tm.tm_hour;
06322    if (!hour)
06323       hour = 12;
06324    else if (hour == 12)
06325       pm = 1;
06326    else if (hour > 12) {
06327       hour -= 12;
06328       pm = 1;
06329    }
06330    if (!res)
06331       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06332 
06333    if (tm.tm_min > 9) {
06334       if (!res)
06335          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06336    } else if (tm.tm_min) {
06337       if (!res)
06338          res = ast_streamfile(chan, "digits/oh", lang);
06339       if (!res)
06340          res = ast_waitstream(chan, ints);
06341       if (!res)
06342          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06343    } else {
06344       if (!res)
06345          res = ast_streamfile(chan, "digits/oclock", lang);
06346       if (!res)
06347          res = ast_waitstream(chan, ints);
06348    }
06349    if (pm) {
06350       if (!res)
06351          res = ast_streamfile(chan, "digits/p-m", lang);
06352    } else {
06353       if (!res)
06354          res = ast_streamfile(chan, "digits/a-m", lang);
06355    }
06356    if (!res)
06357       res = ast_waitstream(chan, ints);
06358    return res;
06359 }

int ast_say_time_fr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

French syntax.

Definition at line 6405 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06406 {
06407    struct timeval when = { t, 0 };
06408    struct ast_tm tm;
06409    int res = 0;
06410 
06411    ast_localtime(&when, &tm, NULL);
06412 
06413    res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
06414    if (!res)
06415       res = ast_streamfile(chan, "digits/oclock", lang);
06416    if (tm.tm_min) {
06417       if (!res)
06418       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06419    }
06420    return res;
06421 }

static int ast_say_time_gr ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Greek support.

A list of the files that you need to create

  • digits/female/1..4 : "Mia, dyo , treis, tesseris "
  • digits/kai : "KAI"
  • didgits : "h wra"
  • digits/p-m : "meta meshmbrias"
  • digits/a-m : "pro meshmbrias"

Definition at line 7412 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), gr_say_number_female(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by ast_say_datetime_gr(), and say_time().

07413 {
07414 
07415    struct timeval when = { t, 0 };
07416    struct ast_tm tm;
07417    int res = 0;
07418    int hour, pm=0;
07419 
07420    ast_localtime(&when, &tm, NULL);
07421    hour = tm.tm_hour;
07422 
07423    if (!hour)
07424       hour = 12;
07425    else if (hour == 12)
07426       pm = 1;
07427    else if (hour > 12) {
07428       hour -= 12;
07429       pm = 1;
07430    }
07431  
07432    res = gr_say_number_female(hour, chan, ints, lang);
07433    if (tm.tm_min) {
07434       if (!res)
07435          res = ast_streamfile(chan, "digits/kai", lang);
07436       if (!res)
07437          res = ast_waitstream(chan, ints);
07438       if (!res)
07439          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
07440    } else {
07441       if (!res)
07442          res = ast_streamfile(chan, "digits/hwra", lang);
07443       if (!res)
07444          res = ast_waitstream(chan, ints);
07445    }
07446    if (pm) {
07447       if (!res)
07448          res = ast_streamfile(chan, "digits/p-m", lang);
07449    } else {
07450       if (!res)
07451          res = ast_streamfile(chan, "digits/a-m", lang);
07452    }
07453    if (!res)
07454       res = ast_waitstream(chan, ints);
07455    return res;
07456 }

int ast_say_time_he ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Hebrew syntax.

Definition at line 6563 of file say.c.

References ast_localtime(), ast_say_number_full_he(), ast_waitstream(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06564 {
06565    struct timeval when = { t, 0 };
06566    struct ast_tm tm;
06567    int res = 0;
06568    int hour;
06569 
06570    ast_localtime(&when, &tm, NULL);
06571    hour = tm.tm_hour;
06572    if (!hour)
06573       hour = 12;
06574 
06575    if (!res)
06576       res = ast_say_number_full_he(chan, hour, ints, lang, "f", -1, -1);
06577 
06578    if (tm.tm_min > 9) {
06579       if (!res)
06580          res = ast_say_number_full_he(chan, tm.tm_min, ints, lang, "f", -1, -1);
06581    } else if (tm.tm_min) {
06582       if (!res) {          /* say a leading zero if needed */
06583          res = ast_say_number_full_he(chan, 0, ints, lang, "f", -1, -1);
06584       }
06585       if (!res)
06586          res = ast_waitstream(chan, ints);
06587       if (!res)
06588          res = ast_say_number_full_he(chan, tm.tm_min, ints, lang, "f", -1, -1);
06589    } else {
06590       if (!res)
06591          res = ast_waitstream(chan, ints);
06592    }
06593    if (!res)
06594       res = ast_waitstream(chan, ints);
06595    return res;
06596 }

int ast_say_time_hu ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Hungarian syntax.

Definition at line 6382 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06383 {
06384    struct timeval when = { t, 0 };
06385    struct ast_tm tm;
06386    int res = 0;
06387 
06388    ast_localtime(&when, &tm, NULL);
06389    if (!res)
06390       res = ast_say_number(chan, tm.tm_hour, ints, lang, "n");
06391    if (!res)
06392       res = ast_streamfile(chan, "digits/oclock", lang);
06393    if (!res)
06394       res = ast_waitstream(chan, ints);
06395    if (!res)
06396        if (tm.tm_min > 0) { 
06397          res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
06398          if (!res)
06399             res = ast_streamfile(chan, "digits/minute", lang);
06400       }
06401    return res;
06402 }

static int ast_say_time_ka ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Georgian syntax. e.g. "otxi saati da eqvsi tsuti".

Definition at line 8157 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

08158 {
08159    struct timeval when = { t, 0 };
08160    struct ast_tm tm;
08161    int res = 0;
08162 
08163    ast_localtime(&when, &tm, NULL);
08164 
08165    res = ast_say_number(chan, tm.tm_hour, ints, lang, (char*)NULL);
08166    if (!res) {
08167       res = ast_streamfile(chan, "digits/saati_da", lang);
08168       if (!res)
08169          res = ast_waitstream(chan, ints);
08170    }
08171 
08172    if (tm.tm_min) {
08173       if (!res) {
08174          res = ast_say_number(chan, tm.tm_min, ints, lang, (char*)NULL);
08175 
08176          if (!res) {
08177             res = ast_streamfile(chan, "digits/tsuti", lang);
08178             if (!res)
08179                res = ast_waitstream(chan, ints);
08180          }
08181       }
08182    }
08183    return res;
08184 }

int ast_say_time_nl ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Dutch syntax.

Definition at line 6424 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06425 {
06426    struct timeval when = { t, 0 };
06427    struct ast_tm tm;
06428    int res = 0;
06429 
06430    ast_localtime(&when, &tm, NULL);
06431    if (!res)
06432       res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
06433    if (!res)
06434       res = ast_streamfile(chan, "digits/nl-uur", lang);
06435    if (!res)
06436       res = ast_waitstream(chan, ints);
06437    if (!res)
06438        if (tm.tm_min > 0) 
06439       res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
06440    return res;
06441 }

int ast_say_time_pt ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Portuguese syntax.

Definition at line 6444 of file say.c.

References ast_localtime(), ast_say_number(), ast_tm::tm_hour, ast_tm::tm_min, and wait_file().

Referenced by say_time().

06445 {
06446    struct timeval when = { t, 0 };
06447    struct ast_tm tm;
06448    int res = 0;
06449    int hour;
06450 
06451    ast_localtime(&when, &tm, NULL);
06452    hour = tm.tm_hour;
06453    if (!res)
06454       res = ast_say_number(chan, hour, ints, lang, "f");
06455    if (tm.tm_min) {
06456       if (!res)
06457          res = wait_file(chan, ints, "digits/pt-e", lang);
06458       if (!res)
06459          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06460    } else {
06461       if (!res)
06462          res = wait_file(chan, ints, "digits/pt-hora", lang);
06463       if (tm.tm_hour != 1)
06464          if (!res)
06465             res = wait_file(chan, ints, "digits/pt-sss", lang);
06466    }
06467    if (!res)
06468       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06469    return res;
06470 }

int ast_say_time_pt_BR ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Brazilian Portuguese syntax.

Definition at line 6473 of file say.c.

References ast_localtime(), ast_say_number(), ast_tm::tm_hour, ast_tm::tm_min, and wait_file().

Referenced by say_time().

06474 {
06475    struct timeval when = { t, 0 };
06476    struct ast_tm tm;
06477    int res = 0;
06478 
06479    ast_localtime(&when, &tm, NULL);
06480 
06481    res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
06482    if (!res) {
06483       if (tm.tm_hour > 1)
06484          res = wait_file(chan, ints, "digits/hours", lang);
06485       else
06486          res = wait_file(chan, ints, "digits/hour", lang);
06487    }
06488    if ((!res) && (tm.tm_min)) {
06489       res = wait_file(chan, ints, "digits/pt-e", lang);
06490       if (!res)
06491          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06492       if (!res) {
06493          if (tm.tm_min > 1)
06494             res = wait_file(chan, ints, "digits/minutes", lang);
06495          else
06496             res = wait_file(chan, ints, "digits/minute", lang);
06497       }
06498    }
06499    return res;
06500 }

int ast_say_time_th ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Thai syntax.

Definition at line 6503 of file say.c.

References ast_localtime(), ast_say_number(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06504 {
06505    struct timeval when = { t, 0 };
06506    struct ast_tm tm;
06507    int res = 0;
06508    int hour;
06509    ast_localtime(&when, &tm, NULL);
06510    hour = tm.tm_hour;
06511    if (!hour)
06512       hour = 24;
06513    if (!res)
06514       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06515    if (!res)
06516       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06517    return res;
06518 }

int ast_say_time_zh ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Taiwanese / Chinese syntax.

Definition at line 6521 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), ast_tm::tm_hour, and ast_tm::tm_min.

Referenced by say_time().

06522 {
06523    struct timeval when = { t, 0 };
06524    struct ast_tm tm;
06525    int res = 0;
06526    int hour, pm=0;
06527 
06528    ast_localtime(&when, &tm, NULL);
06529    hour = tm.tm_hour;
06530    if (!hour)
06531       hour = 12;
06532    else if (hour == 12)
06533       pm = 1;
06534    else if (hour > 12) {
06535       hour -= 12;
06536       pm = 1;
06537    }
06538    if (pm) {
06539       if (!res)
06540          res = ast_streamfile(chan, "digits/p-m", lang);
06541    } else {
06542       if (!res)
06543          res = ast_streamfile(chan, "digits/a-m", lang);
06544    }
06545    if (!res)
06546       res = ast_waitstream(chan, ints);
06547    if (!res)
06548       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
06549    if (!res)
06550       res = ast_streamfile(chan, "digits/oclock", lang);
06551    if (!res)
06552       res = ast_waitstream(chan, ints);
06553    if (!res)
06554       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06555    if (!res)
06556       res = ast_streamfile(chan, "digits/minute", lang);
06557    if (!res)
06558       res = ast_waitstream(chan, ints);
06559    return res;
06560 }

static char* ast_translate_number_ka ( int  num,
char *  res,
int  res_len 
) [static]

Georgian support.

Convert a number into a semi-localized string. Only for Georgian. res must be of at least 256 bytes, preallocated. The output corresponds to Georgian spoken numbers, so it may be either converted to real words by applying a direct conversion table, or played just by substituting the entities with played files.

Output may consist of the following tokens (separated by spaces): 0, minus. 1-9, 1_-9_. (erti, ori, sami, otxi, ... . erti, or, sam, otx, ...). 10-19. 20, 40, 60, 80, 20_, 40_, 60_, 80_. (oci, ormoci, ..., ocda, ormocda, ...). 100, 100_, 200, 200_, ..., 900, 900_. (asi, as, orasi, oras, ...). 1000, 1000_. (atasi, atas). 1000000, 1000000_. (milioni, milion). 1000000000, 1000000000_. (miliardi, miliard).

To be able to play the sounds, each of the above tokens needs a corresponding sound file. (e.g. 200_.gsm).

Definition at line 7904 of file say.c.

Referenced by ast_say_number_full_ka().

07905 {
07906    char buf[256];
07907    int digit = 0;
07908    int remaining = 0;
07909 
07910 
07911    if (num < 0) {
07912       strncat(res, "minus ", res_len - strlen(res) - 1);
07913       if ( num > INT_MIN ) {
07914          num = -num;
07915       } else {
07916          num = 0;
07917       }
07918    }
07919 
07920 
07921    /* directly read the numbers */
07922    if (num <= 20 || num == 40 || num == 60 || num == 80 || num == 100) {
07923       snprintf(buf, sizeof(buf), "%d", num);
07924       strncat(res, buf, res_len - strlen(res) - 1);
07925       return res;
07926    }
07927 
07928 
07929    if (num < 40) {  /* ocda... */
07930       strncat(res, "20_ ", res_len - strlen(res) - 1);
07931       return ast_translate_number_ka(num - 20, res, res_len);
07932    }
07933 
07934    if (num < 60) {  /* ormocda... */
07935       strncat(res, "40_ ", res_len - strlen(res) - 1);
07936       return ast_translate_number_ka(num - 40, res, res_len);
07937    }
07938 
07939    if (num < 80) {  /* samocda... */
07940       strncat(res, "60_ ", res_len - strlen(res) - 1);
07941       return ast_translate_number_ka(num - 60, res, res_len);
07942    }
07943 
07944    if (num < 100) {  /* otxmocda... */
07945       strncat(res, "80_ ", res_len - strlen(res) - 1);
07946       return ast_translate_number_ka(num - 80, res, res_len);
07947    }
07948 
07949 
07950    if (num < 1000) {  /*  as, oras, samas, ..., cxraas. asi, orasi, ..., cxraasi. */
07951       remaining = num % 100;
07952       digit = (num - remaining) / 100;
07953 
07954       if (remaining == 0) {
07955          snprintf(buf, sizeof(buf), "%d", num);
07956          strncat(res, buf, res_len - strlen(res) - 1);
07957          return res;
07958       } else {
07959          snprintf(buf, sizeof(buf), "%d_ ", digit*100);
07960          strncat(res, buf, res_len - strlen(res) - 1);
07961          return ast_translate_number_ka(remaining, res, res_len);
07962       }
07963    }
07964 
07965 
07966    if (num == 1000) {
07967       strncat(res, "1000", res_len - strlen(res) - 1);
07968       return res;
07969    }
07970 
07971 
07972    if (num < 1000000) {
07973       remaining = num % 1000;
07974       digit = (num - remaining) / 1000;
07975 
07976       if (remaining == 0) {
07977          ast_translate_number_ka(digit, res, res_len);
07978          strncat(res, " 1000", res_len - strlen(res) - 1);
07979          return res;
07980       }
07981 
07982       if (digit == 1) {
07983          strncat(res, "1000_ ", res_len - strlen(res) - 1);
07984          return ast_translate_number_ka(remaining, res, res_len);
07985       }
07986 
07987       ast_translate_number_ka(digit, res, res_len);
07988       strncat(res, " 1000_ ", res_len - strlen(res) - 1);
07989       return ast_translate_number_ka(remaining, res, res_len);
07990    }
07991 
07992 
07993    if (num == 1000000) {
07994       strncat(res, "1 1000000", res_len - strlen(res) - 1);
07995       return res;
07996    }
07997 
07998 
07999    if (num < 1000000000) {
08000       remaining = num % 1000000;
08001       digit = (num - remaining) / 1000000;
08002 
08003       if (remaining == 0) {
08004          ast_translate_number_ka(digit, res, res_len);
08005          strncat(res, " 1000000", res_len - strlen(res) - 1);
08006          return res;
08007       }
08008 
08009       ast_translate_number_ka(digit, res, res_len);
08010       strncat(res, " 1000000_ ", res_len - strlen(res) - 1);
08011       return ast_translate_number_ka(remaining, res, res_len);
08012    }
08013 
08014 
08015    if (num == 1000000000) {
08016       strncat(res, "1 1000000000", res_len - strlen(res) - 1);
08017       return res;
08018    }
08019 
08020 
08021    if (num > 1000000000) {
08022       remaining = num % 1000000000;
08023       digit = (num - remaining) / 1000000000;
08024 
08025       if (remaining == 0) {
08026          ast_translate_number_ka(digit, res, res_len);
08027          strncat(res, " 1000000000", res_len - strlen(res) - 1);
08028          return res;
08029       }
08030 
08031       ast_translate_number_ka(digit, res, res_len);
08032       strncat(res, " 1000000000_ ", res_len - strlen(res) - 1);
08033       return ast_translate_number_ka(remaining, res, res_len);
08034    }
08035 
08036    return res;
08037 
08038 }

static const char* counted_adjective_ending_ru ( int  num,
const char  gender[] 
) [static]

In slavic languages such as Russian and Ukrainian the rules for declining adjectives are simpler than those for nouns. When counting we use only the singular (to which we give no suffix) and the genative plural (which we represent by adding an "x"). Oh, an in the singular gender matters so we append the supplied gender suffix ("m", "f", "n").

Definition at line 8320 of file say.c.

Referenced by ast_say_counted_adjective().

08321 {
08322    if (num < 0) {
08323        num *= -1;
08324    }
08325    num %= 100;    /* never pay attention to more than two digits */
08326    if (num >= 20) {  /* at 20 and beyond only the last digit matters */
08327        num %= 10;
08328    }
08329    if (num == 1) {
08330        return gender ? gender : "";
08331    } else {    /* all other numbers get the genative plural */
08332        return "x";
08333    }
08334 }

static const char* counted_noun_ending_en ( int  num  )  [static]

In English, we use the plural for everything but one. For example:

  • 1 degree
  • 2 degrees
  • 5 degrees The filename for the plural form is generated by appending "s". Note that purpose is to generate a unique filename, not to implement irregular declensions. Thus:
  • 1 man
  • 2 mans (the "mans" soundfile will of course say "men").

Definition at line 8256 of file say.c.

Referenced by ast_say_counted_noun().

08257 {
08258    if (num == 1 || num == -1) {
08259       return "";
08260    } else {
08261       return "s";
08262    }
08263 }

static const char* counted_noun_ending_slavic ( int  num  )  [static]

Counting of objects in slavic languages such as Russian and Ukrainian the rules are more complicated. There are two plural forms used in counting. They are the genative singular which we represent with the suffix "x1" and the genative plural which we represent with the suffix "x2". The base names of the soundfiles remain in English. For example:

  • 1 degree (soudfile says "gradus")
  • 2 degreex1 (soundfile says "gradusa")
  • 5 degreex2 (soundfile says "gradusov").

Definition at line 8275 of file say.c.

Referenced by ast_say_counted_noun().

08276 {
08277    if (num < 0) {
08278        num *= -1;
08279    }
08280    num %= 100;       /* never pay attention to more than two digits */
08281    if (num >= 20) {     /* for numbers 20 and above, pay attention to only last digit */
08282        num %= 10;
08283    }
08284    if (num == 1) {         /* singular */
08285        return "";
08286    }
08287    if (num > 0 && num < 5) {  /* 2--4 get genative singular */
08288        return "x1";
08289    } else {       /* 5--19 get genative plural */
08290        return "x2";
08291    }
08292 }

static int exp10_int ( int  power  )  [static]

Definition at line 578 of file say.c.

Referenced by ast_say_number_full_cs().

00579 {
00580    int x, res= 1;
00581    for (x=0;x<power;x++)
00582       res *= 10;
00583    return res;
00584 }

static int get_lastdigits_ru ( int  num  )  [static]

determine last digits for thousands/millions (ru)

Definition at line 2466 of file say.c.

Referenced by ast_say_number_full_ru().

02466                                       {
02467    if (num < 20) {
02468       return num;
02469    } else if (num < 100) {
02470       return get_lastdigits_ru(num % 10);
02471    } else if (num < 1000) {
02472       return get_lastdigits_ru(num % 100);
02473    }
02474    return 0;   /* number too big */
02475 }

static int gr_say_number_female ( int  num,
struct ast_channel chan,
const char *  ints,
const char *  lang 
) [static]

Greek digits/female-[1..4] : "Mia, dyo , treis, tessereis".

Definition at line 7244 of file say.c.

References ast_say_number(), ast_streamfile(), ast_waitstream(), and wait_file().

Referenced by ast_say_date_gr(), ast_say_date_with_format_gr(), ast_say_datetime_gr(), and ast_say_time_gr().

07244                                                                                                       {
07245    int tmp;
07246    int left;
07247    int res;
07248    char fn[256] = "";
07249 
07250    /* ast_debug(1, "\n\n Saying number female %s %d \n\n", lang, num); */
07251    if (num < 5) {
07252       snprintf(fn, sizeof(fn), "digits/female-%d", num);
07253       res = wait_file(chan, ints, fn, lang);
07254    } else if (num < 13) {
07255       res = ast_say_number(chan, num, ints, lang, (char *) NULL);
07256    } else if (num <100 ) {
07257       tmp = (num/10) * 10;
07258       left = num - tmp;
07259       snprintf(fn, sizeof(fn), "digits/%d", tmp);
07260       res = ast_streamfile(chan, fn, lang);
07261       if (!res)
07262          res = ast_waitstream(chan, ints);
07263       if (left)
07264          gr_say_number_female(left, chan, ints, lang);
07265 
07266    } else {
07267       return -1;
07268    }
07269    return res;
07270 }

static char next_item ( const char *  format  )  [static]

Definition at line 3928 of file say.c.

References ast_skip_blanks().

Referenced by ast_say_date_with_format_da(), and ast_say_date_with_format_de().

03929 {
03930    const char *next = ast_skip_blanks(format);
03931    return *next;
03932 }

static char* pl_append ( char *  buffer,
char *  str 
) [static]

Definition at line 1836 of file say.c.

Referenced by powiedz().

01837 {
01838    strcpy(buffer, str);
01839    buffer += strlen(str);
01840    return buffer;
01841 }

static void pl_odtworz_plik ( struct ast_channel chan,
const char *  language,
int  audiofd,
int  ctrlfd,
const char *  ints,
char *  fn 
) [static]

Definition at line 1843 of file say.c.

References ast_debug, ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by powiedz().

01844 {
01845    char file_name[255] = "digits/";
01846    strcat(file_name, fn);
01847    ast_debug(1, "Trying to play: %s\n", file_name);
01848    if (!ast_streamfile(chan, file_name, language)) {
01849       if ((audiofd > -1) && (ctrlfd > -1))
01850          ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01851       else
01852          ast_waitstream(chan, ints);
01853    }
01854    ast_stopstream(chan);
01855 }

static char* pl_rzad_na_tekst ( odmiana odm,
int  i,
int  rzad 
) [static]

Definition at line 1823 of file say.c.

References odmiana::rzedy.

Referenced by powiedz().

01824 {
01825    if (rzad==0)
01826       return "";
01827  
01828    if (i==1)
01829       return odm->rzedy[rzad - 1][0];
01830    if ((i > 21 || i < 11) &&  i%10 > 1 && i%10 < 5)
01831       return odm->rzedy[rzad - 1][1];
01832    else
01833       return odm->rzedy[rzad - 1][2];
01834 }

static void powiedz ( struct ast_channel chan,
const char *  language,
int  audiofd,
int  ctrlfd,
const char *  ints,
odmiana odm,
int  rzad,
int  i 
) [static]

Definition at line 1857 of file say.c.

References odmiana::cyfry, odmiana::cyfry2, odmiana::dziesiatki, odmiana::nastki, pl_append(), pl_odtworz_plik(), pl_rzad_na_tekst(), odmiana::separator_dziesiatek, and odmiana::setki.

Referenced by ast_say_number_full_pl().

01858 {
01859    /* Initialise variables to allow compilation on Debian-stable, etc */
01860    int m1000E6 = 0;
01861    int i1000E6 = 0;
01862    int m1000E3 = 0;
01863    int i1000E3 = 0;
01864    int m1000 = 0;
01865    int i1000 = 0;
01866    int m100 = 0;
01867    int i100 = 0;
01868    
01869    if (i == 0 && rzad > 0) { 
01870       return;
01871    }
01872    if (i == 0) {
01873       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry[0]);
01874       return;
01875    }
01876 
01877    m1000E6 = i % 1000000000;
01878    i1000E6 = i / 1000000000;
01879 
01880    powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+3, i1000E6);
01881 
01882    m1000E3 = m1000E6 % 1000000;
01883    i1000E3 = m1000E6 / 1000000;
01884 
01885    powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+2, i1000E3);
01886 
01887    m1000 = m1000E3 % 1000;
01888    i1000 = m1000E3 / 1000;
01889 
01890    powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+1, i1000);
01891 
01892    m100 = m1000 % 100;
01893    i100 = m1000 / 100;
01894    
01895    if (i100>0)
01896       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->setki[i100]);
01897 
01898    if ( m100 > 0 && m100 <=9 ) {
01899       if (m1000>0)
01900          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry2[m100]);
01901       else
01902          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry[m100]);
01903    } else if (m100 % 10 == 0) {
01904       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->dziesiatki[m100 / 10]);
01905    } else if (m100 <= 19 ) {
01906       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->nastki[m100 % 10]);
01907    } else if (m100 != 0) {
01908       if (odm->separator_dziesiatek[0]==' ') {
01909          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->dziesiatki[m100 / 10]);
01910          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry2[m100 % 10]);
01911       } else {
01912          char buf[10];
01913          char *b = buf;
01914          b = pl_append(b, odm->dziesiatki[m100 / 10]);  
01915          b = pl_append(b, odm->separator_dziesiatek);  
01916          b = pl_append(b, odm->cyfry2[m100 % 10]); 
01917          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, buf);
01918       }
01919    } 
01920 
01921    if (rzad > 0) {
01922       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, pl_rzad_na_tekst(odm, i, rzad));
01923    }
01924 }

static int say_character_str_full ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 60 of file say.c.

References ast_fileexists(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by __say_init(), and say_init_mode().

00061 {
00062    const char *fn;
00063    char fnbuf[10], asciibuf[20] = "letters/ascii";
00064    char ltr;
00065    int num = 0;
00066    int res = 0;
00067 
00068    while (str[num] && !res) {
00069       fn = NULL;
00070       switch (str[num]) {
00071       case ('*'):
00072          fn = "digits/star";
00073          break;
00074       case ('#'):
00075          fn = "digits/pound";
00076          break;
00077       case ('!'):
00078          fn = "letters/exclaimation-point";
00079          break;
00080       case ('@'):
00081          fn = "letters/at";
00082          break;
00083       case ('$'):
00084          fn = "letters/dollar";
00085          break;
00086       case ('-'):
00087          fn = "letters/dash";
00088          break;
00089       case ('.'):
00090          fn = "letters/dot";
00091          break;
00092       case ('='):
00093          fn = "letters/equals";
00094          break;
00095       case ('+'):
00096          fn = "letters/plus";
00097          break;
00098       case ('/'):
00099          fn = "letters/slash";
00100          break;
00101       case (' '):
00102          fn = "letters/space";
00103          break;
00104       case ('0'):
00105       case ('1'):
00106       case ('2'):
00107       case ('3'):
00108       case ('4'):
00109       case ('5'):
00110       case ('6'):
00111       case ('7'):
00112       case ('8'):
00113       case ('9'):
00114          strcpy(fnbuf, "digits/X");
00115          fnbuf[7] = str[num];
00116          fn = fnbuf;
00117          break;
00118       default:
00119          ltr = str[num];
00120          if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A';    /* file names are all lower-case */
00121          strcpy(fnbuf, "letters/X");
00122          fnbuf[8] = ltr;
00123          fn = fnbuf;
00124       }
00125       if ((fn && ast_fileexists(fn, NULL, lang) > 0) ||
00126          (snprintf(asciibuf + 13, sizeof(asciibuf) - 13, "%d", str[num]) > 0 && ast_fileexists(asciibuf, NULL, lang) > 0 && (fn = asciibuf))) {
00127          res = ast_streamfile(chan, fn, lang);
00128          if (!res) {
00129             if ((audiofd  > -1) && (ctrlfd > -1))
00130                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00131             else
00132                res = ast_waitstream(chan, ints);
00133          }
00134          ast_stopstream(chan);
00135       }
00136       num++;
00137    }
00138 
00139    return res;
00140 }

static int say_date ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Definition at line 3288 of file say.c.

References ast_log(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_hu(), ast_say_date_ka(), ast_say_date_nl(), ast_say_date_pt(), ast_say_date_th(), and LOG_WARNING.

03289 {
03290    if (!strncasecmp(lang, "en", 2)) {        /* English syntax */
03291       return ast_say_date_en(chan, t, ints, lang);
03292    } else if (!strncasecmp(lang, "da", 2)) { /* Danish syntax */
03293       return ast_say_date_da(chan, t, ints, lang);
03294    } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */
03295       return ast_say_date_de(chan, t, ints, lang);
03296    } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */
03297       return ast_say_date_fr(chan, t, ints, lang);
03298    } else if (!strncasecmp(lang, "ge", 2)) { /* deprecated Georgian syntax */
03299       static int deprecation_warning = 0;
03300       if (deprecation_warning++ % 10 == 0) {
03301          ast_log(LOG_WARNING, "ge is not a standard language code.  Please switch to using ka instead.\n");
03302       }
03303       return ast_say_date_ka(chan, t, ints, lang);
03304    } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */
03305       return ast_say_date_gr(chan, t, ints, lang);
03306    } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */
03307       return ast_say_date_he(chan, t, ints, lang);
03308    } else if (!strncasecmp(lang, "hu", 2)) { /* Hungarian syntax */
03309       return ast_say_date_hu(chan, t, ints, lang);
03310    } else if (!strncasecmp(lang, "ka", 2)) { /* Georgian syntax */
03311       return ast_say_date_ka(chan, t, ints, lang);
03312    } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */
03313       return ast_say_date_nl(chan, t, ints, lang);
03314    } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */
03315       return ast_say_date_pt(chan, t, ints, lang);
03316    } else if (!strncasecmp(lang, "th", 2)) { /* Thai syntax */
03317       return ast_say_date_th(chan, t, ints, lang);
03318    }
03319 
03320    /* Default to English */
03321    return ast_say_date_en(chan, t, ints, lang);
03322 }

static int say_date_with_format ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang,
const char *  format,
const char *  tzone 
) [static]

Definition at line 3639 of file say.c.

References ast_log(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_date_with_format_zh(), and LOG_WARNING.

03640 {
03641    if (!strncasecmp(lang, "en", 2)) {      /* English syntax */
03642       return ast_say_date_with_format_en(chan, t, ints, lang, format, tzone);
03643    } else if (!strncasecmp(lang, "da", 2)) { /* Danish syntax */
03644       return ast_say_date_with_format_da(chan, t, ints, lang, format, tzone);
03645    } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */
03646       return ast_say_date_with_format_de(chan, t, ints, lang, format, tzone);
03647    } else if (!strncasecmp(lang, "es", 2)) { /* Spanish syntax */
03648       return ast_say_date_with_format_es(chan, t, ints, lang, format, tzone);
03649    } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */
03650       return ast_say_date_with_format_he(chan, t, ints, lang, format, tzone);
03651    } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */
03652       return ast_say_date_with_format_fr(chan, t, ints, lang, format, tzone);
03653    } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */
03654       return ast_say_date_with_format_gr(chan, t, ints, lang, format, tzone);
03655    } else if (!strncasecmp(lang, "it", 2)) { /* Italian syntax */
03656       return ast_say_date_with_format_it(chan, t, ints, lang, format, tzone);
03657    } else if (!strncasecmp(lang, "mx", 2)) { /* deprecated Mexican syntax */
03658       static int deprecation_warning = 0;
03659       if (deprecation_warning++ % 10 == 0) {
03660          ast_log(LOG_WARNING, "mx is not a standard language code.  Please switch to using es_MX instead.\n");
03661       }
03662       return ast_say_date_with_format_es(chan, t, ints, lang, format, tzone);
03663    } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */
03664       return ast_say_date_with_format_nl(chan, t, ints, lang, format, tzone);
03665    } else if (!strncasecmp(lang, "pl", 2)) { /* Polish syntax */
03666       return ast_say_date_with_format_pl(chan, t, ints, lang, format, tzone);
03667    } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */
03668       return ast_say_date_with_format_pt(chan, t, ints, lang, format, tzone);
03669    } else if (!strncasecmp(lang, "th", 2)) { /* Thai syntax */
03670       return ast_say_date_with_format_th(chan, t, ints, lang, format, tzone);
03671    } else if (!strncasecmp(lang, "tw", 2)) { /* deprecated Taiwanese syntax */
03672       static int deprecation_warning = 0;
03673       if (deprecation_warning++ % 10 == 0) {
03674          ast_log(LOG_WARNING, "tw is a standard language code for Twi, not Taiwanese.  Please switch to using zh_TW instead.\n");
03675       }
03676       return ast_say_date_with_format_zh(chan, t, ints, lang, format, tzone);
03677    } else if (!strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */
03678       return ast_say_date_with_format_zh(chan, t, ints, lang, format, tzone);
03679    } else if (!strncasecmp(lang, "vi", 2)) { /* Vietnamese syntax */
03680       return ast_say_date_with_format_vi(chan, t, ints, lang, format, tzone);
03681    }
03682 
03683    /* Default to English */
03684    return ast_say_date_with_format_en(chan, t, ints, lang, format, tzone);
03685 }

static int say_datetime ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Definition at line 6599 of file say.c.

References ast_log(), ast_say_datetime_de(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_gr(), ast_say_datetime_he(), ast_say_datetime_hu(), ast_say_datetime_ka(), ast_say_datetime_nl(), ast_say_datetime_pt(), ast_say_datetime_pt_BR(), ast_say_datetime_th(), ast_say_datetime_zh(), and LOG_WARNING.

06600 {
06601    if (!strncasecmp(lang, "en", 2)) {        /* English syntax */
06602       return ast_say_datetime_en(chan, t, ints, lang);
06603    } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */
06604       return ast_say_datetime_de(chan, t, ints, lang);
06605    } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */
06606       return ast_say_datetime_fr(chan, t, ints, lang);
06607    } else if (!strncasecmp(lang, "ge", 2)) { /* deprecated Georgian syntax */
06608       static int deprecation_warning = 0;
06609       if (deprecation_warning++ % 10 == 0) {
06610          ast_log(LOG_WARNING, "ge is not a standard language code.  Please switch to using ka instead.\n");
06611       }
06612       return ast_say_datetime_ka(chan, t, ints, lang);
06613    } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */
06614       return ast_say_datetime_gr(chan, t, ints, lang);
06615    } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */
06616       return ast_say_datetime_he(chan, t, ints, lang);
06617    } else if (!strncasecmp(lang, "hu", 2)) { /* Hungarian syntax */
06618       return ast_say_datetime_hu(chan, t, ints, lang);
06619    } else if (!strncasecmp(lang, "ka", 2)) { /* Georgian syntax */
06620       return ast_say_datetime_ka(chan, t, ints, lang);
06621    } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */
06622       return ast_say_datetime_nl(chan, t, ints, lang);
06623    } else if (!strncasecmp(lang, "pt_BR", 5)) { /* Brazilian Portuguese syntax */
06624       return ast_say_datetime_pt_BR(chan, t, ints, lang);
06625    } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */
06626       return ast_say_datetime_pt(chan, t, ints, lang);
06627    } else if (!strncasecmp(lang, "th", 2)) { /* Thai syntax */
06628       return ast_say_datetime_th(chan, t, ints, lang);
06629    } else if (!strncasecmp(lang, "tw", 2)) { /* deprecated Taiwanese syntax */
06630       static int deprecation_warning = 0;
06631       if (deprecation_warning++ % 10 == 0) {
06632          ast_log(LOG_WARNING, "tw is a standard language code for Twi, not Taiwanese.  Please switch to using zh_TW instead.\n");
06633       }
06634       return ast_say_datetime_zh(chan, t, ints, lang);
06635    } else if (!strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */
06636       return ast_say_datetime_zh(chan, t, ints, lang);
06637    }
06638 
06639    /* Default to English */
06640    return ast_say_datetime_en(chan, t, ints, lang);
06641 }

static int say_datetime_from_now ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Definition at line 7049 of file say.c.

References ast_log(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_from_now_pt(), and LOG_WARNING.

Referenced by __say_init(), and say_init_mode().

07050 {
07051    if (!strncasecmp(lang, "en", 2)) {        /* English syntax */
07052       return ast_say_datetime_from_now_en(chan, t, ints, lang);
07053    } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */
07054       return ast_say_datetime_from_now_fr(chan, t, ints, lang);
07055    } else if (!strncasecmp(lang, "ge", 2)) { /* deprecated Georgian syntax */
07056       static int deprecation_warning = 0;
07057       if (deprecation_warning++ % 10 == 0) {
07058          ast_log(LOG_WARNING, "ge is not a standard language code.  Please switch to using ka instead.\n");
07059       }
07060       return ast_say_datetime_from_now_ka(chan, t, ints, lang);
07061    } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */
07062       return ast_say_datetime_from_now_he(chan, t, ints, lang);
07063    } else if (!strncasecmp(lang, "ka", 2)) { /* Georgian syntax */
07064       return ast_say_datetime_from_now_ka(chan, t, ints, lang);
07065    } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */
07066       return ast_say_datetime_from_now_pt(chan, t, ints, lang);
07067    }
07068 
07069    /* Default to English */
07070    return ast_say_datetime_from_now_en(chan, t, ints, lang);
07071 }

static int say_digit_str_full ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 222 of file say.c.

References ast_fileexists(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by __say_init(), and say_init_mode().

00223 {
00224    const char *fn;
00225    char fnbuf[256];
00226    int num = 0;
00227    int res = 0;
00228 
00229    while (str[num] && !res) {
00230       fn = NULL;
00231       switch (str[num]) {
00232       case ('*'):
00233          fn = "digits/star";
00234          break;
00235       case ('#'):
00236          fn = "digits/pound";
00237          break;
00238       case ('-'):
00239          fn = "digits/minus";
00240          break;
00241       case '0':
00242       case '1':
00243       case '2':
00244       case '3':
00245       case '4':
00246       case '5':
00247       case '6':
00248       case '7':
00249       case '8':
00250       case '9':
00251          strcpy(fnbuf, "digits/X");
00252          fnbuf[7] = str[num];
00253          fn = fnbuf;
00254          break;
00255       }
00256       if (fn && ast_fileexists(fn, NULL, lang) > 0) {
00257          res = ast_streamfile(chan, fn, lang);
00258          if (!res) {
00259             if ((audiofd  > -1) && (ctrlfd > -1))
00260                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00261             else
00262                res = ast_waitstream(chan, ints);
00263          }
00264          ast_stopstream(chan);
00265       }
00266       num++;
00267    }
00268 
00269    return res;
00270 }

static int say_enumeration_full ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_enumeration_full: call language-specific functions

Note:
Called from AGI

Definition at line 2738 of file say.c.

References ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_he(), and ast_say_enumeration_full_vi().

02739 {
02740    if (!strncasecmp(language, "en", 2)) {        /* English syntax */
02741       return ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd);
02742    } else if (!strncasecmp(language, "da", 2)) { /* Danish syntax */
02743       return ast_say_enumeration_full_da(chan, num, ints, language, options, audiofd, ctrlfd);
02744    } else if (!strncasecmp(language, "de", 2)) { /* German syntax */
02745       return ast_say_enumeration_full_de(chan, num, ints, language, options, audiofd, ctrlfd);
02746    } else if (!strncasecmp(language, "he", 2)) { /* Hebrew syntax */
02747       return ast_say_enumeration_full_he(chan, num, ints, language, options, audiofd, ctrlfd);
02748    } else if (!strncasecmp(language, "vi", 2)) { /* Vietnamese syntax */
02749       return ast_say_enumeration_full_vi(chan, num, ints, language, audiofd, ctrlfd);
02750    }
02751 
02752    /* Default to english */
02753    return ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd);
02754 }

static int say_number_full ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options,
int  audiofd,
int  ctrlfd 
) [static]

ast_say_number_full: call language-specific functions

Note:
Called from AGI

Definition at line 435 of file say.c.

References ast_channel_name(), ast_log(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_gr(), ast_say_number_full_he(), ast_say_number_full_hu(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pl(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_ur(), ast_say_number_full_vi(), ast_say_number_full_zh(), ast_test_suite_event_notify, and LOG_WARNING.

00436 {
00437    ast_test_suite_event_notify("SAYNUM", "Message: saying number %d\r\nNumber: %d\r\nChannel: %s", num, num, ast_channel_name(chan));
00438    if (!strncasecmp(language, "en_GB", 5)) {     /* British syntax */
00439       return ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd);
00440    } else if (!strncasecmp(language, "en", 2)) { /* English syntax */
00441       return ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd);
00442    } else if (!strncasecmp(language, "cs", 2)) { /* Czech syntax */
00443       return ast_say_number_full_cs(chan, num, ints, language, options, audiofd, ctrlfd);
00444    } else if (!strncasecmp(language, "cz", 2)) { /* deprecated Czech syntax */
00445       static int deprecation_warning = 0;
00446       if (deprecation_warning++ % 10 == 0) {
00447          ast_log(LOG_WARNING, "cz is not a standard language code.  Please switch to using cs instead.\n");
00448       }
00449       return ast_say_number_full_cs(chan, num, ints, language, options, audiofd, ctrlfd);
00450    } else if (!strncasecmp(language, "da", 2)) { /* Danish syntax */
00451       return ast_say_number_full_da(chan, num, ints, language, options, audiofd, ctrlfd);
00452    } else if (!strncasecmp(language, "de", 2)) { /* German syntax */
00453       return ast_say_number_full_de(chan, num, ints, language, options, audiofd, ctrlfd);
00454    } else if (!strncasecmp(language, "es", 2)) { /* Spanish syntax */
00455       return ast_say_number_full_es(chan, num, ints, language, options, audiofd, ctrlfd);
00456    } else if (!strncasecmp(language, "fr", 2)) { /* French syntax */
00457       return ast_say_number_full_fr(chan, num, ints, language, options, audiofd, ctrlfd);
00458    } else if (!strncasecmp(language, "ge", 2)) { /* deprecated Georgian syntax */
00459       static int deprecation_warning = 0;
00460       if (deprecation_warning++ % 10 == 0) {
00461          ast_log(LOG_WARNING, "ge is not a standard language code.  Please switch to using ka instead.\n");
00462       }
00463       return ast_say_number_full_ka(chan, num, ints, language, options, audiofd, ctrlfd);
00464    } else if (!strncasecmp(language, "gr", 2)) { /* Greek syntax */
00465       return ast_say_number_full_gr(chan, num, ints, language, audiofd, ctrlfd);
00466    } else if (!strncasecmp(language, "he", 2)) { /* Hebrew syntax */
00467       return ast_say_number_full_he(chan, num, ints, language, options, audiofd, ctrlfd);
00468    } else if (!strncasecmp(language, "hu", 2)) { /* Hungarian syntax */
00469       return ast_say_number_full_hu(chan, num, ints, language, audiofd, ctrlfd);
00470    } else if (!strncasecmp(language, "it", 2)) { /* Italian syntax */
00471       return ast_say_number_full_it(chan, num, ints, language, audiofd, ctrlfd);
00472    } else if (!strncasecmp(language, "ka", 2)) { /* Georgian syntax */
00473       return ast_say_number_full_ka(chan, num, ints, language, options, audiofd, ctrlfd);
00474    } else if (!strncasecmp(language, "mx", 2)) { /* deprecated Mexican syntax */
00475       static int deprecation_warning = 0;
00476       if (deprecation_warning++ % 10 == 0) {
00477          ast_log(LOG_WARNING, "mx is not a standard language code.  Please switch to using es_MX instead.\n");
00478       }
00479       return ast_say_number_full_es(chan, num, ints, language, options, audiofd, ctrlfd);
00480    } else if (!strncasecmp(language, "nl", 2)) { /* Dutch syntax */
00481       return ast_say_number_full_nl(chan, num, ints, language, audiofd, ctrlfd);
00482    } else if (!strncasecmp(language, "no", 2)) { /* Norwegian syntax */
00483       return ast_say_number_full_no(chan, num, ints, language, options, audiofd, ctrlfd);
00484    } else if (!strncasecmp(language, "pl", 2)) { /* Polish syntax */
00485       return ast_say_number_full_pl(chan, num, ints, language, options, audiofd, ctrlfd);
00486    } else if (!strncasecmp(language, "pt", 2)) { /* Portuguese syntax */
00487       return ast_say_number_full_pt(chan, num, ints, language, options, audiofd, ctrlfd);
00488    } else if (!strncasecmp(language, "ru", 2)) { /* Russian syntax */
00489       return ast_say_number_full_ru(chan, num, ints, language, options, audiofd, ctrlfd);
00490    } else if (!strncasecmp(language, "se", 2)) { /* Swedish syntax */
00491       return ast_say_number_full_se(chan, num, ints, language, options, audiofd, ctrlfd);
00492    } else if (!strncasecmp(language, "th", 2)) { /* Thai syntax */
00493       return ast_say_number_full_th(chan, num, ints, language, audiofd, ctrlfd);
00494    } else if (!strncasecmp(language, "tw", 2)) { /* deprecated Taiwanese syntax */
00495       static int deprecation_warning = 0;
00496       if (deprecation_warning++ % 10 == 0) {
00497          ast_log(LOG_WARNING, "tw is a standard language code for Twi, not Taiwanese.  Please switch to using zh_TW instead.\n");
00498       }
00499       return ast_say_number_full_zh(chan, num, ints, language, audiofd, ctrlfd);
00500    } else if (!strncasecmp(language, "zh", 2)) { /* Taiwanese / Chinese syntax */
00501       return ast_say_number_full_zh(chan, num, ints, language, audiofd, ctrlfd);
00502    } else if (!strncasecmp(language, "ur", 2)) { /* Urdu syntax */
00503       return ast_say_number_full_ur(chan, num, ints, language, options, audiofd, ctrlfd);
00504    } else if (!strncasecmp(language, "vi", 2)) { /* Vietnamese syntax */
00505       return ast_say_number_full_vi(chan, num, ints, language, audiofd, ctrlfd);
00506    }
00507 
00508    /* Default to english */
00509    return ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd);
00510 }

static int say_phonetic_str_full ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
) [static]

Definition at line 142 of file say.c.

References ast_fileexists(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().

Referenced by __say_init(), and say_init_mode().

00143 {
00144    const char *fn;
00145    char fnbuf[256];
00146    char ltr;
00147    int num = 0;
00148    int res = 0;
00149 
00150    while (str[num] && !res) {
00151       fn = NULL;
00152       switch (str[num]) {
00153       case ('*'):
00154          fn = "digits/star";
00155          break;
00156       case ('#'):
00157          fn = "digits/pound";
00158          break;
00159       case ('!'):
00160          fn = "letters/exclaimation-point";
00161          break;
00162       case ('@'):
00163          fn = "letters/at";
00164          break;
00165       case ('$'):
00166          fn = "letters/dollar";
00167          break;
00168       case ('-'):
00169          fn = "letters/dash";
00170          break;
00171       case ('.'):
00172          fn = "letters/dot";
00173          break;
00174       case ('='):
00175          fn = "letters/equals";
00176          break;
00177       case ('+'):
00178          fn = "letters/plus";
00179          break;
00180       case ('/'):
00181          fn = "letters/slash";
00182          break;
00183       case (' '):
00184          fn = "letters/space";
00185          break;
00186       case ('0'):
00187       case ('1'):
00188       case ('2'):
00189       case ('3'):
00190       case ('4'):
00191       case ('5'):
00192       case ('6'):
00193       case ('7'):
00194       case ('8'):
00195          strcpy(fnbuf, "digits/X");
00196          fnbuf[7] = str[num];
00197          fn = fnbuf;
00198          break;
00199       default: /* '9' falls here... */
00200          ltr = str[num];
00201          if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A';    /* file names are all lower-case */
00202          strcpy(fnbuf, "phonetic/X_p");
00203          fnbuf[9] = ltr;
00204          fn = fnbuf;
00205       }
00206       if (fn && ast_fileexists(fn, NULL, lang) > 0) {
00207          res = ast_streamfile(chan, fn, lang);
00208          if (!res) {
00209             if ((audiofd  > -1) && (ctrlfd > -1))
00210                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00211             else
00212                res = ast_waitstream(chan, ints);
00213          }
00214          ast_stopstream(chan);
00215       }
00216       num++;
00217    }
00218 
00219    return res;
00220 }

static int say_time ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
) [static]

Definition at line 6268 of file say.c.

References ast_log(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_he(), ast_say_time_hu(), ast_say_time_ka(), ast_say_time_nl(), ast_say_time_pt(), ast_say_time_pt_BR(), ast_say_time_th(), ast_say_time_zh(), and LOG_WARNING.

06269 {
06270    if (!strncasecmp(lang, "en", 2)) {  /* English syntax */
06271       return ast_say_time_en(chan, t, ints, lang);
06272    } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */
06273       return ast_say_time_de(chan, t, ints, lang);
06274    } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */
06275       return ast_say_time_fr(chan, t, ints, lang);
06276    } else if (!strncasecmp(lang, "ge", 2)) { /* deprecated Georgian syntax */
06277       static int deprecation_warning = 0;
06278       if (deprecation_warning++ % 10 == 0) {
06279          ast_log(LOG_WARNING, "ge is not a standard language code.  Please switch to using ka instead.\n");
06280       }
06281       return ast_say_time_ka(chan, t, ints, lang);
06282    } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */
06283       return ast_say_time_gr(chan, t, ints, lang);
06284    } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */
06285       return ast_say_time_he(chan, t, ints, lang);
06286    } else if (!strncasecmp(lang, "hu", 2)) { /* Hungarian syntax */
06287       return(ast_say_time_hu(chan, t, ints, lang));
06288    } else if (!strncasecmp(lang, "ka", 2)) { /* Georgian syntax */
06289       return ast_say_time_ka(chan, t, ints, lang);
06290    } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */
06291       return ast_say_time_nl(chan, t, ints, lang);
06292    } else if (!strncasecmp(lang, "pt_BR", 5)) { /* Brazilian Portuguese syntax */
06293       return ast_say_time_pt_BR(chan, t, ints, lang);
06294    } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */
06295       return ast_say_time_pt(chan, t, ints, lang);
06296    } else if (!strncasecmp(lang, "th", 2)) { /* Thai syntax */
06297       return(ast_say_time_th(chan, t, ints, lang));
06298    } else if (!strncasecmp(lang, "tw", 2)) { /* deprecated Taiwanese syntax */
06299       static int deprecation_warning = 0;
06300       if (deprecation_warning++ % 10 == 0) {
06301          ast_log(LOG_WARNING, "tw is a standard language code for Twi, not Taiwanese.  Please switch to using zh_TW instead.\n");
06302       }
06303       return ast_say_time_zh(chan, t, ints, lang);
06304    } else if (!strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */
06305       return ast_say_time_zh(chan, t, ints, lang);
06306    }
06307 
06308    /* Default to English */
06309    return ast_say_time_en(chan, t, ints, lang);
06310 }

static int wait_file ( struct ast_channel chan,
const char *  ints,
const char *  file,
const char *  lang 
) [static]

Definition at line 423 of file say.c.

References ast_log(), ast_streamfile(), ast_waitstream(), and LOG_WARNING.

00424 {
00425    int res;
00426    if ((res = ast_streamfile(chan, file, lang)))
00427       ast_log(LOG_WARNING, "Unable to play message %s\n", file);
00428    if (!res)
00429       res = ast_waitstream(chan, ints);
00430    return res;
00431 }


Generated on Fri Feb 10 06:37:26 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6