Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:49:17 2009

## 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_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
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_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 3631 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 3633 of file say.c.

Referenced by ast_say_date_with_format_he().

#define IL_TIME_STR "IMp"

Definition at line 3632 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 1228 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 136 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().

    00137 {
    00138    return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
    00139 }

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(), ast_waitstream(), 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] && !res) {
    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          if ((audiofd  > -1) && (ctrlfd > -1))
    00125             res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
    00126          else
    00127             res = ast_waitstream(chan, ints);
    00128       }
    00129       ast_stopstream(chan);
    00130       num++;
    00131    }
    00132
    00133    return res;
    00134 }

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

Definition at line 2731 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(), and handle_saydate().

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

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

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

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

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

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

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

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

Definition at line 2754 of file say.c.

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

Referenced by ast_say_date().

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

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

Definition at line 2879 of file say.c.

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

Referenced by ast_say_date().

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

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

Definition at line 5815 of file say.c.

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

Referenced by ast_say_date().

    05816 {
    05817    struct tm tm;
    05818
    05819    char fn[256];
    05820    int res = 0;
    05821
    05822
    05823    ast_localtime(&t,&tm,NULL);
    05824    /* W E E K - D A Y */
    05825    if (!res) {
    05826       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05827       res = ast_streamfile(chan, fn, lang);
    05828       if (!res)
    05829          res = ast_waitstream(chan, ints);
    05830    }
    05831    /* D A Y */
    05832    if (!res) {
    05833       gr_say_number_female(tm.tm_mday, chan, ints, lang);
    05834    }
    05835    /* M O N T H */
    05836    if (!res) {
    05837       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05838       res = ast_streamfile(chan, fn, lang);
    05839       if (!res)
    05840          res = ast_waitstream(chan, ints);
    05841    }
    05842    /* Y E A R */
    05843    if (!res)
    05844       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
    05845    return res;
    05846 }

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

Definition at line 2907 of file say.c.

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

Referenced by ast_say_date().

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

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

Definition at line 2935 of file say.c.

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

Referenced by ast_say_date().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    05937 {
    05938
    05939    struct tm tm;
    05940    int res=0, offset, sndoffset;
    05941    char sndfile[256], nextmsg[256];
    05942
    05943    ast_localtime(&time,&tm,timezone);
    05944
    05945    for (offset=0 ; format[offset] != '\0' ; offset++) {
    05946       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
    05947       switch (format[offset]) {
    05948          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
    05949       case '\'':
    05950          /* Literal name of a sound file */
    05951          sndoffset=0;
    05952          for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
    05953             sndfile[sndoffset] = format[offset];
    05954          sndfile[sndoffset] = '\0';
    05955          res = wait_file(chan,ints,sndfile,lang);
    05956          break;
    05957       case 'A':
    05958       case 'a':
    05959          /* Sunday - Saturday */
    05960          snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
    05961          res = wait_file(chan,ints,nextmsg,lang);
    05962          break;
    05963       case 'B':
    05964       case 'b':
    05965       case 'h':
    05966          /* January - December */
    05967          snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
    05968          res = wait_file(chan,ints,nextmsg,lang);
    05969          break;
    05970       case 'd':
    05971       case 'e':
    05972          /* first - thirtyfirst */
    05973          gr_say_number_female(tm.tm_mday, chan, ints, lang);
    05974          break;
    05975       case 'Y':
    05976          /* Year */
    05977
    05978          ast_say_number_full_gr(chan, 1900+tm.tm_year, ints, chan->language, -1, -1);
    05979          break;
    05980       case 'I':
    05981       case 'l':
    05982          /* 12-Hour */
    05983          if (tm.tm_hour == 0)
    05984             gr_say_number_female(12, chan, ints, lang);
    05985          else if (tm.tm_hour > 12)
    05986             gr_say_number_female(tm.tm_hour - 12, chan, ints, lang);
    05987          else
    05988             gr_say_number_female(tm.tm_hour, chan, ints, lang);
    05989          break;
    05990       case 'H':
    05991       case 'k':
    05992          /* 24-Hour */
    05993          gr_say_number_female(tm.tm_hour, chan, ints, lang);
    05994          break;
    05995       case 'M':
    05996          /* Minute */
    05997          if (tm.tm_min) {
    05998             if (!res)
    05999                res = ast_streamfile(chan, "digits/kai", lang);
    06000             if (!res)
    06001                res = ast_waitstream(chan, ints);
    06002             if (!res)
    06003                res = ast_say_number_full_gr(chan, tm.tm_min, ints, lang, -1, -1);
    06004          } else {
    06005             if (!res)
    06006                res = ast_streamfile(chan, "digits/oclock", lang);
    06007             if (!res)
    06008                res = ast_waitstream(chan, ints);
    06009          }
    06010          break;
    06011       case 'P':
    06012       case 'p':
    06013          /* AM/PM */
    06014          if (tm.tm_hour > 11)
    06015             snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
    06016          else
    06017             snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
    06018          res = wait_file(chan,ints,nextmsg,lang);
    06019          break;
    06020       case 'Q':
    06021          /* Shorthand for "Today", "Yesterday", or ABdY */
    06022          {
    06023             struct timeval now;
    06024             struct tm tmnow;
    06025             time_t beg_today;
    06026
    06027             gettimeofday(&now,NULL);
    06028             ast_localtime(&now.tv_sec,&tmnow,timezone);
    06029             /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
    06030             /* In any case, it saves not having to do ast_mktime() */
    06031             beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
    06032             if (beg_today < time) {
    06033                /* Today */
    06034                res = wait_file(chan,ints, "digits/today",lang);
    06035             } else if (beg_today - 86400 < time) {
    06036                /* Yesterday */
    06037                res = wait_file(chan,ints, "digits/yesterday",lang);
    06038             } else {
    06039                res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
    06040             }
    06041          }
    06042          break;
    06043       case 'q':
    06044          /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
    06045          {
    06046             struct timeval now;
    06047             struct tm tmnow;
    06048             time_t beg_today;
    06049
    06050             gettimeofday(&now,NULL);
    06051             ast_localtime(&now.tv_sec,&tmnow,timezone);
    06052             /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
    06053             /* In any case, it saves not having to do ast_mktime() */
    06054             beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
    06055             if (beg_today < time) {
    06056                /* Today */
    06057             } else if ((beg_today - 86400) < time) {
    06058                /* Yesterday */
    06059                res = wait_file(chan,ints, "digits/yesterday",lang);
    06060             } else if (beg_today - 86400 * 6 < time) {
    06061                /* Within the last week */
    06062                res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
    06063             } else {
    06064                res = ast_say_date_with_format(chan, time, ints, lang, "AdBY", timezone);
    06065             }
    06066          }
    06067          break;
    06068       case 'R':
    06069          res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
    06070          break;
    06071       case 'S':
    06072          /* Seconds */
    06073          snprintf(nextmsg,sizeof(nextmsg), "digits/kai");
    06074          res = wait_file(chan,ints,nextmsg,lang);
    06075          if (!res)
    06076             res = ast_say_number_full_gr(chan, tm.tm_sec, ints, lang, -1, -1);
    06077          if (!res)
    06078             snprintf(nextmsg,sizeof(nextmsg), "digits/seconds");
    06079          res = wait_file(chan,ints,nextmsg,lang);
    06080          break;
    06081       case 'T':
    06082          res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
    06083          break;
    06084       case ' ':
    06085       case '   ':
    06086          /* Just ignore spaces and tabs */
    06087          break;
    06088       default:
    06089          /* Unknown character */
    06090          ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
    06091       }
    06092       /* Jump out on DTMF */
    06093       if (res) {
    06094          break;
    06095       }
    06096    }
    06097    return res;
    06098 }

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

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

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

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

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

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

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

    04606 {
    04607    struct tm tm;
    04608    int res=0, offset, sndoffset;
    04609    char sndfile[256], nextmsg[256];
    04610
    04611    ast_localtime(&time,&tm,timezone);
    04612
    04613    for (offset=0 ; format[offset] != '\0' ; offset++) {
    04614       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
    04615       switch (format[offset]) {
    04616          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
    04617          case '\'':
    04618             /* Literal name of a sound file */
    04619             sndoffset=0;
    04620             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
    04621                sndfile[sndoffset] = format[offset];
    04622             sndfile[sndoffset] = '\0';
    04623             snprintf(nextmsg,sizeof(nextmsg), "%s", sndfile);
    04624             res = wait_file(chan,ints,nextmsg,lang);
    04625             break;
    04626          case 'A':
    04627          case 'a':
    04628             /* Sunday - Saturday */
    04629             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
    04630             res = wait_file(chan,ints,nextmsg,lang);
    04631             break;
    04632          case 'B':
    04633          case 'b':
    04634          case 'h':
    04635             /* January - December */
    04636             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
    04637             res = wait_file(chan,ints,nextmsg,lang);
    04638             break;
    04639          case 'm':
    04640             /* First - Twelfth */
    04641             snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
    04642             res = wait_file(chan,ints,nextmsg,lang);
    04643             break;
    04644          case 'd':
    04645          case 'e':
    04646             /* First - Thirtyfirst */
    04647             res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
    04648             break;
    04649          case 'Y':
    04650             /* Year */
    04651             res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
    04652             break;
    04653          case 'I':
    04654          case 'l':
    04655             /* 12-Hour */
    04656             if (tm.tm_hour == 0) {
    04657                if (format[offset] == 'I')
    04658                   res = wait_file(chan, ints, "digits/pt-ah", lang);
    04659                if (!res)
    04660                   res = wait_file(chan, ints, "digits/pt-meianoite", lang);
    04661             }
    04662             else if (tm.tm_hour == 12) {
    04663                if (format[offset] == 'I')
    04664                   res = wait_file(chan, ints, "digits/pt-ao", lang);
    04665                if (!res)
    04666                   res = wait_file(chan, ints, "digits/pt-meiodia", lang);
    04667             }
    04668             else {
    04669                if (format[offset] == 'I') {
    04670                   res = wait_file(chan, ints, "digits/pt-ah", lang);
    04671                   if ((tm.tm_hour % 12) != 1)
    04672                      if (!res)
    04673                         res = wait_file(chan, ints, "digits/pt-sss", lang);
    04674                }
    04675                if (!res)
    04676                   res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
    04677             }
    04678             break;
    04679          case 'H':
    04680          case 'k':
    04681             /* 24-Hour */
    04682             res = ast_say_number(chan, -tm.tm_hour, ints, lang, NULL);
    04683             if (!res) {
    04684                if (tm.tm_hour != 0) {
    04685                   int remainder = tm.tm_hour;
    04686                   if (tm.tm_hour > 20) {
    04687                      res = wait_file(chan,ints, "digits/20",lang);
    04688                      remainder -= 20;
    04689                   }
    04690                   if (!res) {
    04691                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", remainder);
    04692                      res = wait_file(chan,ints,nextmsg,lang);
    04693                   }
    04694                }
    04695             }
    04696             break;
    04697          case 'M':
    04698             /* Minute */
    04699             if (tm.tm_min == 0) {
    04700                res = wait_file(chan, ints, "digits/pt-hora", lang);
    04701                if (tm.tm_hour != 1)
    04702                   if (!res)
    04703                      res = wait_file(chan, ints, "digits/pt-sss", lang);         } else {
    04704                res = wait_file(chan,ints,"digits/pt-e",lang);
    04705                if (!res)
    04706                   res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    04707             }
    04708             break;
    04709          case 'P':
    04710          case 'p':
    04711             /* AM/PM */
    04712             if (tm.tm_hour > 12)
    04713                res = wait_file(chan, ints, "digits/p-m", lang);
    04714             else if (tm.tm_hour  && tm.tm_hour < 12)
    04715                res = wait_file(chan, ints, "digits/a-m", lang);
    04716             break;
    04717          case 'Q':
    04718             /* Shorthand for "Today", "Yesterday", or ABdY */
    04719             {
    04720                struct timeval now;
    04721                struct tm tmnow;
    04722                time_t beg_today;
    04723
    04724                gettimeofday(&now,NULL);
    04725                ast_localtime(&now.tv_sec,&tmnow,timezone);
    04726                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
    04727                /* In any case, it saves not having to do ast_mktime() */
    04728                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
    04729                if (beg_today < time) {
    04730                   /* Today */
    04731                   res = wait_file(chan,ints, "digits/today",lang);
    04732                } else if (beg_today - 86400 < time) {
    04733                   /* Yesterday */
    04734                   res = wait_file(chan,ints, "digits/yesterday",lang);
    04735                } else {
    04736                   res = ast_say_date_with_format(chan, time, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", timezone);
    04737                }
    04738             }
    04739             break;
    04740          case 'q':
    04741             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
    04742             {
    04743                struct timeval now;
    04744                struct tm tmnow;
    04745                time_t beg_today;
    04746
    04747                gettimeofday(&now,NULL);
    04748                ast_localtime(&now.tv_sec,&tmnow,timezone);
    04749                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
    04750                /* In any case, it saves not having to do ast_mktime() */
    04751                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
    04752                if (beg_today < time) {
    04753                   /* Today */
    04754                } else if ((beg_today - 86400) < time) {
    04755                   /* Yesterday */
    04756                   res = wait_file(chan,ints, "digits/yesterday",lang);
    04757                } else if (beg_today - 86400 * 6 < time) {
    04758                   /* Within the last week */
    04759                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
    04760                } else {
    04761                   res = ast_say_date_with_format(chan, time, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", timezone);
    04762                }
    04763             }
    04764             break;
    04765          case 'R':
    04766             res = ast_say_date_with_format(chan, time, ints, lang, "H 'digits/pt-e' M", timezone);
    04767             break;
    04768          case 'S':
    04769             /* Seconds */
    04770             if (tm.tm_sec == 0) {
    04771                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
    04772                res = wait_file(chan,ints,nextmsg,lang);
    04773             } else if (tm.tm_sec < 10) {
    04774                res = wait_file(chan,ints, "digits/oh",lang);
    04775                if (!res) {
    04776                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
    04777                   res = wait_file(chan,ints,nextmsg,lang);
    04778                }
    04779             } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
    04780                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
    04781                res = wait_file(chan,ints,nextmsg,lang);
    04782             } else {
    04783                int ten, one;
    04784                ten = (tm.tm_sec / 10) * 10;
    04785                one = (tm.tm_sec % 10);
    04786                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
    04787                res = wait_file(chan,ints,nextmsg,lang);
    04788                if (!res) {
    04789                   /* Fifty, not fifty-zero */
    04790                   if (one != 0) {
    04791                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
    04792                      res = wait_file(chan,ints,nextmsg,lang);
    04793                   }
    04794                }
    04795             }
    04796             break;
    04797          case 'T':
    04798             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
    04799             break;
    04800          case ' ':
    04801          case '   ':
    04802             /* Just ignore spaces and tabs */
    04803             break;
    04804          default:
    04805             /* Unknown character */
    04806             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
    04807       }
    04808       /* Jump out on DTMF */
    04809       if (res) {
    04810          break;
    04811       }
    04812    }
    04813    return res;
    04814 }

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

    04818 {
    04819    struct tm tm;
    04820    int res=0, offset, sndoffset;
    04821    char sndfile[256], nextmsg[256];
    04822
    04823    ast_localtime(&time,&tm,timezone);
    04824
    04825    for (offset=0 ; format[offset] != '\0' ; offset++) {
    04826       ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
    04827       switch (format[offset]) {
    04828          /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
    04829          case '\'':
    04830             /* Literal name of a sound file */
    04831             sndoffset=0;
    04832             for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
    04833                sndfile[sndoffset] = format[offset];
    04834             sndfile[sndoffset] = '\0';
    04835             res = wait_file(chan,ints,sndfile,lang);
    04836             break;
    04837          case 'A':
    04838          case 'a':
    04839             /* Sunday - Saturday */
    04840             snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
    04841             res = wait_file(chan,ints,nextmsg,lang);
    04842             break;
    04843          case 'B':
    04844          case 'b':
    04845          case 'h':
    04846             /* January - December */
    04847             snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
    04848             res = wait_file(chan,ints,nextmsg,lang);
    04849             break;
    04850          case 'm':
    04851             /* First - Twelfth */
    04852             snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
    04853             res = wait_file(chan,ints,nextmsg,lang);
    04854             break;
    04855          case 'd':
    04856          case 'e':
    04857             /* First - Thirtyfirst */
    04858             if (!(tm.tm_mday % 10) || (tm.tm_mday < 10)) {
    04859                snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
    04860                res = wait_file(chan,ints,nextmsg,lang);
    04861             } else {
    04862                snprintf(nextmsg,sizeof(nextmsg), "digits/h-%dh", tm.tm_mday - (tm.tm_mday % 10));
    04863                res = wait_file(chan,ints,nextmsg,lang);
    04864                if(!res) {
    04865                   snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday % 10);
    04866                   res = wait_file(chan,ints,nextmsg,lang);
    04867                }
    04868             }
    04869             break;
    04870          case 'Y':
    04871             /* Year */
    04872             if (tm.tm_year > 99) {
    04873                res = wait_file(chan,ints, "digits/2",lang);
    04874                if (!res) {
    04875                   res = wait_file(chan,ints, "digits/thousand",lang);
    04876                }
    04877                if (tm.tm_year > 100) {
    04878                   if (!res) {
    04879                      snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) / 10);
    04880                      res = wait_file(chan,ints,nextmsg,lang);
    04881                      if (!res) {
    04882                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) % 10);
    04883                         res = wait_file(chan,ints,nextmsg,lang);
    04884                      }
    04885                   }
    04886                }
    04887                if (!res) {
    04888                   res = wait_file(chan,ints, "digits/year",lang);
    04889                }
    04890             } else {
    04891                if (tm.tm_year < 1) {
    04892                   /* I'm not going to handle 1900 and prior */
    04893                   /* We'll just be silent on the year, instead of bombing out. */
    04894                } else {
    04895                   res = wait_file(chan,ints, "digits/1",lang);
    04896                   if (!res) {
    04897                      res = wait_file(chan,ints, "digits/9",lang);
    04898                   }
    04899                   if (!res) {
    04900                      if (tm.tm_year <= 9) {
    04901                         /* 1901 - 1909 */
    04902                         res = wait_file(chan,ints, "digits/0",lang);
    04903                         if (!res) {
    04904                            snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
    04905                            res = wait_file(chan,ints,nextmsg,lang);
    04906                         }
    04907                      } else {
    04908                         /* 1910 - 1999 */
    04909                         snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year / 10);
    04910                         res = wait_file(chan,ints,nextmsg,lang);
    04911                         if (!res) {
    04912                            snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year % 10);
    04913                            res = wait_file(chan,ints,nextmsg,lang);
    04914                         }
    04915                      }
    04916                   }
    04917                }
    04918                if (!res) {
    04919                   res = wait_file(chan,ints, "digits/year",lang);
    04920                }
    04921             }
    04922             break;
    04923          case 'I':
    04924          case 'l':
    04925             /* 12-Hour */
    04926             if (tm.tm_hour == 0)
    04927                snprintf(nextmsg,sizeof(nextmsg), "digits/12");
    04928             else if (tm.tm_hour > 12)
    04929                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
    04930             else
    04931                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
    04932             res = wait_file(chan,ints,nextmsg,lang);
    04933             if (!res) {
    04934                res = wait_file(chan,ints, "digits/oclock",lang);
    04935             }
    04936             break;
    04937          case 'H':
    04938          case 'k':
    04939             /* 24-Hour */
    04940             if (!(tm.tm_hour % 10) || tm.tm_hour < 10) {
    04941                if (tm.tm_hour < 10) {
    04942                   res = wait_file(chan, ints, "digits/0", lang);
    04943                }
    04944                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
    04945                res = wait_file(chan,ints,nextmsg,lang);
    04946             } else {
    04947                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - (tm.tm_hour % 10));
    04948                res = wait_file(chan,ints,nextmsg,lang);
    04949                if (!res) {
    04950                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour % 10);
    04951                   res = wait_file(chan,ints,nextmsg,lang);
    04952                }
    04953             }
    04954             if (!res) {
    04955                res = wait_file(chan,ints, "digits/oclock",lang);
    04956             }
    04957             break;
    04958          case 'M':
    04959             /* Minute */
    04960             if (!(tm.tm_min % 10) || tm.tm_min < 10) {
    04961                if (tm.tm_min < 10) {
    04962                   res = wait_file(chan, ints, "digits/0", lang);
    04963                }
    04964                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min);
    04965                res = wait_file(chan,ints,nextmsg,lang);
    04966             } else {
    04967                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min - (tm.tm_min % 10));
    04968                res = wait_file(chan,ints,nextmsg,lang);
    04969                if (!res) {
    04970                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min % 10);
    04971                   res = wait_file(chan,ints,nextmsg,lang);
    04972                }
    04973             }
    04974             if (!res) {
    04975                res = wait_file(chan,ints, "digits/minute",lang);
    04976             }
    04977             break;
    04978          case 'P':
    04979          case 'p':
    04980             /* AM/PM */
    04981             if (tm.tm_hour > 11)
    04982                snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
    04983             else
    04984                snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
    04985             res = wait_file(chan,ints,nextmsg,lang);
    04986             break;
    04987          case 'Q':
    04988             /* Shorthand for "Today", "Yesterday", or ABdY */
    04989             {
    04990                struct timeval now;
    04991                struct tm tmnow;
    04992                time_t beg_today;
    04993
    04994                gettimeofday(&now,NULL);
    04995                ast_localtime(&now.tv_sec,&tmnow,timezone);
    04996                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
    04997                /* In any case, it saves not having to do ast_mktime() */
    04998                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
    04999                if (beg_today < time) {
    05000                   /* Today */
    05001                   res = wait_file(chan,ints, "digits/today",lang);
    05002                } else if (beg_today - 86400 < time) {
    05003                   /* Yesterday */
    05004                   res = wait_file(chan,ints, "digits/yesterday",lang);
    05005                } else {
    05006                   res = ast_say_date_with_format(chan, time, ints, lang, "YBdA", timezone);
    05007                }
    05008             }
    05009             break;
    05010          case 'q':
    05011             /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
    05012             {
    05013                struct timeval now;
    05014                struct tm tmnow;
    05015                time_t beg_today;
    05016
    05017                gettimeofday(&now,NULL);
    05018                ast_localtime(&now.tv_sec,&tmnow,timezone);
    05019                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
    05020                /* In any case, it saves not having to do ast_mktime() */
    05021                beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
    05022                if (beg_today < time) {
    05023                   /* Today */
    05024                } else if ((beg_today - 86400) < time) {
    05025                   /* Yesterday */
    05026                   res = wait_file(chan,ints, "digits/yesterday",lang);
    05027                } else if (beg_today - 86400 * 6 < time) {
    05028                   /* Within the last week */
    05029                   res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
    05030                } else {
    05031                   res = ast_say_date_with_format(chan, time, ints, lang, "YBdA", timezone);
    05032                }
    05033             }
    05034             break;
    05035          case 'R':
    05036             res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
    05037             break;
    05038          case 'S':
    05039             /* Seconds */
    05040             if (!(tm.tm_sec % 10) || tm.tm_sec < 10) {
    05041                if (tm.tm_sec < 10) {
    05042                   res = wait_file(chan, ints, "digits/0", lang);
    05043                }
    05044                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
    05045                res = wait_file(chan,ints,nextmsg,lang);
    05046             } else {
    05047                snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec - (tm.tm_sec % 10));
    05048                res = wait_file(chan,ints,nextmsg,lang);
    05049                if (!res) {
    05050                   snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec % 10);
    05051                   res = wait_file(chan,ints,nextmsg,lang);
    05052                }
    05053             }
    05054             if (!res) {
    05055                res = wait_file(chan,ints, "digits/second",lang);
    05056             }
    05057             break;
    05058          case 'T':
    05059             res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
    05060             break;
    05061          case ' ':
    05062          case '   ':
    05063             /* Just ignore spaces and tabs */
    05064          break;
    05065          default:
    05066             /* Unknown character */
    05067             ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
    05068       }
    05069       /* Jump out on DTMF */
    05070       if (res) {
    05071          break;
    05072       }
    05073    }
    05074    return res;
    05075 }

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

Definition at line 5266 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(), and ast_say_datetime_tw().

Referenced by datetime_exec().

    05267 {
    05268    if (!strcasecmp(lang, "en") ) {  /* English syntax */
    05269       return(ast_say_datetime_en(chan, t, ints, lang));
    05270    } else if (!strcasecmp(lang, "de") ) { /* German syntax */
    05271       return(ast_say_datetime_de(chan, t, ints, lang));
    05272    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
    05273       return(ast_say_datetime_fr(chan, t, ints, lang));
    05274    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
    05275       return(ast_say_datetime_nl(chan, t, ints, lang));
    05276    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
    05277       return(ast_say_datetime_pt(chan, t, ints, lang));
    05278    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
    05279       return(ast_say_datetime_tw(chan, t, ints, lang));
    05280    } else if (!strcasecmp(lang, "gr") ) {          /* Greek syntax */
    05281       return(ast_say_datetime_gr(chan, t, ints, lang));
    05282    }
    05283
    05284    /* Default to English */
    05285    return(ast_say_datetime_en(chan, t, ints, lang));
    05286 }

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

Definition at line 5354 of file say.c.

References ast_say_date(), and ast_say_time().

Referenced by ast_say_datetime().

    05355 {
    05356    struct tm tm;
    05357    int res = 0;
    05358    localtime_r(&t,&tm);
    05359    res = ast_say_date(chan, t, ints, lang);
    05360    if (!res)
    05361       ast_say_time(chan, t, ints, lang);
    05362    return res;
    05363
    05364 }

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

Definition at line 5289 of file say.c.

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

Referenced by ast_say_datetime().

    05290 {
    05291    struct tm tm;
    05292    char fn[256];
    05293    int res = 0;
    05294    int hour, pm=0;
    05295    localtime_r(&t,&tm);
    05296    if (!res) {
    05297       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05298       res = ast_streamfile(chan, fn, lang);
    05299       if (!res)
    05300          res = ast_waitstream(chan, ints);
    05301    }
    05302    if (!res) {
    05303       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05304       res = ast_streamfile(chan, fn, lang);
    05305       if (!res)
    05306          res = ast_waitstream(chan, ints);
    05307    }
    05308    if (!res)
    05309       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
    05310
    05311    hour = tm.tm_hour;
    05312    if (!hour)
    05313       hour = 12;
    05314    else if (hour == 12)
    05315       pm = 1;
    05316    else if (hour > 12) {
    05317       hour -= 12;
    05318       pm = 1;
    05319    }
    05320    if (!res)
    05321       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
    05322
    05323    if (tm.tm_min > 9) {
    05324       if (!res)
    05325          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05326    } else if (tm.tm_min) {
    05327       if (!res)
    05328          res = ast_streamfile(chan, "digits/oh", lang);
    05329       if (!res)
    05330          res = ast_waitstream(chan, ints);
    05331       if (!res)
    05332          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05333    } else {
    05334       if (!res)
    05335          res = ast_streamfile(chan, "digits/oclock", lang);
    05336       if (!res)
    05337          res = ast_waitstream(chan, ints);
    05338    }
    05339    if (pm) {
    05340       if (!res)
    05341          res = ast_streamfile(chan, "digits/p-m", lang);
    05342    } else {
    05343       if (!res)
    05344          res = ast_streamfile(chan, "digits/a-m", lang);
    05345    }
    05346    if (!res)
    05347       res = ast_waitstream(chan, ints);
    05348    if (!res)
    05349       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
    05350    return res;
    05351 }

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

Definition at line 5367 of file say.c.

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

Referenced by ast_say_datetime().

    05368 {
    05369    struct tm tm;
    05370    char fn[256];
    05371    int res = 0;
    05372    localtime_r(&t,&tm);
    05373
    05374    if (!res)
    05375       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
    05376
    05377    if (!res) {
    05378       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05379       res = ast_streamfile(chan, fn, lang);
    05380       if (!res)
    05381          res = ast_waitstream(chan, ints);
    05382    }
    05383    if (!res) {
    05384       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05385       res = ast_streamfile(chan, fn, lang);
    05386       if (!res)
    05387          res = ast_waitstream(chan, ints);
    05388    }
    05389
    05390    if (!res)
    05391       res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
    05392    if (!res)
    05393          res = ast_streamfile(chan, "digits/oclock", lang);
    05394    if (tm.tm_min > 0) {
    05395       if (!res)
    05396          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05397    }
    05398    if (!res)
    05399       res = ast_waitstream(chan, ints);
    05400    if (!res)
    05401       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
    05402    return res;
    05403 }

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

Definition at line 5545 of file say.c.

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

    05546 {
    05547    if (!strcasecmp(lang, "en") ) {  /* English syntax */
    05548       return(ast_say_datetime_from_now_en(chan, t, ints, lang));
    05549    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
    05550       return(ast_say_datetime_from_now_fr(chan, t, ints, lang));
    05551    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
    05552       return(ast_say_datetime_from_now_pt(chan, t, ints, lang));
    05553    }
    05554
    05555    /* Default to English */
    05556    return(ast_say_datetime_from_now_en(chan, t, ints, lang));
    05557 }

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

Definition at line 5560 of file say.c.

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

Referenced by ast_say_datetime_from_now().

    05561 {
    05562    int res=0;
    05563    time_t nowt;
    05564    int daydiff;
    05565    struct tm tm;
    05566    struct tm now;
    05567    char fn[256];
    05568
    05569    time(&nowt);
    05570
    05571    localtime_r(&t,&tm);
    05572    localtime_r(&nowt,&now);
    05573    daydiff = now.tm_yday - tm.tm_yday;
    05574    if ((daydiff < 0) || (daydiff > 6)) {
    05575       /* Day of month and month */
    05576       if (!res) {
    05577          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05578          res = ast_streamfile(chan, fn, lang);
    05579          if (!res)
    05580             res = ast_waitstream(chan, ints);
    05581       }
    05582       if (!res)
    05583          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
    05584
    05585    } else if (daydiff) {
    05586       /* Just what day of the week */
    05587       if (!res) {
    05588          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05589          res = ast_streamfile(chan, fn, lang);
    05590          if (!res)
    05591             res = ast_waitstream(chan, ints);
    05592       }
    05593    } /* Otherwise, it was today */
    05594    if (!res)
    05595       res = ast_say_time(chan, t, ints, lang);
    05596    return res;
    05597 }

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

Definition at line 5600 of file say.c.

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

Referenced by ast_say_datetime_from_now().

    05601 {
    05602    int res=0;
    05603    time_t nowt;
    05604    int daydiff;
    05605    struct tm tm;
    05606    struct tm now;
    05607    char fn[256];
    05608
    05609    time(&nowt);
    05610
    05611    localtime_r(&t,&tm);
    05612    localtime_r(&nowt,&now);
    05613    daydiff = now.tm_yday - tm.tm_yday;
    05614    if ((daydiff < 0) || (daydiff > 6)) {
    05615       /* Day of month and month */
    05616       if (!res) {
    05617          snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05618          res = ast_streamfile(chan, fn, lang);
    05619          if (!res)
    05620             res = ast_waitstream(chan, ints);
    05621       }
    05622       if (!res)
    05623          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
    05624
    05625    } else if (daydiff) {
    05626       /* Just what day of the week */
    05627       if (!res) {
    05628          snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05629          res = ast_streamfile(chan, fn, lang);
    05630          if (!res)
    05631             res = ast_waitstream(chan, ints);
    05632       }
    05633    } /* Otherwise, it was today */
    05634    if (!res)
    05635       res = ast_say_time(chan, t, ints, lang);
    05636    return res;
    05637 }

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

Definition at line 5640 of file say.c.

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

Referenced by ast_say_datetime_from_now().

    05641 {
    05642    int res=0;
    05643    time_t nowt;
    05644    int daydiff;
    05645    struct tm tm;
    05646    struct tm now;
    05647    char fn[256];
    05648
    05649    time(&nowt);
    05650
    05651    localtime_r(&t,&tm);
    05652    localtime_r(&nowt,&now);
    05653    daydiff = now.tm_yday - tm.tm_yday;
    05654    if ((daydiff < 0) || (daydiff > 6)) {
    05655       /* Day of month and month */
    05656       if (!res)
    05657          res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
    05658       if (!res)
    05659          res = wait_file(chan, ints, "digits/pt-de", lang);
    05660       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05661       if (!res)
    05662          res = wait_file(chan, ints, fn, lang);
    05663
    05664    } else if (daydiff) {
    05665       /* Just what day of the week */
    05666       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05667       if (!res)
    05668          res = wait_file(chan, ints, fn, lang);
    05669    }  /* Otherwise, it was today */
    05670    snprintf(fn, sizeof(fn), "digits/pt-ah");
    05671    if (!res)
    05672       res = wait_file(chan, ints, fn, lang);
    05673    if (tm.tm_hour != 1)
    05674    if (!res)
    05675       res = wait_file(chan, ints, "digits/pt-sss", lang);
    05676    if (!res)
    05677       res = ast_say_time(chan, t, ints, lang);
    05678    return res;
    05679 }

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

Definition at line 5905 of file say.c.

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

Referenced by ast_say_datetime().

    05906 {
    05907    struct tm tm;
    05908    char fn[256];
    05909    int res = 0;
    05910    localtime_r(&t,&tm);
    05911
    05912
    05913    /* W E E K - D A Y */
    05914    if (!res) {
    05915       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05916       res = ast_streamfile(chan, fn, lang);
    05917       if (!res)
    05918          res = ast_waitstream(chan, ints);
    05919    }
    05920    /* D A Y */
    05921    if (!res) {
    05922       gr_say_number_female(tm.tm_mday, chan, ints, lang);
    05923    }
    05924    /* M O N T H */
    05925    if (!res) {
    05926       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05927       res = ast_streamfile(chan, fn, lang);
    05928       if (!res)
    05929          res = ast_waitstream(chan, ints);
    05930    }
    05931
    05932    res = ast_say_time_gr(chan, t, ints, lang);
    05933    return res;
    05934 }

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

Definition at line 5406 of file say.c.

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

Referenced by ast_say_datetime().

    05407 {
    05408    struct tm tm;
    05409    int res = 0;
    05410    localtime_r(&t,&tm);
    05411    res = ast_say_date(chan, t, ints, lang);
    05412    if (!res) {
    05413       res = ast_streamfile(chan, "digits/nl-om", lang);
    05414       if (!res)
    05415          res = ast_waitstream(chan, ints);
    05416    }
    05417    if (!res)
    05418       ast_say_time(chan, t, ints, lang);
    05419    return res;
    05420 }

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

Definition at line 5423 of file say.c.

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

Referenced by ast_say_datetime().

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

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

Definition at line 5488 of file say.c.

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

Referenced by ast_say_datetime().

    05489 {
    05490    struct tm tm;
    05491    char fn[256];
    05492    int res = 0;
    05493    int hour, pm=0;
    05494    localtime_r(&t,&tm);
    05495    if (!res)
    05496       res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
    05497    if (!res) {
    05498       snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
    05499       res = ast_streamfile(chan, fn, lang);
    05500       if (!res)
    05501          res = ast_waitstream(chan, ints);
    05502    }
    05503    if (!res)
    05504       res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
    05505    if (!res) {
    05506       snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
    05507       res = ast_streamfile(chan, fn, lang);
    05508       if (!res)
    05509          res = ast_waitstream(chan, ints);
    05510    }
    05511
    05512    hour = tm.tm_hour;
    05513    if (!hour)
    05514       hour = 12;
    05515    else if (hour == 12)
    05516       pm = 1;
    05517    else if (hour > 12) {
    05518       hour -= 12;
    05519       pm = 1;
    05520    }
    05521    if (pm) {
    05522       if (!res)
    05523          res = ast_streamfile(chan, "digits/p-m", lang);
    05524    } else {
    05525       if (!res)
    05526          res = ast_streamfile(chan, "digits/a-m", lang);
    05527    }
    05528    if (!res)
    05529       res = ast_waitstream(chan, ints);
    05530    if (!res)
    05531       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
    05532    if (!res)
    05533       res = ast_streamfile(chan, "digits/oclock", lang);
    05534    if (!res)
    05535       res = ast_waitstream(chan, ints);
    05536    if (!res)
    05537       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05538    if (!res)
    05539       res = ast_streamfile(chan, "digits/minute", lang);
    05540    if (!res)
    05541       res = ast_waitstream(chan, ints);
    05542    return res;
    05543 }

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

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

    00275 {
    00276    return ast_say_digit_str_full(chan, str, ints, lang, -1, -1);
    00277 }

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

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

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

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

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

Definition at line 287 of file say.c.

References ast_say_digits_full().

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

    00288 {
    00289    return ast_say_digits_full(chan, num, ints, lang, -1, -1);
    00290 }

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

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

    00280 {
    00281    char fn2[256];
    00282
    00283    snprintf(fn2, sizeof(fn2), "%d", num);
    00284    return ast_say_digit_str_full(chan, fn2, ints, lang, audiofd, ctrlfd);
    00285 }

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

    02302 {
    02303    return(ast_say_enumeration_full(chan, num, ints, language, options, -1, -1));
    02304 }

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

    02287 {
    02288    if (!strcasecmp(language,"en") ) {  /* English syntax */
    02289       return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd));
    02290    } else if (!strcasecmp(language, "da") ) {   /* Danish syntax */
    02291       return(ast_say_enumeration_full_da(chan, num, ints, language, options, audiofd, ctrlfd));
    02292    } else if (!strcasecmp(language, "de") ) {   /* German syntax */
    02293       return(ast_say_enumeration_full_de(chan, num, ints, language, options, audiofd, ctrlfd));
    02294    }
    02295
    02296    /* Default to english */
    02297    return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd));
    02298 }

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

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

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

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

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

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

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 469 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_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(), and vm_intro_pt().

    00470 {
    00471    return(ast_say_number_full(chan, num, ints, language, options, -1, -1));
    00472 }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    05735 {
    05736    int res = 0;
    05737    char fn[256] = "";
    05738    int i=0;
    05739
    05740
    05741    if (!num) {
    05742       snprintf(fn, sizeof(fn), "digits/0");
    05743       res = ast_streamfile(chan, fn, chan->language);
    05744       if (!res)
    05745          return  ast_waitstream(chan, ints);
    05746    }
    05747
    05748    while(!res && num ) {
    05749       i++;
    05750       if (num < 13) {
    05751          snprintf(fn, sizeof(fn), "digits/%d", num);
    05752          num = 0;
    05753       } else if (num <= 100) {
    05754          /* 13 < num <= 100  */
    05755          snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
    05756          num -= ((num / 10) * 10);
    05757       } else if (num < 200) {
    05758          /* 100 < num < 200 */
    05759          snprintf(fn, sizeof(fn), "digits/hundred-100");
    05760          num -= ((num / 100) * 100);
    05761       }else if (num < 1000) {
    05762          /* 200 < num < 1000 */
    05763          snprintf(fn, sizeof(fn), "digits/hundred-%d", (num/100)*100);
    05764          num -= ((num / 100) * 100);
    05765       }else if (num < 2000){
    05766          snprintf(fn, sizeof(fn), "digits/xilia");
    05767          num -= ((num / 1000) * 1000);
    05768       }
    05769       else {
    05770          /* num >  1000 */
    05771          if (num < 1000000) {
    05772             res = ast_say_number_full_gr(chan, (num / 1000), ints, chan->language, audiofd, ctrlfd);
    05773             if (res)
    05774                return res;
    05775             num = num % 1000;
    05776             snprintf(fn, sizeof(fn), "digits/thousands");
    05777          }  else {
    05778             if (num < 1000000000) { /* 1,000,000,000 */
    05779                res = ast_say_number_full_gr(chan, (num / 1000000), ints, chan->language ,audiofd, ctrlfd);
    05780                if (res)
    05781                   return res;
    05782                num = num % 1000000;
    05783                snprintf(fn, sizeof(fn), "digits/millions");
    05784             } else {
    05785                ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
    05786                res = -1;
    05787             }
    05788          }
    05789       }
    05790       if (!res) {
    05791          if(!ast_streamfile(chan, fn, language)) {
    05792             if ((audiofd > -1) && (ctrlfd > -1))
    05793                res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
    05794             else
    05795                res = ast_waitstream(chan, ints);
    05796          }
    05797          ast_stopstream(chan);
    05798       }
    05799    }
    05800    return res;
    05801 }

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

Definition at line 1229 of file say.c.

References ast_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().

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

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

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

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

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

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

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

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

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

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

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

Referenced by ast_say_number_full().

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

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

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

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

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

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

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

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

Definition at line 219 of file say.c.

References ast_say_phonetic_str_full().

Referenced by pbx_builtin_sayphonetic().

    00220 {
    00221    return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
    00222 }

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

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

Referenced by ast_say_phonetic_str(), and handle_sayphonetic().

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

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

Definition at line 5077 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(), 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(), handle_saytime(), and rpt_tele_thread().

    05078 {
    05079    if (!strcasecmp(lang, "en") ) {  /* English syntax */
    05080       return(ast_say_time_en(chan, t, ints, lang));
    05081    } else if (!strcasecmp(lang, "de") ) { /* German syntax */
    05082       return(ast_say_time_de(chan, t, ints, lang));
    05083    } else if (!strcasecmp(lang, "fr") ) { /* French syntax */
    05084       return(ast_say_time_fr(chan, t, ints, lang));
    05085    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
    05086       return(ast_say_time_nl(chan, t, ints, lang));
    05087    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
    05088       return(ast_say_time_pt(chan, t, ints, lang));
    05089    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
    05090       return(ast_say_time_tw(chan, t, ints, lang));
    05091    } else if (!strcasecmp(lang, "gr") ) {          /* Greek syntax */
    05092       return(ast_say_time_gr(chan, t, ints, lang));
    05093    }
    05094
    05095    /* Default to English */
    05096    return(ast_say_time_en(chan, t, ints, lang));
    05097 }

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

Definition at line 5147 of file say.c.

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

Referenced by ast_say_time().

    05148 {
    05149    struct tm tm;
    05150    int res = 0;
    05151    localtime_r(&t,&tm);
    05152    if (!res)
    05153       res = ast_say_number(chan, tm.tm_hour, ints, lang, "n");
    05154    if (!res)
    05155       res = ast_streamfile(chan, "digits/oclock", lang);
    05156    if (!res)
    05157       res = ast_waitstream(chan, ints);
    05158    if (!res)
    05159        if (tm.tm_min > 0)
    05160       res = ast_say_number(chan, tm.tm_min, ints, lang, "f");
    05161    return res;
    05162 }

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

Definition at line 5100 of file say.c.

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

Referenced by ast_say_time().

    05101 {
    05102    struct tm tm;
    05103    int res = 0;
    05104    int hour, pm=0;
    05105    localtime_r(&t,&tm);
    05106    hour = tm.tm_hour;
    05107    if (!hour)
    05108       hour = 12;
    05109    else if (hour == 12)
    05110       pm = 1;
    05111    else if (hour > 12) {
    05112       hour -= 12;
    05113       pm = 1;
    05114    }
    05115    if (!res)
    05116       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
    05117
    05118    if (tm.tm_min > 9) {
    05119       if (!res)
    05120          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05121    } else if (tm.tm_min) {
    05122       if (!res)
    05123          res = ast_streamfile(chan, "digits/oh", lang);
    05124       if (!res)
    05125          res = ast_waitstream(chan, ints);
    05126       if (!res)
    05127          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05128    } else {
    05129       if (!res)
    05130          res = ast_streamfile(chan, "digits/oclock", lang);
    05131       if (!res)
    05132          res = ast_waitstream(chan, ints);
    05133    }
    05134    if (pm) {
    05135       if (!res)
    05136          res = ast_streamfile(chan, "digits/p-m", lang);
    05137    } else {
    05138       if (!res)
    05139          res = ast_streamfile(chan, "digits/a-m", lang);
    05140    }
    05141    if (!res)
    05142       res = ast_waitstream(chan, ints);
    05143    return res;
    05144 }

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

Definition at line 5165 of file say.c.

References ast_say_number(), and ast_streamfile().

Referenced by ast_say_time().

    05166 {
    05167    struct tm tm;
    05168    int res = 0;
    05169    localtime_r(&t,&tm);
    05170
    05171    res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
    05172    if (!res)
    05173       res = ast_streamfile(chan, "digits/oclock", lang);
    05174    if (tm.tm_min) {
    05175       if (!res)
    05176       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05177    }
    05178    return res;
    05179 }

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

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

    05859 {
    05860
    05861    struct tm tm;
    05862    int res = 0;
    05863    int hour, pm=0;
    05864
    05865    localtime_r(&t,&tm);
    05866    hour = tm.tm_hour;
    05867
    05868    if (!hour)
    05869       hour = 12;
    05870    else if (hour == 12)
    05871       pm = 1;
    05872    else if (hour > 12) {
    05873       hour -= 12;
    05874       pm = 1;
    05875    }
    05876
    05877    res = gr_say_number_female(hour, chan, ints, lang);
    05878    if (tm.tm_min) {
    05879       if (!res)
    05880          res = ast_streamfile(chan, "digits/kai", lang);
    05881       if (!res)
    05882          res = ast_waitstream(chan, ints);
    05883       if (!res)
    05884          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05885    } else {
    05886       if (!res)
    05887          res = ast_streamfile(chan, "digits/hwra", lang);
    05888       if (!res)
    05889          res = ast_waitstream(chan, ints);
    05890    }
    05891    if (pm) {
    05892       if (!res)
    05893          res = ast_streamfile(chan, "digits/p-m", lang);
    05894    } else {
    05895       if (!res)
    05896          res = ast_streamfile(chan, "digits/a-m", lang);
    05897    }
    05898    if (!res)
    05899       res = ast_waitstream(chan, ints);
    05900    return res;
    05901 }

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

Definition at line 5182 of file say.c.

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

Referenced by ast_say_time().

    05183 {
    05184    struct tm tm;
    05185    int res = 0;
    05186    localtime_r(&t,&tm);
    05187    if (!res)
    05188       res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL);
    05189    if (!res)
    05190       res = ast_streamfile(chan, "digits/nl-uur", lang);
    05191    if (!res)
    05192       res = ast_waitstream(chan, ints);
    05193    if (!res)
    05194        if (tm.tm_min > 0)
    05195       res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
    05196    return res;
    05197 }

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

Definition at line 5200 of file say.c.

References ast_say_number(), and wait_file().

Referenced by ast_say_time().

    05201 {
    05202    struct tm tm;
    05203    int res = 0;
    05204    int hour;
    05205    localtime_r(&t,&tm);
    05206    hour = tm.tm_hour;
    05207    if (!res)
    05208       res = ast_say_number(chan, hour, ints, lang, "f");
    05209    if (tm.tm_min) {
    05210       if (!res)
    05211          res = wait_file(chan, ints, "digits/pt-e", lang);
    05212       if (!res)
    05213          res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05214    } else {
    05215       if (!res)
    05216          res = wait_file(chan, ints, "digits/pt-hora", lang);
    05217       if (tm.tm_hour != 1)
    05218          if (!res)
    05219             res = wait_file(chan, ints, "digits/pt-sss", lang);
    05220    }
    05221    if (!res)
    05222       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
    05223    return res;
    05224 }

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

Definition at line 5227 of file say.c.

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

Referenced by ast_say_time().

    05228 {
    05229    struct tm tm;
    05230    int res = 0;
    05231    int hour, pm=0;
    05232    localtime_r(&t,&tm);
    05233    hour = tm.tm_hour;
    05234    if (!hour)
    05235       hour = 12;
    05236    else if (hour == 12)
    05237       pm = 1;
    05238    else if (hour > 12) {
    05239       hour -= 12;
    05240       pm = 1;
    05241    }
    05242    if (pm) {
    05243       if (!res)
    05244          res = ast_streamfile(chan, "digits/p-m", lang);
    05245    } else {
    05246       if (!res)
    05247          res = ast_streamfile(chan, "digits/a-m", lang);
    05248    }
    05249    if (!res)
    05250       res = ast_waitstream(chan, ints);
    05251    if (!res)
    05252       res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
    05253    if (!res)
    05254       res = ast_streamfile(chan, "digits/oclock", lang);
    05255    if (!res)
    05256       res = ast_waitstream(chan, ints);
    05257    if (!res)
    05258       res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
    05259    if (!res)
    05260       res = ast_streamfile(chan, "digits/minute", lang);
    05261    if (!res)
    05262       res = ast_waitstream(chan, ints);
    05263    return res;
    05264 }

static int exp10_int | ( | int | power | ) | `[static]`

Definition at line 540 of file say.c.

Referenced by ast_say_number_full_cz().

    00541 {
    00542    int x, res= 1;
    00543    for (x=0;x<power;x++)
    00544       res *= 10;
    00545    return res;
    00546 }

static int get_lastdigits_ru | ( | int | num | ) | `[static]`

determine last digits for thousands/millions (ru)

Definition at line 2179 of file say.c.

Referenced by ast_say_number_full_ru().

    02179                                       {
    02180    if (num < 20) {
    02181       return num;
    02182    } else if (num < 100) {
    02183       return get_lastdigits_ru(num % 10);
    02184    } else if (num < 1000) {
    02185       return get_lastdigits_ru(num % 100);
    02186    }
    02187    return 0;   /* number too big */
    02188 }

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

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

    05688                                                                                                       {
    05689    int tmp;
    05690    int left;
    05691    int res;
    05692    char fn[256] = "";
    05693
    05694    /* ast_log(LOG_DEBUG, "\n\n Saying number female %s %d \n\n",lang, num); */
    05695    if (num < 5) {
    05696       snprintf(fn, sizeof(fn), "digits/female-%d", num);
    05697       res = wait_file(chan, ints, fn, lang);
    05698    } else if (num < 13) {
    05699       res = ast_say_number(chan, num, ints, lang, (char *) NULL);
    05700    } else if (num <100 ) {
    05701       tmp = (num/10) * 10;
    05702       left = num - tmp;
    05703       snprintf(fn, sizeof(fn), "digits/%d", tmp);
    05704       res = ast_streamfile(chan, fn, lang);
    05705       if (!res)
    05706          res = ast_waitstream(chan, ints);
    05707       if (left)
    05708          gr_say_number_female(left, chan, ints, lang);
    05709
    05710    } else {
    05711       return -1;
    05712    }
    05713    return res;
    05714 }

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

Definition at line 1674 of file say.c.

Referenced by powiedz().

    01675 {
    01676    strcpy(buffer, str);
    01677    buffer += strlen(str);
    01678    return buffer;
    01679 }

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

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

Referenced by powiedz().

    01682 {
    01683    char file_name[255] = "digits/";
    01684    strcat(file_name, fn);
    01685    ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name);
    01686    if (!ast_streamfile(chan, file_name, language)) {
    01687       if ((audiofd > -1) && (ctrlfd > -1))
    01688          ast_waitstream_full(chan, ints, audiofd, ctrlfd);
    01689       else
    01690          ast_waitstream(chan, ints);
    01691    }
    01692    ast_stopstream(chan);
    01693 }

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

Definition at line 1661 of file say.c.

References odmiana::rzedy.

Referenced by powiedz().

    01662 {
    01663    if (rzad==0)
    01664       return "";
    01665
    01666    if (i==1)
    01667       return odm->rzedy[rzad - 1][0];
    01668    if ((i > 21 || i < 11) &&  i%10 > 1 && i%10 < 5)
    01669       return odm->rzedy[rzad - 1][1];
    01670    else
    01671       return odm->rzedy[rzad - 1][2];
    01672 }

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

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

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

Definition at line 414 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(), gr_say_number_female(), and play_message().

    00415 {
    00416    int res;
    00417    if ((res = ast_streamfile(chan, file, lang)))
    00418       ast_log(LOG_WARNING, "Unable to play message %s\n", file);
    00419    if (!res)
    00420       res = ast_waitstream(chan, ints);
    00421    return res;
    00422 }