Sat Mar 24 22:57:24 2007

Asterisk developer's documentation


say.c File Reference

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

#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <time.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/say.h"
#include "asterisk/lock.h"
#include "asterisk/localtime.h"
#include "asterisk/utils.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   "IMp"
#define SAY_NUM_BUF_SIZE   256
 ast_say_number_full_he: Hebrew syntax

Functions

int ast_say_character_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
int ast_say_character_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
int ast_say_date (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_date_da (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_date_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_date_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_date_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_date_gr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_date_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_date_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
int ast_say_date_with_format (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_da (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_de (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_en (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_es (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_fr (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_gr (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_he (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_it (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_nl (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_pt (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
static int ast_say_date_with_format_tw (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone)
int ast_say_datetime (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
int ast_say_datetime_from_now (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_from_now_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_from_now_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_from_now_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_gr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_pt_BR (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_datetime_tw (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
int ast_say_digit_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
int ast_say_digit_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
int ast_say_digits (struct ast_channel *chan, int num, const char *ints, const char *lang)
int ast_say_digits_full (struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
int ast_say_enumeration (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 ast_say_enumeration: call language-specific functions without file descriptors
int ast_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 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
int ast_say_number (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 ast_say_number: call language-specific functions without file descriptors
int ast_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 ast_say_number_full_cz (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
 ast_say_number_full_cz: 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
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 and Norwegian syntax
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
static int ast_say_number_full_gr (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
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_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_nl (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_nl: dutch syntax
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
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 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)
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_tw (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd)
 ast_say_number_full_tw: Taiwanese syntax
int ast_say_phonetic_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
int ast_say_phonetic_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
int ast_say_time (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_gr (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_pt_BR (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
static int ast_say_time_tw (struct ast_channel *chan, time_t t, const char *ints, const char *lang)
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)
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 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).

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

Definition in file say.c.


Define Documentation

#define IL_DATE_STR   "AdBY"

ast_say_date_with_format_he Say formmated 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 3625 of file say.c.

Referenced by ast_say_date_with_format_he().

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

Definition at line 3627 of file say.c.

Referenced by ast_say_date_with_format_he().

#define IL_TIME_STR   "IMp"

Definition at line 3626 of file say.c.

Referenced by ast_say_date_with_format_he().

#define SAY_NUM_BUF_SIZE   256

ast_say_number_full_he: Hebrew syntax

Definition at line 1218 of file say.c.

Referenced by ast_say_number_full_he().


Function Documentation

int ast_say_character_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang 
)

Definition at line 132 of file say.c.

References ast_say_character_str_full().

Referenced by chanspy_exec(), pbx_builtin_saycharacters(), play_mailbox_owner(), rpt_tele_thread(), and saycharstr().

00133 {
00134    return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
00135 }

int ast_say_character_str_full ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
)

Definition at line 57 of file say.c.

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

Referenced by ast_say_character_str(), and handle_sayalpha().

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

int ast_say_date ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
)

Definition at line 2725 of file say.c.

References ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_nl(), and ast_say_date_pt().

Referenced by ast_say_datetime_de(), ast_say_datetime_nl(), ast_say_datetime_pt_BR(), and handle_saydate().

02726 {
02727    if (!strcasecmp(lang, "en") ) {  /* English syntax */
02728       return(ast_say_date_en(chan, t, ints, lang));
02729    } else if (!strcasecmp(lang, "da") ) { /* Danish syntax */
02730       return(ast_say_date_da(chan, t, ints, lang));
02731    } else if (!strcasecmp(lang, "de") ) { /* German syntax */
02732       return(ast_say_date_de(chan, t, ints, lang));
02733    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
02734       return(ast_say_date_fr(chan, t, ints, lang));
02735    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
02736       return(ast_say_date_nl(chan, t, ints, lang));
02737    } else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) {  /* Portuguese syntax */
02738       return(ast_say_date_pt(chan, t, ints, lang));
02739    } else if (!strcasecmp(lang, "gr") ) {          /* Greek syntax */
02740       return(ast_say_date_gr(chan, t, ints, lang));
02741    }
02742 
02743    /* Default to English */
02744    return(ast_say_date_en(chan, t, ints, lang));
02745 }

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

Definition at line 2776 of file say.c.

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

Referenced by ast_say_date().

02777 {
02778    struct tm tm;
02779    char fn[256];
02780    int res = 0;
02781    ast_localtime(&t,&tm,NULL);
02782    if (!res) {
02783       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
02784       res = ast_streamfile(chan, fn, lang);
02785       if (!res)
02786          res = ast_waitstream(chan, ints);
02787    }
02788    if (!res)
02789       res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL);
02790    if (!res)
02791       res = ast_waitstream(chan, ints);
02792    if (!res) {
02793       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
02794       res = ast_streamfile(chan, fn, lang);
02795       if (!res)
02796          res = ast_waitstream(chan, ints);
02797    }
02798    if (!res) {
02799       /* Year */
02800       int year = tm.tm_year + 1900;
02801       if (year > 1999) {   /* year 2000 and later */
02802          res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
02803       } else {
02804          if (year < 1100) {
02805             /* I'm not going to handle 1100 and prior */
02806             /* We'll just be silent on the year, instead of bombing out. */
02807          } else {
02808              /* year 1100 to 1999. will anybody need this?!? */
02809             snprintf(fn,sizeof(fn), "digits/%d", (year / 100) );
02810             res = wait_file(chan, ints, fn, lang);
02811             if (!res) {
02812                res = wait_file(chan,ints, "digits/hundred", lang);
02813                if (!res && year % 100 != 0) {
02814                   res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
02815                }
02816             }
02817          }
02818       }
02819    }
02820    return res;
02821 }

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

Definition at line 2824 of file say.c.

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

Referenced by ast_say_date().

02825 {
02826    struct tm tm;
02827    char fn[256];
02828    int res = 0;
02829    ast_localtime(&t,&tm,NULL);
02830    if (!res) {
02831       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
02832       res = ast_streamfile(chan, fn, lang);
02833       if (!res)
02834          res = ast_waitstream(chan, ints);
02835    }
02836    if (!res)
02837       res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL);
02838    if (!res)
02839       res = ast_waitstream(chan, ints);
02840    if (!res) {
02841       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
02842       res = ast_streamfile(chan, fn, lang);
02843       if (!res)
02844          res = ast_waitstream(chan, ints);
02845    }
02846    if (!res) {
02847       /* Year */
02848       int year = tm.tm_year + 1900;
02849       if (year > 1999) {   /* year 2000 and later */
02850          res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
02851       } else {
02852          if (year < 1100) {
02853             /* I'm not going to handle 1100 and prior */
02854             /* We'll just be silent on the year, instead of bombing out. */
02855          } else {
02856              /* year 1100 to 1999. will anybody need this?!? */
02857              /* say 1967 as 'neunzehn hundert sieben und sechzig' */
02858             snprintf(fn,sizeof(fn), "digits/%d", (year / 100) );
02859             res = wait_file(chan, ints, fn, lang);
02860             if (!res) {
02861                res = wait_file(chan,ints, "digits/hundred", lang);
02862                if (!res && year % 100 != 0) {
02863                   res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
02864                }
02865             }
02866          }
02867       }
02868    }
02869    return res;
02870 }

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

Definition at line 2748 of file say.c.

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

Referenced by ast_say_date().

02749 {
02750    struct tm tm;
02751    char fn[256];
02752    int res = 0;
02753    ast_localtime(&t,&tm,NULL);
02754    if (!res) {
02755       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
02756       res = ast_streamfile(chan, fn, lang);
02757       if (!res)
02758          res = ast_waitstream(chan, ints);
02759    }
02760    if (!res) {
02761       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
02762       res = ast_streamfile(chan, fn, lang);
02763       if (!res)
02764          res = ast_waitstream(chan, ints);
02765    }
02766    if (!res)
02767       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
02768    if (!res)
02769       res = ast_waitstream(chan, ints);
02770    if (!res)
02771       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
02772    return res;
02773 }

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

Definition at line 2873 of file say.c.

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

Referenced by ast_say_date().

02874 {
02875    struct tm tm;
02876    char fn[256];
02877    int res = 0;
02878    ast_localtime(&t,&tm,NULL);
02879    if (!res) {
02880       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
02881       res = ast_streamfile(chan, fn, lang);
02882       if (!res)
02883          res = ast_waitstream(chan, ints);
02884    }
02885    if (!res)
02886       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
02887    if (!res)
02888       res = ast_waitstream(chan, ints);
02889    if (!res) {
02890       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
02891       res = ast_streamfile(chan, fn, lang);
02892       if (!res)
02893          res = ast_waitstream(chan, ints);
02894    }
02895    if (!res)
02896       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
02897    return res;
02898 }

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

Definition at line 5968 of file say.c.

References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), and gr_say_number_female().

Referenced by ast_say_date().

05969 {
05970    struct tm tm;
05971    
05972    char fn[256];
05973    int res = 0;
05974    
05975 
05976    ast_localtime(&t,&tm,NULL);
05977    /* W E E K - D A Y */
05978    if (!res) {
05979       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05980       res = ast_streamfile(chan, fn, lang);
05981       if (!res)
05982          res = ast_waitstream(chan, ints);
05983    }
05984    /* D A Y */
05985    if (!res) {
05986       gr_say_number_female(tm.tm_mday, chan, ints, lang);
05987    }
05988    /* M O N T H */
05989    if (!res) {
05990       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05991       res = ast_streamfile(chan, fn, lang);
05992       if (!res)
05993          res = ast_waitstream(chan, ints);
05994    }
05995    /* Y E A R */
05996    if (!res)
05997       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
05998    return res; 
05999 }

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

Definition at line 2901 of file say.c.

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

Referenced by ast_say_date().

02902 {
02903    struct tm tm;
02904    char fn[256];
02905    int res = 0;
02906    ast_localtime(&t,&tm,NULL);
02907    if (!res) {
02908       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
02909       res = ast_streamfile(chan, fn, lang);
02910       if (!res)
02911          res = ast_waitstream(chan, ints);
02912    }
02913    if (!res)
02914       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
02915    if (!res) {
02916       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
02917       res = ast_streamfile(chan, fn, lang);
02918       if (!res)
02919          res = ast_waitstream(chan, ints);
02920    }
02921    if (!res)
02922       res = ast_waitstream(chan, ints);
02923    if (!res)
02924       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
02925    return res;
02926 }

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

Definition at line 2929 of file say.c.

References ast_localtime(), ast_say_number(), and wait_file().

Referenced by ast_say_date().

02930 {
02931    struct tm tm;
02932    char fn[256];
02933    int res = 0;
02934    ast_localtime(&t,&tm,NULL);
02935    localtime_r(&t,&tm);
02936    snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
02937    if (!res)
02938       res = wait_file(chan, ints, fn, lang);
02939    if (!res)
02940       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
02941    if (!res)
02942       res = wait_file(chan, ints, "digits/pt-de", lang);
02943    snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
02944    if (!res)
02945       res = wait_file(chan, ints, fn, lang);
02946    if (!res)
02947       res = wait_file(chan, ints, "digits/pt-de", lang);
02948    if (!res)
02949       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
02950 
02951    return res;
02952 }

int ast_say_date_with_format ( struct ast_channel chan,
time_t  time,
const char *  ints,
const char *  lang,
const char *  format,
const char *  timezone 
)

Definition at line 2954 of file say.c.

References 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_pt(), and ast_say_date_with_format_tw().

Referenced by 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_pt(), ast_say_date_with_format_tw(), handle_saydatetime(), play_message_datetime(), and sayunixtime_exec().

02955 {
02956    if (!strcasecmp(lang, "en") ) {  /* English syntax */
02957       return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone));
02958    } else if (!strcasecmp(lang, "da") ) { /* Danish syntax */
02959       return(ast_say_date_with_format_da(chan, time, ints, lang, format, timezone));
02960    } else if (!strcasecmp(lang, "de") ) { /* German syntax */
02961       return(ast_say_date_with_format_de(chan, time, ints, lang, format, timezone));
02962    } else if (!strcasecmp(lang, "es") || !strcasecmp(lang, "mx")) {  /* Spanish syntax */
02963       return(ast_say_date_with_format_es(chan, time, ints, lang, format, timezone));
02964    } else if (!strcasecmp(lang, "he")) {  /* Hebrew syntax */
02965       return(ast_say_date_with_format_he(chan, time, ints, lang, format, timezone));
02966    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
02967       return(ast_say_date_with_format_fr(chan, time, ints, lang, format, timezone));
02968    } else if (!strcasecmp(lang, "it") ) {  /* Italian syntax */
02969       return(ast_say_date_with_format_it(chan, time, ints, lang, format, timezone));
02970    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
02971       return(ast_say_date_with_format_nl(chan, time, ints, lang, format, timezone));
02972    } else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) {  /* Portuguese syntax */
02973       return(ast_say_date_with_format_pt(chan, time, ints, lang, format, timezone));
02974    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
02975       return(ast_say_date_with_format_tw(chan, time, ints, lang, format, timezone));
02976    } else if (!strcasecmp(lang, "gr") ) { /* Greek syntax */
02977       return(ast_say_date_with_format_gr(chan, time, ints, lang, format, timezone));
02978    }
02979 
02980    /* Default to English */
02981    return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone));
02982 }

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

Definition at line 3220 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_enumeration(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

03221 {
03222    struct tm tm;
03223    int res=0, offset, sndoffset;
03224    char sndfile[256], nextmsg[256];
03225 
03226    ast_localtime(&time,&tm,timezone);
03227 
03228    for (offset=0 ; format[offset] != '\0' ; offset++) {
03229       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
03230       switch (format[offset]) {
03231          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
03232          case '\'':
03233             /* Literal name of a sound file */
03234             sndoffset=0;
03235             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
03236                sndfile[sndoffset] = format[offset];
03237             sndfile[sndoffset] = '\0';
03238             res = wait_file(chan,ints,sndfile,lang);
03239             break;
03240          case 'A':
03241          case 'a':
03242             /* Sunday - Saturday */
03243             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
03244             res = wait_file(chan,ints,nextmsg,lang);
03245             break;
03246          case 'B':
03247          case 'b':
03248          case 'h':
03249             /* January - December */
03250             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
03251             res = wait_file(chan,ints,nextmsg,lang);
03252             break;
03253          case 'm':
03254             /* Month enumerated */
03255             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");   
03256             break;
03257          case 'd':
03258          case 'e':
03259             /* First - Thirtyfirst */
03260             res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");  
03261             break;
03262          case 'Y':
03263             /* Year */
03264             {
03265                int year = tm.tm_year + 1900;
03266                if (year > 1999) {   /* year 2000 and later */
03267                   res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
03268                } else {
03269                   if (year < 1100) {
03270                      /* I'm not going to handle 1100 and prior */
03271                      /* We'll just be silent on the year, instead of bombing out. */
03272                   } else {
03273                       /* year 1100 to 1999. will anybody need this?!? */
03274                       /* say 1967 as 'nineteen hundred seven and sixty' */
03275                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (year / 100) );
03276                      res = wait_file(chan,ints,nextmsg,lang);
03277                      if (!res) {
03278                         res = wait_file(chan,ints, "digits/hundred",lang);
03279                         if (!res && year % 100 != 0) {
03280                            res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
03281                         }
03282                      }
03283                   }
03284                }
03285             }
03286             break;
03287          case 'I':
03288          case 'l':
03289             /* 12-Hour */
03290             res = wait_file(chan,ints,"digits/oclock",lang);
03291             if (tm.tm_hour == 0)
03292                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
03293             else if (tm.tm_hour > 12)
03294                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
03295             else
03296                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
03297             if (!res) {
03298                res = wait_file(chan,ints,nextmsg,lang);
03299             }
03300             break;
03301          case 'H':
03302             /* 24-Hour, single digit hours preceeded by "oh" (0) */
03303             if (tm.tm_hour < 10 && tm.tm_hour > 0) {
03304                res = wait_file(chan,ints, "digits/0",lang);
03305             }
03306             /* FALLTRHU */
03307          case 'k':
03308             /* 24-Hour */
03309             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);   
03310             break;
03311          case 'M':
03312             /* Minute */
03313             if (tm.tm_min > 0 || format[offset+ 1 ] == 'S' ) { /* zero 'digits/0' only if seconds follow (kind of a hack) */
03314                res = ast_say_number(chan, tm.tm_min, ints, lang, "f");  
03315             }
03316             if ( !res && format[offset + 1] == 'S' ) { /* minutes only if seconds follow (kind of a hack) */
03317                if (tm.tm_min == 1) {
03318                   res = wait_file(chan,ints,"digits/minute",lang);
03319                } else {
03320                   res = wait_file(chan,ints,"digits/minutes",lang);
03321                }
03322             }
03323             break;
03324          case 'P':
03325          case 'p':
03326             /* AM/PM */
03327             if (tm.tm_hour > 11)
03328                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
03329             else
03330                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
03331             res = wait_file(chan,ints,nextmsg,lang);
03332             break;
03333          case 'Q':
03334             /* Shorthand for "Today", "Yesterday", or AdBY */
03335             {
03336                struct timeval now;
03337                struct tm tmnow;
03338                time_t beg_today;
03339 
03340                gettimeofday(&now,NULL);
03341                ast_localtime(&now.tv_sec,&tmnow,timezone);
03342                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03343                /* In any case, it saves not having to do ast_mktime() */
03344                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03345                if (beg_today < time) {
03346                   /* Today */
03347                   res = wait_file(chan,ints, "digits/today",lang);
03348                } else if (beg_today - 86400 < time) {
03349                   /* Yesterday */
03350                   res = wait_file(chan,ints, "digits/yesterday",lang);
03351                } else {
03352                   res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
03353                }
03354             }
03355             break;
03356          case 'q':
03357             /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */
03358             {
03359                struct timeval now;
03360                struct tm tmnow;
03361                time_t beg_today;
03362 
03363                gettimeofday(&now,NULL);
03364                ast_localtime(&now.tv_sec,&tmnow,timezone);
03365                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03366                /* In any case, it saves not having to do ast_mktime() */
03367                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03368                if (beg_today < time) {
03369                   /* Today */
03370                } else if ((beg_today - 86400) < time) {
03371                   /* Yesterday */
03372                   res = wait_file(chan,ints, "digits/yesterday",lang);
03373                } else if (beg_today - 86400 * 6 < time) {
03374                   /* Within the last week */
03375                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
03376                } else {
03377                   res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
03378                }
03379             }
03380             break;
03381          case 'R':
03382             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
03383             break;
03384          case 'S':
03385             /* Seconds */
03386             res = wait_file(chan,ints, "digits/and",lang);
03387             if (!res) {
03388                res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");  
03389                if (!res) {
03390                   res = wait_file(chan,ints, "digits/seconds",lang);
03391                }
03392             }
03393             break;
03394          case 'T':
03395             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
03396             break;
03397          case ' ':
03398          case '   ':
03399             /* Just ignore spaces and tabs */
03400             break;
03401          default:
03402             /* Unknown character */
03403             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
03404       }
03405       /* Jump out on DTMF */
03406       if (res) {
03407          break;
03408       }
03409    }
03410    return res;
03411 }

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

Definition at line 3414 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_enumeration(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

03415 {
03416    struct tm tm;
03417    int res=0, offset, sndoffset;
03418    char sndfile[256], nextmsg[256];
03419 
03420    ast_localtime(&time,&tm,timezone);
03421 
03422    for (offset=0 ; format[offset] != '\0' ; offset++) {
03423       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
03424       switch (format[offset]) {
03425          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
03426          case '\'':
03427             /* Literal name of a sound file */
03428             sndoffset=0;
03429             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
03430                sndfile[sndoffset] = format[offset];
03431             sndfile[sndoffset] = '\0';
03432             res = wait_file(chan,ints,sndfile,lang);
03433             break;
03434          case 'A':
03435          case 'a':
03436             /* Sunday - Saturday */
03437             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
03438             res = wait_file(chan,ints,nextmsg,lang);
03439             break;
03440          case 'B':
03441          case 'b':
03442          case 'h':
03443             /* January - December */
03444             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
03445             res = wait_file(chan,ints,nextmsg,lang);
03446             break;
03447          case 'm':
03448             /* Month enumerated */
03449             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m");   
03450             break;
03451          case 'd':
03452          case 'e':
03453             /* First - Thirtyfirst */
03454             res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m");  
03455             break;
03456          case 'Y':
03457             /* Year */
03458             {
03459                int year = tm.tm_year + 1900;
03460                if (year > 1999) {   /* year 2000 and later */
03461                   res = ast_say_number(chan, year, ints, lang, (char *) NULL);   
03462                } else {
03463                   if (year < 1100) {
03464                      /* I'm not going to handle 1100 and prior */
03465                      /* We'll just be silent on the year, instead of bombing out. */
03466                   } else {
03467                       /* year 1100 to 1999. will anybody need this?!? */
03468                       /* say 1967 as 'neunzehn hundert sieben und sechzig' */
03469                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (year / 100) );
03470                      res = wait_file(chan,ints,nextmsg,lang);
03471                      if (!res) {
03472                         res = wait_file(chan,ints, "digits/hundred",lang);
03473                         if (!res && year % 100 != 0) {
03474                            res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 
03475                         }
03476                      }
03477                   }
03478                }
03479             }
03480             break;
03481          case 'I':
03482          case 'l':
03483             /* 12-Hour */
03484             if (tm.tm_hour == 0)
03485                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
03486             else if (tm.tm_hour > 12)
03487                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
03488             else
03489                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
03490             res = wait_file(chan,ints,nextmsg,lang);
03491             if (!res) {
03492                res = wait_file(chan,ints,"digits/oclock",lang);
03493             }
03494             break;
03495          case 'H':
03496          case 'k':
03497             /* 24-Hour */
03498             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);   
03499             if (!res) {
03500                res = wait_file(chan,ints,"digits/oclock",lang);
03501             }
03502             break;
03503          case 'M':
03504             /* Minute */
03505             if (tm.tm_min > 0 || format[offset+ 1 ] == 'S' ) { /* zero 'digits/0' only if seconds follow (kind of a hack) */
03506                res = ast_say_number(chan, tm.tm_min, ints, lang, "f");  
03507             }
03508             if ( !res && format[offset + 1] == 'S' ) { /* minutes only if seconds follow (kind of a hack) */
03509                if (tm.tm_min == 1) {
03510                   res = wait_file(chan,ints,"digits/minute",lang);
03511                } else {
03512                   res = wait_file(chan,ints,"digits/minutes",lang);
03513                }
03514             }
03515             break;
03516          case 'P':
03517          case 'p':
03518             /* AM/PM */
03519             if (tm.tm_hour > 11)
03520                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
03521             else
03522                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
03523             res = wait_file(chan,ints,nextmsg,lang);
03524             break;
03525          case 'Q':
03526             /* Shorthand for "Today", "Yesterday", or AdBY */
03527             {
03528                struct timeval now;
03529                struct tm tmnow;
03530                time_t beg_today;
03531 
03532                gettimeofday(&now,NULL);
03533                ast_localtime(&now.tv_sec,&tmnow,timezone);
03534                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03535                /* In any case, it saves not having to do ast_mktime() */
03536                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03537                if (beg_today < time) {
03538                   /* Today */
03539                   res = wait_file(chan,ints, "digits/today",lang);
03540                } else if (beg_today - 86400 < time) {
03541                   /* Yesterday */
03542                   res = wait_file(chan,ints, "digits/yesterday",lang);
03543                } else {
03544                   res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
03545                }
03546             }
03547             break;
03548          case 'q':
03549             /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */
03550             {
03551                struct timeval now;
03552                struct tm tmnow;
03553                time_t beg_today;
03554 
03555                gettimeofday(&now,NULL);
03556                ast_localtime(&now.tv_sec,&tmnow,timezone);
03557                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03558                /* In any case, it saves not having to do ast_mktime() */
03559                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03560                if (beg_today < time) {
03561                   /* Today */
03562                } else if ((beg_today - 86400) < time) {
03563                   /* Yesterday */
03564                   res = wait_file(chan,ints, "digits/yesterday",lang);
03565                } else if (beg_today - 86400 * 6 < time) {
03566                   /* Within the last week */
03567                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
03568                } else {
03569                   res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
03570                }
03571             }
03572             break;
03573          case 'R':
03574             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
03575             break;
03576          case 'S':
03577             /* Seconds */
03578             res = wait_file(chan,ints, "digits/and",lang);
03579             if (!res) {
03580                res = ast_say_number(chan, tm.tm_sec, ints, lang, "f");  
03581                if (!res) {
03582                   res = wait_file(chan,ints, "digits/seconds",lang);
03583                }
03584             }
03585             break;
03586          case 'T':
03587             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
03588             break;
03589          case ' ':
03590          case '   ':
03591             /* Just ignore spaces and tabs */
03592             break;
03593          default:
03594             /* Unknown character */
03595             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
03596       }
03597       /* Jump out on DTMF */
03598       if (res) {
03599          break;
03600       }
03601    }
03602    return res;
03603 }

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

Definition at line 2985 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_enumeration(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

02986 {
02987    struct tm tm;
02988    int res=0, offset, sndoffset;
02989    char sndfile[256], nextmsg[256];
02990 
02991    ast_localtime(&time,&tm,timezone);
02992 
02993    for (offset=0 ; format[offset] != '\0' ; offset++) {
02994       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
02995       switch (format[offset]) {
02996          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
02997          case '\'':
02998             /* Literal name of a sound file */
02999             sndoffset=0;
03000             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
03001                sndfile[sndoffset] = format[offset];
03002             sndfile[sndoffset] = '\0';
03003             res = wait_file(chan,ints,sndfile,lang);
03004             break;
03005          case 'A':
03006          case 'a':
03007             /* Sunday - Saturday */
03008             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
03009             res = wait_file(chan,ints,nextmsg,lang);
03010             break;
03011          case 'B':
03012          case 'b':
03013          case 'h':
03014             /* January - December */
03015             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
03016             res = wait_file(chan,ints,nextmsg,lang);
03017             break;
03018          case 'm':
03019             /* Month enumerated */
03020             res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL);  
03021             break;
03022          case 'd':
03023          case 'e':
03024             /* First - Thirtyfirst */
03025             res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char *) NULL); 
03026             break;
03027          case 'Y':
03028             /* Year */
03029             if (tm.tm_year > 99) {
03030                     res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03031             } else {
03032                if (tm.tm_year < 1) {
03033                   /* I'm not going to handle 1900 and prior */
03034                   /* We'll just be silent on the year, instead of bombing out. */
03035                } else {
03036                   res = wait_file(chan,ints, "digits/19",lang);
03037                   if (!res) {
03038                      if (tm.tm_year <= 9) {
03039                         /* 1901 - 1909 */
03040                         res = wait_file(chan,ints, "digits/oh",lang);
03041                         if (!res) {
03042                            snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
03043                            res = wait_file(chan,ints,nextmsg,lang);
03044                         }
03045                      } else if (tm.tm_year <= 20) {
03046                         /* 1910 - 1920 */
03047                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
03048                         res = wait_file(chan,ints,nextmsg,lang);
03049                      } else {
03050                         /* 1921 - 1999 */
03051                         int ten, one;
03052                         ten = tm.tm_year / 10;
03053                         one = tm.tm_year % 10;
03054                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten * 10);
03055                         res = wait_file(chan,ints,nextmsg,lang);
03056                         if (!res) {
03057                            if (one != 0) {
03058                               snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
03059                               res = wait_file(chan,ints,nextmsg,lang);
03060                            }
03061                         }
03062                      }
03063                   }
03064                }
03065             }
03066             break;
03067          case 'I':
03068          case 'l':
03069             /* 12-Hour */
03070             if (tm.tm_hour == 0)
03071                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
03072             else if (tm.tm_hour > 12)
03073                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
03074             else
03075                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
03076             res = wait_file(chan,ints,nextmsg,lang);
03077             break;
03078          case 'H':
03079          case 'k':
03080             /* 24-Hour */
03081             if (format[offset] == 'H') {
03082                /* e.g. oh-eight */
03083                if (tm.tm_hour < 10) {
03084                   res = wait_file(chan,ints, "digits/oh",lang);
03085                }
03086             } else {
03087                /* e.g. eight */
03088                if (tm.tm_hour == 0) {
03089                   res = wait_file(chan,ints, "digits/oh",lang);
03090                }
03091             }
03092             if (!res) {
03093                if (tm.tm_hour != 0) {
03094                   int remainder = tm.tm_hour;
03095                   if (tm.tm_hour > 20) {
03096                      res = wait_file(chan,ints, "digits/20",lang);
03097                      remainder -= 20;
03098                   }
03099                   if (!res) {
03100                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", remainder);
03101                      res = wait_file(chan,ints,nextmsg,lang);
03102                   }
03103                }
03104             }
03105             break;
03106          case 'M':
03107          case 'N':
03108             /* Minute */
03109             if (tm.tm_min == 0) {
03110                if (format[offset] == 'M') {
03111                   res = wait_file(chan, ints, "digits/oclock", lang);
03112                } else {
03113                   res = wait_file(chan, ints, "digits/hundred", lang);
03114                }
03115             } else if (tm.tm_min < 10) {
03116                res = wait_file(chan,ints, "digits/oh",lang);
03117                if (!res) {
03118                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min);
03119                   res = wait_file(chan,ints,nextmsg,lang);
03120                }
03121             } else {
03122                res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
03123             }
03124             break;
03125          case 'P':
03126          case 'p':
03127             /* AM/PM */
03128             if (tm.tm_hour > 11)
03129                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
03130             else
03131                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
03132             res = wait_file(chan,ints,nextmsg,lang);
03133             break;
03134          case 'Q':
03135             /* Shorthand for "Today", "Yesterday", or ABdY */
03136             {
03137                struct timeval now;
03138                struct tm tmnow;
03139                time_t beg_today;
03140 
03141                gettimeofday(&now,NULL);
03142                ast_localtime(&now.tv_sec,&tmnow,timezone);
03143                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03144                /* In any case, it saves not having to do ast_mktime() */
03145                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03146                if (beg_today < time) {
03147                   /* Today */
03148                   res = wait_file(chan,ints, "digits/today",lang);
03149                } else if (beg_today - 86400 < time) {
03150                   /* Yesterday */
03151                   res = wait_file(chan,ints, "digits/yesterday",lang);
03152                } else {
03153                   res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
03154                }
03155             }
03156             break;
03157          case 'q':
03158             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
03159             {
03160                struct timeval now;
03161                struct tm tmnow;
03162                time_t beg_today;
03163 
03164                gettimeofday(&now,NULL);
03165                ast_localtime(&now.tv_sec,&tmnow,timezone);
03166                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03167                /* In any case, it saves not having to do ast_mktime() */
03168                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03169                if (beg_today < time) {
03170                   /* Today */
03171                } else if ((beg_today - 86400) < time) {
03172                   /* Yesterday */
03173                   res = wait_file(chan,ints, "digits/yesterday",lang);
03174                } else if (beg_today - 86400 * 6 < time) {
03175                   /* Within the last week */
03176                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
03177                } else {
03178                   res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
03179                }
03180             }
03181             break;
03182          case 'R':
03183             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
03184             break;
03185          case 'S':
03186             /* Seconds */
03187             if (tm.tm_sec == 0) {
03188                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
03189                res = wait_file(chan,ints,nextmsg,lang);
03190             } else if (tm.tm_sec < 10) {
03191                res = wait_file(chan,ints, "digits/oh",lang);
03192                if (!res) {
03193                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
03194                   res = wait_file(chan,ints,nextmsg,lang);
03195                }
03196             } else {
03197                res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL);
03198             }
03199             break;
03200          case 'T':
03201             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
03202             break;
03203          case ' ':
03204          case '   ':
03205             /* Just ignore spaces and tabs */
03206             break;
03207          default:
03208             /* Unknown character */
03209             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
03210       }
03211       /* Jump out on DTMF */
03212       if (res) {
03213          break;
03214       }
03215    }
03216    return res;
03217 }

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

Definition at line 3808 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

03809 {
03810    struct tm tm;
03811    int res=0, offset, sndoffset;
03812    char sndfile[256], nextmsg[256];
03813 
03814    ast_localtime(&time,&tm,timezone);
03815 
03816    for (offset=0 ; format[offset] != '\0' ; offset++) {
03817       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
03818       switch (format[offset]) {
03819          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
03820          case '\'':
03821             /* Literal name of a sound file */
03822             sndoffset=0;
03823             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
03824                sndfile[sndoffset] = format[offset];
03825             sndfile[sndoffset] = '\0';
03826             snprintf(nextmsg,sizeof(nextmsg), "%s", sndfile);
03827             res = wait_file(chan,ints,nextmsg,lang);
03828             break;
03829          case 'A':
03830          case 'a':
03831             /* Sunday - Saturday */
03832             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
03833             res = wait_file(chan,ints,nextmsg,lang);
03834             break;
03835          case 'B':
03836          case 'b':
03837          case 'h':
03838             /* January - December */
03839             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
03840             res = wait_file(chan,ints,nextmsg,lang);
03841             break;
03842          case 'm':
03843             /* First - Twelfth */
03844             if (!strcasecmp(lang, "pt_BR")) {
03845                     res = ast_say_number(chan, tm.tm_mon+1, ints, lang, (char *) NULL);
03846             } else {
03847                 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
03848                 res = wait_file(chan,ints,nextmsg,lang);
03849             }
03850             break;
03851          case 'd':
03852          case 'e':
03853             /* First - Thirtyfirst */
03854             res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
03855             break;
03856          case 'Y':
03857             /* Year */
03858             res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
03859             break;
03860          case 'I':
03861          case 'l':
03862             /* 12-Hour */
03863             if (tm.tm_hour == 0)
03864                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
03865             else if (tm.tm_hour > 12)
03866                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
03867             else
03868                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
03869             res = wait_file(chan,ints,nextmsg,lang);
03870             break;
03871          case 'H':
03872          case 'k':
03873             /* 24-Hour */
03874             res = ast_say_number(chan, tm.tm_hour, ints, lang, NULL);
03875             break;
03876          case 'M':
03877             /* Minute */
03878             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 
03879             break;
03880          case 'P':
03881          case 'p':
03882             /* AM/PM */
03883             if (tm.tm_hour > 12)
03884                res = wait_file(chan, ints, "digits/p-m", lang);
03885             else if (tm.tm_hour  && tm.tm_hour < 12)
03886                res = wait_file(chan, ints, "digits/a-m", lang);
03887             break;
03888          case 'Q':
03889             /* Shorthand for "Today", "Yesterday", or ABdY */
03890             {
03891                struct timeval now;
03892                struct tm tmnow;
03893                time_t beg_today;
03894 
03895                gettimeofday(&now,NULL);
03896                ast_localtime(&now.tv_sec,&tmnow,timezone);
03897                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03898                /* In any case, it saves not having to do ast_mktime() */
03899                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03900                if (beg_today < time) {
03901                   /* Today */
03902                   res = wait_file(chan,ints, "digits/today",lang);
03903                } else if (beg_today - 86400 < time) {
03904                   /* Yesterday */
03905                   res = wait_file(chan,ints, "digits/yesterday",lang);
03906                } else {
03907                   res = ast_say_date_with_format(chan, time, ints, lang, "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y", timezone);
03908                }
03909             }
03910             break;
03911          case 'q':
03912             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
03913             {
03914                struct timeval now;
03915                struct tm tmnow;
03916                time_t beg_today;
03917 
03918                gettimeofday(&now,NULL);
03919                ast_localtime(&now.tv_sec,&tmnow,timezone);
03920                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03921                /* In any case, it saves not having to do ast_mktime() */
03922                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03923                if (beg_today < time) {
03924                   /* Today */
03925                   res = wait_file(chan,ints, "digits/today",lang);
03926                } else if ((beg_today - 86400) < time) {
03927                   /* Yesterday */
03928                   res = wait_file(chan,ints, "digits/yesterday",lang);
03929                } else if (beg_today - 86400 * 6 < time) {
03930                   /* Within the last week */
03931                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
03932                } else {
03933                   res = ast_say_date_with_format(chan, time, ints, lang, "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y", timezone);
03934                }
03935             }
03936             break;
03937          case 'R':
03938             res = ast_say_date_with_format(chan, time, ints, lang, "H 'digits/y' M", timezone);
03939             break;
03940          case 'S':
03941             /* Seconds */
03942             if (tm.tm_sec == 0) {
03943                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
03944                res = wait_file(chan,ints,nextmsg,lang);
03945             } else if (tm.tm_sec < 10) {
03946                res = wait_file(chan,ints, "digits/oh",lang);
03947                if (!res) {
03948                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
03949                   res = wait_file(chan,ints,nextmsg,lang);
03950                }
03951             } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
03952                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
03953                res = wait_file(chan,ints,nextmsg,lang);
03954             } else {
03955                int ten, one;
03956                ten = (tm.tm_sec / 10) * 10;
03957                one = (tm.tm_sec % 10);
03958                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
03959                res = wait_file(chan,ints,nextmsg,lang);
03960                if (!res) {
03961                   /* Fifty, not fifty-zero */
03962                   if (one != 0) {
03963                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
03964                      res = wait_file(chan,ints,nextmsg,lang);
03965                   }
03966                }
03967             }
03968             break;
03969          case 'T':
03970             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
03971             break;
03972          case ' ':
03973          case '   ':
03974             /* Just ignore spaces and tabs */
03975             break;
03976          default:
03977             /* Unknown character */
03978             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
03979       }
03980       /* Jump out on DTMF */
03981       if (res) {
03982          break;
03983       }
03984    }
03985    return res;
03986 }

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

Definition at line 3991 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

03992 {
03993    struct tm tm;
03994    int res=0, offset, sndoffset;
03995    char sndfile[256], nextmsg[256];
03996 
03997    ast_localtime(&time,&tm,timezone);
03998 
03999    for (offset=0 ; format[offset] != '\0' ; offset++) {
04000       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04001       switch (format[offset]) {
04002          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04003          case '\'':
04004             /* Literal name of a sound file */
04005             sndoffset=0;
04006             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
04007                sndfile[sndoffset] = format[offset];
04008             sndfile[sndoffset] = '\0';
04009             res = wait_file(chan,ints,sndfile,lang);
04010             break;
04011          case 'A':
04012          case 'a':
04013             /* Sunday - Saturday */
04014             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04015             res = wait_file(chan,ints,nextmsg,lang);
04016             break;
04017          case 'B':
04018          case 'b':
04019          case 'h':
04020             /* January - December */
04021             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04022             res = wait_file(chan,ints,nextmsg,lang);
04023             break;
04024          case 'm':
04025             /* First - Twelfth */
04026             snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
04027             res = wait_file(chan,ints,nextmsg,lang);
04028             break;
04029          case 'd':
04030          case 'e':
04031             /* First */
04032             if (tm.tm_mday == 1) {
04033                snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
04034                res = wait_file(chan,ints,nextmsg,lang);
04035             } else {
04036                res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL);
04037             }
04038             break;
04039          case 'Y':
04040             /* Year */
04041             if (tm.tm_year > 99) {
04042                res = wait_file(chan,ints, "digits/2",lang);
04043                if (!res) {
04044                   res = wait_file(chan,ints, "digits/thousand",lang);
04045                }
04046                if (tm.tm_year > 100) {
04047                   if (!res) {
04048                      res = ast_say_number(chan, tm.tm_year - 100, ints, lang, (char * ) NULL);
04049                   }
04050                }
04051             } else {
04052                if (tm.tm_year < 1) {
04053                   /* I'm not going to handle 1900 and prior */
04054                   /* We'll just be silent on the year, instead of bombing out. */
04055                } else {
04056                   res = wait_file(chan,ints, "digits/thousand",lang);
04057                   if (!res) {
04058                      wait_file(chan,ints, "digits/9",lang);
04059                      wait_file(chan,ints, "digits/hundred",lang);
04060                      res = ast_say_number(chan, tm.tm_year, ints, lang, (char * ) NULL);
04061                   }
04062                }
04063             }
04064             break;
04065          case 'I':
04066          case 'l':
04067             /* 12-Hour */
04068             if (tm.tm_hour == 0)
04069                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
04070             else if (tm.tm_hour > 12)
04071                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
04072             else
04073                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
04074             res = wait_file(chan,ints,nextmsg,lang);
04075             if (!res)
04076                res = wait_file(chan,ints, "digits/oclock",lang);
04077             break;
04078          case 'H':
04079          case 'k':
04080             /* 24-Hour */
04081             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char * ) NULL);
04082             if (!res) {
04083                if (format[offset] == 'H') {
04084                   res = wait_file(chan,ints, "digits/oclock",lang);
04085                }
04086             }
04087             if (!res)
04088                res = wait_file(chan,ints, "digits/oclock",lang);
04089             break;
04090          case 'M':
04091             /* Minute */
04092             if (tm.tm_min == 0) {
04093                break;
04094             }
04095             res = ast_say_number(chan, tm.tm_min, ints, lang, (char * ) NULL);
04096             break;
04097          case 'P':
04098          case 'p':
04099             /* AM/PM */
04100             if (tm.tm_hour > 11)
04101                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
04102             else
04103                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
04104             res = wait_file(chan,ints,nextmsg,lang);
04105             break;
04106          case 'Q':
04107             /* Shorthand for "Today", "Yesterday", or AdBY */
04108             {
04109                struct timeval now;
04110                struct tm tmnow;
04111                time_t beg_today;
04112 
04113                gettimeofday(&now,NULL);
04114                ast_localtime(&now.tv_sec,&tmnow,timezone);
04115                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04116                /* In any case, it saves not having to do ast_mktime() */
04117                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04118                if (beg_today < time) {
04119                   /* Today */
04120                   res = wait_file(chan,ints, "digits/today",lang);
04121                } else if (beg_today - 86400 < time) {
04122                   /* Yesterday */
04123                   res = wait_file(chan,ints, "digits/yesterday",lang);
04124                } else {
04125                   res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
04126                }
04127             }
04128             break;
04129          case 'q':
04130             /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */
04131             {
04132                struct timeval now;
04133                struct tm tmnow;
04134                time_t beg_today;
04135 
04136                gettimeofday(&now,NULL);
04137                ast_localtime(&now.tv_sec,&tmnow,timezone);
04138                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04139                /* In any case, it saves not having to do ast_mktime() */
04140                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04141                if (beg_today < time) {
04142                   /* Today */
04143                } else if ((beg_today - 86400) < time) {
04144                   /* Yesterday */
04145                   res = wait_file(chan,ints, "digits/yesterday",lang);
04146                } else if (beg_today - 86400 * 6 < time) {
04147                   /* Within the last week */
04148                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
04149                } else {
04150                   res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
04151                }
04152             }
04153             break;
04154          case 'R':
04155             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
04156             break;
04157          case 'S':
04158             /* Seconds */
04159             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char * ) NULL);
04160             if (!res) {
04161                res = wait_file(chan,ints, "digits/second",lang);
04162             }
04163             break;
04164          case 'T':
04165             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
04166             break;
04167          case ' ':
04168          case '   ':
04169             /* Just ignore spaces and tabs */
04170             break;
04171          default:
04172             /* Unknown character */
04173             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04174       }
04175       /* Jump out on DTMF */
04176       if (res) {
04177          break;
04178       }
04179    }
04180    return res;
04181 }

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

Definition at line 6089 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_number_full_gr(), ast_streamfile(), ast_waitstream(), gr_say_number_female(), ast_channel::language, LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

06090 {
06091    
06092    struct tm tm;
06093    int res=0, offset, sndoffset;
06094    char sndfile[256], nextmsg[256];
06095    
06096    ast_localtime(&time,&tm,timezone);
06097    
06098    for (offset=0 ; format[offset] != '\0' ; offset++) {
06099       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
06100       switch (format[offset]) {
06101          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
06102       case '\'':
06103          /* Literal name of a sound file */
06104          sndoffset=0;
06105          for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
06106             sndfile[sndoffset] = format[offset];
06107          sndfile[sndoffset] = '\0';
06108          res = wait_file(chan,ints,sndfile,lang);
06109          break;
06110       case 'A':
06111       case 'a':
06112          /* Sunday - Saturday */
06113          snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
06114          res = wait_file(chan,ints,nextmsg,lang);
06115          break;
06116       case 'B':
06117       case 'b':
06118       case 'h':
06119          /* January - December */
06120          snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
06121          res = wait_file(chan,ints,nextmsg,lang);
06122          break;
06123       case 'd':
06124       case 'e':
06125          /* first - thirtyfirst */
06126          gr_say_number_female(tm.tm_mday, chan, ints, lang);
06127          break;
06128       case 'Y':
06129          /* Year */
06130          
06131          ast_say_number_full_gr(chan, 1900+tm.tm_year, ints, chan->language, -1, -1);
06132          break;
06133       case 'I':
06134       case 'l':
06135          /* 12-Hour */
06136          if (tm.tm_hour == 0)
06137             gr_say_number_female(12, chan, ints, lang);
06138          else if (tm.tm_hour > 12)
06139             gr_say_number_female(tm.tm_hour - 12, chan, ints, lang);
06140          else
06141             gr_say_number_female(tm.tm_hour, chan, ints, lang);
06142          break;
06143       case 'H':
06144       case 'k':
06145          /* 24-Hour */
06146          gr_say_number_female(tm.tm_hour, chan, ints, lang);
06147          break;
06148       case 'M':
06149          /* Minute */
06150          if (tm.tm_min) {
06151             if (!res)
06152                res = ast_streamfile(chan, "digits/kai", lang);
06153             if (!res)
06154                res = ast_waitstream(chan, ints);
06155             if (!res)
06156                res = ast_say_number_full_gr(chan, tm.tm_min, ints, lang, -1, -1);
06157          } else {
06158             if (!res)
06159                res = ast_streamfile(chan, "digits/oclock", lang);
06160             if (!res)
06161                res = ast_waitstream(chan, ints);
06162          }
06163          break;
06164       case 'P':
06165       case 'p':
06166          /* AM/PM */
06167          if (tm.tm_hour > 11)
06168             snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
06169          else
06170             snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
06171          res = wait_file(chan,ints,nextmsg,lang);
06172          break;
06173       case 'Q':
06174          /* Shorthand for "Today", "Yesterday", or ABdY */
06175          {
06176             struct timeval now;
06177             struct tm tmnow;
06178             time_t beg_today;
06179             
06180             gettimeofday(&now,NULL);
06181             ast_localtime(&now.tv_sec,&tmnow,timezone);
06182             /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
06183             /* In any case, it saves not having to do ast_mktime() */
06184             beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
06185             if (beg_today < time) {
06186                /* Today */
06187                res = wait_file(chan,ints, "digits/today",lang);
06188             } else if (beg_today - 86400 < time) {
06189                /* Yesterday */
06190                res = wait_file(chan,ints, "digits/yesterday",lang);
06191             } else {
06192                res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
06193             }
06194          }
06195          break;
06196       case 'q':
06197          /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
06198          {
06199             struct timeval now;
06200             struct tm tmnow;
06201             time_t beg_today;
06202             
06203             gettimeofday(&now,NULL);
06204             ast_localtime(&now.tv_sec,&tmnow,timezone);
06205             /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
06206             /* In any case, it saves not having to do ast_mktime() */
06207             beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
06208             if (beg_today < time) {
06209                /* Today */
06210             } else if ((beg_today - 86400) < time) {
06211                /* Yesterday */
06212                res = wait_file(chan,ints, "digits/yesterday",lang);
06213             } else if (beg_today - 86400 * 6 < time) {
06214                /* Within the last week */
06215                res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
06216             } else {
06217                res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
06218             }
06219          }
06220          break;
06221       case 'R':
06222          res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
06223          break;
06224       case 'S':
06225          /* Seconds */
06226          snprintf(nextmsg,sizeof(nextmsg), "digits/kai");
06227          res = wait_file(chan,ints,nextmsg,lang);
06228          if (!res)
06229             res = ast_say_number_full_gr(chan, tm.tm_sec, ints, lang, -1, -1);
06230          if (!res)
06231             snprintf(nextmsg,sizeof(nextmsg), "digits/seconds");
06232          res = wait_file(chan,ints,nextmsg,lang);
06233          break;
06234       case 'T':
06235          res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
06236          break;
06237       case ' ':
06238       case '   ':
06239          /* Just ignore spaces and tabs */
06240          break;
06241       default:
06242          /* Unknown character */
06243          ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
06244       }
06245       /* Jump out on DTMF */
06246       if (res) {
06247          break;
06248       }
06249    }
06250    return res;
06251 }

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

Definition at line 3628 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_number_full_he(), IL_DATE_STR, IL_DATE_STR_FULL, IL_TIME_STR, LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

03631 {
03632    /* TODO: This whole function is cut&paste from 
03633     * ast_say_date_with_format_en . Is that considered acceptable?
03634     **/
03635    struct tm tm;
03636    int res=0, offset, sndoffset;
03637    char sndfile[256], nextmsg[256];
03638 
03639    ast_localtime(&time,&tm,timezone);
03640 
03641    for (offset=0 ; format[offset] != '\0' ; offset++) {
03642       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
03643       switch (format[offset]) {
03644          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
03645          case '\'':
03646             /* Literal name of a sound file */
03647             sndoffset=0;
03648             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
03649                sndfile[sndoffset] = format[offset];
03650             sndfile[sndoffset] = '\0';
03651             res = wait_file(chan,ints,sndfile,lang);
03652             break;
03653          case 'A':
03654          case 'a':
03655             /* Sunday - Saturday */
03656             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
03657             res = wait_file(chan,ints,nextmsg,lang);
03658             break;
03659          case 'B':
03660          case 'b':
03661          case 'h':
03662             /* January - December */
03663             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
03664             res = wait_file(chan,ints,nextmsg,lang);
03665             break;
03666          case 'd':
03667          case 'e': /* Day of the month */
03668                                 /* I'm not sure exactly what the parameters 
03669                                  * audiofd and ctrlfd to 
03670                                  * ast_say_number_full_he mean, but it seems
03671                                  * safe to pass -1 there. 
03672                                  *
03673                                  * At least in one of the pathes :-( 
03674                                  */
03675             res = ast_say_number_full_he(chan, tm.tm_mday,
03676                ints, lang, "m", -1, -1
03677             );
03678             break;
03679          case 'Y': /* Year */
03680             res = ast_say_number_full_he(chan, tm.tm_year+1900,
03681                ints, lang, "f", -1, -1
03682             );
03683             break;
03684          case 'I':
03685          case 'l': /* 12-Hour */
03686             {
03687                int hour = tm.tm_hour;
03688                hour = hour%12;
03689                if (hour == 0) hour=12;
03690             
03691                res = ast_say_number_full_he(chan, hour,
03692                   ints, lang, "f", -1, -1
03693                );
03694             }
03695             break;
03696          case 'H':
03697          case 'k': /* 24-Hour */
03698             /* With 'H' there is an 'oh' after a single-
03699              * digit hour */
03700             if ((format[offset] == 'H') && 
03701                 (tm.tm_hour <10)&&(tm.tm_hour>0)
03702             ) { /* e.g. oh-eight */
03703                res = wait_file(chan,ints, "digits/oh",lang);
03704             }
03705             
03706             res = ast_say_number_full_he(chan, tm.tm_hour,
03707                ints, lang, "f", -1, -1
03708             );
03709             break;
03710          case 'M': /* Minute */
03711             res = ast_say_number_full_he(chan, tm.tm_min, 
03712                ints, lang,"f", -1, -1
03713             );
03714             break;
03715          case 'P':
03716          case 'p':
03717             /* AM/PM */
03718             if (tm.tm_hour > 11)
03719                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
03720             else
03721                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
03722             res = wait_file(chan,ints,nextmsg,lang);
03723             break;
03724          case 'Q':
03725             /* Shorthand for "Today", "Yesterday", or "date" */
03726          case 'q':
03727             /* Shorthand for "" (today), "Yesterday", A 
03728                                  * (weekday), or "date" */
03729             {
03730                struct timeval now;
03731                struct tm tmnow;
03732                time_t beg_today;
03733                char todo = format[offset]; /* The letter to format*/
03734 
03735                gettimeofday(&now,NULL);
03736                ast_localtime(&now.tv_sec,&tmnow,timezone);
03737                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
03738                /* In any case, it saves not having to do ast_mktime() */
03739                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
03740                if (beg_today < time) {
03741                   /* Today */
03742                   if (todo == 'Q') {
03743                      res = wait_file(chan,
03744                            ints, 
03745                            "digits/today",
03746                            lang);
03747                   }
03748                } else if (beg_today - 86400 < time) {
03749                   /* Yesterday */
03750                   res = wait_file(chan,ints, "digits/yesterday",lang);
03751                } else if ((todo != 'Q') &&
03752                   (beg_today - 86400 * 6 < time))
03753                {
03754                   /* Within the last week */
03755                   res = ast_say_date_with_format_he(chan,
03756                                 time, ints, lang, 
03757                                 "A", timezone);
03758                } else {
03759                   res = ast_say_date_with_format_he(chan,
03760                                 time, ints, lang, 
03761                                 IL_DATE_STR, timezone);
03762                }
03763             }
03764             break;
03765          case 'R':
03766             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
03767             break;
03768          case 'S': /* Seconds */
03769             res = ast_say_number_full_he(chan, tm.tm_sec,
03770                ints, lang, "f", -1, -1
03771             );
03772             break;
03773          case 'T':
03774             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
03775             break;
03776          /* c, x, and X seem useful for testing. Not sure
03777                          * if thiey're good for the general public */
03778                         case 'c':
03779             res = ast_say_date_with_format_he(chan, time, 
03780                                     ints, lang, IL_DATE_STR_FULL, timezone);
03781             break;
03782                         case 'x':
03783             res = ast_say_date_with_format_he(chan, time, 
03784                                     ints, lang, IL_DATE_STR, timezone);
03785             break;
03786                         case 'X': /* Currently not locale-dependent...*/
03787             res = ast_say_date_with_format_he(chan, time, 
03788                                     ints, lang, IL_TIME_STR, timezone);
03789             break;
03790          case ' ':
03791          case '   ':
03792             /* Just ignore spaces and tabs */
03793             break;
03794          default:
03795             /* Unknown character */
03796             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
03797       }
03798       /* Jump out on DTMF */
03799       if (res) {
03800          break;
03801       }
03802    }
03803    return res;
03804 }

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

Definition at line 4183 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

04184 {
04185    struct tm tm;
04186    int res=0, offset, sndoffset;
04187    char sndfile[256], nextmsg[256];
04188 
04189    ast_localtime(&time,&tm,timezone);
04190 
04191    for (offset=0 ; format[offset] != '\0' ; offset++) {
04192       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04193       switch (format[offset]) {
04194          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04195          case '\'':
04196             /* Literal name of a sound file */
04197             sndoffset=0;
04198             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
04199             sndfile[sndoffset] = format[offset];
04200             sndfile[sndoffset] = '\0';
04201             res = wait_file(chan,ints,sndfile,lang);
04202             break;
04203          case 'A':
04204          case 'a':
04205             /* Sunday - Saturday */
04206             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04207             res = wait_file(chan,ints,nextmsg,lang);
04208             break;
04209          case 'B':
04210          case 'b':
04211          case 'h':
04212             /* January - December */
04213             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04214             res = wait_file(chan,ints,nextmsg,lang);
04215             break;
04216          case 'm':
04217             /* First - Twelfth */
04218             snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
04219             res = wait_file(chan,ints,nextmsg,lang);
04220             break;
04221          case 'd':
04222          case 'e':
04223             /* First day of the month is spelled as ordinal */
04224             if (tm.tm_mday == 1) {
04225                snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
04226                res = wait_file(chan,ints,nextmsg,lang);
04227             } else {
04228                if (!res) {
04229                   res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
04230                }
04231             }
04232             break;
04233          case 'Y':
04234             /* Year */
04235             if (tm.tm_year > 99) {
04236                res = wait_file(chan,ints, "digits/ore-2000",lang);
04237                if (tm.tm_year > 100) {
04238                   if (!res) {
04239                   /* This works until the end of 2021 */
04240                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year - 100);
04241                   res = wait_file(chan,ints,nextmsg,lang);
04242                   }
04243                }
04244             } else {
04245                if (tm.tm_year < 1) {
04246                   /* I'm not going to handle 1900 and prior */
04247                   /* We'll just be silent on the year, instead of bombing out. */
04248                } else {
04249                   res = wait_file(chan,ints, "digits/ore-1900",lang);
04250                   if ((!res) && (tm.tm_year != 0)) {
04251                      if (tm.tm_year <= 21) {
04252                         /* 1910 - 1921 */
04253                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
04254                         res = wait_file(chan,ints,nextmsg,lang);
04255                      } else {
04256                         /* 1922 - 1999, but sounds badly in 1928, 1931, 1938, etc... */
04257                         int ten, one;
04258                         ten = tm.tm_year / 10;
04259                         one = tm.tm_year % 10;
04260                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten * 10);
04261                         res = wait_file(chan,ints,nextmsg,lang);
04262                         if (!res) {
04263                            if (one != 0) {
04264                               snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
04265                               res = wait_file(chan,ints,nextmsg,lang);
04266                            }
04267                         }
04268                      }
04269                   }
04270                }
04271             }
04272             break;
04273          case 'I':
04274          case 'l':
04275             /* 12-Hour */
04276             if (tm.tm_hour == 0)
04277                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
04278             else if (tm.tm_hour > 12)
04279                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
04280             else
04281                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
04282                res = wait_file(chan,ints,nextmsg,lang);
04283             break;
04284          case 'H':
04285          case 'k':
04286             /* 24-Hour */
04287             if (tm.tm_hour == 0) {
04288                res = wait_file(chan,ints, "digits/ore-mezzanotte",lang);
04289             } else if (tm.tm_hour == 1) {
04290                res = wait_file(chan,ints, "digits/ore-una",lang);
04291             } else {
04292                res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
04293             }
04294             break;
04295          case 'M':
04296             /* Minute */
04297             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
04298             break;
04299          case 'P':
04300          case 'p':
04301             /* AM/PM */
04302             if (tm.tm_hour > 11)
04303                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
04304             else
04305                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
04306                res = wait_file(chan,ints,nextmsg,lang);
04307             break;
04308          case 'Q':
04309             /* Shorthand for "Today", "Yesterday", or ABdY */
04310             {
04311                  struct timeval now;
04312                struct tm tmnow;
04313                time_t beg_today;
04314    
04315                  gettimeofday(&now,NULL);
04316                ast_localtime(&now.tv_sec,&tmnow,timezone);
04317                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04318                /* In any case, it saves not having to do ast_mktime() */
04319                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04320                if (beg_today < time) {
04321                   /* Today */
04322                   res = wait_file(chan,ints, "digits/today",lang);
04323                } else if (beg_today - 86400 < time) {
04324                   /* Yesterday */
04325                   res = wait_file(chan,ints, "digits/yesterday",lang);
04326                } else {
04327                   res = ast_say_date_with_format(chan, time, ints, lang, "AdB", timezone);
04328                }
04329             }
04330             break;
04331          case 'q':
04332             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
04333             {
04334                struct timeval now;
04335                struct tm tmnow;
04336                time_t beg_today;
04337    
04338                gettimeofday(&now,NULL);
04339                ast_localtime(&now.tv_sec,&tmnow,timezone);
04340                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04341                /* In any case, it saves not having to do ast_mktime() */
04342                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04343                if (beg_today < time) {
04344                   /* Today */
04345                } else if ((beg_today - 86400) < time) {
04346                   /* Yesterday */
04347                   res = wait_file(chan,ints, "digits/yesterday",lang);
04348                } else if (beg_today - 86400 * 6 < time) {
04349                   /* Within the last week */
04350                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
04351                } else {
04352                   res = ast_say_date_with_format(chan, time, ints, lang, "AdB", timezone);
04353                }
04354             }
04355             break;
04356          case 'R':
04357             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
04358             break;
04359          case 'S':
04360             /* Seconds */
04361             if (tm.tm_sec == 0) {
04362                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04363                res = wait_file(chan,ints,nextmsg,lang);
04364             } else if (tm.tm_sec < 10) {
04365                res = wait_file(chan,ints, "digits/oh",lang);
04366                if (!res) {
04367                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04368                   res = wait_file(chan,ints,nextmsg,lang);
04369                }
04370             } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
04371                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04372                res = wait_file(chan,ints,nextmsg,lang);
04373             } else {
04374                int ten, one;
04375                ten = (tm.tm_sec / 10) * 10;
04376                one = (tm.tm_sec % 10);
04377                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
04378                res = wait_file(chan,ints,nextmsg,lang);
04379                if (!res) {
04380                   /* Fifty, not fifty-zero */
04381                   if (one != 0) {
04382                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
04383                      res = wait_file(chan,ints,nextmsg,lang);
04384                   }
04385                }
04386             }
04387               break;
04388          case 'T':
04389             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
04390             break;
04391          case ' ':
04392          case '   ':
04393             /* Just ignore spaces and tabs */
04394             break;
04395          default:
04396             /* Unknown character */
04397             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04398       }
04399       /* Jump out on DTMF */
04400       if (res) {
04401          break;
04402       }
04403    }
04404    return res;
04405 }

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

Definition at line 4408 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

04409 {
04410    struct tm tm;
04411    int res=0, offset, sndoffset;
04412    char sndfile[256], nextmsg[256];
04413 
04414    ast_localtime(&time,&tm,timezone);
04415 
04416    for (offset=0 ; format[offset] != '\0' ; offset++) {
04417       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04418       switch (format[offset]) {
04419          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04420          case '\'':
04421             /* Literal name of a sound file */
04422             sndoffset=0;
04423             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
04424                sndfile[sndoffset] = format[offset];
04425             sndfile[sndoffset] = '\0';
04426             res = wait_file(chan,ints,sndfile,lang);
04427             break;
04428          case 'A':
04429          case 'a':
04430             /* Sunday - Saturday */
04431             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04432             res = wait_file(chan,ints,nextmsg,lang);
04433             break;
04434          case 'B':
04435          case 'b':
04436          case 'h':
04437             /* January - December */
04438             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04439             res = wait_file(chan,ints,nextmsg,lang);
04440             break;
04441          case 'm':
04442             /* First - Twelfth */
04443             snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
04444             res = wait_file(chan,ints,nextmsg,lang);
04445             break;
04446          case 'd':
04447          case 'e':
04448             /* First - Thirtyfirst */
04449             res = ast_say_number(chan, tm.tm_mday, ints, lang, NULL);
04450             break;
04451          case 'Y':
04452             /* Year */
04453             if (tm.tm_year > 99) {
04454                res = wait_file(chan,ints, "digits/2",lang);
04455                if (!res) {
04456                   res = wait_file(chan,ints, "digits/thousand",lang);
04457                }
04458                if (tm.tm_year > 100) {
04459                   if (!res) {
04460                      /* This works until the end of 2020 */
04461                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year - 100);
04462                      res = wait_file(chan,ints,nextmsg,lang);
04463                   }
04464                }
04465             } else {
04466                if (tm.tm_year < 1) {
04467                   /* I'm not going to handle 1900 and prior */
04468                   /* We'll just be silent on the year, instead of bombing out. */
04469                } else {
04470                   res = wait_file(chan,ints, "digits/19",lang);
04471                   if (!res) {
04472                      if (tm.tm_year <= 9) {
04473                         /* 1901 - 1909 */
04474                         res = wait_file(chan,ints, "digits/oh",lang);
04475                         if (!res) {
04476                            snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
04477                            res = wait_file(chan,ints,nextmsg,lang);
04478                         }
04479                      } else if (tm.tm_year <= 20) {
04480                         /* 1910 - 1920 */
04481                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
04482                         res = wait_file(chan,ints,nextmsg,lang);
04483                      } else {
04484                         /* 1921 - 1999 */
04485                         int ten, one;
04486                         ten = tm.tm_year / 10;
04487                         one = tm.tm_year % 10;
04488                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten * 10);
04489                         res = wait_file(chan,ints,nextmsg,lang);
04490                         if (!res) {
04491                            if (one != 0) {
04492                               snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
04493                               res = wait_file(chan,ints,nextmsg,lang);
04494                            }
04495                         }
04496                      }
04497                   }
04498                }
04499             }
04500             break;
04501          case 'I':
04502          case 'l':
04503             /* 12-Hour */
04504             if (tm.tm_hour == 0)
04505                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
04506             else if (tm.tm_hour > 12)
04507                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
04508             else
04509                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
04510             res = wait_file(chan,ints,nextmsg,lang);
04511             break;
04512          case 'H':
04513          case 'k':
04514             /* 24-Hour */
04515             res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
04516             if (!res) {
04517                res = wait_file(chan,ints, "digits/nl-uur",lang);
04518             }
04519             break;
04520          case 'M':
04521             /* Minute */
04522             res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
04523             break;
04524          case 'P':
04525          case 'p':
04526             /* AM/PM */
04527             if (tm.tm_hour > 11)
04528                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
04529             else
04530                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
04531             res = wait_file(chan,ints,nextmsg,lang);
04532             break;
04533          case 'Q':
04534             /* Shorthand for "Today", "Yesterday", or ABdY */
04535             {
04536                struct timeval now;
04537                struct tm tmnow;
04538                time_t beg_today;
04539 
04540                gettimeofday(&now,NULL);
04541                ast_localtime(&now.tv_sec,&tmnow,timezone);
04542                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04543                /* In any case, it saves not having to do ast_mktime() */
04544                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04545                if (beg_today < time) {
04546                   /* Today */
04547                   res = wait_file(chan,ints, "digits/today",lang);
04548                } else if (beg_today - 86400 < time) {
04549                   /* Yesterday */
04550                   res = wait_file(chan,ints, "digits/yesterday",lang);
04551                } else {
04552                   res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
04553                }
04554             }
04555             break;
04556          case 'q':
04557             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
04558             {
04559                struct timeval now;
04560                struct tm tmnow;
04561                time_t beg_today;
04562 
04563                gettimeofday(&now,NULL);
04564                ast_localtime(&now.tv_sec,&tmnow,timezone);
04565                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04566                /* In any case, it saves not having to do ast_mktime() */
04567                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04568                if (beg_today < time) {
04569                   /* Today */
04570                } else if ((beg_today - 86400) < time) {
04571                   /* Yesterday */
04572                   res = wait_file(chan,ints, "digits/yesterday",lang);
04573                } else if (beg_today - 86400 * 6 < time) {
04574                   /* Within the last week */
04575                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
04576                } else {
04577                   res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
04578                }
04579             }
04580             break;
04581          case 'R':
04582             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
04583             break;
04584          case 'S':
04585             /* Seconds */
04586             if (tm.tm_sec == 0) {
04587                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04588                res = wait_file(chan,ints,nextmsg,lang);
04589             } else if (tm.tm_sec < 10) {
04590                res = wait_file(chan,ints, "digits/oh",lang);
04591                if (!res) {
04592                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04593                   res = wait_file(chan,ints,nextmsg,lang);
04594                }
04595             } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
04596                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04597                res = wait_file(chan,ints,nextmsg,lang);
04598             } else {
04599                int ten, one;
04600                ten = (tm.tm_sec / 10) * 10;
04601                one = (tm.tm_sec % 10);
04602                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
04603                res = wait_file(chan,ints,nextmsg,lang);
04604                if (!res) {
04605                   /* Fifty, not fifty-zero */
04606                   if (one != 0) {
04607                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
04608                      res = wait_file(chan,ints,nextmsg,lang);
04609                   }
04610                }
04611             }
04612             break;
04613          case 'T':
04614             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
04615             break;
04616          case ' ':
04617          case '   ':
04618             /* Just ignore spaces and tabs */
04619             break;
04620          default:
04621             /* Unknown character */
04622             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04623       }
04624       /* Jump out on DTMF */
04625       if (res) {
04626          break;
04627       }
04628    }
04629    return res;
04630 }

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

Definition at line 4633 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

04634 {
04635    struct tm tm;
04636    int res=0, offset, sndoffset;
04637    char sndfile[256], nextmsg[256];
04638 
04639    ast_localtime(&time,&tm,timezone);
04640 
04641    for (offset=0 ; format[offset] != '\0' ; offset++) {
04642       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04643       switch (format[offset]) {
04644          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04645          case '\'':
04646             /* Literal name of a sound file */
04647             sndoffset=0;
04648             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
04649                sndfile[sndoffset] = format[offset];
04650             sndfile[sndoffset] = '\0';
04651             snprintf(nextmsg,sizeof(nextmsg), "%s", sndfile);
04652             res = wait_file(chan,ints,nextmsg,lang);
04653             break;
04654          case 'A':
04655          case 'a':
04656             /* Sunday - Saturday */
04657             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04658             res = wait_file(chan,ints,nextmsg,lang);
04659             break;
04660          case 'B':
04661          case 'b':
04662          case 'h':
04663             /* January - December */
04664             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04665             res = wait_file(chan,ints,nextmsg,lang);
04666             break;
04667          case 'm':
04668             /* First - Twelfth */
04669             snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
04670             res = wait_file(chan,ints,nextmsg,lang);
04671             break;
04672          case 'd':
04673          case 'e':
04674             /* First - Thirtyfirst */
04675             res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
04676             break;
04677          case 'Y':
04678             /* Year */
04679             res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
04680             break;
04681          case 'I':
04682          case 'l':
04683             /* 12-Hour */
04684             if (!strcasecmp(lang, "pt_BR")) {
04685                     if (tm.tm_hour == 0) {
04686                         if (format[offset] == 'I')
04687                             res = wait_file(chan, ints, "digits/pt-a", lang);
04688                         if (!res)
04689                             res = wait_file(chan, ints, "digits/pt-meianoite", lang);
04690                     } else if (tm.tm_hour == 12) {
04691                         if (format[offset] == 'I')
04692                             res = wait_file(chan, ints, "digits/pt-ao", lang);
04693                         if (!res)
04694                             res = wait_file(chan, ints, "digits/pt-meiodia", lang);
04695                     } else {
04696                         if (format[offset] == 'I') {
04697                             if ((tm.tm_hour % 12) != 1)
04698                                 res = wait_file(chan, ints, "digits/pt-as", lang);
04699                             else
04700                                 res = wait_file(chan, ints, "digits/pt-a", lang);
04701                         }
04702                         if (!res)
04703                             res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
04704                         if ((!res) && (format[offset] == 'I'))
04705                             res = ast_say_date_with_format(chan, time, ints, lang, "P", timezone);
04706                     }
04707             } else {
04708                     if (tm.tm_hour == 0) {
04709                         if (format[offset] == 'I')
04710                             res = wait_file(chan, ints, "digits/pt-ah", lang);
04711                         if (!res)
04712                             res = wait_file(chan, ints, "digits/pt-meianoite", lang);
04713                     }
04714                     else if (tm.tm_hour == 12) {
04715                         if (format[offset] == 'I')
04716                             res = wait_file(chan, ints, "digits/pt-ao", lang);
04717                         if (!res)
04718                             res = wait_file(chan, ints, "digits/pt-meiodia", lang);
04719                     }
04720                     else {
04721                         if (format[offset] == 'I') {
04722                             res = wait_file(chan, ints, "digits/pt-ah", lang);
04723                             if ((tm.tm_hour % 12) != 1)
04724                                 if (!res)
04725                                     res = wait_file(chan, ints, "digits/pt-sss", lang);
04726                         }
04727                         if (!res)
04728                             res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
04729                     }
04730             }
04731             break;
04732          case 'H':
04733          case 'k':
04734             /* 24-Hour */
04735             if (!strcasecmp(lang, "pt_BR")) {
04736                res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
04737                if ((!res) && (format[offset] == 'H')) {
04738                   if (tm.tm_hour > 1) {
04739                      res = wait_file(chan,ints,"digits/hours",lang);
04740                   } else {
04741                      res = wait_file(chan,ints,"digits/hour",lang);
04742                   }
04743                }
04744             } else {
04745                res = ast_say_number(chan, -tm.tm_hour, ints, lang, NULL);
04746                if (!res) {
04747                   if (tm.tm_hour != 0) {
04748                      int remainder = tm.tm_hour;
04749                      if (tm.tm_hour > 20) {
04750                         res = wait_file(chan,ints, "digits/20",lang);
04751                         remainder -= 20;
04752                      }
04753                      if (!res) {
04754                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", remainder);
04755                         res = wait_file(chan,ints,nextmsg,lang);
04756                      }
04757                   }
04758                }
04759             }
04760             break;
04761          case 'M':
04762             /* Minute */
04763             if (!strcasecmp(lang, "pt_BR")) {
04764                res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
04765                     if (!res) {
04766                   if (tm.tm_min > 1) {
04767                      res = wait_file(chan,ints,"digits/minutes",lang);
04768                   } else {
04769                      res = wait_file(chan,ints,"digits/minute",lang);
04770                   }
04771                }
04772             } else {
04773                if (tm.tm_min == 0) {
04774                   res = wait_file(chan, ints, "digits/pt-hora", lang);
04775                   if (tm.tm_hour != 1)
04776                      if (!res)
04777                         res = wait_file(chan, ints, "digits/pt-sss", lang);         } else {
04778                   res = wait_file(chan,ints,"digits/pt-e",lang);
04779                   if (!res)
04780                      res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 
04781                }  
04782             }
04783             break;
04784          case 'P':
04785          case 'p':
04786             /* AM/PM */
04787             if (!strcasecmp(lang, "pt_BR")) {
04788                     if ((tm.tm_hour != 0) && (tm.tm_hour != 12)) {
04789                         res = wait_file(chan, ints, "digits/pt-da", lang);
04790                         if (!res) {
04791                             if ((tm.tm_hour >= 0) && (tm.tm_hour < 12))
04792                                 res = wait_file(chan, ints, "digits/morning", lang);
04793                             else if ((tm.tm_hour >= 12) && (tm.tm_hour < 18))
04794                                 res = wait_file(chan, ints, "digits/afternoon", lang);
04795                             else res = wait_file(chan, ints, "digits/night", lang);
04796                         }
04797                }
04798             } else {
04799                if (tm.tm_hour > 12)
04800                   res = wait_file(chan, ints, "digits/p-m", lang);
04801                else if (tm.tm_hour  && tm.tm_hour < 12)
04802                   res = wait_file(chan, ints, "digits/a-m", lang);
04803             }
04804             break;
04805          case 'Q':
04806             /* Shorthand for "Today", "Yesterday", or ABdY */
04807             {
04808                struct timeval now;
04809                struct tm tmnow;
04810                time_t beg_today;
04811 
04812                gettimeofday(&now,NULL);
04813                ast_localtime(&now.tv_sec,&tmnow,timezone);
04814                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04815                /* In any case, it saves not having to do ast_mktime() */
04816                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04817                if (beg_today < time) {
04818                   /* Today */
04819                   res = wait_file(chan,ints, "digits/today",lang);
04820                } else if (beg_today - 86400 < time) {
04821                   /* Yesterday */
04822                   res = wait_file(chan,ints, "digits/yesterday",lang);
04823                } else {
04824                   res = ast_say_date_with_format(chan, time, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", timezone);
04825                }
04826             }
04827             break;
04828          case 'q':
04829             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
04830             {
04831                struct timeval now;
04832                struct tm tmnow;
04833                time_t beg_today;
04834 
04835                gettimeofday(&now,NULL);
04836                ast_localtime(&now.tv_sec,&tmnow,timezone);
04837                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
04838                /* In any case, it saves not having to do ast_mktime() */
04839                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
04840                if (beg_today < time) {
04841                   /* Today */
04842                } else if ((beg_today - 86400) < time) {
04843                   /* Yesterday */
04844                   res = wait_file(chan,ints, "digits/yesterday",lang);
04845                } else if (beg_today - 86400 * 6 < time) {
04846                   /* Within the last week */
04847                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
04848                } else {
04849                   res = ast_say_date_with_format(chan, time, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", timezone);
04850                }
04851             }
04852             break;
04853          case 'R':
04854             res = ast_say_date_with_format(chan, time, ints, lang, "H 'digits/pt-e' M", timezone);
04855             break;
04856          case 'S':
04857             /* Seconds */
04858             if (!strcasecmp(lang, "pt_BR")) {
04859                res = ast_say_number(chan, tm.tm_sec, ints, lang, NULL);
04860                if (!res) {
04861                   if (tm.tm_sec > 1) {
04862                      res = wait_file(chan,ints,"digits/seconds",lang);
04863                   } else {
04864                      res = wait_file(chan,ints,"digits/second",lang);
04865                   }
04866                }
04867             } else {
04868                if (tm.tm_sec == 0) {
04869                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04870                   res = wait_file(chan,ints,nextmsg,lang);
04871                } else if (tm.tm_sec < 10) {
04872                   res = wait_file(chan,ints, "digits/oh",lang);
04873                   if (!res) {
04874                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04875                      res = wait_file(chan,ints,nextmsg,lang);
04876                   }
04877                } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
04878                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
04879                   res = wait_file(chan,ints,nextmsg,lang);
04880                } else {
04881                   int ten, one;
04882                   ten = (tm.tm_sec / 10) * 10;
04883                   one = (tm.tm_sec % 10);
04884                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
04885                   res = wait_file(chan,ints,nextmsg,lang);
04886                   if (!res) {
04887                      /* Fifty, not fifty-zero */
04888                      if (one != 0) {
04889                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
04890                         res = wait_file(chan,ints,nextmsg,lang);
04891                      }
04892                   }
04893                }
04894             }
04895             break;
04896          case 'T':
04897             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
04898             break;
04899          case ' ':
04900          case '   ':
04901             /* Just ignore spaces and tabs */
04902             break;
04903          default:
04904             /* Unknown character */
04905             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
04906       }
04907       /* Jump out on DTMF */
04908       if (res) {
04909          break;
04910       }
04911    }
04912    return res;
04913 }

int ast_say_date_with_format_tw ( struct ast_channel chan,
time_t  time,
const char *  ints,
const char *  lang,
const char *  format,
const char *  timezone 
) [static]

Definition at line 4916 of file say.c.

References ast_localtime(), ast_log(), ast_say_date_with_format(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().

Referenced by ast_say_date_with_format().

04917 {
04918    struct tm tm;
04919    int res=0, offset, sndoffset;
04920    char sndfile[256], nextmsg[256];
04921 
04922    ast_localtime(&time,&tm,timezone);
04923 
04924    for (offset=0 ; format[offset] != '\0' ; offset++) {
04925       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
04926       switch (format[offset]) {
04927          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
04928          case '\'':
04929             /* Literal name of a sound file */
04930             sndoffset=0;
04931             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
04932                sndfile[sndoffset] = format[offset];
04933             sndfile[sndoffset] = '\0';
04934             res = wait_file(chan,ints,sndfile,lang);
04935             break;
04936          case 'A':
04937          case 'a':
04938             /* Sunday - Saturday */
04939             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
04940             res = wait_file(chan,ints,nextmsg,lang);
04941             break;
04942          case 'B':
04943          case 'b':
04944          case 'h':
04945             /* January - December */
04946             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
04947             res = wait_file(chan,ints,nextmsg,lang);
04948             break;
04949          case 'm':
04950             /* First - Twelfth */
04951             snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
04952             res = wait_file(chan,ints,nextmsg,lang);
04953             break;
04954          case 'd':
04955          case 'e':
04956             /* First - Thirtyfirst */
04957             if (!(tm.tm_mday % 10) || (tm.tm_mday < 10)) {
04958                snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
04959                res = wait_file(chan,ints,nextmsg,lang);
04960             } else {
04961                snprintf(nextmsg,sizeof(nextmsg), "digits/h-%dh", tm.tm_mday - (tm.tm_mday % 10));
04962                res = wait_file(chan,ints,nextmsg,lang);
04963                if(!res) {
04964                   snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday % 10);
04965                   res = wait_file(chan,ints,nextmsg,lang);
04966                }
04967             }
04968             break;
04969          case 'Y':
04970             /* Year */
04971             if (tm.tm_year > 99) {
04972                res = wait_file(chan,ints, "digits/2",lang);
04973                if (!res) {
04974                   res = wait_file(chan,ints, "digits/thousand",lang);
04975                }
04976                if (tm.tm_year > 100) {
04977                   if (!res) {
04978                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) / 10);
04979                      res = wait_file(chan,ints,nextmsg,lang);
04980                      if (!res) {
04981                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) % 10);
04982                         res = wait_file(chan,ints,nextmsg,lang);
04983                      }
04984                   }
04985                }
04986                if (!res) {
04987                   res = wait_file(chan,ints, "digits/year",lang);
04988                }
04989             } else {
04990                if (tm.tm_year < 1) {
04991                   /* I'm not going to handle 1900 and prior */
04992                   /* We'll just be silent on the year, instead of bombing out. */
04993                } else {
04994                   res = wait_file(chan,ints, "digits/1",lang);
04995                   if (!res) {
04996                      res = wait_file(chan,ints, "digits/9",lang);
04997                   }
04998                   if (!res) {
04999                      if (tm.tm_year <= 9) {
05000                         /* 1901 - 1909 */
05001                         res = wait_file(chan,ints, "digits/0",lang);
05002                         if (!res) {
05003                            snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
05004                            res = wait_file(chan,ints,nextmsg,lang);
05005                         }
05006                      } else {
05007                         /* 1910 - 1999 */
05008                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year / 10);
05009                         res = wait_file(chan,ints,nextmsg,lang);
05010                         if (!res) {
05011                            snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year % 10);
05012                            res = wait_file(chan,ints,nextmsg,lang);
05013                         }
05014                      }
05015                   }
05016                }
05017                if (!res) {
05018                   res = wait_file(chan,ints, "digits/year",lang);
05019                }
05020             }
05021             break;
05022          case 'I':
05023          case 'l':
05024             /* 12-Hour */
05025             if (tm.tm_hour == 0)
05026                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
05027             else if (tm.tm_hour > 12)
05028                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
05029             else
05030                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
05031             res = wait_file(chan,ints,nextmsg,lang);
05032             if (!res) {
05033                res = wait_file(chan,ints, "digits/oclock",lang);
05034             }
05035             break;
05036          case 'H':
05037          case 'k':
05038             /* 24-Hour */
05039             if (!(tm.tm_hour % 10) || tm.tm_hour < 10) {
05040                if (tm.tm_hour < 10) {
05041                   res = wait_file(chan, ints, "digits/0", lang);
05042                }
05043                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
05044                res = wait_file(chan,ints,nextmsg,lang);
05045             } else {
05046                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - (tm.tm_hour % 10));
05047                res = wait_file(chan,ints,nextmsg,lang);
05048                if (!res) {
05049                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour % 10);
05050                   res = wait_file(chan,ints,nextmsg,lang);
05051                }
05052             }
05053             if (!res) {
05054                res = wait_file(chan,ints, "digits/oclock",lang);
05055             }
05056             break;
05057          case 'M':
05058             /* Minute */
05059             if (!(tm.tm_min % 10) || tm.tm_min < 10) {
05060                if (tm.tm_min < 10) {
05061                   res = wait_file(chan, ints, "digits/0", lang);
05062                }
05063                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min);
05064                res = wait_file(chan,ints,nextmsg,lang);
05065             } else {
05066                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min - (tm.tm_min % 10));
05067                res = wait_file(chan,ints,nextmsg,lang);
05068                if (!res) {
05069                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min % 10);
05070                   res = wait_file(chan,ints,nextmsg,lang);
05071                }
05072             }
05073             if (!res) {
05074                res = wait_file(chan,ints, "digits/minute",lang);
05075             }
05076             break;
05077          case 'P':
05078          case 'p':
05079             /* AM/PM */
05080             if (tm.tm_hour > 11)
05081                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
05082             else
05083                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
05084             res = wait_file(chan,ints,nextmsg,lang);
05085             break;
05086          case 'Q':
05087             /* Shorthand for "Today", "Yesterday", or ABdY */
05088             {
05089                struct timeval now;
05090                struct tm tmnow;
05091                time_t beg_today;
05092 
05093                gettimeofday(&now,NULL);
05094                ast_localtime(&now.tv_sec,&tmnow,timezone);
05095                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05096                /* In any case, it saves not having to do ast_mktime() */
05097                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05098                if (beg_today < time) {
05099                   /* Today */
05100                   res = wait_file(chan,ints, "digits/today",lang);
05101                } else if (beg_today - 86400 < time) {
05102                   /* Yesterday */
05103                   res = wait_file(chan,ints, "digits/yesterday",lang);
05104                } else {
05105                   res = ast_say_date_with_format(chan, time, ints, lang, "YBdA", timezone);
05106                }
05107             }
05108             break;
05109          case 'q':
05110             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
05111             {
05112                struct timeval now;
05113                struct tm tmnow;
05114                time_t beg_today;
05115 
05116                gettimeofday(&now,NULL);
05117                ast_localtime(&now.tv_sec,&tmnow,timezone);
05118                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
05119                /* In any case, it saves not having to do ast_mktime() */
05120                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
05121                if (beg_today < time) {
05122                   /* Today */
05123                } else if ((beg_today - 86400) < time) {
05124                   /* Yesterday */
05125                   res = wait_file(chan,ints, "digits/yesterday",lang);
05126                } else if (beg_today - 86400 * 6 < time) {
05127                   /* Within the last week */
05128                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
05129                } else {
05130                   res = ast_say_date_with_format(chan, time, ints, lang, "YBdA", timezone);
05131                }
05132             }
05133             break;
05134          case 'R':
05135             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
05136             break;
05137          case 'S':
05138             /* Seconds */
05139             if (!(tm.tm_sec % 10) || tm.tm_sec < 10) {
05140                if (tm.tm_sec < 10) {
05141                   res = wait_file(chan, ints, "digits/0", lang);
05142                }
05143                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
05144                res = wait_file(chan,ints,nextmsg,lang);
05145             } else {
05146                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec - (tm.tm_sec % 10));
05147                res = wait_file(chan,ints,nextmsg,lang);
05148                if (!res) {
05149                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec % 10);
05150                   res = wait_file(chan,ints,nextmsg,lang);
05151                }
05152             }
05153             if (!res) {
05154                res = wait_file(chan,ints, "digits/second",lang);
05155             }
05156             break;
05157          case 'T':
05158             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
05159             break;
05160          case ' ':
05161          case '   ':
05162             /* Just ignore spaces and tabs */
05163          break;
05164          default:
05165             /* Unknown character */
05166             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
05167       }
05168       /* Jump out on DTMF */
05169       if (res) {
05170          break;
05171       }
05172    }
05173    return res;
05174 }

int ast_say_datetime ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
)

Definition at line 5395 of file say.c.

References ast_say_datetime_de(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_gr(), ast_say_datetime_nl(), ast_say_datetime_pt(), ast_say_datetime_pt_BR(), and ast_say_datetime_tw().

Referenced by datetime_exec().

05396 {
05397    if (!strcasecmp(lang, "en") ) {  /* English syntax */
05398       return(ast_say_datetime_en(chan, t, ints, lang));
05399    } else if (!strcasecmp(lang, "de") ) { /* German syntax */
05400       return(ast_say_datetime_de(chan, t, ints, lang));
05401    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
05402       return(ast_say_datetime_fr(chan, t, ints, lang));
05403    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
05404       return(ast_say_datetime_nl(chan, t, ints, lang));
05405    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
05406       return(ast_say_datetime_pt(chan, t, ints, lang));
05407    } else if (!strcasecmp(lang, "pt_BR") ) { /* Brazilian Portuguese syntax */
05408       return(ast_say_datetime_pt_BR(chan, t, ints, lang));
05409    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
05410       return(ast_say_datetime_tw(chan, t, ints, lang));
05411    } else if (!strcasecmp(lang, "gr") ) {          /* Greek syntax */
05412       return(ast_say_datetime_gr(chan, t, ints, lang));
05413    }
05414 
05415    /* Default to English */
05416    return(ast_say_datetime_en(chan, t, ints, lang));
05417 }

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

Definition at line 5485 of file say.c.

References ast_say_date(), and ast_say_time().

Referenced by ast_say_datetime().

05486 {
05487    struct tm tm;
05488    int res = 0;
05489    localtime_r(&t,&tm);
05490    res = ast_say_date(chan, t, ints, lang);
05491    if (!res) 
05492       ast_say_time(chan, t, ints, lang);
05493    return res;
05494 
05495 }

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

Definition at line 5420 of file say.c.

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

Referenced by ast_say_datetime().

05421 {
05422    struct tm tm;
05423    char fn[256];
05424    int res = 0;
05425    int hour, pm=0;
05426    localtime_r(&t,&tm);
05427    if (!res) {
05428       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05429       res = ast_streamfile(chan, fn, lang);
05430       if (!res)
05431          res = ast_waitstream(chan, ints);
05432    }
05433    if (!res) {
05434       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05435       res = ast_streamfile(chan, fn, lang);
05436       if (!res)
05437          res = ast_waitstream(chan, ints);
05438    }
05439    if (!res)
05440       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05441 
05442    hour = tm.tm_hour;
05443    if (!hour)
05444       hour = 12;
05445    else if (hour == 12)
05446       pm = 1;
05447    else if (hour > 12) {
05448       hour -= 12;
05449       pm = 1;
05450    }
05451    if (!res)
05452       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
05453 
05454    if (tm.tm_min > 9) {
05455       if (!res)
05456          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05457    } else if (tm.tm_min) {
05458       if (!res)
05459          res = ast_streamfile(chan, "digits/oh", lang);
05460       if (!res)
05461          res = ast_waitstream(chan, ints);
05462       if (!res)
05463          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05464    } else {
05465       if (!res)
05466          res = ast_streamfile(chan, "digits/oclock", lang);
05467       if (!res)
05468          res = ast_waitstream(chan, ints);
05469    }
05470    if (pm) {
05471       if (!res)
05472          res = ast_streamfile(chan, "digits/p-m", lang);
05473    } else {
05474       if (!res)
05475          res = ast_streamfile(chan, "digits/a-m", lang);
05476    }
05477    if (!res)
05478       res = ast_waitstream(chan, ints);
05479    if (!res)
05480       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
05481    return res;
05482 }

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

Definition at line 5498 of file say.c.

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

Referenced by ast_say_datetime().

05499 {
05500    struct tm tm;
05501    char fn[256];
05502    int res = 0;
05503    localtime_r(&t,&tm);
05504 
05505    if (!res)
05506       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05507 
05508    if (!res) {
05509       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05510       res = ast_streamfile(chan, fn, lang);
05511       if (!res)
05512          res = ast_waitstream(chan, ints);
05513    }
05514    if (!res) {
05515       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05516       res = ast_streamfile(chan, fn, lang);
05517       if (!res)
05518          res = ast_waitstream(chan, ints);
05519    }
05520 
05521    if (!res)
05522       res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
05523    if (!res)
05524          res = ast_streamfile(chan, "digits/oclock", lang);
05525    if (tm.tm_min > 0) {
05526       if (!res)
05527          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05528    } 
05529    if (!res)
05530       res = ast_waitstream(chan, ints);
05531    if (!res)
05532       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
05533    return res;
05534 }

int ast_say_datetime_from_now ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
)

Definition at line 5688 of file say.c.

References ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), and ast_say_datetime_from_now_pt().

05689 {
05690    if (!strcasecmp(lang, "en") ) {  /* English syntax */
05691       return(ast_say_datetime_from_now_en(chan, t, ints, lang));
05692    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
05693       return(ast_say_datetime_from_now_fr(chan, t, ints, lang));
05694    } else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) {  /* Portuguese syntax */
05695       return(ast_say_datetime_from_now_pt(chan, t, ints, lang));
05696    }
05697 
05698    /* Default to English */
05699    return(ast_say_datetime_from_now_en(chan, t, ints, lang));
05700 }

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

Definition at line 5703 of file say.c.

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

Referenced by ast_say_datetime_from_now().

05704 {
05705    int res=0;
05706    time_t nowt;
05707    int daydiff;
05708    struct tm tm;
05709    struct tm now;
05710    char fn[256];
05711 
05712    time(&nowt);
05713 
05714    localtime_r(&t,&tm);
05715    localtime_r(&nowt,&now);
05716    daydiff = now.tm_yday - tm.tm_yday;
05717    if ((daydiff < 0) || (daydiff > 6)) {
05718       /* Day of month and month */
05719       if (!res) {
05720          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05721          res = ast_streamfile(chan, fn, lang);
05722          if (!res)
05723             res = ast_waitstream(chan, ints);
05724       }
05725       if (!res)
05726          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05727 
05728    } else if (daydiff) {
05729       /* Just what day of the week */
05730       if (!res) {
05731          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05732          res = ast_streamfile(chan, fn, lang);
05733          if (!res)
05734             res = ast_waitstream(chan, ints);
05735       }
05736    } /* Otherwise, it was today */
05737    if (!res)
05738       res = ast_say_time(chan, t, ints, lang);
05739    return res;
05740 }

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

Definition at line 5743 of file say.c.

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

Referenced by ast_say_datetime_from_now().

05744 {
05745    int res=0;
05746    time_t nowt;
05747    int daydiff;
05748    struct tm tm;
05749    struct tm now;
05750    char fn[256];
05751 
05752    time(&nowt);
05753 
05754    localtime_r(&t,&tm);
05755    localtime_r(&nowt,&now);
05756    daydiff = now.tm_yday - tm.tm_yday;
05757    if ((daydiff < 0) || (daydiff > 6)) {
05758       /* Day of month and month */
05759       if (!res) {
05760          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05761          res = ast_streamfile(chan, fn, lang);
05762          if (!res)
05763             res = ast_waitstream(chan, ints);
05764       }
05765       if (!res)
05766          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05767 
05768    } else if (daydiff) {
05769       /* Just what day of the week */
05770       if (!res) {
05771          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05772          res = ast_streamfile(chan, fn, lang);
05773          if (!res)
05774             res = ast_waitstream(chan, ints);
05775       }
05776    } /* Otherwise, it was today */
05777    if (!res)
05778       res = ast_say_time(chan, t, ints, lang);
05779    return res;
05780 }

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

Definition at line 5783 of file say.c.

References ast_say_number(), ast_say_time(), and wait_file().

Referenced by ast_say_datetime_from_now().

05784 {
05785    int res=0;
05786    time_t nowt;
05787    int daydiff;
05788    struct tm tm;
05789    struct tm now;
05790    char fn[256];
05791 
05792    time(&nowt);
05793 
05794    localtime_r(&t,&tm);
05795    localtime_r(&nowt,&now);
05796    daydiff = now.tm_yday - tm.tm_yday;
05797    if ((daydiff < 0) || (daydiff > 6)) {
05798       /* Day of month and month */
05799       if (!res)
05800          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05801       if (!res)
05802          res = wait_file(chan, ints, "digits/pt-de", lang);
05803       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05804       if (!res)
05805          res = wait_file(chan, ints, fn, lang);
05806    
05807    } else if (daydiff) {
05808       /* Just what day of the week */
05809       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05810       if (!res)
05811          res = wait_file(chan, ints, fn, lang);
05812    }  /* Otherwise, it was today */
05813    if (!strcasecmp(lang, "pt_BR")) {
05814         if (tm.tm_hour > 1) {
05815             snprintf(fn, sizeof(fn), "digits/pt-as");
05816         } else {
05817             snprintf(fn, sizeof(fn), "digits/pt-a");
05818         }
05819         if (!res)
05820             res = wait_file(chan, ints, fn, lang);
05821    } else {
05822         snprintf(fn, sizeof(fn), "digits/pt-ah");
05823         if (!res)
05824             res = wait_file(chan, ints, fn, lang);
05825         if (tm.tm_hour != 1)
05826         if (!res)
05827             res = wait_file(chan, ints, "digits/pt-sss", lang);
05828         if (!res)
05829             res = ast_say_time(chan, t, ints, lang);
05830    }
05831    return res;
05832 }

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

Definition at line 6058 of file say.c.

References ast_say_time_gr(), ast_streamfile(), ast_waitstream(), and gr_say_number_female().

Referenced by ast_say_datetime().

06059 {
06060    struct tm tm;
06061    char fn[256];
06062    int res = 0;
06063    localtime_r(&t,&tm);
06064 
06065    
06066    /* W E E K - D A Y */
06067    if (!res) {
06068       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
06069       res = ast_streamfile(chan, fn, lang);
06070       if (!res)
06071          res = ast_waitstream(chan, ints);
06072    }
06073    /* D A Y */
06074    if (!res) {
06075       gr_say_number_female(tm.tm_mday, chan, ints, lang);
06076    }
06077    /* M O N T H */
06078    if (!res) {
06079       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
06080       res = ast_streamfile(chan, fn, lang);
06081       if (!res)
06082          res = ast_waitstream(chan, ints);
06083    }
06084 
06085    res = ast_say_time_gr(chan, t, ints, lang);
06086    return res;
06087 }

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

Definition at line 5537 of file say.c.

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

Referenced by ast_say_datetime().

05538 {
05539    struct tm tm;
05540    int res = 0;
05541    localtime_r(&t,&tm);
05542    res = ast_say_date(chan, t, ints, lang);
05543    if (!res) {
05544       res = ast_streamfile(chan, "digits/nl-om", lang);
05545       if (!res)
05546          res = ast_waitstream(chan, ints);
05547    }
05548    if (!res) 
05549       ast_say_time(chan, t, ints, lang);
05550    return res;
05551 }

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

Definition at line 5554 of file say.c.

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

Referenced by ast_say_datetime().

05555 {
05556    struct tm tm;
05557    char fn[256];
05558    int res = 0;
05559    int hour, pm=0;
05560    localtime_r(&t,&tm);
05561    if (!res) {
05562       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05563       res = ast_streamfile(chan, fn, lang);
05564       if (!res)
05565          res = ast_waitstream(chan, ints);
05566    }
05567    if (!res) {
05568       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05569       res = ast_streamfile(chan, fn, lang);
05570       if (!res)
05571          res = ast_waitstream(chan, ints);
05572    }
05573    if (!res)
05574       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05575 
05576    hour = tm.tm_hour;
05577    if (!hour)
05578       hour = 12;
05579    else if (hour == 12)
05580       pm = 1;
05581    else if (hour > 12) {
05582       hour -= 12;
05583       pm = 1;
05584    }
05585    if (!res)
05586       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
05587 
05588    if (tm.tm_min > 9) {
05589       if (!res)
05590          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05591    } else if (tm.tm_min) {
05592       if (!res)
05593          res = ast_streamfile(chan, "digits/oh", lang);
05594       if (!res)
05595          res = ast_waitstream(chan, ints);
05596       if (!res)
05597          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05598    } else {
05599       if (!res)
05600          res = ast_streamfile(chan, "digits/oclock", lang);
05601       if (!res)
05602          res = ast_waitstream(chan, ints);
05603    }
05604    if (pm) {
05605       if (!res)
05606          res = ast_streamfile(chan, "digits/p-m", lang);
05607    } else {
05608       if (!res)
05609          res = ast_streamfile(chan, "digits/a-m", lang);
05610    }
05611    if (!res)
05612       res = ast_waitstream(chan, ints);
05613    if (!res)
05614       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
05615    return res;
05616 }

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

Definition at line 5619 of file say.c.

References ast_say_date(), and ast_say_time().

Referenced by ast_say_datetime().

05620 {
05621    struct tm tm;
05622    int res = 0;
05623    localtime_r(&t,&tm);
05624    res = ast_say_date(chan, t, ints, lang);
05625    if (!res)
05626        res = ast_say_time(chan, t, ints, lang);
05627    return res;
05628 }

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

Definition at line 5631 of file say.c.

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

Referenced by ast_say_datetime().

05632 {
05633    struct tm tm;
05634    char fn[256];
05635    int res = 0;
05636    int hour, pm=0;
05637    localtime_r(&t,&tm);
05638    if (!res)
05639       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
05640    if (!res) {
05641       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
05642       res = ast_streamfile(chan, fn, lang);
05643       if (!res)
05644          res = ast_waitstream(chan, ints);
05645    }
05646    if (!res)
05647       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
05648    if (!res) {
05649       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
05650       res = ast_streamfile(chan, fn, lang);
05651       if (!res)
05652          res = ast_waitstream(chan, ints);
05653    }
05654 
05655    hour = tm.tm_hour;
05656    if (!hour)
05657       hour = 12;
05658    else if (hour == 12)
05659       pm = 1;
05660    else if (hour > 12) {
05661       hour -= 12;
05662       pm = 1;
05663    }
05664    if (pm) {
05665       if (!res)
05666          res = ast_streamfile(chan, "digits/p-m", lang);
05667    } else {
05668       if (!res)
05669          res = ast_streamfile(chan, "digits/a-m", lang);
05670    }
05671    if (!res)
05672       res = ast_waitstream(chan, ints);
05673    if (!res)
05674       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
05675    if (!res)
05676       res = ast_streamfile(chan, "digits/oclock", lang);
05677    if (!res)
05678       res = ast_waitstream(chan, ints);
05679    if (!res)
05680       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05681    if (!res)
05682       res = ast_streamfile(chan, "digits/minute", lang);
05683    if (!res)
05684       res = ast_waitstream(chan, ints);
05685    return res;
05686 }

int ast_say_digit_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang 
)

Definition at line 262 of file say.c.

References ast_say_digit_str_full().

Referenced by invent_message(), mgcp_ss(), pbx_builtin_saydigits(), play_message_callerid(), skinny_ss(), and ss_thread().

00263 {
00264    return ast_say_digit_str_full(chan, str, ints, lang, -1, -1);
00265 }

int ast_say_digit_str_full ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
)

Definition at line 216 of file say.c.

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

Referenced by ast_say_digit_str(), ast_say_digits_full(), and handle_saydigits().

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

int ast_say_digits ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang 
)

Definition at line 275 of file say.c.

References ast_say_digits_full().

Referenced by ast_park_call(), chanspy_exec(), conf_exec(), parkandannounce_exec(), and rpt_tele_thread().

00276 {
00277    return ast_say_digits_full(chan, num, ints, lang, -1, -1);
00278 }

int ast_say_digits_full ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
)

Definition at line 267 of file say.c.

References ast_say_digit_str_full().

Referenced by ast_say_digits(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_number_full_cz(), 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_he(), ast_say_number_full_it(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), and ast_say_number_full_tw().

00268 {
00269    char fn2[256];
00270 
00271    snprintf(fn2, sizeof(fn2), "%d", num);
00272    return ast_say_digit_str_full(chan, fn2, ints, lang, audiofd, ctrlfd);
00273 }

int ast_say_enumeration ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options 
)

ast_say_enumeration: call language-specific functions without file descriptors

Definition at line 2295 of file say.c.

References ast_say_enumeration_full().

Referenced by ast_say_date_da(), ast_say_date_de(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), and ast_say_date_with_format_en().

02296 {
02297    return(ast_say_enumeration_full(chan, num, ints, language, options, -1, -1));
02298 }

int ast_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

Definition at line 2280 of file say.c.

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

Referenced by ast_say_enumeration().

02281 {
02282    if (!strcasecmp(language,"en") ) {  /* English syntax */
02283       return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd));
02284    } else if (!strcasecmp(language, "da") ) {   /* Danish syntax */
02285       return(ast_say_enumeration_full_da(chan, num, ints, language, options, audiofd, ctrlfd));
02286    } else if (!strcasecmp(language, "de") ) {   /* German syntax */
02287       return(ast_say_enumeration_full_de(chan, num, ints, language, options, audiofd, ctrlfd));
02288    } 
02289    
02290    /* Default to english */
02291    return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd));
02292 }

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 2400 of file say.c.

References ast_log(), ast_say_digits_full(), ast_say_number_full_de(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, and t.

Referenced by ast_say_enumeration_full().

02401 {
02402    /* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */
02403    int res = 0, t = 0;
02404    char fn[256] = "", fna[256] = "";
02405    char *gender;
02406 
02407    if (options && !strncasecmp(options, "f",1)) {
02408       gender = "F";
02409    } else if (options && !strncasecmp(options, "n",1)) {
02410       gender = "N";
02411    } else {
02412       gender = "";
02413    }
02414 
02415    if (!num) 
02416       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
02417 
02418    while(!res && num) {
02419       if (num < 0) {
02420          snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
02421          if ( num > INT_MIN ) {
02422             num = -num;
02423          } else {
02424             num = 0;
02425          }  
02426       } else if (num < 100 && t) {
02427          snprintf(fn, sizeof(fn), "digits/and");
02428          t = 0;
02429       } else if (num < 20) {
02430          snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
02431          num = 0;
02432       } else if (num < 100) {
02433          int ones = num % 10;
02434          if (ones) {
02435             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
02436             num -= ones;
02437          } else {
02438             snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
02439             num = 0;
02440          }
02441       } else if (num == 100 && t == 0) {
02442          snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender);
02443          num = 0;
02444       } else if (num < 1000) {
02445          int hundreds = num / 100;
02446          num = num % 100;
02447          if (hundreds == 1) {
02448             snprintf(fn, sizeof(fn), "digits/1N");
02449          } else {
02450             snprintf(fn, sizeof(fn), "digits/%d", hundreds);
02451          }
02452          if (num) {              
02453             snprintf(fna, sizeof(fna), "digits/hundred");
02454          } else {
02455             snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
02456          }
02457          t = 1;
02458       } else   if (num < 1000000) {
02459          int thousands = num / 1000;
02460          num = num % 1000;
02461          if (thousands == 1) {
02462             if (num) {              
02463                snprintf(fn, sizeof(fn), "digits/1N");
02464                snprintf(fna, sizeof(fna), "digits/thousand");
02465             } else {
02466                if (t) {
02467                   snprintf(fn, sizeof(fn), "digits/1N");
02468                   snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender);
02469                } else {
02470                   snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
02471                }
02472             }
02473          } else {
02474             res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
02475             if (res) {
02476                return res;
02477             }
02478             if (num) {              
02479                snprintf(fn, sizeof(fn), "digits/thousand");
02480             } else {
02481                snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
02482             }
02483          }
02484          t = 1;
02485       } else if (num < 1000000000) {
02486          int millions = num / 1000000;
02487          num = num % 1000000;
02488          if (millions == 1) {
02489             if (num) {              
02490                snprintf(fn, sizeof(fn), "digits/1F");
02491                snprintf(fna, sizeof(fna), "digits/million");
02492             } else {
02493                snprintf(fn, sizeof(fn), "digits/1N");
02494                snprintf(fna, sizeof(fna), "digits/h-million%s", gender);
02495             }
02496          } else {
02497             res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
02498             if (res) {
02499                return res;
02500             }
02501             if (num) {              
02502                snprintf(fn, sizeof(fn), "digits/millions");
02503             } else {
02504                snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
02505             }
02506          }
02507          t = 1;
02508       } else if (num < INT_MAX) {
02509          int billions = num / 1000000000;
02510          num = num % 1000000000;
02511          if (billions == 1) {
02512             if (num) {              
02513                snprintf(fn, sizeof(fn), "digits/1F");
02514                snprintf(fna, sizeof(fna), "digits/milliard");
02515             } else {
02516                snprintf(fn, sizeof(fn), "digits/1N");
02517                snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender);
02518             }
02519          } else {
02520             res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
02521             if (res)
02522                return res;
02523             if (num) {              
02524                snprintf(fn, sizeof(fna), "digits/milliards");
02525             } else {
02526                snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender);
02527             }
02528          }
02529          t = 1;
02530       } else if (num == INT_MAX) {
02531          snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
02532          num = 0;
02533       } else {
02534          ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
02535          res = -1;
02536       }
02537 
02538       if (!res) {
02539          if (!ast_streamfile(chan, fn, language)) {
02540             if ((audiofd > -1) && (ctrlfd > -1)) 
02541                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02542             else  
02543                res = ast_waitstream(chan, ints);
02544          }
02545          ast_stopstream(chan);
02546          if (!res) {
02547             if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
02548                if ((audiofd > -1) && (ctrlfd > -1)) {
02549                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02550                } else {
02551                   res = ast_waitstream(chan, ints);
02552                }
02553             }
02554             ast_stopstream(chan);
02555             strcpy(fna, "");
02556          }
02557       }
02558    }
02559    return res;
02560 }

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 2563 of file say.c.

References ast_log(), ast_say_digits_full(), ast_say_number_full_de(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, and t.

Referenced by ast_say_enumeration_full().

02564 {
02565    /* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */
02566    int res = 0, t = 0;
02567    char fn[256] = "", fna[256] = "";
02568    char *gender;
02569 
02570    if (options && !strncasecmp(options, "f",1)) {
02571       gender = "F";
02572    } else if (options && !strncasecmp(options, "n",1)) {
02573       gender = "N";
02574    } else {
02575       gender = "";
02576    }
02577 
02578    if (!num) 
02579       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
02580 
02581    while(!res && num) {
02582       if (num < 0) {
02583          snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
02584          if ( num > INT_MIN ) {
02585             num = -num;
02586          } else {
02587             num = 0;
02588          }  
02589       } else if (num < 100 && t) {
02590          snprintf(fn, sizeof(fn), "digits/and");
02591          t = 0;
02592       } else if (num < 20) {
02593          snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
02594          num = 0;
02595       } else if (num < 100) {
02596          int ones = num % 10;
02597          if (ones) {
02598             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
02599             num -= ones;
02600          } else {
02601             snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender);
02602             num = 0;
02603          }
02604       } else if (num == 100 && t == 0) {
02605          snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender);
02606          num = 0;
02607       } else if (num < 1000) {
02608          int hundreds = num / 100;
02609          num = num % 100;
02610          if (hundreds == 1) {
02611             snprintf(fn, sizeof(fn), "digits/1N");
02612          } else {
02613             snprintf(fn, sizeof(fn), "digits/%d", hundreds);
02614          }
02615          if (num) {              
02616             snprintf(fna, sizeof(fna), "digits/hundred");
02617          } else {
02618             snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender);
02619          }
02620          t = 1;
02621       } else   if (num < 1000000) {
02622          int thousands = num / 1000;
02623          num = num % 1000;
02624          if (thousands == 1) {
02625             if (num) {              
02626                snprintf(fn, sizeof(fn), "digits/1N");
02627                snprintf(fna, sizeof(fna), "digits/thousand");
02628             } else {
02629                if (t) {
02630                   snprintf(fn, sizeof(fn), "digits/1N");
02631                   snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender);
02632                } else {
02633                   snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
02634                }
02635             }
02636          } else {
02637             res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
02638             if (res) {
02639                return res;
02640             }
02641             if (num) {              
02642                snprintf(fn, sizeof(fn), "digits/thousand");
02643             } else {
02644                snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender);
02645             }
02646          }
02647          t = 1;
02648       } else if (num < 1000000000) {
02649          int millions = num / 1000000;
02650          num = num % 1000000;
02651          if (millions == 1) {
02652             if (num) {              
02653                snprintf(fn, sizeof(fn), "digits/1F");
02654                snprintf(fna, sizeof(fna), "digits/million");
02655             } else {
02656                snprintf(fn, sizeof(fn), "digits/1N");
02657                snprintf(fna, sizeof(fna), "digits/h-million%s", gender);
02658             }
02659          } else {
02660             res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
02661             if (res) {
02662                return res;
02663             }
02664             if (num) {              
02665                snprintf(fn, sizeof(fn), "digits/millions");
02666             } else {
02667                snprintf(fn, sizeof(fn), "digits/h-million%s", gender);
02668             }
02669          }
02670          t = 1;
02671       } else if (num < INT_MAX) {
02672          int billions = num / 1000000000;
02673          num = num % 1000000000;
02674          if (billions == 1) {
02675             if (num) {              
02676                snprintf(fn, sizeof(fn), "digits/1F");
02677                snprintf(fna, sizeof(fna), "digits/milliard");
02678             } else {
02679                snprintf(fn, sizeof(fn), "digits/1N");
02680                snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender);
02681             }
02682          } else {
02683             res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
02684             if (res)
02685                return res;
02686             if (num) {              
02687                snprintf(fn, sizeof(fna), "digits/milliards");
02688             } else {
02689                snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender);
02690             }
02691          }
02692          t = 1;
02693       } else if (num == INT_MAX) {
02694          snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
02695          num = 0;
02696       } else {
02697          ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
02698          res = -1;
02699       }
02700 
02701       if (!res) {
02702          if (!ast_streamfile(chan, fn, language)) {
02703             if ((audiofd > -1) && (ctrlfd > -1)) 
02704                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02705             else  
02706                res = ast_waitstream(chan, ints);
02707          }
02708          ast_stopstream(chan);
02709          if (!res) {
02710             if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
02711                if ((audiofd > -1) && (ctrlfd > -1)) {
02712                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02713                } else {
02714                   res = ast_waitstream(chan, ints);
02715                }
02716             }
02717             ast_stopstream(chan);
02718             strcpy(fna, "");
02719          }
02720       }
02721    }
02722    return res;
02723 }

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

Definition at line 2302 of file say.c.

References ast_log(), ast_say_number_full_en(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, and t.

Referenced by ast_say_enumeration_full().

02303 {
02304    int res = 0, t = 0;
02305    char fn[256] = "";
02306    
02307    while(!res && num) {
02308       if (num < 0) {
02309          snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
02310          if ( num > INT_MIN ) {
02311             num = -num;
02312          } else {
02313             num = 0;
02314          }  
02315       } else if (num < 20) {
02316          snprintf(fn, sizeof(fn), "digits/h-%d", num);
02317          num = 0;
02318       } else if (num < 100) { 
02319          int tens = num / 10;
02320          num = num % 10;
02321          if (num == 0) {
02322             snprintf(fn, sizeof(fn), "digits/h-%d", (tens * 10));
02323          } else {
02324             snprintf(fn, sizeof(fn), "digits/%d", (tens * 10));
02325          }
02326       } else if (num < 1000) {
02327          int hundreds = num / 100;
02328          num = num % 100;
02329          if (hundreds > 1 || t == 1) {
02330             res = ast_say_number_full_en(chan, hundreds, ints, language, audiofd, ctrlfd);
02331          }        
02332          if (res)
02333             return res;
02334          if (num) {
02335             snprintf(fn, sizeof(fn), "digits/hundred");
02336          } else {
02337             snprintf(fn, sizeof(fn), "digits/h-hundred");
02338          }
02339       } else if (num < 1000000) {
02340          int thousands = num / 1000;
02341          num = num % 1000;
02342          if (thousands > 1 || t == 1) {
02343             res = ast_say_number_full_en(chan, thousands, ints, language, audiofd, ctrlfd);
02344          }
02345          if (res)
02346             return res;
02347          if (num) {              
02348             snprintf(fn, sizeof(fn), "digits/thousand");
02349          } else {
02350             snprintf(fn, sizeof(fn), "digits/h-thousand");
02351          }
02352          t = 1;
02353       } else if (num < 1000000000) {
02354          int millions = num / 1000000;
02355          num = num % 1000000;
02356          t = 1;
02357          res = ast_say_number_full_en(chan, millions, ints, language, audiofd, ctrlfd);
02358          if (res)
02359             return res;
02360          if (num) {              
02361             snprintf(fn, sizeof(fn), "digits/million");
02362          } else {
02363             snprintf(fn, sizeof(fn), "digits/h-million");
02364          }
02365       } else if (num < INT_MAX) {
02366          int billions = num / 1000000000;
02367          num = num % 1000000000;
02368          t = 1;
02369          res = ast_say_number_full_en(chan, billions, ints, language, audiofd, ctrlfd);
02370          if (res)
02371             return res;
02372          if (num) {              
02373             snprintf(fn, sizeof(fn), "digits/billion");
02374          } else {
02375             snprintf(fn, sizeof(fn), "digits/h-billion");
02376          }
02377       } else if (num == INT_MAX) {
02378          snprintf(fn, sizeof(fn), "digits/h-last");
02379          num = 0;
02380       } else {
02381          ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
02382          res = -1;
02383       }
02384 
02385       if (!res) {
02386          if (!ast_streamfile(chan, fn, language)) {
02387             if ((audiofd > -1) && (ctrlfd > -1)) {
02388                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02389             } else {
02390                res = ast_waitstream(chan, ints);
02391             }
02392          }
02393          ast_stopstream(chan);
02394       }
02395    }
02396    return res;
02397 }

int ast_say_number ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  language,
const char *  options 
)

ast_say_number: call language-specific functions without file descriptors

Definition at line 459 of file say.c.

References ast_say_number_full().

Referenced by ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_nl(), ast_say_date_pt(), 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_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pt(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_pt(), ast_say_datetime_pt(), ast_say_datetime_tw(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_nl(), ast_say_time_pt(), ast_say_time_pt_BR(), ast_say_time_tw(), bridge_playfile(), conf_exec(), conf_run(), count_exec(), dictate_exec(), get_folder(), gr_say_number_female(), pbx_builtin_saynumber(), play_message(), play_message_duration(), rpt_tele_thread(), say_and_wait(), say_position(), saynum(), try_calling(), vm_intro_gr(), vm_intro_pt(), and vm_intro_pt_BR().

00460 {
00461    return(ast_say_number_full(chan, num, ints, language, options, -1, -1));
00462 }

int ast_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

Definition at line 416 of file say.c.

References ast_say_number_full_cz(), 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_it(), 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(), and ast_say_number_full_tw().

Referenced by ast_say_number(), and handle_saynumber().

00417 {
00418    if (!strcasecmp(language,"en") ) {  /* English syntax */
00419       return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd));
00420    } else if (!strcasecmp(language, "cz") ) {   /* Czech syntax */
00421       return(ast_say_number_full_cz(chan, num, ints, language, options, audiofd, ctrlfd));
00422    } else if (!strcasecmp(language, "da") ) {   /* Danish syntax */
00423       return(ast_say_number_full_da(chan, num, ints, language, options, audiofd, ctrlfd));
00424    } else if (!strcasecmp(language, "de") ) {   /* German syntax */
00425       return(ast_say_number_full_de(chan, num, ints, language, options, audiofd, ctrlfd));
00426    } else if (!strcasecmp(language, "en_GB") ) {   /* British syntax */
00427       return(ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd));
00428    } else if (!strcasecmp(language, "no") ) {   /* Norwegian syntax */
00429       return(ast_say_number_full_no(chan, num, ints, language, options, audiofd, ctrlfd));
00430    } else if (!strcasecmp(language, "es") || !strcasecmp(language, "mx")) {   /* Spanish syntax */
00431       return(ast_say_number_full_es(chan, num, ints, language, options, audiofd, ctrlfd));
00432    } else if (!strcasecmp(language, "fr") ) {   /* French syntax */
00433       return(ast_say_number_full_fr(chan, num, ints, language, options, audiofd, ctrlfd));
00434    } else if (!strcasecmp(language, "he") ) {   /* Hebrew syntax */
00435       return(ast_say_number_full_he(chan, num, ints, language, options, audiofd, ctrlfd));
00436    } else if (!strcasecmp(language, "it") ) {   /* Italian syntax */
00437       return(ast_say_number_full_it(chan, num, ints, language, audiofd, ctrlfd));
00438    } else if (!strcasecmp(language, "nl") ) {   /* Dutch syntax */
00439       return(ast_say_number_full_nl(chan, num, ints, language, audiofd, ctrlfd));
00440    } else if (!strcasecmp(language, "pl") ) {   /* Polish syntax */
00441       return(ast_say_number_full_pl(chan, num, ints, language, options, audiofd, ctrlfd));
00442    } else if (!strcasecmp(language, "pt") || !strcasecmp(language, "pt_BR")) {   /* Portuguese syntax */
00443       return(ast_say_number_full_pt(chan, num, ints, language, options, audiofd, ctrlfd));
00444    } else if (!strcasecmp(language, "se") ) {   /* Swedish syntax */
00445       return(ast_say_number_full_se(chan, num, ints, language, options, audiofd, ctrlfd));
00446    } else if (!strcasecmp(language, "tw")) { /* Taiwanese syntax */
00447       return(ast_say_number_full_tw(chan, num, ints, language, audiofd, ctrlfd));
00448    } else if (!strcasecmp(language, "gr") ) {   /* Greek syntax */
00449       return(ast_say_number_full_gr(chan, num, ints, language, audiofd, ctrlfd));
00450    } else if (!strcasecmp(language, "ru") ) {   /* Russian syntax */
00451       return(ast_say_number_full_ru(chan, num, ints, language, options, audiofd, ctrlfd));
00452    }
00453 
00454    /* Default to english */
00455    return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd));
00456 }

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

ast_say_number_full_cz: Czech syntax

Definition at line 559 of file say.c.

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

Referenced by ast_say_number_full().

00560 {
00561    int res = 0;
00562    int playh = 0;
00563    char fn[256] = "";
00564    
00565    int hundered = 0;
00566    int left = 0;
00567    int length = 0;
00568    
00569    /* options - w = woman, m = man, n = neutral. Defaultl is woman */
00570    if (!options)
00571       options = "w";
00572    
00573    if (!num) 
00574       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
00575    
00576    while(!res && (num || playh)) {
00577       if (num < 0) {
00578          snprintf(fn, sizeof(fn), "digits/minus");
00579          if ( num > INT_MIN ) {
00580             num = -num;
00581          } else {
00582             num = 0;
00583          }  
00584       } else if (num < 3 ) {
00585          snprintf(fn, sizeof(fn), "digits/%d%c",num,options[0]);
00586          playh = 0;
00587          num = 0;
00588       } else if (num < 20) {
00589          snprintf(fn, sizeof(fn), "digits/%d",num);
00590          playh = 0;
00591          num = 0;
00592       } else if (num < 100) {
00593          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
00594          num -= ((num / 10) * 10);
00595       } else if (num < 1000) {
00596          hundered = num / 100;
00597          if ( hundered == 1 ) {
00598             snprintf(fn, sizeof(fn), "digits/1sto");
00599          } else if ( hundered == 2 ) {
00600             snprintf(fn, sizeof(fn), "digits/2ste");
00601          } else {
00602                res = ast_say_number_full_cz(chan,hundered,ints,language,options,audiofd,ctrlfd);
00603             if (res)
00604                return res;
00605             if (hundered == 3 || hundered == 4) {  
00606                snprintf(fn, sizeof(fn), "digits/sta");
00607             } else if ( hundered > 4 ) {
00608                snprintf(fn, sizeof(fn), "digits/set");
00609             }
00610          }
00611          num -= (hundered * 100);
00612       } else { /* num > 1000 */
00613          length = (int)log10(num)+1;  
00614          while ( (length % 3 ) != 1 ) {
00615             length--;      
00616          }
00617          left = num / (exp10_int(length-1));
00618          if ( left == 2 ) {  
00619             switch (length-1) {
00620                case 9: options = "w";  /* 1,000,000,000 gender female */
00621                   break;
00622                default : options = "m"; /* others are male */
00623             }
00624          }
00625          if ( left > 1 )   { /* we dont say "one thousand" but only thousand */
00626             res = ast_say_number_full_cz(chan,left,ints,language,options,audiofd,ctrlfd);
00627             if (res) 
00628                return res;
00629          }
00630          if ( left >= 5 ) { /* >= 5 have the same declesion */
00631             snprintf(fn, sizeof(fn), "digits/5_E%d",length-1); 
00632          } else if ( left >= 2 && left <= 4 ) {
00633             snprintf(fn, sizeof(fn), "digits/2-4_E%d",length-1);
00634          } else { /* left == 1 */
00635             snprintf(fn, sizeof(fn), "digits/1_E%d",length-1);
00636          }
00637          num -= left * (exp10_int(length-1));
00638       }
00639       if (!res) {
00640          if(!ast_streamfile(chan, fn, language)) {
00641             if ((audiofd > -1) && (ctrlfd > -1)) {
00642                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00643             } else {
00644                res = ast_waitstream(chan, ints);
00645             }
00646          }
00647          ast_stopstream(chan);
00648       }
00649    }
00650    return res; 
00651 }

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

Definition at line 657 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_number_full().

00658 {
00659    int res = 0;
00660    int playh = 0;
00661    int playa = 0;
00662    int cn = 1;    /* +1 = commune; -1 = neuter */
00663    char fn[256] = "";
00664    if (!num) 
00665       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
00666 
00667    if (options && !strncasecmp(options, "n",1)) cn = -1;
00668 
00669    while(!res && (num || playh || playa )) {
00670       /* The grammar for Danish numbers is the same as for English except
00671       * for the following:
00672       * - 1 exists in both commune ("en", file "1N") and neuter ("et", file "1")
00673       * - numbers 20 through 99 are said in reverse order, i.e. 21 is
00674       *   "one-and twenty" and 68 is "eight-and sixty".
00675       * - "million" is different in singular and plural form
00676       * - numbers > 1000 with zero as the third digit from last have an
00677       *   "and" before the last two digits, i.e. 2034 is "two thousand and
00678       *   four-and thirty" and 1000012 is "one million and twelve".
00679       */
00680       if (num < 0) {
00681          snprintf(fn, sizeof(fn), "digits/minus");
00682          if ( num > INT_MIN ) {
00683             num = -num;
00684          } else {
00685             num = 0;
00686          }  
00687       } else if (playh) {
00688          snprintf(fn, sizeof(fn), "digits/hundred");
00689          playh = 0;
00690       } else if (playa) {
00691          snprintf(fn, sizeof(fn), "digits/and");
00692          playa = 0;
00693       } else if (num == 1 && cn == -1) {
00694          snprintf(fn, sizeof(fn), "digits/1N");
00695          num = 0;
00696       } else if (num < 20) {
00697          snprintf(fn, sizeof(fn), "digits/%d", num);
00698          num = 0;
00699       } else if (num < 100) {
00700          int ones = num % 10;
00701          if (ones) {
00702             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
00703             num -= ones;
00704          } else {
00705             snprintf(fn, sizeof(fn), "digits/%d", num);
00706             num = 0;
00707          }
00708       } else {
00709          if (num < 1000) {
00710             int hundreds = num / 100;
00711             if (hundreds == 1)
00712                snprintf(fn, sizeof(fn), "digits/1N");
00713             else
00714                snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
00715 
00716             playh++;
00717             num -= 100 * hundreds;
00718             if (num)
00719                playa++;
00720 
00721          } else {
00722             if (num < 1000000) {
00723                res = ast_say_number_full_da(chan, num / 1000, ints, language, "n", audiofd, ctrlfd);
00724                if (res)
00725                   return res;
00726                num = num % 1000;
00727                snprintf(fn, sizeof(fn), "digits/thousand");
00728             } else {
00729                if (num < 1000000000) {
00730                   int millions = num / 1000000;
00731                   res = ast_say_number_full_da(chan, millions, ints, language, "c", audiofd, ctrlfd);
00732                   if (res)
00733                      return res;
00734                   if (millions == 1)
00735                      snprintf(fn, sizeof(fn), "digits/million");
00736                   else
00737                      snprintf(fn, sizeof(fn), "digits/millions");
00738                   num = num % 1000000;
00739                } else {
00740                   ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
00741                   res = -1;
00742                }
00743             }
00744             if (num && num < 100)
00745                playa++;
00746          }
00747       }
00748       if (!res) {
00749          if(!ast_streamfile(chan, fn, language)) {
00750             if ((audiofd > -1) && (ctrlfd > -1)) 
00751                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00752             else  
00753                res = ast_waitstream(chan, ints);
00754          }
00755          ast_stopstream(chan);
00756       }
00757    }
00758    return res;
00759 }

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

Definition at line 770 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, mf, and t.

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

00771 {
00772    int res = 0, t = 0;
00773    int mf = 1;                            /* +1 = male and neuter; -1 = female */
00774    char fn[256] = "";
00775    char fna[256] = "";
00776    if (!num) 
00777       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
00778 
00779    if (options && (!strncasecmp(options, "f",1)))
00780       mf = -1;
00781 
00782    while(!res && num) {
00783       /* The grammar for German numbers is the same as for English except
00784       * for the following:
00785       * - numbers 20 through 99 are said in reverse order, i.e. 21 is
00786       *   "one-and twenty" and 68 is "eight-and sixty".
00787       * - "one" varies according to gender
00788       * - 100 is 'hundert', however all other instances are 'ein hundert'
00789       * - 1000 is 'tausend', however all other instances are 'ein tausend'
00790       * - 1000000 is always 'eine million'
00791       * - "million" is different in singular and plural form
00792       */
00793       if (num < 0) {
00794          snprintf(fn, sizeof(fn), "digits/minus");
00795          if ( num > INT_MIN ) {
00796             num = -num;
00797          } else {
00798             num = 0;
00799          }  
00800       } else if (num < 100 && t) {
00801          snprintf(fn, sizeof(fn), "digits/and");
00802          t = 0;
00803       } else if (num == 1 && mf == -1) {
00804          snprintf(fn, sizeof(fn), "digits/%dF", num);
00805          num = 0;
00806       } else if (num < 20) {
00807          snprintf(fn, sizeof(fn), "digits/%d", num);
00808          num = 0;
00809       } else if (num < 100) {
00810          int ones = num % 10;
00811          if (ones) {
00812             snprintf(fn, sizeof(fn), "digits/%d-and", ones);
00813             num -= ones;
00814          } else {
00815             snprintf(fn, sizeof(fn), "digits/%d", num);
00816             num = 0;
00817          }
00818       } else if (num == 100 && t == 0) {
00819          snprintf(fn, sizeof(fn), "digits/hundred");
00820          num = 0;
00821       } else if (num < 1000) {
00822          int hundreds = num / 100;
00823          num = num % 100;
00824          if (hundreds == 1) {
00825             snprintf(fn, sizeof(fn), "digits/1N");
00826          } else {
00827             snprintf(fn, sizeof(fn), "digits/%d", hundreds);
00828          }
00829          snprintf(fna, sizeof(fna), "digits/hundred");
00830          t = 1;
00831       } else if (num == 1000 && t == 0) {
00832          snprintf(fn, sizeof(fn), "digits/thousand");
00833          num = 0;
00834       } else   if (num < 1000000) {
00835          int thousands = num / 1000;
00836          num = num % 1000;
00837          t = 1;
00838          if (thousands == 1) {
00839             snprintf(fn, sizeof(fn), "digits/1N");
00840             snprintf(fna, sizeof(fna), "digits/thousand");
00841          } else {
00842             res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
00843             if (res)
00844                return res;
00845             snprintf(fn, sizeof(fn), "digits/thousand");
00846          }
00847       } else if (num < 1000000000) {
00848          int millions = num / 1000000;
00849          num = num % 1000000;
00850          t = 1;
00851          if (millions == 1) {
00852             snprintf(fn, sizeof(fn), "digits/1F");
00853             snprintf(fna, sizeof(fna), "digits/million");
00854          } else {
00855             res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
00856             if (res)
00857                return res;
00858             snprintf(fn, sizeof(fn), "digits/millions");
00859          }
00860       } else if (num <= INT_MAX) {
00861          int billions = num / 1000000000;
00862          num = num % 1000000000;
00863          t = 1;
00864          if (billions == 1) {
00865             snprintf(fn, sizeof(fn), "digits/1F");
00866             snprintf(fna, sizeof(fna), "digits/milliard");
00867          } else {
00868             res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd);
00869             if (res) {
00870                return res;
00871             }
00872             snprintf(fn, sizeof(fn), "digits/milliards");
00873          }
00874       } else {
00875          ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
00876          res = -1;
00877       }
00878       if (!res) {
00879          if(!ast_streamfile(chan, fn, language)) {
00880             if ((audiofd > -1) && (ctrlfd > -1)) 
00881                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00882             else  
00883                res = ast_waitstream(chan, ints);
00884          }
00885          ast_stopstream(chan);
00886          if (!res) {
00887             if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) {
00888                if ((audiofd > -1) && (ctrlfd > -1))
00889                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00890                else
00891                   res = ast_waitstream(chan, ints);
00892             }
00893             ast_stopstream(chan);
00894             strcpy(fna, "");
00895          }
00896       }
00897    }
00898    return res;
00899 }

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

Definition at line 466 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_enumeration_full_en(), ast_say_number_full(), and ast_say_number_full_nl().

00467 {
00468    int res = 0;
00469    int playh = 0;
00470    char fn[256] = "";
00471    if (!num) 
00472       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
00473 
00474    while(!res && (num || playh)) {
00475       if (num < 0) {
00476          snprintf(fn, sizeof(fn), "digits/minus");
00477          if ( num > INT_MIN ) {
00478             num = -num;
00479          } else {
00480             num = 0;
00481          }  
00482       } else if (playh) {
00483          snprintf(fn, sizeof(fn), "digits/hundred");
00484          playh = 0;
00485       } else   if (num < 20) {
00486          snprintf(fn, sizeof(fn), "digits/%d", num);
00487          num = 0;
00488       } else   if (num < 100) {
00489          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
00490          num -= ((num / 10) * 10);
00491       } else {
00492          if (num < 1000){
00493             snprintf(fn, sizeof(fn), "digits/%d", (num/100));
00494             playh++;
00495             num -= ((num / 100) * 100);
00496          } else {
00497             if (num < 1000000) { /* 1,000,000 */
00498                res = ast_say_number_full_en(chan, num / 1000, ints, language, audiofd, ctrlfd);
00499                if (res)
00500                   return res;
00501                num = num % 1000;
00502                snprintf(fn, sizeof(fn), "digits/thousand");
00503             } else {
00504                if (num < 1000000000) { /* 1,000,000,000 */
00505                   res = ast_say_number_full_en(chan, num / 1000000, ints, language, audiofd, ctrlfd);
00506                   if (res)
00507                      return res;
00508                   num = num % 1000000;
00509                   snprintf(fn, sizeof(fn), "digits/million");
00510                } else {
00511                   ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
00512                   res = -1;
00513                }
00514             }
00515          }
00516       }
00517       if (!res) {
00518          if(!ast_streamfile(chan, fn, language)) {
00519             if ((audiofd  > -1) && (ctrlfd > -1))
00520                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00521             else
00522                res = ast_waitstream(chan, ints);
00523          }
00524          ast_stopstream(chan);
00525       }
00526    }
00527    return res;
00528 }

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 and Norwegian syntax

Definition at line 905 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_number_full().

00906 {
00907    int res = 0;
00908    int playh = 0;
00909    int playa = 0;
00910    char fn[256] = "";
00911    if (!num) 
00912       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
00913 
00914    while(!res && (num || playh || playa )) {
00915       if (num < 0) {
00916          snprintf(fn, sizeof(fn), "digits/minus");
00917          if ( num > INT_MIN ) {
00918             num = -num;
00919          } else {
00920             num = 0;
00921          }  
00922       } else if (playh) {
00923          snprintf(fn, sizeof(fn), "digits/hundred");
00924          playh = 0;
00925       } else if (playa) {
00926          snprintf(fn, sizeof(fn), "digits/and");
00927          playa = 0;
00928       } else if (num < 20) {
00929          snprintf(fn, sizeof(fn), "digits/%d", num);
00930          num = 0;
00931       } else if (num < 100) {
00932          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
00933          num -= ((num / 10) * 10);
00934       } else if (num < 1000) {
00935          int hundreds = num / 100;
00936          snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
00937 
00938          playh++;
00939          num -= 100 * hundreds;
00940          if (num)
00941             playa++;
00942       } else   if (num < 1000000) {
00943          res = ast_say_number_full_en_GB(chan, num / 1000, ints, language, audiofd, ctrlfd);
00944          if (res)
00945             return res;
00946          snprintf(fn, sizeof(fn), "digits/thousand");
00947          num = num % 1000;
00948          if (num && num < 100)
00949             playa++;
00950       } else   if (num < 1000000000) {
00951             int millions = num / 1000000;
00952             res = ast_say_number_full_en_GB(chan, millions, ints, language, audiofd, ctrlfd);
00953             if (res)
00954                return res;
00955             snprintf(fn, sizeof(fn), "digits/million");
00956             num = num % 1000000;
00957             if (num && num < 100)
00958                playa++;
00959       } else {
00960             ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
00961             res = -1;
00962       }
00963       
00964       if (!res) {
00965          if(!ast_streamfile(chan, fn, language)) {
00966             if ((audiofd > -1) && (ctrlfd > -1)) 
00967                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
00968             else  
00969                res = ast_waitstream(chan, ints);
00970          }
00971          ast_stopstream(chan);
00972       }
00973    }
00974    return res;
00975 }

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

Definition at line 983 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, and mf.

Referenced by ast_say_number_full().

00984 {
00985    int res = 0;
00986    int playa = 0;
00987    int mf = 0;                            /* +1 = male; -1 = female */
00988    char fn[256] = "";
00989    if (!num) 
00990       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
00991 
00992    if (options) {
00993       if (!strncasecmp(options, "f",1))
00994          mf = -1;
00995       else if (!strncasecmp(options, "m", 1))
00996          mf = 1;
00997    }
00998 
00999    while (!res && num) {
01000       if (num < 0) {
01001          snprintf(fn, sizeof(fn), "digits/minus");
01002          if ( num > INT_MIN ) {
01003             num = -num;
01004          } else {
01005             num = 0;
01006          }  
01007       } else if (playa) {
01008          snprintf(fn, sizeof(fn), "digits/and");
01009          playa = 0;
01010       } else if (num == 1) {
01011          if (mf < 0)
01012             snprintf(fn, sizeof(fn), "digits/%dF", num);
01013          else if (mf > 0)
01014             snprintf(fn, sizeof(fn), "digits/%dM", num);
01015          else 
01016             snprintf(fn, sizeof(fn), "digits/%d", num);
01017          num = 0;
01018       } else if (num < 31) {
01019          snprintf(fn, sizeof(fn), "digits/%d", num);
01020          num = 0;
01021       } else if (num < 100) {
01022          snprintf(fn, sizeof(fn), "digits/%d", (num/10)*10);
01023          num -= ((num/10)*10);
01024          if (num)
01025             playa++;
01026       } else if (num == 100) {
01027          snprintf(fn, sizeof(fn), "digits/100");
01028          num = 0;
01029       } else if (num < 200) {
01030          snprintf(fn, sizeof(fn), "digits/100-and");
01031          num -= 100;
01032       } else {
01033          if (num < 1000) {
01034             snprintf(fn, sizeof(fn), "digits/%d", (num/100)*100);
01035             num -= ((num/100)*100);
01036          } else if (num < 2000) {
01037             num = num % 1000;
01038             snprintf(fn, sizeof(fn), "digits/thousand");
01039          } else {
01040             if (num < 1000000) {
01041                res = ast_say_number_full_es(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
01042                if (res)
01043                   return res;
01044                num = num % 1000;
01045                snprintf(fn, sizeof(fn), "digits/thousand");
01046             } else {
01047                if (num < 2147483640) {
01048                   if ((num/1000000) == 1) {
01049                      res = ast_say_number_full_es(chan, num / 1000000, ints, language, "M", audiofd, ctrlfd);
01050                      if (res)
01051                         return res;
01052                      snprintf(fn, sizeof(fn), "digits/million");
01053                   } else {
01054                      res = ast_say_number_full_es(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);
01055                      if (res)
01056                         return res;
01057                      snprintf(fn, sizeof(fn), "digits/millions");
01058                   }
01059                   num = num % 1000000;
01060                } else {
01061                   ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
01062                   res = -1;
01063                }
01064             }
01065          }
01066       }
01067 
01068       if (!res) {
01069          if(!ast_streamfile(chan, fn, language)) {
01070             if ((audiofd > -1) && (ctrlfd > -1))
01071                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01072             else
01073                res = ast_waitstream(chan, ints);
01074          }
01075          ast_stopstream(chan);
01076 
01077       }
01078          
01079    }
01080    return res;
01081 }

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

Definition at line 1087 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, and mf.

Referenced by ast_say_number_full().

01088 {
01089    int res = 0;
01090    int playh = 0;
01091    int playa = 0;
01092    int mf = 1;                            /* +1 = male; -1 = female */
01093    char fn[256] = "";
01094    if (!num) 
01095       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
01096    
01097    if (options && !strncasecmp(options, "f",1))
01098       mf = -1;
01099 
01100    while(!res && (num || playh || playa)) {
01101       if (num < 0) {
01102          snprintf(fn, sizeof(fn), "digits/minus");
01103          if ( num > INT_MIN ) {
01104             num = -num;
01105          } else {
01106             num = 0;
01107          }  
01108       } else if (playh) {
01109          snprintf(fn, sizeof(fn), "digits/hundred");
01110          playh = 0;
01111       } else if (playa) {
01112          snprintf(fn, sizeof(fn), "digits/et");
01113          playa = 0;
01114       } else if (num == 1) {
01115          if (mf < 0)
01116             snprintf(fn, sizeof(fn), "digits/%dF", num);
01117          else
01118             snprintf(fn, sizeof(fn), "digits/%d", num);
01119          num = 0;
01120       } else if (num < 21) {
01121          snprintf(fn, sizeof(fn), "digits/%d", num);
01122          num = 0;
01123       } else if (num < 70) {
01124          snprintf(fn, sizeof(fn), "digits/%d", (num/10)*10);
01125          if ((num % 10) == 1) playa++;
01126          num = num % 10;
01127       } else if (num < 80) {
01128          snprintf(fn, sizeof(fn), "digits/60");
01129          if ((num % 10) == 1) playa++;
01130          num = num - 60;
01131       } else if (num < 100) {
01132          snprintf(fn, sizeof(fn), "digits/80");
01133          num = num - 80;
01134       } else if (num < 200) {
01135          snprintf(fn, sizeof(fn), "digits/hundred");
01136          num = num - 100;
01137       } else if (num < 1000) {
01138          snprintf(fn, sizeof(fn), "digits/%d", (num/100));
01139          playh++;
01140          num = num % 100;
01141       } else if (num < 2000) {
01142          snprintf(fn, sizeof(fn), "digits/thousand");
01143          num = num - 1000;
01144       } else if (num < 1000000) {
01145          res = ast_say_number_full_fr(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
01146          if (res)
01147             return res;
01148          snprintf(fn, sizeof(fn), "digits/thousand");
01149          num = num % 1000;
01150       } else   if (num < 1000000000) {
01151          res = ast_say_number_full_fr(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);
01152          if (res)
01153             return res;
01154          snprintf(fn, sizeof(fn), "digits/million");
01155          num = num % 1000000;
01156       } else {
01157          ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
01158          res = -1;
01159       }
01160       if (!res) {
01161          if(!ast_streamfile(chan, fn, language)) {
01162             if ((audiofd > -1) && (ctrlfd > -1))
01163                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01164             else
01165                res = ast_waitstream(chan, ints);
01166          }
01167          ast_stopstream(chan);
01168       }
01169    }
01170    return res;
01171 }

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

Definition at line 5887 of file say.c.

References ast_log(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), ast_channel::language, and LOG_DEBUG.

Referenced by ast_say_date_with_format_gr(), and ast_say_number_full().

05888 {
05889    int res = 0;
05890    char fn[256] = "";
05891    int i=0;
05892 
05893  
05894    if (!num) {
05895       snprintf(fn, sizeof(fn), "digits/0");
05896       res = ast_streamfile(chan, fn, chan->language);
05897       if (!res)
05898          return  ast_waitstream(chan, ints);
05899    }
05900 
05901    while(!res && num ) {
05902       i++;
05903       if (num < 13) {
05904          snprintf(fn, sizeof(fn), "digits/%d", num);
05905          num = 0;
05906       } else if (num <= 100) {
05907          /* 13 < num <= 100  */
05908          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
05909          num -= ((num / 10) * 10); 
05910       } else if (num < 200) {
05911          /* 100 < num < 200 */
05912          snprintf(fn, sizeof(fn), "digits/hundred-100");
05913          num -= ((num / 100) * 100);
05914       }else if (num < 1000) {
05915          /* 200 < num < 1000 */
05916          snprintf(fn, sizeof(fn), "digits/hundred-%d", (num/100)*100);
05917          num -= ((num / 100) * 100);
05918       }else if (num < 2000){
05919          snprintf(fn, sizeof(fn), "digits/xilia");
05920          num -= ((num / 1000) * 1000);
05921       }
05922       else {
05923          /* num >  1000 */ 
05924          if (num < 1000000) {
05925             res = ast_say_number_full_gr(chan, (num / 1000), ints, chan->language, audiofd, ctrlfd);
05926             if (res)
05927                return res;
05928             num = num % 1000;
05929             snprintf(fn, sizeof(fn), "digits/thousands");
05930          }  else {
05931             if (num < 1000000000) { /* 1,000,000,000 */
05932                res = ast_say_number_full_gr(chan, (num / 1000000), ints, chan->language ,audiofd, ctrlfd);
05933                if (res)
05934                   return res;
05935                num = num % 1000000;
05936                snprintf(fn, sizeof(fn), "digits/millions");
05937             } else {
05938                ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
05939                res = -1;
05940             }
05941          }
05942       } 
05943       if (!res) {
05944          if(!ast_streamfile(chan, fn, language)) {
05945             if ((audiofd > -1) && (ctrlfd > -1))
05946                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
05947             else
05948                res = ast_waitstream(chan, ints);
05949          }
05950          ast_stopstream(chan);
05951       }
05952    }
05953    return res;
05954 }

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 1219 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_verbose(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, mf, SAY_NUM_BUF_SIZE, and VERBOSE_PREFIX_3.

Referenced by ast_say_date_with_format_he(), and ast_say_number_full().

01222 {
01223    int res = 0;
01224    int state = 0; /* no need to save anything */
01225    int mf = 1;    /* +1 = Masculin; -1 = Feminin */
01226    char fn[SAY_NUM_BUF_SIZE] = "";
01227    ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: started. "
01228       "num: %d, options=\"%s\"\n",
01229       num, options
01230    );
01231    if (!num) 
01232       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
01233    
01234    if (options && !strncasecmp(options, "f",1))
01235       mf = -1;
01236 
01237    /* Do we have work to do? */
01238    while(!res && (num || (state>0) ))  {
01239       /* first type of work: play a second sound. In this loop
01240        * we can only play one sound file at a time. Thus playing 
01241        * a second one requires repeating the loop just for the 
01242        * second file. The variable 'state' remembers where we were.
01243        * state==0 is the normal mode and it means that we continue
01244        * to check if the number num has yet anything left.
01245        */
01246       ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, "
01247          "state=%d, options=\"%s\", mf=%d\n",
01248          num, state, options, mf
01249       );
01250       if (state==1) {
01251          snprintf(fn, sizeof(fn), "digits/hundred");
01252          state = 0;
01253       } else if (state==2) {
01254          snprintf(fn, sizeof(fn), "digits/ve");
01255          state = 0;
01256       } else if (state==3) {
01257          snprintf(fn, sizeof(fn), "digits/thousands");
01258          state=0;
01259       } else if (num <21) {
01260          if (mf < 0)
01261             snprintf(fn, sizeof(fn), "digits/%dF", num);
01262          else
01263             snprintf(fn, sizeof(fn), "digits/%d", num);
01264          num = 0;
01265       } else if (num < 100) {
01266          snprintf(fn, sizeof(fn), "digits/%d", (num/10)*10);
01267          num = num % 10;
01268          if (num>0) state=2;
01269       } else if (num < 200) {
01270          snprintf(fn, sizeof(fn), "digits/hundred");
01271          num = num - 100;
01272       } else if (num < 300) {
01273          snprintf(fn, sizeof(fn), "digits/hundred");
01274          num = num - 100;
01275       } else if (num < 1000) {
01276          snprintf(fn, sizeof(fn), "digits/%d", (num/100));
01277          state=1;
01278          num = num % 100;
01279       } else if (num < 2000) {
01280          snprintf(fn, sizeof(fn), "digits/thousand");
01281          num = num - 1000;
01282       } else if (num < 3000) {
01283          snprintf(fn, sizeof(fn), "digits/2thousand");
01284          num = num - 2000;
01285                         if (num>0) state=2;
01286       } else if (num < 20000) {
01287          snprintf(fn, sizeof(fn), "digits/%ds",(num/1000));
01288          num = num % 1000;
01289          state=3;
01290       } else if (num < 1000000) {
01291          res = ast_say_number_full_he(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
01292          if (res)
01293             return res;
01294          snprintf(fn, sizeof(fn), "digits/thousand");
01295          num = num % 1000;
01296       } else   if (num < 1000000000) {
01297          res = ast_say_number_full_he(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);
01298          if (res)
01299             return res;
01300          snprintf(fn, sizeof(fn), "digits/million");
01301          num = num % 1000000;
01302       } else {
01303          ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
01304          res = -1;
01305       }
01306       if (!res) {
01307          if(!ast_streamfile(chan, fn, language)) {
01308             if ((audiofd > -1) && (ctrlfd > -1))
01309                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01310             else
01311                res = ast_waitstream(chan, ints);
01312          }
01313          ast_stopstream(chan);
01314       }
01315    }
01316    return res;
01317 }

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 1320 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_number_full().

01321 {
01322    int res = 0;
01323    int playh = 0;
01324    int tempnum = 0;
01325    char fn[256] = "";
01326 
01327    if (!num)
01328       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
01329 
01330       /*
01331       Italian support
01332 
01333       Like english, numbers up to 20 are a single 'word', and others
01334       compound, but with exceptions.
01335       For example 21 is not twenty-one, but there is a single word in 'it'.
01336       Idem for 28 (ie when a the 2nd part of a compund number
01337       starts with a vowel)
01338 
01339       There are exceptions also for hundred, thousand and million.
01340       In english 100 = one hundred, 200 is two hundred.
01341       In italian 100 = cento , like to say hundred (without one),
01342       200 and more are like english.
01343       
01344       Same applies for thousand:
01345       1000 is one thousand in en, 2000 is two thousand.
01346       In it we have 1000 = mille , 2000 = 2 mila 
01347 
01348       For million(s) we use the plural, if more than one
01349       Also, one million is abbreviated in it, like on-million,
01350       or 'un milione', not 'uno milione'.
01351       So the right file is provided.
01352       */
01353 
01354       while(!res && (num || playh)) {
01355          if (num < 0) {
01356             snprintf(fn, sizeof(fn), "digits/minus");
01357             if ( num > INT_MIN ) {
01358                num = -num;
01359             } else {
01360                num = 0;
01361             }  
01362          } else if (playh) {
01363             snprintf(fn, sizeof(fn), "digits/hundred");
01364             playh = 0;
01365          } else if (num < 20) {
01366             snprintf(fn, sizeof(fn), "digits/%d", num);
01367             num = 0;
01368          } else if (num == 21) {
01369             snprintf(fn, sizeof(fn), "digits/%d", num);
01370             num = 0;
01371          } else if (num == 28) {
01372             snprintf(fn, sizeof(fn), "digits/%d", num);
01373             num = 0;
01374          } else if (num == 31) {
01375             snprintf(fn, sizeof(fn), "digits/%d", num);
01376             num = 0;
01377          } else if (num == 38) {
01378             snprintf(fn, sizeof(fn), "digits/%d", num);
01379             num = 0;
01380          } else if (num == 41) {
01381             snprintf(fn, sizeof(fn), "digits/%d", num);
01382             num = 0;
01383          } else if (num == 48) {
01384             snprintf(fn, sizeof(fn), "digits/%d", num);
01385             num = 0;
01386          } else if (num == 51) {
01387             snprintf(fn, sizeof(fn), "digits/%d", num);
01388             num = 0;
01389          } else if (num == 58) {
01390             snprintf(fn, sizeof(fn), "digits/%d", num);
01391             num = 0;
01392          } else if (num == 61) {
01393             snprintf(fn, sizeof(fn), "digits/%d", num);
01394             num = 0;
01395          } else if (num == 68) {
01396             snprintf(fn, sizeof(fn), "digits/%d", num);
01397             num = 0;
01398          } else if (num == 71) {
01399             snprintf(fn, sizeof(fn), "digits/%d", num);
01400             num = 0;
01401          } else if (num == 78) {
01402             snprintf(fn, sizeof(fn), "digits/%d", num);
01403             num = 0;
01404          } else if (num == 81) {
01405             snprintf(fn, sizeof(fn), "digits/%d", num);
01406             num = 0;
01407          } else if (num == 88) {
01408             snprintf(fn, sizeof(fn), "digits/%d", num);
01409             num = 0;
01410          } else if (num == 91) {
01411             snprintf(fn, sizeof(fn), "digits/%d", num);
01412             num = 0;
01413          } else if (num == 98) {
01414             snprintf(fn, sizeof(fn), "digits/%d", num);
01415             num = 0;
01416          } else if (num < 100) {
01417             snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
01418             num -= ((num / 10) * 10);
01419          } else {
01420             if (num < 1000) {
01421                if ((num / 100) > 1) {
01422                   snprintf(fn, sizeof(fn), "digits/%d", (num/100));
01423                   playh++;
01424                } else {
01425                   snprintf(fn, sizeof(fn), "digits/hundred");
01426                }
01427                num -= ((num / 100) * 100);
01428             } else {
01429                if (num < 1000000) { /* 1,000,000 */
01430                   if ((num/1000) > 1)
01431                      res = ast_say_number_full_it(chan, num / 1000, ints, language, audiofd, ctrlfd);
01432                   if (res)
01433                      return res;
01434                   tempnum = num;
01435                   num = num % 1000;
01436                   if ((tempnum / 1000) < 2)
01437                      snprintf(fn, sizeof(fn), "digits/thousand");
01438                   else /* for 1000 it says mille, for >1000 (eg 2000) says mila */
01439                      snprintf(fn, sizeof(fn), "digits/thousands");
01440                } else {
01441                   if (num < 1000000000) { /* 1,000,000,000 */
01442                      if ((num / 1000000) > 1)
01443                         res = ast_say_number_full_it(chan, num / 1000000, ints, language, audiofd, ctrlfd);
01444                      if (res)
01445                         return res;
01446                      tempnum = num;
01447                      num = num % 1000000;
01448                      if ((tempnum / 1000000) < 2)
01449                         snprintf(fn, sizeof(fn), "digits/million");
01450                      else
01451                         snprintf(fn, sizeof(fn), "digits/millions");
01452                   } else {
01453                      ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
01454                      res = -1;
01455                   }
01456                }
01457             }
01458          }
01459          if (!res) {
01460             if(!ast_streamfile(chan, fn, language)) {
01461                if ((audiofd > -1) && (ctrlfd > -1))
01462                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01463                else
01464                   res = ast_waitstream(chan, ints);
01465             }
01466             ast_stopstream(chan);
01467          }
01468       }
01469    return res;
01470 }

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

Definition at line 1475 of file say.c.

References ast_log(), ast_say_digits_full(), ast_say_number_full_en(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_number_full().

01476 {
01477    int res = 0;
01478    int playh = 0;
01479    int units = 0;
01480    char fn[256] = "";
01481    if (!num) 
01482       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
01483    while (!res && (num || playh )) {
01484       if (num < 0) {
01485          snprintf(fn, sizeof(fn), "digits/minus");
01486          if ( num > INT_MIN ) {
01487             num = -num;
01488          } else {
01489             num = 0;
01490          }  
01491       } else if (playh) {
01492          snprintf(fn, sizeof(fn), "digits/hundred");
01493          playh = 0;
01494       } else if (num < 20) {
01495          snprintf(fn, sizeof(fn), "digits/%d", num);
01496          num = 0;
01497       } else if (num < 100) {
01498          units = num % 10;
01499          if (units > 0) {
01500             res = ast_say_number_full_nl(chan, units, ints, language, audiofd, ctrlfd);
01501             if (res)
01502                return res;
01503             num = num - units;
01504             snprintf(fn, sizeof(fn), "digits/nl-en");
01505          } else {
01506             snprintf(fn, sizeof(fn), "digits/%d", num - units);
01507             num = 0;
01508          }
01509       } else {
01510          if (num < 1000) {
01511             snprintf(fn, sizeof(fn), "digits/%d", (num/100));
01512             playh++;
01513             num -= ((num / 100) * 100);
01514          } else {
01515             if (num < 1000000) { /* 1,000,000 */
01516                res = ast_say_number_full_en(chan, num / 1000, ints, language, audiofd, ctrlfd);
01517                if (res)
01518                   return res;
01519                num = num % 1000;
01520                snprintf(fn, sizeof(fn), "digits/thousand");
01521             } else {
01522                if (num < 1000000000) { /* 1,000,000,000 */
01523                   res = ast_say_number_full_en(chan, num / 1000000, ints, language, audiofd, ctrlfd);
01524                   if (res)
01525                      return res;
01526                   num = num % 1000000;
01527                   snprintf(fn, sizeof(fn), "digits/million");
01528                } else {
01529                   ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
01530                   res = -1;
01531                }
01532             }
01533          }
01534       }
01535 
01536       if (!res) {
01537          if(!ast_streamfile(chan, fn, language)) {
01538             if ((audiofd > -1) && (ctrlfd > -1))
01539                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01540             else
01541                res = ast_waitstream(chan, ints);
01542          }
01543          ast_stopstream(chan);
01544       }
01545    }
01546    return res;
01547 }

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

Definition at line 1553 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_number_full().

01554 {
01555    int res = 0;
01556    int playh = 0;
01557    int playa = 0;
01558    int cn = 1;    /* +1 = commune; -1 = neuter */
01559    char fn[256] = "";
01560    
01561    if (!num) 
01562       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
01563    
01564    if (options && !strncasecmp(options, "n",1)) cn = -1;
01565 
01566    while(!res && (num || playh || playa )) {
01567       /* The grammar for Norwegian numbers is the same as for English except
01568       * for the following:
01569       * - 1 exists in both commune ("en", file "1") and neuter ("ett", file "1N")
01570       *   "and" before the last two digits, i.e. 2034 is "two thousand and
01571       *   thirty-four" and 1000012 is "one million and twelve".
01572       */
01573       if (num < 0) {
01574          snprintf(fn, sizeof(fn), "digits/minus");
01575          if ( num > INT_MIN ) {
01576             num = -num;
01577          } else {
01578             num = 0;
01579          }  
01580       } else if (playh) {
01581          snprintf(fn, sizeof(fn), "digits/hundred");
01582          playh = 0;
01583       } else if (playa) {
01584          snprintf(fn, sizeof(fn), "digits/and");
01585          playa = 0;
01586       } else if (num == 1 && cn == -1) {
01587          snprintf(fn, sizeof(fn), "digits/1N");
01588          num = 0;
01589       } else if (num < 20) {
01590          snprintf(fn, sizeof(fn), "digits/%d", num);
01591          num = 0;
01592       } else if (num < 100) {
01593          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
01594          num -= ((num / 10) * 10);
01595       } else if (num < 1000) {
01596          int hundreds = num / 100;
01597          if (hundreds == 1)
01598             snprintf(fn, sizeof(fn), "digits/1N");
01599          else
01600             snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
01601 
01602          playh++;
01603          num -= 100 * hundreds;
01604          if (num)
01605             playa++;
01606       } else   if (num < 1000000) {
01607          res = ast_say_number_full_no(chan, num / 1000, ints, language, "n", audiofd, ctrlfd);
01608          if (res)
01609             return res;
01610          snprintf(fn, sizeof(fn), "digits/thousand");
01611          num = num % 1000;
01612          if (num && num < 100)
01613             playa++;
01614       } else   if (num < 1000000000) {
01615             int millions = num / 1000000;
01616             res = ast_say_number_full_no(chan, millions, ints, language, "c", audiofd, ctrlfd);
01617             if (res)
01618                return res;
01619             snprintf(fn, sizeof(fn), "digits/million");
01620             num = num % 1000000;
01621             if (num && num < 100)
01622                playa++;
01623       } else {
01624             ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
01625             res = -1;
01626       }
01627       
01628       if (!res) {
01629          if(!ast_streamfile(chan, fn, language)) {
01630             if ((audiofd > -1) && (ctrlfd > -1)) 
01631                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01632             else  
01633                res = ast_waitstream(chan, ints);
01634          }
01635          ast_stopstream(chan);
01636       }
01637    }
01638    return res;
01639 }

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 1754 of file say.c.

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

Referenced by ast_say_number_full().

01756              :
01757 0     zero
01758 1     jeden
01759 10    dziesiec
01760 100      sto
01761 1000     tysiac
01762 1000000     milion
01763 1000000000  miliard
01764 1000000000.2   miliardy
01765 1000000000.5   miliardow
01766 1000000.2   miliony
01767 1000000.5   milionow
01768 1000.2      tysiace
01769 1000.5      tysiecy
01770 100m     stu
01771 10m      dziesieciu
01772 11    jedenascie
01773 11m      jedenastu
01774 12    dwanascie
01775 12m      dwunastu
01776 13    trzynascie
01777 13m      trzynastu
01778 14    czternascie
01779 14m      czternastu
01780 15    pietnascie
01781 15m      pietnastu
01782 16    szesnascie
01783 16m      szesnastu
01784 17    siedemnascie
01785 17m      siedemnastu
01786 18    osiemnascie
01787 18m      osiemnastu
01788 19    dziewietnascie
01789 19m      dziewietnastu
01790 1z    jedna
01791 2     dwie
01792 20    dwadziescia
01793 200      dwiescie
01794 200m     dwustu
01795 20m      dwudziestu
01796 2-1m     dwaj
01797 2-2m     dwoch
01798 2z    dwie
01799 3     trzy
01800 30    trzydziesci
01801 300      trzysta
01802 300m     trzystu
01803 30m      trzydziestu
01804 3-1m     trzej
01805 3-2m     trzech
01806 4     cztery
01807 40    czterdziesci
01808 400      czterysta
01809 400m     czterystu
01810 40m      czterdziestu
01811 4-1m     czterej
01812 4-2m     czterech
01813 5     piec
01814 50    piecdziesiat
01815 500      piecset
01816 500m     pieciuset
01817 50m      piedziesieciu
01818 5m    pieciu
01819 6     szesc
01820 60    szescdziesiat
01821 600      szescset
01822 600m     szesciuset
01823 60m      szescdziesieciu
01824 6m    szesciu
01825 7     siedem
01826 70    siedemdziesiat
01827 700      siedemset
01828 700m     siedmiuset
01829 70m      siedemdziesieciu
01830 7m    siedmiu
01831 8     osiem
01832 80    osiemdziesiat
01833 800      osiemset
01834 800m     osmiuset
01835 80m      osiemdziesieciu
01836 8m    osmiu
01837 9     dziewiec
01838 90    dziewiecdziesiat
01839 900      dziewiecset
01840 900m     dziewieciuset
01841 90m      dziewiedziesieciu
01842 9m    dziewieciu
01843 and combinations of eg.: 20_1, 30m_3m, etc...
01844 
01845 */
01846 {
01847    char *zenski_cyfry[] = {"0","1z", "2z", "3", "4", "5", "6", "7", "8", "9"};
01848 
01849    char *zenski_cyfry2[] = {"0","1", "2z", "3", "4", "5", "6", "7", "8", "9"};
01850 
01851    char *meski_cyfry[] = {"0","1", "2-1m", "3-1m", "4-1m", "5m",  /*"2-1mdwaj"*/ "6m", "7m", "8m", "9m"};
01852 
01853    char *meski_cyfry2[] = {"0","1", "2-2m", "3-2m", "4-2m", "5m", "6m", "7m", "8m", "9m"};
01854 
01855    char *meski_setki[] = {"", "100m", "200m", "300m", "400m", "500m", "600m", "700m", "800m", "900m"};
01856 
01857    char *meski_dziesiatki[] = {"", "10m", "20m", "30m", "40m", "50m", "60m", "70m", "80m", "90m"};
01858 
01859    char *meski_nastki[] = {"", "11m", "12m", "13m", "14m", "15m", "16m", "17m", "18m", "19m"};
01860 
01861    char *nijaki_cyfry[] = {"0","1", "2", "3", "4", "5", "6", "7", "8", "9"};
01862 
01863    char *nijaki_cyfry2[] = {"0","1", "2", "3", "4", "5", "6", "7", "8", "9"};
01864 
01865    char *nijaki_setki[] = {"", "100", "200", "300", "400", "500", "600", "700", "800", "900"};
01866 
01867    char *nijaki_dziesiatki[] = {"", "10", "20", "30", "40", "50", "60", "70", "80", "90"};
01868 
01869    char *nijaki_nastki[] = {"", "11", "12", "13", "14", "15", "16", "17", "18", "19"};
01870 
01871    char *rzedy[][3] = { {"1000", "1000.2", "1000.5"}, {"1000000", "1000000.2", "1000000.5"}, {"1000000000", "1000000000.2", "1000000000.5"}}; 
01872 
01873    /* Initialise variables to allow compilation on Debian-stable, etc */
01874    odmiana *o;
01875 
01876    static odmiana *odmiana_nieosobowa = NULL; 
01877    static odmiana *odmiana_meska = NULL; 
01878    static odmiana *odmiana_zenska = NULL; 
01879 
01880    if (odmiana_nieosobowa == NULL) {
01881       odmiana_nieosobowa = (odmiana *) malloc(sizeof(odmiana));
01882 
01883       odmiana_nieosobowa->separator_dziesiatek = "_";
01884 
01885       memcpy(odmiana_nieosobowa->cyfry, nijaki_cyfry, sizeof(odmiana_nieosobowa->cyfry));
01886       memcpy(odmiana_nieosobowa->cyfry2, nijaki_cyfry2, sizeof(odmiana_nieosobowa->cyfry));
01887       memcpy(odmiana_nieosobowa->setki, nijaki_setki, sizeof(odmiana_nieosobowa->setki));
01888       memcpy(odmiana_nieosobowa->dziesiatki, nijaki_dziesiatki, sizeof(odmiana_nieosobowa->dziesiatki));
01889       memcpy(odmiana_nieosobowa->nastki, nijaki_nastki, sizeof(odmiana_nieosobowa->nastki));
01890       memcpy(odmiana_nieosobowa->rzedy, rzedy, sizeof(odmiana_nieosobowa->rzedy));
01891    }
01892 
01893    if (odmiana_zenska == NULL) {
01894       odmiana_zenska = (odmiana *) malloc(sizeof(odmiana));
01895 
01896       odmiana_zenska->separator_dziesiatek = " ";
01897 
01898       memcpy(odmiana_zenska->cyfry, zenski_cyfry, sizeof(odmiana_zenska->cyfry));
01899       memcpy(odmiana_zenska->cyfry2, zenski_cyfry2, sizeof(odmiana_zenska->cyfry));
01900       memcpy(odmiana_zenska->setki, nijaki_setki, sizeof(odmiana_zenska->setki));
01901       memcpy(odmiana_zenska->dziesiatki, nijaki_dziesiatki, sizeof(odmiana_zenska->dziesiatki));
01902       memcpy(odmiana_zenska->nastki, nijaki_nastki, sizeof(odmiana_zenska->nastki));
01903       memcpy(odmiana_zenska->rzedy, rzedy, sizeof(odmiana_zenska->rzedy));
01904    }
01905 
01906    if (odmiana_meska == NULL) {
01907       odmiana_meska = (odmiana *) malloc(sizeof(odmiana));
01908 
01909       odmiana_meska->separator_dziesiatek = " ";
01910 
01911       memcpy(odmiana_meska->cyfry, meski_cyfry, sizeof(odmiana_meska->cyfry));
01912       memcpy(odmiana_meska->cyfry2, meski_cyfry2, sizeof(odmiana_meska->cyfry));
01913       memcpy(odmiana_meska->setki, meski_setki, sizeof(odmiana_meska->setki));
01914       memcpy(odmiana_meska->dziesiatki, meski_dziesiatki, sizeof(odmiana_meska->dziesiatki));
01915       memcpy(odmiana_meska->nastki, meski_nastki, sizeof(odmiana_meska->nastki));
01916       memcpy(odmiana_meska->rzedy, rzedy, sizeof(odmiana_meska->rzedy));
01917    }
01918 
01919    if (options) {
01920       if (strncasecmp(options, "f", 1) == 0)
01921          o = odmiana_zenska;
01922       else if (strncasecmp(options, "m", 1) == 0)
01923          o = odmiana_meska;
01924       else
01925          o = odmiana_nieosobowa;
01926    } else
01927       o = odmiana_nieosobowa;
01928 
01929    powiedz(chan, language, audiofd, ctrlfd, ints, o, 0, num);
01930    return 0;
01931 }

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 1939 of file say.c.

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

Referenced by ast_say_number_full().

01940 {
01941    int res = 0;
01942    int playh = 0;
01943    int mf = 1;                            /* +1 = male; -1 = female */
01944    char fn[256] = "";
01945 
01946    if (!num) 
01947       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
01948 
01949    if (options && !strncasecmp(options, "f",1))
01950       mf = -1;
01951 
01952    while(!res && num ) {
01953       if (num < 0) {
01954          snprintf(fn, sizeof(fn), "digits/minus");
01955          if ( num > INT_MIN ) {
01956             num = -num;
01957          } else {
01958             num = 0;
01959          }  
01960       } else if (num < 20) {
01961          if ((num == 1 || num == 2) && (mf < 0))
01962             snprintf(fn, sizeof(fn), "digits/%dF", num);
01963          else
01964             snprintf(fn, sizeof(fn), "digits/%d", num);
01965          num = 0;
01966       } else if (num < 100) {
01967          snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10);
01968          if (num % 10)
01969             playh = 1;
01970          num = num % 10;
01971       } else if (num < 1000) {
01972          if (num == 100)
01973             snprintf(fn, sizeof(fn), "digits/100");
01974          else if (num < 200)
01975             snprintf(fn, sizeof(fn), "digits/100E");
01976          else {
01977             if (mf < 0 && num > 199)
01978                snprintf(fn, sizeof(fn), "digits/%dF", (num / 100) * 100);
01979             else
01980                snprintf(fn, sizeof(fn), "digits/%d", (num / 100) * 100);
01981             if (num % 100)
01982                playh = 1;
01983          }
01984          num = num % 100;
01985       } else if (num < 1000000) {
01986          if (num > 1999) {
01987             res = ast_say_number_full_pt(chan, (num / 1000) * mf, ints, language, options, audiofd, ctrlfd);
01988             if (res)
01989                return res;
01990          }
01991          snprintf(fn, sizeof(fn), "digits/1000");
01992          if ((num % 1000) && ((num % 1000) < 100  || !(num % 100)))
01993             playh = 1;
01994          num = num % 1000;
01995       } else if (num < 1000000000) {
01996          res = ast_say_number_full_pt(chan, (num / 1000000), ints, language, options, audiofd, ctrlfd );
01997          if (res)
01998             return res;
01999          if (num < 2000000)
02000             snprintf(fn, sizeof(fn), "digits/1000000");
02001          else
02002             snprintf(fn, sizeof(fn), "digits/1000000S");
02003  
02004          if ((num % 1000000) &&
02005             /* no thousands */
02006             ((!((num / 1000) % 1000) && ((num % 1000) < 100 || !(num % 100))) ||
02007             /* no hundreds and below */
02008             (!(num % 1000) && (((num / 1000) % 1000) < 100 || !((num / 1000) % 100))) ) )
02009             playh = 1;
02010          num = num % 1000000;
02011       } else {
02012          /** Protection: number is to big **/
02013          ast_log(LOG_WARNING, "Number '%d' is too big to say.", num);
02014          res = -1;
02015       }
02016       if (!res) {
02017          if (!ast_streamfile(chan, fn, language)) {
02018             if ((audiofd > -1) && (ctrlfd > -1))
02019                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);  
02020             else
02021                res = ast_waitstream(chan, ints);
02022          }
02023          ast_stopstream(chan);
02024       }
02025       if (!res && playh) {
02026          res = wait_file(chan, ints, "digits/pt-e", language);
02027          ast_stopstream(chan);
02028          playh = 0;
02029       }
02030    }
02031    return res;
02032 }

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 2199 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), get_lastdigits_ru(), and LOG_DEBUG.

Referenced by ast_say_number_full().

02200 {
02201    int res = 0;
02202    int lastdigits = 0;
02203    char fn[256] = "";
02204    if (!num) 
02205       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
02206 
02207    while(!res && (num)) {
02208       if (num < 0) {
02209          snprintf(fn, sizeof(fn), "digits/minus");
02210          if ( num > INT_MIN ) {
02211             num = -num;
02212          } else {
02213             num = 0;
02214          }  
02215       } else   if (num < 20) {
02216          if(options && strlen(options) == 1 && num < 3) {
02217              snprintf(fn, sizeof(fn), "digits/%d%s", num, options);
02218          } else {
02219                 snprintf(fn, sizeof(fn), "digits/%d", num);
02220          }
02221          num = 0;
02222       } else   if (num < 100) {
02223          snprintf(fn, sizeof(fn), "digits/%d", num - (num % 10));
02224          num %= 10;
02225       } else   if (num < 1000){
02226          snprintf(fn, sizeof(fn), "digits/%d", num - (num % 100));
02227          num %= 100;
02228       } else   if (num < 1000000) { /* 1,000,000 */
02229          lastdigits = get_lastdigits_ru(num / 1000);
02230          /* say thousands */
02231          if (lastdigits < 3) {
02232             res = ast_say_number_full_ru(chan, num / 1000, ints, language, "f", audiofd, ctrlfd);
02233          } else {
02234             res = ast_say_number_full_ru(chan, num / 1000, ints, language, NULL, audiofd, ctrlfd);
02235          }
02236          if (res)
02237             return res;
02238          if (lastdigits == 1) {
02239             snprintf(fn, sizeof(fn), "digits/thousand");
02240          } else if (lastdigits > 1 && lastdigits < 5) {
02241             snprintf(fn, sizeof(fn), "digits/thousands-i");
02242          } else {
02243             snprintf(fn, sizeof(fn), "digits/thousands");
02244          }
02245          num %= 1000;
02246       } else   if (num < 1000000000) { /* 1,000,000,000 */
02247          lastdigits = get_lastdigits_ru(num / 1000000);
02248          /* say millions */
02249          res = ast_say_number_full_ru(chan, num / 1000000, ints, language, NULL, audiofd, ctrlfd);
02250          if (res)
02251             return res;
02252          if (lastdigits == 1) {
02253             snprintf(fn, sizeof(fn), "digits/million");
02254          } else if (lastdigits > 1 && lastdigits < 5) {
02255             snprintf(fn, sizeof(fn), "digits/million-a");
02256          } else {
02257             snprintf(fn, sizeof(fn), "digits/millions");
02258          }
02259          num %= 1000000;
02260       } else {
02261          ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
02262             res = -1;
02263       }
02264       if (!res) {
02265          if (!ast_streamfile(chan, fn, language)) {
02266             if ((audiofd  > -1) && (ctrlfd > -1))
02267                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02268             else
02269                res = ast_waitstream(chan, ints);
02270          }
02271          ast_stopstream(chan);
02272       }
02273    }
02274    return res;
02275 }

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

Definition at line 2035 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_number_full().

02036 {
02037    int res = 0;
02038    int playh = 0;
02039    char fn[256] = "";
02040    int cn = 1;    /* +1 = commune; -1 = neuter */
02041    if (!num) 
02042       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
02043    if (options && !strncasecmp(options, "n",1)) cn = -1;
02044 
02045    while(!res && (num || playh)) {
02046       if (num < 0) {
02047          snprintf(fn, sizeof(fn), "digits/minus");
02048          if ( num > INT_MIN ) {
02049             num = -num;
02050          } else {
02051             num = 0;
02052          }  
02053       } else if (playh) {
02054          snprintf(fn, sizeof(fn), "digits/hundred");
02055          playh = 0;
02056       } else if (num < 20) {
02057          snprintf(fn, sizeof(fn), "digits/%d", num);
02058          num = 0;
02059       } else if (num < 100) {
02060          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
02061          num -= ((num / 10) * 10);
02062       } else if (num == 1 && cn == -1) {  /* En eller ett? */
02063          snprintf(fn, sizeof(fn), "digits/1N");
02064          num = 0;
02065       } else {
02066          if (num < 1000){
02067             snprintf(fn, sizeof(fn), "digits/%d", (num/100));
02068             playh++;
02069             num -= ((num / 100) * 100);
02070          } else {
02071             if (num < 1000000) { /* 1,000,000 */
02072                res = ast_say_number_full_se(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
02073                if (res) {
02074                   return res;
02075                }
02076                num = num % 1000;
02077                snprintf(fn, sizeof(fn), "digits/thousand");
02078             } else {
02079                if (num < 1000000000) { /* 1,000,000,000 */
02080                   res = ast_say_number_full_se(chan, num / 1000000, ints, language, options, audiofd, ctrlfd);
02081                   if (res) {
02082                      return res;
02083                   }
02084                   num = num % 1000000;
02085                   snprintf(fn, sizeof(fn), "digits/million");
02086                } else {
02087                   ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
02088                   res = -1;
02089                }
02090             }
02091          }
02092       }
02093       if (!res) {
02094          if(!ast_streamfile(chan, fn, language)) {
02095             if ((audiofd > -1) && (ctrlfd > -1))
02096                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02097             else
02098                res = ast_waitstream(chan, ints);
02099             ast_stopstream(chan);
02100          }
02101       }
02102    }
02103    return res;
02104 }

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

ast_say_number_full_tw: Taiwanese syntax

Definition at line 2107 of file say.c.

References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by ast_say_number_full().

02108 {
02109    int res = 0;
02110    int playh = 0;
02111    char fn[256] = "";
02112    if (!num)
02113       return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
02114 
02115    while(!res && (num || playh)) {
02116          if (num < 0) {
02117             snprintf(fn, sizeof(fn), "digits/minus");
02118             if ( num > INT_MIN ) {
02119                num = -num;
02120             } else {
02121                num = 0;
02122             }  
02123          } else if (playh) {
02124             snprintf(fn, sizeof(fn), "digits/hundred");
02125             playh = 0;
02126          } else   if (num < 10) {
02127             snprintf(fn, sizeof(fn), "digits/%d", num);
02128             num = 0;
02129          } else   if (num < 100) {
02130             snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
02131             num -= ((num / 10) * 10);
02132          } else {
02133             if (num < 1000){
02134                snprintf(fn, sizeof(fn), "digits/%d", (num/100));
02135                playh++;
02136                num -= ((num / 100) * 100);
02137             } else {
02138                if (num < 1000000) { /* 1,000,000 */
02139                   res = ast_say_number_full_tw(chan, num / 1000, ints, language, audiofd, ctrlfd);
02140                   if (res)
02141                      return res;
02142                   num = num % 1000;
02143                   snprintf(fn, sizeof(fn), "digits/thousand");
02144                } else {
02145                   if (num < 1000000000) { /* 1,000,000,000 */
02146                      res = ast_say_number_full_tw(chan, num / 1000000, ints, language, audiofd, ctrlfd);
02147                      if (res)
02148                         return res;
02149                      num = num % 1000000;
02150                      snprintf(fn, sizeof(fn), "digits/million");
02151                   } else {
02152                      ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
02153                      res = -1;
02154                   }
02155                }
02156             }
02157          }
02158          if (!res) {
02159             if(!ast_streamfile(chan, fn, language)) {
02160                if ((audiofd > -1) && (ctrlfd > -1))
02161                   res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
02162                else
02163                   res = ast_waitstream(chan, ints);
02164             }
02165             ast_stopstream(chan);
02166          }
02167    }
02168    return res;
02169 }

int ast_say_phonetic_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang 
)

Definition at line 211 of file say.c.

References ast_say_phonetic_str_full().

Referenced by pbx_builtin_sayphonetic().

00212 {
00213    return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
00214 }

int ast_say_phonetic_str_full ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
)

Definition at line 137 of file say.c.

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

Referenced by ast_say_phonetic_str(), and handle_sayphonetic().

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

int ast_say_time ( struct ast_channel chan,
time_t  t,
const char *  ints,
const char *  lang 
)

Definition at line 5176 of file say.c.

References ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_nl(), ast_say_time_pt(), ast_say_time_pt_BR(), and ast_say_time_tw().

Referenced by ast_say_datetime_de(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_pt(), ast_say_datetime_nl(), ast_say_datetime_pt_BR(), handle_saytime(), and rpt_tele_thread().

05177 {
05178    if (!strcasecmp(lang, "en") ) {  /* English syntax */
05179       return(ast_say_time_en(chan, t, ints, lang));
05180    } else if (!strcasecmp(lang, "de") ) { /* German syntax */
05181       return(ast_say_time_de(chan, t, ints, lang));
05182    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
05183       return(ast_say_time_fr(chan, t, ints, lang));
05184    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
05185       return(ast_say_time_nl(chan, t, ints, lang));
05186    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
05187       return(ast_say_time_pt(chan, t, ints, lang));
05188    } else if (!strcasecmp(lang, "pt_BR") ) { /* Brazilian Portuguese syntax */
05189       return(ast_say_time_pt_BR(chan, t, ints, lang));
05190    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
05191       return(ast_say_time_tw(chan, t, ints, lang));
05192    } else if (!strcasecmp(lang, "gr") ) {          /* Greek syntax */
05193       return(ast_say_time_gr(chan, t, ints, lang));
05194    }
05195 
05196    /* Default to English */
05197    return(ast_say_time_en(chan, t, ints, lang));
05198 }

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

Definition at line 5248 of file say.c.

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

Referenced by ast_say_time().

05249 {
05250    struct tm tm;
05251    int res = 0;
05252    localtime_r(&t,&tm);
05253    if (!res)
05254       res = ast_say_number(chan, tm.tm_hour, ints, lang, "n");
05255    if (!res)
05256       res = ast_streamfile(chan, "digits/oclock", lang);
05257    if (!res)
05258       res = ast_waitstream(chan, ints);
05259    if (!res)
05260        if (tm.tm_min > 0) 
05261       res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
05262    return res;
05263 }

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

Definition at line 5201 of file say.c.

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

Referenced by ast_say_time().

05202 {
05203    struct tm tm;
05204    int res = 0;
05205    int hour, pm=0;
05206    localtime_r(&t,&tm);
05207    hour = tm.tm_hour;
05208    if (!hour)
05209       hour = 12;
05210    else if (hour == 12)
05211       pm = 1;
05212    else if (hour > 12) {
05213       hour -= 12;
05214       pm = 1;
05215    }
05216    if (!res)
05217       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
05218 
05219    if (tm.tm_min > 9) {
05220       if (!res)
05221          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05222    } else if (tm.tm_min) {
05223       if (!res)
05224          res = ast_streamfile(chan, "digits/oh", lang);
05225       if (!res)
05226          res = ast_waitstream(chan, ints);
05227       if (!res)
05228          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05229    } else {
05230       if (!res)
05231          res = ast_streamfile(chan, "digits/oclock", lang);
05232       if (!res)
05233          res = ast_waitstream(chan, ints);
05234    }
05235    if (pm) {
05236       if (!res)
05237          res = ast_streamfile(chan, "digits/p-m", lang);
05238    } else {
05239       if (!res)
05240          res = ast_streamfile(chan, "digits/a-m", lang);
05241    }
05242    if (!res)
05243       res = ast_waitstream(chan, ints);
05244    return res;
05245 }

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

Definition at line 5266 of file say.c.

References ast_say_number(), and ast_streamfile().

Referenced by ast_say_time().

05267 {
05268    struct tm tm;
05269    int res = 0;
05270    localtime_r(&t,&tm);
05271 
05272    res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
05273    if (!res)
05274       res = ast_streamfile(chan, "digits/oclock", lang);
05275    if (tm.tm_min) {
05276       if (!res)
05277       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05278    }
05279    return res;
05280 }

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

Definition at line 6011 of file say.c.

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

Referenced by ast_say_datetime_gr(), and ast_say_time().

06012 {
06013 
06014    struct tm tm;
06015    int res = 0;
06016    int hour, pm=0;
06017 
06018    localtime_r(&t,&tm);
06019    hour = tm.tm_hour;
06020 
06021    if (!hour)
06022       hour = 12;
06023    else if (hour == 12)
06024       pm = 1;
06025    else if (hour > 12) {
06026       hour -= 12;
06027       pm = 1;
06028    }
06029  
06030    res = gr_say_number_female(hour, chan, ints, lang);
06031    if (tm.tm_min) {
06032       if (!res)
06033          res = ast_streamfile(chan, "digits/kai", lang);
06034       if (!res)
06035          res = ast_waitstream(chan, ints);
06036       if (!res)
06037          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
06038    } else {
06039       if (!res)
06040          res = ast_streamfile(chan, "digits/hwra", lang);
06041       if (!res)
06042          res = ast_waitstream(chan, ints);
06043    }
06044    if (pm) {
06045       if (!res)
06046          res = ast_streamfile(chan, "digits/p-m", lang);
06047    } else {
06048       if (!res)
06049          res = ast_streamfile(chan, "digits/a-m", lang);
06050    }
06051    if (!res)
06052       res = ast_waitstream(chan, ints);
06053    return res;
06054 }

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

Definition at line 5283 of file say.c.

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

Referenced by ast_say_time().

05284 {
05285    struct tm tm;
05286    int res = 0;
05287    localtime_r(&t,&tm);
05288    if (!res)
05289       res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
05290    if (!res)
05291       res = ast_streamfile(chan, "digits/nl-uur", lang);
05292    if (!res)
05293       res = ast_waitstream(chan, ints);
05294    if (!res)
05295        if (tm.tm_min > 0) 
05296       res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
05297    return res;
05298 }

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

Definition at line 5301 of file say.c.

References ast_say_number(), and wait_file().

Referenced by ast_say_time().

05302 {
05303    struct tm tm;
05304    int res = 0;
05305    int hour;
05306    localtime_r(&t,&tm);
05307    hour = tm.tm_hour;
05308    if (!res)
05309       res = ast_say_number(chan, hour, ints, lang, "f");
05310    if (tm.tm_min) {
05311       if (!res)
05312          res = wait_file(chan, ints, "digits/pt-e", lang);
05313       if (!res)
05314          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05315    } else {
05316       if (!res)
05317          res = wait_file(chan, ints, "digits/pt-hora", lang);
05318       if (tm.tm_hour != 1)
05319          if (!res)
05320             res = wait_file(chan, ints, "digits/pt-sss", lang);
05321    }
05322    if (!res)
05323       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
05324    return res;
05325 }

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

Definition at line 5328 of file say.c.

References ast_say_number(), and wait_file().

Referenced by ast_say_time().

05329 {
05330    struct tm tm;
05331    int res = 0;
05332    localtime_r(&t,&tm);
05333 
05334    res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
05335    if (!res) {
05336       if (tm.tm_hour > 1)
05337             res = wait_file(chan, ints, "digits/hours", lang);
05338         else
05339             res = wait_file(chan, ints, "digits/hour", lang);
05340    }
05341    if ((!res) && (tm.tm_min)) {
05342       res = wait_file(chan, ints, "digits/pt-e", lang);
05343       if (!res)
05344          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05345         if (!res) {
05346             if (tm.tm_min > 1)
05347                 res = wait_file(chan, ints, "digits/minutes", lang);
05348             else
05349                 res = wait_file(chan, ints, "digits/minute", lang);
05350         }
05351    }
05352    return res;
05353 }

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

Definition at line 5356 of file say.c.

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

Referenced by ast_say_time().

05357 {
05358    struct tm tm;
05359    int res = 0;
05360    int hour, pm=0;
05361    localtime_r(&t,&tm);
05362    hour = tm.tm_hour;
05363    if (!hour)
05364       hour = 12;
05365    else if (hour == 12)
05366       pm = 1;
05367    else if (hour > 12) {
05368       hour -= 12;
05369       pm = 1;
05370    }
05371    if (pm) {
05372       if (!res)
05373          res = ast_streamfile(chan, "digits/p-m", lang);
05374    } else {
05375       if (!res)
05376          res = ast_streamfile(chan, "digits/a-m", lang);
05377    }
05378    if (!res)
05379       res = ast_waitstream(chan, ints);
05380    if (!res)
05381       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
05382    if (!res)
05383       res = ast_streamfile(chan, "digits/oclock", lang);
05384    if (!res)
05385       res = ast_waitstream(chan, ints);
05386    if (!res)
05387       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
05388    if (!res)
05389       res = ast_streamfile(chan, "digits/minute", lang);
05390    if (!res)
05391       res = ast_waitstream(chan, ints);
05392    return res;
05393 }

static int exp10_int ( int  power  )  [static]

Definition at line 530 of file say.c.

Referenced by ast_say_number_full_cz().

00531 {
00532    int x, res= 1;
00533    for (x=0;x<power;x++)
00534       res *= 10;
00535    return res;
00536 }

static int get_lastdigits_ru ( int  num  )  [static]

determine last digits for thousands/millions (ru)

Definition at line 2173 of file say.c.

Referenced by ast_say_number_full_ru().

02173                                       {
02174    if (num < 20) {
02175       return num;
02176    } else if (num < 100) {
02177       return get_lastdigits_ru(num % 10);
02178    } else if (num < 1000) {
02179       return get_lastdigits_ru(num % 100);
02180    }
02181    return 0;   /* number too big */
02182 }

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

Definition at line 5841 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().

05841                                                                                                       {
05842    int tmp;
05843    int left;
05844    int res;
05845    char fn[256] = "";
05846 
05847    /* ast_log(LOG_DEBUG, "\n\n Saying number female %s %d \n\n",lang, num); */
05848    if (num < 5) {
05849       snprintf(fn, sizeof(fn), "digits/female-%d", num);
05850       res = wait_file(chan, ints, fn, lang);
05851    } else if (num < 13) {
05852       res = ast_say_number(chan, num, ints, lang, (char *) NULL);
05853    } else if (num <100 ) { 
05854       tmp = (num/10) * 10;
05855       left = num - tmp;
05856       snprintf(fn, sizeof(fn), "digits/%d", tmp);
05857       res = ast_streamfile(chan, fn, lang);
05858       if (!res)
05859          res = ast_waitstream(chan, ints);
05860       if (left)
05861          gr_say_number_female(left, chan, ints, lang);
05862          
05863    } else {
05864       return -1;
05865    }
05866    return res;
05867 }

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

Definition at line 1664 of file say.c.

Referenced by powiedz().

01665 {
01666    strcpy(buffer, str);
01667    buffer += strlen(str); 
01668    return buffer;
01669 }

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 1671 of file say.c.

References ast_log(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.

Referenced by powiedz().

01672 {    
01673    char file_name[255] = "digits/";
01674    strcat(file_name, fn);
01675    ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name);
01676    if (!ast_streamfile(chan, file_name, language)) {
01677       if ((audiofd > -1) && (ctrlfd > -1))
01678          ast_waitstream_full(chan, ints, audiofd, ctrlfd);
01679       else
01680          ast_waitstream(chan, ints);
01681    }
01682    ast_stopstream(chan);
01683 }

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

Definition at line 1651 of file say.c.

References odmiana::rzedy.

Referenced by powiedz().

01652 {
01653    if (rzad==0)
01654       return "";
01655  
01656    if (i==1)
01657       return odm->rzedy[rzad - 1][0];
01658    if ((i > 21 || i < 11) &&  i%10 > 1 && i%10 < 5)
01659       return odm->rzedy[rzad - 1][1];
01660    else
01661       return odm->rzedy[rzad - 1][2];
01662 }

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 1685 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().

01686 {
01687    /* Initialise variables to allow compilation on Debian-stable, etc */
01688    int m1000E6 = 0;
01689    int i1000E6 = 0;
01690    int m1000E3 = 0;
01691    int i1000E3 = 0;
01692    int m1000 = 0;
01693    int i1000 = 0;
01694    int m100 = 0;
01695    int i100 = 0;
01696    
01697    if (i == 0 && rzad > 0) { 
01698       return;
01699    }
01700    if (i == 0) {
01701       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry[0]);
01702    }
01703 
01704    m1000E6 = i % 1000000000;
01705    i1000E6 = i / 1000000000;
01706 
01707    powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+3, i1000E6);
01708 
01709    m1000E3 = m1000E6 % 1000000;
01710    i1000E3 = m1000E6 / 1000000;
01711 
01712    powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+2, i1000E3);
01713 
01714    m1000 = m1000E3 % 1000;
01715    i1000 = m1000E3 / 1000;
01716 
01717    powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+1, i1000);
01718 
01719    m100 = m1000 % 100;
01720    i100 = m1000 / 100;
01721    
01722    if (i100>0)
01723       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->setki[i100]);
01724 
01725    if ( m100 > 0 && m100 <=9 ) {
01726       if (m1000>0)
01727          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry2[m100]);
01728       else
01729          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry[m100]);
01730    } else if (m100 % 10 == 0) {
01731       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->dziesiatki[m100 / 10]);
01732    } else if (m100 <= 19 ) {
01733       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->nastki[m100 % 10]);
01734    } else if (m100 != 0) {
01735       if (odm->separator_dziesiatek[0]==' ') {
01736          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->dziesiatki[m100 / 10]);
01737          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry2[m100 % 10]);
01738       } else {
01739          char buf[10];
01740          char *b = buf;
01741          b = pl_append(b, odm->dziesiatki[m100 / 10]);  
01742          b = pl_append(b, odm->separator_dziesiatek);  
01743          b = pl_append(b, odm->cyfry2[m100 % 10]); 
01744          pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, buf);
01745       }
01746    } 
01747 
01748    if (rzad > 0) {
01749       pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, pl_rzad_na_tekst(odm, i, rzad));
01750    }
01751 }

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

Definition at line 404 of file say.c.

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

Referenced by advanced_options(), ast_say_date_da(), ast_say_date_de(), ast_say_date_pt(), 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_pt(), ast_say_date_with_format_tw(), ast_say_datetime_from_now_pt(), ast_say_number_full_pt(), ast_say_time_pt(), ast_say_time_pt_BR(), gr_say_number_female(), and play_message().

00405 {
00406    int res;
00407    if ((res = ast_streamfile(chan, file, lang)))
00408       ast_log(LOG_WARNING, "Unable to play message %s\n", file);
00409    if (!res)
00410       res = ast_waitstream(chan, ints);
00411    return res;
00412 }


Generated on Sat Mar 24 22:57:25 2007 for Asterisk - the Open Source PBX by  doxygen 1.4.7