#include "asterisk.h"
#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/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"
Go to the source code of this file.
Data Structures | |
struct | odmiana |
Defines | |
#define | IL_DATE_STR "AdBY" |
#define | IL_DATE_STR_FULL IL_DATE_STR " 'digits/at' " IL_TIME_STR |
#define | IL_TIME_STR "HM" |
#define | SAY_NUM_BUF_SIZE 256 |
Functions | |
static void | __say_init (void) |
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_es (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_ge (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_he (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) |
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_pl (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) |
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) |
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_ge (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_datetime_from_now_he (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_ge (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_he (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_datetime_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_datetime_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_datetime_pt_BR (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_datetime_tw (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_enumeration_full_da (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_enumeration_full_da: Danish syntax | |
static int | ast_say_enumeration_full_de (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_enumeration_full_de: German syntax | |
static int | ast_say_enumeration_full_en (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd) |
ast_say_enumeration_full_en: English syntax | |
static int | ast_say_enumeration_full_he (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
static int | ast_say_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_ge (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_number_full_ge: Georgian syntax | |
static int | ast_say_number_full_gr (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd) |
static int | ast_say_number_full_he (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
static int | ast_say_number_full_it (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd) |
ast_say_number_full_it: Italian | |
static int | ast_say_number_full_nl (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd) |
ast_say_number_full_nl: dutch syntax | |
static int | ast_say_number_full_no (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_number_full_no: Norwegian syntax | |
static int | ast_say_number_full_pl (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
static int | ast_say_number_full_pt (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
static int | ast_say_number_full_ru (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_number_full_ru: Russian syntax additional files: n00.gsm (one hundred, two hundred, ...) thousand.gsm million.gsm thousands-i.gsm (tisyachi) million-a.gsm (milliona) thousands.gsm millions.gsm 1f.gsm (odna) 2f.gsm (dve) | |
static int | ast_say_number_full_se (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_number_full_se: Swedish syntax | |
static int | ast_say_number_full_tw (struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd) |
ast_say_number_full_tw: Taiwanese / Chinese syntax | |
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_es (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_ge (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_he (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_time_nl (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_time_pt (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_time_pt_BR (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | ast_say_time_tw (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static char * | ast_translate_number_ge (int num, char *res, int res_len) |
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 | say_character_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd) |
static int | say_date (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | say_date_with_format (struct ast_channel *chan, time_t time, const char *ints, const char *lang, const char *format, const char *timezone) |
static int | say_datetime (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | say_datetime_from_now (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | say_digit_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd) |
static int | say_enumeration_full (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_enumeration_full: call language-specific functions | |
static int | say_number_full (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) |
ast_say_number_full: call language-specific functions | |
static int | say_phonetic_str_full (struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd) |
static int | say_time (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
static int | wait_file (struct ast_channel *chan, const char *ints, const char *file, const char *lang) |
2007-02-08 : Support for Georgian added by Alexander Shaduri <ashaduri@gmail.com>, Next Generation Networks (NGN).
Definition in file say.c.
#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 3911 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 |
#define IL_TIME_STR "HM" |
#define SAY_NUM_BUF_SIZE 256 |
static void __say_init | ( | void | ) | [static] |
Definition at line 7252 of file say.c.
References ast_say_character_str_full, ast_say_date, ast_say_date_with_format, ast_say_datetime, ast_say_datetime_from_now, ast_say_digit_str_full, ast_say_enumeration_full, ast_say_number_full, ast_say_phonetic_str_full, ast_say_time, say_character_str_full(), say_date(), say_date_with_format(), say_datetime(), say_datetime_from_now(), say_digit_str_full(), say_enumeration_full(), say_number_full(), say_phonetic_str_full(), and say_time().
07253 { 07254 ast_say_number_full = say_number_full; 07255 ast_say_enumeration_full = say_enumeration_full; 07256 ast_say_digit_str_full = say_digit_str_full; 07257 ast_say_character_str_full = say_character_str_full; 07258 ast_say_phonetic_str_full = say_phonetic_str_full; 07259 ast_say_datetime = say_datetime; 07260 ast_say_time = say_time; 07261 ast_say_date = say_date; 07262 ast_say_datetime_from_now = say_datetime_from_now; 07263 ast_say_date_with_format = say_date_with_format; 07264 }
int ast_say_date_da | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 2968 of file say.c.
References ast_localtime(), ast_say_enumeration(), ast_say_number(), ast_streamfile(), ast_waitstream(), and wait_file().
Referenced by say_date().
02969 { 02970 struct tm tm; 02971 char fn[256]; 02972 int res = 0; 02973 ast_localtime(&t,&tm,NULL); 02974 if (!res) { 02975 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 02976 res = ast_streamfile(chan, fn, lang); 02977 if (!res) 02978 res = ast_waitstream(chan, ints); 02979 } 02980 if (!res) 02981 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL); 02982 if (!res) 02983 res = ast_waitstream(chan, ints); 02984 if (!res) { 02985 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 02986 res = ast_streamfile(chan, fn, lang); 02987 if (!res) 02988 res = ast_waitstream(chan, ints); 02989 } 02990 if (!res) { 02991 /* Year */ 02992 int year = tm.tm_year + 1900; 02993 if (year > 1999) { /* year 2000 and later */ 02994 res = ast_say_number(chan, year, ints, lang, (char *) NULL); 02995 } else { 02996 if (year < 1100) { 02997 /* I'm not going to handle 1100 and prior */ 02998 /* We'll just be silent on the year, instead of bombing out. */ 02999 } else { 03000 /* year 1100 to 1999. will anybody need this?!? */ 03001 snprintf(fn,sizeof(fn), "digits/%d", (year / 100) ); 03002 res = wait_file(chan, ints, fn, lang); 03003 if (!res) { 03004 res = wait_file(chan,ints, "digits/hundred", lang); 03005 if (!res && year % 100 != 0) { 03006 res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 03007 } 03008 } 03009 } 03010 } 03011 } 03012 return res; 03013 }
int ast_say_date_de | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 3016 of file say.c.
References ast_localtime(), ast_say_enumeration(), ast_say_number(), ast_streamfile(), ast_waitstream(), and wait_file().
Referenced by say_date().
03017 { 03018 struct tm tm; 03019 char fn[256]; 03020 int res = 0; 03021 ast_localtime(&t,&tm,NULL); 03022 if (!res) { 03023 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03024 res = ast_streamfile(chan, fn, lang); 03025 if (!res) 03026 res = ast_waitstream(chan, ints); 03027 } 03028 if (!res) 03029 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL); 03030 if (!res) 03031 res = ast_waitstream(chan, ints); 03032 if (!res) { 03033 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03034 res = ast_streamfile(chan, fn, lang); 03035 if (!res) 03036 res = ast_waitstream(chan, ints); 03037 } 03038 if (!res) { 03039 /* Year */ 03040 int year = tm.tm_year + 1900; 03041 if (year > 1999) { /* year 2000 and later */ 03042 res = ast_say_number(chan, year, ints, lang, (char *) NULL); 03043 } else { 03044 if (year < 1100) { 03045 /* I'm not going to handle 1100 and prior */ 03046 /* We'll just be silent on the year, instead of bombing out. */ 03047 } else { 03048 /* year 1100 to 1999. will anybody need this?!? */ 03049 /* say 1967 as 'neunzehn hundert sieben und sechzig' */ 03050 snprintf(fn,sizeof(fn), "digits/%d", (year / 100) ); 03051 res = wait_file(chan, ints, fn, lang); 03052 if (!res) { 03053 res = wait_file(chan,ints, "digits/hundred", lang); 03054 if (!res && year % 100 != 0) { 03055 res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 03056 } 03057 } 03058 } 03059 } 03060 } 03061 return res; 03062 }
int ast_say_date_en | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 2940 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
02941 { 02942 struct tm tm; 02943 char fn[256]; 02944 int res = 0; 02945 ast_localtime(&t,&tm,NULL); 02946 if (!res) { 02947 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 02948 res = ast_streamfile(chan, fn, lang); 02949 if (!res) 02950 res = ast_waitstream(chan, ints); 02951 } 02952 if (!res) { 02953 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 02954 res = ast_streamfile(chan, fn, lang); 02955 if (!res) 02956 res = ast_waitstream(chan, ints); 02957 } 02958 if (!res) 02959 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 02960 if (!res) 02961 res = ast_waitstream(chan, ints); 02962 if (!res) 02963 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 02964 return res; 02965 }
int ast_say_date_es | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 3065 of file say.c.
References ast_localtime(), ast_say_number(), ast_waitstream(), and wait_file().
Referenced by say_date().
03066 { 03067 struct tm tm; 03068 char fn[256]; 03069 int res = 0; 03070 ast_localtime(&t,&tm,NULL); 03071 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03072 res = wait_file(chan, ints, fn, lang); 03073 if (!res) { 03074 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 03075 if (!res) 03076 res = ast_waitstream(chan, ints); 03077 } 03078 if (!res) 03079 res = wait_file(chan, ints, "digits/es-de", lang); 03080 if (!res) { 03081 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03082 res = wait_file(chan, ints, fn, lang); 03083 } 03084 if (!res) 03085 res = wait_file(chan, ints, "digits/es-de", lang); 03086 if (!res) { 03087 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03088 if (!res) 03089 res = ast_waitstream(chan, ints); 03090 } 03091 return res; 03092 }
int ast_say_date_fr | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 3095 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
03096 { 03097 struct tm tm; 03098 char fn[256]; 03099 int res = 0; 03100 ast_localtime(&t,&tm,NULL); 03101 if (!res) { 03102 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03103 res = ast_streamfile(chan, fn, lang); 03104 if (!res) 03105 res = ast_waitstream(chan, ints); 03106 } 03107 if (!res) 03108 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 03109 if (!res) 03110 res = ast_waitstream(chan, ints); 03111 if (!res) { 03112 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03113 res = ast_streamfile(chan, fn, lang); 03114 if (!res) 03115 res = ast_waitstream(chan, ints); 03116 } 03117 if (!res) 03118 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03119 return res; 03120 }
static int ast_say_date_ge | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 7120 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
07121 { 07122 struct tm tm; 07123 char fn[256]; 07124 int res = 0; 07125 ast_localtime(&t,&tm,NULL); 07126 07127 if (!res) 07128 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 07129 07130 if (!res) { 07131 snprintf(fn, sizeof(fn), "digits/tslis %d", tm.tm_wday); 07132 res = ast_streamfile(chan, fn, lang); 07133 if (!res) 07134 res = ast_waitstream(chan, ints); 07135 } 07136 07137 if (!res) { 07138 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 07139 /* if (!res) 07140 res = ast_waitstream(chan, ints); 07141 */ 07142 } 07143 07144 if (!res) { 07145 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 07146 res = ast_streamfile(chan, fn, lang); 07147 if (!res) 07148 res = ast_waitstream(chan, ints); 07149 } 07150 return res; 07151 07152 }
static int ast_say_date_gr | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6578 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), and gr_say_number_female().
Referenced by say_date().
06579 { 06580 struct tm tm; 06581 06582 char fn[256]; 06583 int res = 0; 06584 06585 06586 ast_localtime(&t,&tm,NULL); 06587 /* W E E K - D A Y */ 06588 if (!res) { 06589 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06590 res = ast_streamfile(chan, fn, lang); 06591 if (!res) 06592 res = ast_waitstream(chan, ints); 06593 } 06594 /* D A Y */ 06595 if (!res) { 06596 gr_say_number_female(tm.tm_mday, chan, ints, lang); 06597 } 06598 /* M O N T H */ 06599 if (!res) { 06600 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06601 res = ast_streamfile(chan, fn, lang); 06602 if (!res) 06603 res = ast_waitstream(chan, ints); 06604 } 06605 /* Y E A R */ 06606 if (!res) 06607 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 06608 return res; 06609 }
int ast_say_date_he | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 3177 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
03178 { 03179 struct tm tm; 03180 char fn[256]; 03181 int res = 0; 03182 ast_localtime(&t, &tm, NULL); 03183 if (!res) { 03184 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03185 res = ast_streamfile(chan, fn, lang); 03186 if (!res) { 03187 res = ast_waitstream(chan, ints); 03188 } 03189 } 03190 if (!res) { 03191 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03192 res = ast_streamfile(chan, fn, lang); 03193 if (!res) { 03194 res = ast_waitstream(chan, ints); 03195 } 03196 } 03197 if (!res) { 03198 res = ast_say_number(chan, tm.tm_mday, ints, lang, "m"); 03199 } 03200 if (!res) { 03201 res = ast_waitstream(chan, ints); 03202 } 03203 if (!res) { 03204 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, "m"); 03205 } 03206 return res; 03207 }
int ast_say_date_nl | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 3123 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
03124 { 03125 struct tm tm; 03126 char fn[256]; 03127 int res = 0; 03128 ast_localtime(&t,&tm,NULL); 03129 if (!res) { 03130 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03131 res = ast_streamfile(chan, fn, lang); 03132 if (!res) 03133 res = ast_waitstream(chan, ints); 03134 } 03135 if (!res) 03136 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 03137 if (!res) { 03138 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03139 res = ast_streamfile(chan, fn, lang); 03140 if (!res) 03141 res = ast_waitstream(chan, ints); 03142 } 03143 if (!res) 03144 res = ast_waitstream(chan, ints); 03145 if (!res) 03146 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03147 return res; 03148 }
int ast_say_date_pt | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 3151 of file say.c.
References ast_localtime(), ast_say_number(), and wait_file().
Referenced by say_date().
03152 { 03153 struct tm tm; 03154 char fn[256]; 03155 int res = 0; 03156 03157 ast_localtime(&t, &tm, NULL); 03158 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03159 if (!res) 03160 res = wait_file(chan, ints, fn, lang); 03161 if (!res) 03162 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 03163 if (!res) 03164 res = wait_file(chan, ints, "digits/pt-de", lang); 03165 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03166 if (!res) 03167 res = wait_file(chan, ints, fn, lang); 03168 if (!res) 03169 res = wait_file(chan, ints, "digits/pt-de", lang); 03170 if (!res) 03171 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03172 03173 return res; 03174 }
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 3484 of file say.c.
References ast_localtime(), ast_log(), ast_say_enumeration(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
03485 { 03486 struct tm tm; 03487 int res=0, offset, sndoffset; 03488 char sndfile[256], nextmsg[256]; 03489 03490 if (!format) 03491 format = "A dBY HMS"; 03492 03493 ast_localtime(&time,&tm,timezone); 03494 03495 for (offset=0 ; format[offset] != '\0' ; offset++) { 03496 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 03497 switch (format[offset]) { 03498 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 03499 case '\'': 03500 /* Literal name of a sound file */ 03501 sndoffset=0; 03502 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 03503 sndfile[sndoffset] = format[offset]; 03504 sndfile[sndoffset] = '\0'; 03505 res = wait_file(chan,ints,sndfile,lang); 03506 break; 03507 case 'A': 03508 case 'a': 03509 /* Sunday - Saturday */ 03510 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 03511 res = wait_file(chan,ints,nextmsg,lang); 03512 break; 03513 case 'B': 03514 case 'b': 03515 case 'h': 03516 /* January - December */ 03517 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 03518 res = wait_file(chan,ints,nextmsg,lang); 03519 break; 03520 case 'm': 03521 /* Month enumerated */ 03522 res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m"); 03523 break; 03524 case 'd': 03525 case 'e': 03526 /* First - Thirtyfirst */ 03527 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m"); 03528 break; 03529 case 'Y': 03530 /* Year */ 03531 { 03532 int year = tm.tm_year + 1900; 03533 if (year > 1999) { /* year 2000 and later */ 03534 res = ast_say_number(chan, year, ints, lang, (char *) NULL); 03535 } else { 03536 if (year < 1100) { 03537 /* I'm not going to handle 1100 and prior */ 03538 /* We'll just be silent on the year, instead of bombing out. */ 03539 } else { 03540 /* year 1100 to 1999. will anybody need this?!? */ 03541 /* say 1967 as 'nineteen hundred seven and sixty' */ 03542 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (year / 100) ); 03543 res = wait_file(chan,ints,nextmsg,lang); 03544 if (!res) { 03545 res = wait_file(chan,ints, "digits/hundred",lang); 03546 if (!res && year % 100 != 0) { 03547 res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 03548 } 03549 } 03550 } 03551 } 03552 } 03553 break; 03554 case 'I': 03555 case 'l': 03556 /* 12-Hour */ 03557 res = wait_file(chan,ints,"digits/oclock",lang); 03558 if (tm.tm_hour == 0) 03559 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 03560 else if (tm.tm_hour > 12) 03561 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 03562 else 03563 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 03564 if (!res) { 03565 res = wait_file(chan,ints,nextmsg,lang); 03566 } 03567 break; 03568 case 'H': 03569 /* 24-Hour, single digit hours preceeded by "oh" (0) */ 03570 if (tm.tm_hour < 10 && tm.tm_hour > 0) { 03571 res = wait_file(chan,ints, "digits/0",lang); 03572 } 03573 /* FALLTRHU */ 03574 case 'k': 03575 /* 24-Hour */ 03576 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); 03577 break; 03578 case 'M': 03579 /* Minute */ 03580 if (tm.tm_min > 0 || format[offset+ 1 ] == 'S' ) { /* zero 'digits/0' only if seconds follow (kind of a hack) */ 03581 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 03582 } 03583 if ( !res && format[offset + 1] == 'S' ) { /* minutes only if seconds follow (kind of a hack) */ 03584 if (tm.tm_min == 1) { 03585 res = wait_file(chan,ints,"digits/minute",lang); 03586 } else { 03587 res = wait_file(chan,ints,"digits/minutes",lang); 03588 } 03589 } 03590 break; 03591 case 'P': 03592 case 'p': 03593 /* AM/PM */ 03594 if (tm.tm_hour > 11) 03595 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 03596 else 03597 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 03598 res = wait_file(chan,ints,nextmsg,lang); 03599 break; 03600 case 'Q': 03601 /* Shorthand for "Today", "Yesterday", or AdBY */ 03602 /* XXX As emphasized elsewhere, this should the native way in your 03603 * language to say the date, with changes in what you say, depending 03604 * upon how recent the date is. XXX */ 03605 { 03606 struct timeval now; 03607 struct tm tmnow; 03608 time_t beg_today, tt; 03609 03610 gettimeofday(&now,NULL); 03611 tt = now.tv_sec; 03612 ast_localtime(&tt,&tmnow,timezone); 03613 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03614 /* In any case, it saves not having to do ast_mktime() */ 03615 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03616 if (beg_today < time) { 03617 /* Today */ 03618 res = wait_file(chan,ints, "digits/today",lang); 03619 } else if (beg_today - 86400 < time) { 03620 /* Yesterday */ 03621 res = wait_file(chan,ints, "digits/yesterday",lang); 03622 } else { 03623 res = ast_say_date_with_format_da(chan, time, ints, lang, "AdBY", timezone); 03624 } 03625 } 03626 break; 03627 case 'q': 03628 /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */ 03629 /* XXX As emphasized elsewhere, this should the native way in your 03630 * language to say the date, with changes in what you say, depending 03631 * upon how recent the date is. XXX */ 03632 { 03633 struct timeval now; 03634 struct tm tmnow; 03635 time_t beg_today, tt; 03636 03637 gettimeofday(&now,NULL); 03638 tt = now.tv_sec; 03639 ast_localtime(&tt,&tmnow,timezone); 03640 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03641 /* In any case, it saves not having to do ast_mktime() */ 03642 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03643 if (beg_today < time) { 03644 /* Today */ 03645 } else if ((beg_today - 86400) < time) { 03646 /* Yesterday */ 03647 res = wait_file(chan,ints, "digits/yesterday",lang); 03648 } else if (beg_today - 86400 * 6 < time) { 03649 /* Within the last week */ 03650 res = ast_say_date_with_format_da(chan, time, ints, lang, "A", timezone); 03651 } else { 03652 res = ast_say_date_with_format_da(chan, time, ints, lang, "AdBY", timezone); 03653 } 03654 } 03655 break; 03656 case 'R': 03657 res = ast_say_date_with_format_da(chan, time, ints, lang, "HM", timezone); 03658 break; 03659 case 'S': 03660 /* Seconds */ 03661 res = wait_file(chan,ints, "digits/and",lang); 03662 if (!res) { 03663 res = ast_say_number(chan, tm.tm_sec, ints, lang, "f"); 03664 if (!res) { 03665 res = wait_file(chan,ints, "digits/seconds",lang); 03666 } 03667 } 03668 break; 03669 case 'T': 03670 res = ast_say_date_with_format_da(chan, time, ints, lang, "HMS", timezone); 03671 break; 03672 case ' ': 03673 case ' ': 03674 /* Just ignore spaces and tabs */ 03675 break; 03676 default: 03677 /* Unknown character */ 03678 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 03679 } 03680 /* Jump out on DTMF */ 03681 if (res) { 03682 break; 03683 } 03684 } 03685 return res; 03686 }
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 3689 of file say.c.
References ast_localtime(), ast_log(), ast_say_enumeration(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
03690 { 03691 struct tm tm; 03692 int res=0, offset, sndoffset; 03693 char sndfile[256], nextmsg[256]; 03694 03695 if (!format) 03696 format = "A dBY HMS"; 03697 03698 ast_localtime(&time,&tm,timezone); 03699 03700 for (offset=0 ; format[offset] != '\0' ; offset++) { 03701 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 03702 switch (format[offset]) { 03703 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 03704 case '\'': 03705 /* Literal name of a sound file */ 03706 sndoffset=0; 03707 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 03708 sndfile[sndoffset] = format[offset]; 03709 sndfile[sndoffset] = '\0'; 03710 res = wait_file(chan,ints,sndfile,lang); 03711 break; 03712 case 'A': 03713 case 'a': 03714 /* Sunday - Saturday */ 03715 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 03716 res = wait_file(chan,ints,nextmsg,lang); 03717 break; 03718 case 'B': 03719 case 'b': 03720 case 'h': 03721 /* January - December */ 03722 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 03723 res = wait_file(chan,ints,nextmsg,lang); 03724 break; 03725 case 'm': 03726 /* Month enumerated */ 03727 res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m"); 03728 break; 03729 case 'd': 03730 case 'e': 03731 /* First - Thirtyfirst */ 03732 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m"); 03733 break; 03734 case 'Y': 03735 /* Year */ 03736 { 03737 int year = tm.tm_year + 1900; 03738 if (year > 1999) { /* year 2000 and later */ 03739 res = ast_say_number(chan, year, ints, lang, (char *) NULL); 03740 } else { 03741 if (year < 1100) { 03742 /* I'm not going to handle 1100 and prior */ 03743 /* We'll just be silent on the year, instead of bombing out. */ 03744 } else { 03745 /* year 1100 to 1999. will anybody need this?!? */ 03746 /* say 1967 as 'neunzehn hundert sieben und sechzig' */ 03747 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (year / 100) ); 03748 res = wait_file(chan,ints,nextmsg,lang); 03749 if (!res) { 03750 res = wait_file(chan,ints, "digits/hundred",lang); 03751 if (!res && year % 100 != 0) { 03752 res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 03753 } 03754 } 03755 } 03756 } 03757 } 03758 break; 03759 case 'I': 03760 case 'l': 03761 /* 12-Hour */ 03762 if (tm.tm_hour == 0) 03763 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 03764 else if (tm.tm_hour > 12) 03765 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 03766 else 03767 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 03768 res = wait_file(chan,ints,nextmsg,lang); 03769 if (!res) { 03770 res = wait_file(chan,ints,"digits/oclock",lang); 03771 } 03772 break; 03773 case 'H': 03774 case 'k': 03775 /* 24-Hour */ 03776 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); 03777 if (!res) { 03778 res = wait_file(chan,ints,"digits/oclock",lang); 03779 } 03780 break; 03781 case 'M': 03782 /* Minute */ 03783 if (tm.tm_min > 0 || format[offset+ 1 ] == 'S' ) { /* zero 'digits/0' only if seconds follow (kind of a hack) */ 03784 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 03785 } 03786 if ( !res && format[offset + 1] == 'S' ) { /* minutes only if seconds follow (kind of a hack) */ 03787 if (tm.tm_min == 1) { 03788 res = wait_file(chan,ints,"digits/minute",lang); 03789 } else { 03790 res = wait_file(chan,ints,"digits/minutes",lang); 03791 } 03792 } 03793 break; 03794 case 'P': 03795 case 'p': 03796 /* AM/PM */ 03797 if (tm.tm_hour > 11) 03798 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 03799 else 03800 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 03801 res = wait_file(chan,ints,nextmsg,lang); 03802 break; 03803 case 'Q': 03804 /* Shorthand for "Today", "Yesterday", or AdBY */ 03805 /* XXX As emphasized elsewhere, this should the native way in your 03806 * language to say the date, with changes in what you say, depending 03807 * upon how recent the date is. XXX */ 03808 { 03809 struct timeval now; 03810 struct tm tmnow; 03811 time_t beg_today, tt; 03812 03813 gettimeofday(&now,NULL); 03814 tt = now.tv_sec; 03815 ast_localtime(&tt,&tmnow,timezone); 03816 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03817 /* In any case, it saves not having to do ast_mktime() */ 03818 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03819 if (beg_today < time) { 03820 /* Today */ 03821 res = wait_file(chan,ints, "digits/today",lang); 03822 } else if (beg_today - 86400 < time) { 03823 /* Yesterday */ 03824 res = wait_file(chan,ints, "digits/yesterday",lang); 03825 } else { 03826 res = ast_say_date_with_format_de(chan, time, ints, lang, "AdBY", timezone); 03827 } 03828 } 03829 break; 03830 case 'q': 03831 /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */ 03832 /* XXX As emphasized elsewhere, this should the native way in your 03833 * language to say the date, with changes in what you say, depending 03834 * upon how recent the date is. XXX */ 03835 { 03836 struct timeval now; 03837 struct tm tmnow; 03838 time_t beg_today, tt; 03839 03840 gettimeofday(&now,NULL); 03841 tt = now.tv_sec; 03842 ast_localtime(&tt,&tmnow,timezone); 03843 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03844 /* In any case, it saves not having to do ast_mktime() */ 03845 beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03846 if (beg_today < time) { 03847 /* Today */ 03848 } else if ((beg_today - 86400) < time) { 03849 /* Yesterday */ 03850 res = wait_file(chan,ints, "digits/yesterday",lang); 03851 } else if (beg_today - 86400 * 6 < time) { 03852 /* Within the last week */ 03853 res = ast_say_date_with_format_de(chan, time, ints, lang, "A", timezone); 03854 } else { 03855 res = ast_say_date_with_format_de(chan, time, ints, lang, "AdBY", timezone); 03856 } 03857 } 03858 break; 03859 case 'R': 03860 res = ast_say_date_with_format_de(chan, time, ints, lang, "HM", timezone); 03861 break; 03862 case 'S': 03863 /* Seconds */ 03864 res = wait_file(chan,ints, "digits/and",lang); 03865 if (!res) { 03866 res = ast_say_number(chan, tm.tm_sec, ints, lang, "f"); 03867 if (!res) { 03868 res = wait_file(chan,ints, "digits/seconds",lang); 03869 } 03870 } 03871 break; 03872 case 'T': 03873 res = ast_say_date_with_format_de(chan, time, ints, lang, "HMS", timezone); 03874 break; 03875 case ' ': 03876 case ' ': 03877 /* Just ignore spaces and tabs */ 03878 break; 03879 default: 03880 /* Unknown character */ 03881 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 03882 } 03883 /* Jump out on DTMF */ 03884 if (res) { 03885 break; 03886 } 03887 } 03888 return res; 03889 }
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 3242 of file say.c.
References ast_localtime(), ast_log(), ast_say_enumeration(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
03243 { 03244 struct tm tm; 03245 int res=0, offset, sndoffset; 03246 char sndfile[256], nextmsg[256]; 03247 03248 if (format == NULL) 03249 format = "ABdY 'digits/at' IMp"; 03250 03251 ast_localtime(&time,&tm,timezone); 03252 03253 for (offset=0 ; format[offset] != '\0' ; offset++) { 03254 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 03255 switch (format[offset]) { 03256 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 03257 case '\'': 03258 /* Literal name of a sound file */ 03259 sndoffset=0; 03260 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 03261 sndfile[sndoffset] = format[offset]; 03262 sndfile[sndoffset] = '\0'; 03263 res = wait_file(chan,ints,sndfile,lang); 03264 break; 03265 case 'A': 03266 case 'a': 03267 /* Sunday - Saturday */ 03268 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 03269 res = wait_file(chan,ints,nextmsg,lang); 03270 break; 03271 case 'B': 03272 case 'b': 03273 case 'h': 03274 /* January - December */ 03275 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 03276 res = wait_file(chan,ints,nextmsg,lang); 03277 break; 03278 case 'm': 03279 /* Month enumerated */ 03280 res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, (char *) NULL); 03281 break; 03282 case 'd': 03283 case 'e': 03284 /* First - Thirtyfirst */ 03285 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char *) NULL); 03286 break; 03287 case 'Y': 03288 /* Year */ 03289 if (tm.tm_year > 99) { 03290 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03291 } else if (tm.tm_year < 1) { 03292 /* I'm not going to handle 1900 and prior */ 03293 /* We'll just be silent on the year, instead of bombing out. */ 03294 } else { 03295 res = wait_file(chan, ints, "digits/19", lang); 03296 if (!res) { 03297 if (tm.tm_year <= 9) { 03298 /* 1901 - 1909 */ 03299 res = wait_file(chan,ints, "digits/oh", lang); 03300 } 03301 03302 res |= ast_say_number(chan, tm.tm_year, ints, lang, (char *) NULL); 03303 } 03304 } 03305 break; 03306 case 'I': 03307 case 'l': 03308 /* 12-Hour */ 03309 if (tm.tm_hour == 0) 03310 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 03311 else if (tm.tm_hour > 12) 03312 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 03313 else 03314 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 03315 res = wait_file(chan,ints,nextmsg,lang); 03316 break; 03317 case 'H': 03318 case 'k': 03319 /* 24-Hour */ 03320 if (format[offset] == 'H') { 03321 /* e.g. oh-eight */ 03322 if (tm.tm_hour < 10) { 03323 res = wait_file(chan,ints, "digits/oh",lang); 03324 } 03325 } else { 03326 /* e.g. eight */ 03327 if (tm.tm_hour == 0) { 03328 res = wait_file(chan,ints, "digits/oh",lang); 03329 } 03330 } 03331 if (!res) { 03332 if (tm.tm_hour != 0) { 03333 int remainder = tm.tm_hour; 03334 if (tm.tm_hour > 20) { 03335 res = wait_file(chan,ints, "digits/20",lang); 03336 remainder -= 20; 03337 } 03338 if (!res) { 03339 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", remainder); 03340 res = wait_file(chan,ints,nextmsg,lang); 03341 } 03342 } 03343 } 03344 break; 03345 case 'M': 03346 case 'N': 03347 /* Minute */ 03348 if (tm.tm_min == 0) { 03349 if (format[offset] == 'M') { 03350 res = wait_file(chan, ints, "digits/oclock", lang); 03351 } else { 03352 res = wait_file(chan, ints, "digits/hundred", lang); 03353 } 03354 } else if (tm.tm_min < 10) { 03355 res = wait_file(chan,ints, "digits/oh",lang); 03356 if (!res) { 03357 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min); 03358 res = wait_file(chan,ints,nextmsg,lang); 03359 } 03360 } else { 03361 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 03362 } 03363 break; 03364 case 'P': 03365 case 'p': 03366 /* AM/PM */ 03367 if (tm.tm_hour > 11) 03368 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 03369 else 03370 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 03371 res = wait_file(chan,ints,nextmsg,lang); 03372 break; 03373 case 'Q': 03374 /* Shorthand for "Today", "Yesterday", or ABdY */ 03375 /* XXX As emphasized elsewhere, this should the native way in your 03376 * language to say the date, with changes in what you say, depending 03377 * upon how recent the date is. XXX */ 03378 { 03379 struct timeval now; 03380 struct tm tmnow; 03381 time_t beg_today, tt; 03382 03383 gettimeofday(&now,NULL); 03384 tt = now.tv_sec; 03385 ast_localtime(&tt,&tmnow,timezone); 03386 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03387 /* In any case, it saves not having to do ast_mktime() */ 03388 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03389 if (beg_today < time) { 03390 /* Today */ 03391 res = wait_file(chan,ints, "digits/today",lang); 03392 } else if (beg_today - 86400 < time) { 03393 /* Yesterday */ 03394 res = wait_file(chan,ints, "digits/yesterday",lang); 03395 } else if (beg_today - 86400 * 6 < time) { 03396 /* Within the last week */ 03397 res = ast_say_date_with_format_en(chan, time, ints, lang, "A", timezone); 03398 } else if (beg_today - 2628000 < time) { 03399 /* Less than a month ago - "Sunday, October third" */ 03400 res = ast_say_date_with_format_en(chan, time, ints, lang, "ABd", timezone); 03401 } else if (beg_today - 15768000 < time) { 03402 /* Less than 6 months ago - "August seventh" */ 03403 res = ast_say_date_with_format_en(chan, time, ints, lang, "Bd", timezone); 03404 } else { 03405 /* More than 6 months ago - "April nineteenth two thousand three" */ 03406 res = ast_say_date_with_format_en(chan, time, ints, lang, "BdY", timezone); 03407 } 03408 } 03409 break; 03410 case 'q': 03411 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */ 03412 /* XXX As emphasized elsewhere, this should the native way in your 03413 * language to say the date, with changes in what you say, depending 03414 * upon how recent the date is. XXX */ 03415 { 03416 struct timeval now; 03417 struct tm tmnow; 03418 time_t beg_today, tt; 03419 03420 gettimeofday(&now,NULL); 03421 tt = now.tv_sec; 03422 ast_localtime(&tt,&tmnow,timezone); 03423 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03424 /* In any case, it saves not having to do ast_mktime() */ 03425 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03426 if (beg_today < time) { 03427 /* Today */ 03428 } else if ((beg_today - 86400) < time) { 03429 /* Yesterday */ 03430 res = wait_file(chan,ints, "digits/yesterday",lang); 03431 } else if (beg_today - 86400 * 6 < time) { 03432 /* Within the last week */ 03433 res = ast_say_date_with_format_en(chan, time, ints, lang, "A", timezone); 03434 } else if (beg_today - 2628000 < time) { 03435 /* Less than a month ago - "Sunday, October third" */ 03436 res = ast_say_date_with_format_en(chan, time, ints, lang, "ABd", timezone); 03437 } else if (beg_today - 15768000 < time) { 03438 /* Less than 6 months ago - "August seventh" */ 03439 res = ast_say_date_with_format_en(chan, time, ints, lang, "Bd", timezone); 03440 } else { 03441 /* More than 6 months ago - "April nineteenth two thousand three" */ 03442 res = ast_say_date_with_format_en(chan, time, ints, lang, "BdY", timezone); 03443 } 03444 } 03445 break; 03446 case 'R': 03447 res = ast_say_date_with_format_en(chan, time, ints, lang, "HM", timezone); 03448 break; 03449 case 'S': 03450 /* Seconds */ 03451 if (tm.tm_sec == 0) { 03452 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec); 03453 res = wait_file(chan,ints,nextmsg,lang); 03454 } else if (tm.tm_sec < 10) { 03455 res = wait_file(chan,ints, "digits/oh",lang); 03456 if (!res) { 03457 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec); 03458 res = wait_file(chan,ints,nextmsg,lang); 03459 } 03460 } else { 03461 res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL); 03462 } 03463 break; 03464 case 'T': 03465 res = ast_say_date_with_format_en(chan, time, ints, lang, "HMS", timezone); 03466 break; 03467 case ' ': 03468 case ' ': 03469 /* Just ignore spaces and tabs */ 03470 break; 03471 default: 03472 /* Unknown character */ 03473 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 03474 } 03475 /* Jump out on DTMF */ 03476 if (res) { 03477 break; 03478 } 03479 } 03480 return res; 03481 }
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 4073 of file say.c.
References ast_localtime(), ast_log(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
04074 { 04075 struct tm tm; 04076 int res=0, offset, sndoffset; 04077 char sndfile[256], nextmsg[256]; 04078 04079 if (format == NULL) 04080 format = "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y 'digits/at' IMp"; 04081 04082 ast_localtime(&time,&tm,timezone); 04083 04084 for (offset=0 ; format[offset] != '\0' ; offset++) { 04085 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 04086 switch (format[offset]) { 04087 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 04088 case '\'': 04089 /* Literal name of a sound file */ 04090 sndoffset=0; 04091 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 04092 sndfile[sndoffset] = format[offset]; 04093 sndfile[sndoffset] = '\0'; 04094 snprintf(nextmsg,sizeof(nextmsg), "%s", sndfile); 04095 res = wait_file(chan,ints,nextmsg,lang); 04096 break; 04097 case 'A': 04098 case 'a': 04099 /* Sunday - Saturday */ 04100 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 04101 res = wait_file(chan,ints,nextmsg,lang); 04102 break; 04103 case 'B': 04104 case 'b': 04105 case 'h': 04106 /* January - December */ 04107 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 04108 res = wait_file(chan,ints,nextmsg,lang); 04109 break; 04110 case 'm': 04111 /* First - Twelfth */ 04112 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1); 04113 res = wait_file(chan,ints,nextmsg,lang); 04114 break; 04115 case 'd': 04116 case 'e': 04117 /* First - Thirtyfirst */ 04118 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 04119 break; 04120 case 'Y': 04121 /* Year */ 04122 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 04123 break; 04124 case 'I': 04125 case 'l': 04126 /* 12-Hour */ 04127 if (tm.tm_hour == 0) 04128 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 04129 else if (tm.tm_hour > 12) 04130 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 04131 else 04132 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 04133 res = wait_file(chan,ints,nextmsg,lang); 04134 break; 04135 case 'H': 04136 case 'k': 04137 /* 24-Hour */ 04138 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); 04139 if ((!res) && (format[offset] == 'H')) { 04140 if (tm.tm_hour == 1) { 04141 res = wait_file(chan,ints,"digits/hour",lang); 04142 } else { 04143 res = wait_file(chan,ints,"digits/hours",lang); 04144 } 04145 } 04146 break; 04147 break; 04148 case 'M': 04149 /* Minute */ 04150 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 04151 if (!res) { 04152 if (tm.tm_min == 1) { 04153 res = wait_file(chan,ints,"digits/minute",lang); 04154 } else { 04155 res = wait_file(chan,ints,"digits/minutes",lang); 04156 } 04157 } 04158 break; 04159 case 'P': 04160 case 'p': 04161 /* AM/PM */ 04162 if (tm.tm_hour > 18) 04163 res = wait_file(chan, ints, "digits/p-m", lang); 04164 else if (tm.tm_hour > 12) 04165 res = wait_file(chan, ints, "digits/afternoon", lang); 04166 else if (tm.tm_hour) 04167 res = wait_file(chan, ints, "digits/a-m", lang); 04168 break; 04169 case 'Q': 04170 /* Shorthand for "Today", "Yesterday", or ABdY */ 04171 /* XXX As emphasized elsewhere, this should the native way in your 04172 * language to say the date, with changes in what you say, depending 04173 * upon how recent the date is. XXX */ 04174 { 04175 struct timeval now; 04176 struct tm tmnow; 04177 time_t beg_today, tt; 04178 04179 gettimeofday(&now,NULL); 04180 tt = now.tv_sec; 04181 ast_localtime(&tt,&tmnow,timezone); 04182 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04183 /* In any case, it saves not having to do ast_mktime() */ 04184 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04185 if (beg_today < time) { 04186 /* Today */ 04187 res = wait_file(chan,ints, "digits/today",lang); 04188 } else if (beg_today - 86400 < time) { 04189 /* Yesterday */ 04190 res = wait_file(chan,ints, "digits/yesterday",lang); 04191 } else { 04192 res = ast_say_date_with_format_es(chan, time, ints, lang, "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y", timezone); 04193 } 04194 } 04195 break; 04196 case 'q': 04197 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */ 04198 /* XXX As emphasized elsewhere, this should the native way in your 04199 * language to say the date, with changes in what you say, depending 04200 * upon how recent the date is. XXX */ 04201 { 04202 struct timeval now; 04203 struct tm tmnow; 04204 time_t beg_today, tt; 04205 04206 gettimeofday(&now,NULL); 04207 tt = now.tv_sec; 04208 ast_localtime(&tt,&tmnow,timezone); 04209 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04210 /* In any case, it saves not having to do ast_mktime() */ 04211 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04212 if (beg_today < time) { 04213 /* Today */ 04214 res = wait_file(chan,ints, "digits/today",lang); 04215 } else if ((beg_today - 86400) < time) { 04216 /* Yesterday */ 04217 res = wait_file(chan,ints, "digits/yesterday",lang); 04218 } else if (beg_today - 86400 * 6 < time) { 04219 /* Within the last week */ 04220 res = ast_say_date_with_format_es(chan, time, ints, lang, "A", timezone); 04221 } else { 04222 res = ast_say_date_with_format_es(chan, time, ints, lang, "'digits/es-el' Ad 'digits/es-de' B 'digits/es-de' Y", timezone); 04223 } 04224 } 04225 break; 04226 case 'R': 04227 res = ast_say_date_with_format_es(chan, time, ints, lang, "H 'digits/and' M", timezone); 04228 break; 04229 case 'S': 04230 /* Seconds */ 04231 res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL); 04232 if (!res) { 04233 if (tm.tm_sec == 1) { 04234 res = wait_file(chan,ints,"digits/second",lang); 04235 } else { 04236 res = wait_file(chan,ints,"digits/seconds",lang); 04237 } 04238 } 04239 break; 04240 case 'T': 04241 res = ast_say_date_with_format_es(chan, time, ints, lang, "HMS", timezone); 04242 break; 04243 case ' ': 04244 case ' ': 04245 /* Just ignore spaces and tabs */ 04246 break; 04247 default: 04248 /* Unknown character */ 04249 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 04250 } 04251 /* Jump out on DTMF */ 04252 if (res) { 04253 break; 04254 } 04255 } 04256 return res; 04257 }
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 4262 of file say.c.
References ast_localtime(), ast_log(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
04263 { 04264 struct tm tm; 04265 int res=0, offset, sndoffset; 04266 char sndfile[256], nextmsg[256]; 04267 04268 if (format == NULL) 04269 format = "AdBY 'digits/at' IMp"; 04270 04271 ast_localtime(&time,&tm,timezone); 04272 04273 for (offset=0 ; format[offset] != '\0' ; offset++) { 04274 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 04275 switch (format[offset]) { 04276 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 04277 case '\'': 04278 /* Literal name of a sound file */ 04279 sndoffset=0; 04280 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 04281 sndfile[sndoffset] = format[offset]; 04282 sndfile[sndoffset] = '\0'; 04283 res = wait_file(chan,ints,sndfile,lang); 04284 break; 04285 case 'A': 04286 case 'a': 04287 /* Sunday - Saturday */ 04288 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 04289 res = wait_file(chan,ints,nextmsg,lang); 04290 break; 04291 case 'B': 04292 case 'b': 04293 case 'h': 04294 /* January - December */ 04295 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 04296 res = wait_file(chan,ints,nextmsg,lang); 04297 break; 04298 case 'm': 04299 /* First - Twelfth */ 04300 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1); 04301 res = wait_file(chan,ints,nextmsg,lang); 04302 break; 04303 case 'd': 04304 case 'e': 04305 /* First */ 04306 if (tm.tm_mday == 1) { 04307 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday); 04308 res = wait_file(chan,ints,nextmsg,lang); 04309 } else { 04310 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 04311 } 04312 break; 04313 case 'Y': 04314 /* Year */ 04315 if (tm.tm_year > 99) { 04316 res = wait_file(chan,ints, "digits/2",lang); 04317 if (!res) { 04318 res = wait_file(chan,ints, "digits/thousand",lang); 04319 } 04320 if (tm.tm_year > 100) { 04321 if (!res) { 04322 res = ast_say_number(chan, tm.tm_year - 100, ints, lang, (char * ) NULL); 04323 } 04324 } 04325 } else { 04326 if (tm.tm_year < 1) { 04327 /* I'm not going to handle 1900 and prior */ 04328 /* We'll just be silent on the year, instead of bombing out. */ 04329 } else { 04330 res = wait_file(chan,ints, "digits/thousand",lang); 04331 if (!res) { 04332 wait_file(chan,ints, "digits/9",lang); 04333 wait_file(chan,ints, "digits/hundred",lang); 04334 res = ast_say_number(chan, tm.tm_year, ints, lang, (char * ) NULL); 04335 } 04336 } 04337 } 04338 break; 04339 case 'I': 04340 case 'l': 04341 /* 12-Hour */ 04342 if (tm.tm_hour == 0) 04343 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 04344 else if (tm.tm_hour > 12) 04345 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 04346 else 04347 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 04348 res = wait_file(chan,ints,nextmsg,lang); 04349 if (!res) 04350 res = wait_file(chan,ints, "digits/oclock",lang); 04351 break; 04352 case 'H': 04353 case 'k': 04354 /* 24-Hour */ 04355 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char * ) NULL); 04356 if (!res) 04357 res = wait_file(chan,ints, "digits/oclock",lang); 04358 break; 04359 case 'M': 04360 /* Minute */ 04361 if (tm.tm_min == 0) { 04362 break; 04363 } 04364 res = ast_say_number(chan, tm.tm_min, ints, lang, (char * ) NULL); 04365 break; 04366 case 'P': 04367 case 'p': 04368 /* AM/PM */ 04369 if (tm.tm_hour > 11) 04370 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 04371 else 04372 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 04373 res = wait_file(chan,ints,nextmsg,lang); 04374 break; 04375 case 'Q': 04376 /* Shorthand for "Today", "Yesterday", or AdBY */ 04377 /* XXX As emphasized elsewhere, this should the native way in your 04378 * language to say the date, with changes in what you say, depending 04379 * upon how recent the date is. XXX */ 04380 { 04381 struct timeval now; 04382 struct tm tmnow; 04383 time_t beg_today, tt; 04384 04385 gettimeofday(&now,NULL); 04386 tt = now.tv_sec; 04387 ast_localtime(&tt,&tmnow,timezone); 04388 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04389 /* In any case, it saves not having to do ast_mktime() */ 04390 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04391 if (beg_today < time) { 04392 /* Today */ 04393 res = wait_file(chan,ints, "digits/today",lang); 04394 } else if (beg_today - 86400 < time) { 04395 /* Yesterday */ 04396 res = wait_file(chan,ints, "digits/yesterday",lang); 04397 } else { 04398 res = ast_say_date_with_format_fr(chan, time, ints, lang, "AdBY", timezone); 04399 } 04400 } 04401 break; 04402 case 'q': 04403 /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */ 04404 /* XXX As emphasized elsewhere, this should the native way in your 04405 * language to say the date, with changes in what you say, depending 04406 * upon how recent the date is. XXX */ 04407 { 04408 struct timeval now; 04409 struct tm tmnow; 04410 time_t beg_today, tt; 04411 04412 gettimeofday(&now,NULL); 04413 tt = now.tv_sec; 04414 ast_localtime(&tt,&tmnow,timezone); 04415 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04416 /* In any case, it saves not having to do ast_mktime() */ 04417 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04418 if (beg_today < time) { 04419 /* Today */ 04420 } else if ((beg_today - 86400) < time) { 04421 /* Yesterday */ 04422 res = wait_file(chan,ints, "digits/yesterday",lang); 04423 } else if (beg_today - 86400 * 6 < time) { 04424 /* Within the last week */ 04425 res = ast_say_date_with_format_fr(chan, time, ints, lang, "A", timezone); 04426 } else { 04427 res = ast_say_date_with_format_fr(chan, time, ints, lang, "AdBY", timezone); 04428 } 04429 } 04430 break; 04431 case 'R': 04432 res = ast_say_date_with_format_fr(chan, time, ints, lang, "HM", timezone); 04433 break; 04434 case 'S': 04435 /* Seconds */ 04436 res = ast_say_number(chan, tm.tm_sec, ints, lang, (char * ) NULL); 04437 if (!res) { 04438 res = wait_file(chan,ints, "digits/second",lang); 04439 } 04440 break; 04441 case 'T': 04442 res = ast_say_date_with_format_fr(chan, time, ints, lang, "HMS", timezone); 04443 break; 04444 case ' ': 04445 case ' ': 04446 /* Just ignore spaces and tabs */ 04447 break; 04448 default: 04449 /* Unknown character */ 04450 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 04451 } 04452 /* Jump out on DTMF */ 04453 if (res) { 04454 break; 04455 } 04456 } 04457 return res; 04458 }
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 6700 of file say.c.
References ast_localtime(), ast_log(), 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 say_date_with_format().
06701 { 06702 06703 struct tm tm; 06704 int res=0, offset, sndoffset; 06705 char sndfile[256], nextmsg[256]; 06706 06707 if (!format) 06708 format = "AdBY 'digits/at' IMp"; 06709 06710 ast_localtime(&time,&tm,timezone); 06711 06712 for (offset=0 ; format[offset] != '\0' ; offset++) { 06713 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 06714 switch (format[offset]) { 06715 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 06716 case '\'': 06717 /* Literal name of a sound file */ 06718 sndoffset=0; 06719 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 06720 sndfile[sndoffset] = format[offset]; 06721 sndfile[sndoffset] = '\0'; 06722 res = wait_file(chan,ints,sndfile,lang); 06723 break; 06724 case 'A': 06725 case 'a': 06726 /* Sunday - Saturday */ 06727 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 06728 res = wait_file(chan,ints,nextmsg,lang); 06729 break; 06730 case 'B': 06731 case 'b': 06732 case 'h': 06733 /* January - December */ 06734 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 06735 res = wait_file(chan,ints,nextmsg,lang); 06736 break; 06737 case 'd': 06738 case 'e': 06739 /* first - thirtyfirst */ 06740 gr_say_number_female(tm.tm_mday, chan, ints, lang); 06741 break; 06742 case 'Y': 06743 /* Year */ 06744 06745 ast_say_number_full_gr(chan, 1900+tm.tm_year, ints, chan->language, -1, -1); 06746 break; 06747 case 'I': 06748 case 'l': 06749 /* 12-Hour */ 06750 if (tm.tm_hour == 0) 06751 gr_say_number_female(12, chan, ints, lang); 06752 else if (tm.tm_hour > 12) 06753 gr_say_number_female(tm.tm_hour - 12, chan, ints, lang); 06754 else 06755 gr_say_number_female(tm.tm_hour, chan, ints, lang); 06756 break; 06757 case 'H': 06758 case 'k': 06759 /* 24-Hour */ 06760 gr_say_number_female(tm.tm_hour, chan, ints, lang); 06761 break; 06762 case 'M': 06763 /* Minute */ 06764 if (tm.tm_min) { 06765 if (!res) 06766 res = ast_streamfile(chan, "digits/kai", lang); 06767 if (!res) 06768 res = ast_waitstream(chan, ints); 06769 if (!res) 06770 res = ast_say_number_full_gr(chan, tm.tm_min, ints, lang, -1, -1); 06771 } else { 06772 if (!res) 06773 res = ast_streamfile(chan, "digits/oclock", lang); 06774 if (!res) 06775 res = ast_waitstream(chan, ints); 06776 } 06777 break; 06778 case 'P': 06779 case 'p': 06780 /* AM/PM */ 06781 if (tm.tm_hour > 11) 06782 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 06783 else 06784 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 06785 res = wait_file(chan,ints,nextmsg,lang); 06786 break; 06787 case 'Q': 06788 /* Shorthand for "Today", "Yesterday", or ABdY */ 06789 /* XXX As emphasized elsewhere, this should the native way in your 06790 * language to say the date, with changes in what you say, depending 06791 * upon how recent the date is. XXX */ 06792 { 06793 struct timeval now; 06794 struct tm tmnow; 06795 time_t beg_today, tt; 06796 06797 gettimeofday(&now,NULL); 06798 tt = now.tv_sec; 06799 ast_localtime(&tt,&tmnow,timezone); 06800 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 06801 /* In any case, it saves not having to do ast_mktime() */ 06802 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 06803 if (beg_today < time) { 06804 /* Today */ 06805 res = wait_file(chan,ints, "digits/today",lang); 06806 } else if (beg_today - 86400 < time) { 06807 /* Yesterday */ 06808 res = wait_file(chan,ints, "digits/yesterday",lang); 06809 } else { 06810 res = ast_say_date_with_format_gr(chan, time, ints, lang, "AdBY", timezone); 06811 } 06812 } 06813 break; 06814 case 'q': 06815 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */ 06816 /* XXX As emphasized elsewhere, this should the native way in your 06817 * language to say the date, with changes in what you say, depending 06818 * upon how recent the date is. XXX */ 06819 { 06820 struct timeval now; 06821 struct tm tmnow; 06822 time_t beg_today, tt; 06823 06824 gettimeofday(&now,NULL); 06825 tt = now.tv_sec; 06826 ast_localtime(&tt,&tmnow,timezone); 06827 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 06828 /* In any case, it saves not having to do ast_mktime() */ 06829 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 06830 if (beg_today < time) { 06831 /* Today */ 06832 } else if ((beg_today - 86400) < time) { 06833 /* Yesterday */ 06834 res = wait_file(chan,ints, "digits/yesterday",lang); 06835 } else if (beg_today - 86400 * 6 < time) { 06836 /* Within the last week */ 06837 res = ast_say_date_with_format_gr(chan, time, ints, lang, "A", timezone); 06838 } else { 06839 res = ast_say_date_with_format_gr(chan, time, ints, lang, "AdBY", timezone); 06840 } 06841 } 06842 break; 06843 case 'R': 06844 res = ast_say_date_with_format_gr(chan, time, ints, lang, "HM", timezone); 06845 break; 06846 case 'S': 06847 /* Seconds */ 06848 snprintf(nextmsg,sizeof(nextmsg), "digits/kai"); 06849 res = wait_file(chan,ints,nextmsg,lang); 06850 if (!res) 06851 res = ast_say_number_full_gr(chan, tm.tm_sec, ints, lang, -1, -1); 06852 if (!res) 06853 snprintf(nextmsg,sizeof(nextmsg), "digits/seconds"); 06854 res = wait_file(chan,ints,nextmsg,lang); 06855 break; 06856 case 'T': 06857 res = ast_say_date_with_format_gr(chan, time, ints, lang, "HMS", timezone); 06858 break; 06859 case ' ': 06860 case ' ': 06861 /* Just ignore spaces and tabs */ 06862 break; 06863 default: 06864 /* Unknown character */ 06865 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 06866 } 06867 /* Jump out on DTMF */ 06868 if (res) { 06869 break; 06870 } 06871 } 06872 return res; 06873 }
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 3914 of file say.c.
References ast_localtime(), ast_log(), 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 say_date_with_format().
03915 { 03916 /* TODO: This whole function is cut&paste from 03917 * ast_say_date_with_format_en . Is that considered acceptable? 03918 **/ 03919 struct tm tm; 03920 int res = 0, offset, sndoffset; 03921 char sndfile[256], nextmsg[256]; 03922 03923 if (!format) { 03924 format = IL_DATE_STR_FULL; 03925 } 03926 03927 ast_localtime(&time, &tm, timezone); 03928 03929 for (offset = 0; format[offset] != '\0'; offset++) { 03930 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 03931 switch (format[offset]) { 03932 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 03933 case '\'': 03934 /* Literal name of a sound file */ 03935 sndoffset=0; 03936 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 03937 sndfile[sndoffset] = format[offset]; 03938 sndfile[sndoffset] = '\0'; 03939 res = wait_file(chan,ints,sndfile,lang); 03940 break; 03941 case 'A': 03942 case 'a': 03943 /* Sunday - Saturday */ 03944 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 03945 res = wait_file(chan,ints,nextmsg,lang); 03946 break; 03947 case 'B': 03948 case 'b': 03949 case 'h': 03950 /* January - December */ 03951 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 03952 res = wait_file(chan,ints,nextmsg,lang); 03953 break; 03954 case 'd': 03955 case 'e': /* Day of the month */ 03956 /* I'm not sure exactly what the parameters 03957 * audiofd and ctrlfd to 03958 * ast_say_number_full_he mean, but it seems 03959 * safe to pass -1 there. 03960 * 03961 * At least in one of the pathes :-( 03962 */ 03963 res = ast_say_number_full_he(chan, tm.tm_mday, ints, lang, "m", -1, -1); 03964 break; 03965 case 'Y': /* Year */ 03966 res = ast_say_number_full_he(chan, tm.tm_year+1900, 03967 ints, lang, "f", -1, -1 03968 ); 03969 break; 03970 case 'I': 03971 case 'l': /* 12-Hour -> we do not support 12 hour based langauges in Hebrew */ 03972 case 'H': 03973 case 'k': /* 24-Hour */ 03974 res = ast_say_number_full_he(chan, tm.tm_hour, ints, lang, "f", -1, -1); 03975 break; 03976 case 'M': /* Minute */ 03977 if (tm.tm_min >= 0 && tm.tm_min <= 9) /* say a leading zero if needed */ 03978 res = ast_say_number_full_he(chan, 0, ints, lang, "f", -1, -1); 03979 res = ast_say_number_full_he(chan, tm.tm_min, ints, lang, "f", -1, -1); 03980 break; 03981 case 'P': 03982 case 'p': 03983 /* AM/PM - There is no AM/PM in Hebrew... */ 03984 break; 03985 case 'Q': 03986 /* Shorthand for "Today", "Yesterday", or "date" */ 03987 case 'q': 03988 /* Shorthand for "" (today), "Yesterday", A 03989 * (weekday), or "date" */ 03990 /* XXX As emphasized elsewhere, this should the native way in your 03991 * language to say the date, with changes in what you say, depending 03992 * upon how recent the date is. XXX */ 03993 { 03994 struct timeval now; 03995 struct tm tmnow; 03996 time_t beg_today, tt; 03997 char todo = format[offset]; /* The letter to format*/ 03998 03999 gettimeofday(&now,NULL); 04000 tt = now.tv_sec; 04001 ast_localtime(&tt,&tmnow,timezone); 04002 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04003 /* In any case, it saves not having to do ast_mktime() */ 04004 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04005 if (beg_today < time) { 04006 /* Today */ 04007 if (todo == 'Q') { 04008 res = wait_file(chan, 04009 ints, 04010 "digits/today", 04011 lang); 04012 } 04013 } else if (beg_today - 86400 < time) { 04014 /* Yesterday */ 04015 res = wait_file(chan,ints, "digits/yesterday",lang); 04016 } else if ((todo != 'Q') && 04017 (beg_today - 86400 * 6 < time)) 04018 { 04019 /* Within the last week */ 04020 res = ast_say_date_with_format_he(chan, 04021 time, ints, lang, 04022 "A", timezone); 04023 } else { 04024 res = ast_say_date_with_format_he(chan, 04025 time, ints, lang, 04026 IL_DATE_STR, timezone); 04027 } 04028 } 04029 break; 04030 case 'R': 04031 res = ast_say_date_with_format_he(chan, time, ints, lang, "HM", timezone); 04032 break; 04033 case 'S': /* Seconds */ 04034 res = ast_say_number_full_he(chan, tm.tm_sec, 04035 ints, lang, "f", -1, -1 04036 ); 04037 break; 04038 case 'T': 04039 res = ast_say_date_with_format_he(chan, time, ints, lang, "HMS", timezone); 04040 break; 04041 /* c, x, and X seem useful for testing. Not sure 04042 * if thiey're good for the general public */ 04043 case 'c': 04044 res = ast_say_date_with_format_he(chan, time, 04045 ints, lang, IL_DATE_STR_FULL, timezone); 04046 break; 04047 case 'x': 04048 res = ast_say_date_with_format_he(chan, time, 04049 ints, lang, IL_DATE_STR, timezone); 04050 break; 04051 case 'X': /* Currently not locale-dependent...*/ 04052 res = ast_say_date_with_format_he(chan, time, 04053 ints, lang, IL_TIME_STR, timezone); 04054 break; 04055 case ' ': 04056 case ' ': 04057 /* Just ignore spaces and tabs */ 04058 break; 04059 default: 04060 /* Unknown character */ 04061 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 04062 } 04063 /* Jump out on DTMF */ 04064 if (res) { 04065 break; 04066 } 04067 } 04068 return res; 04069 }
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 4460 of file say.c.
References ast_localtime(), ast_log(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
04461 { 04462 struct tm tm; 04463 int res=0, offset, sndoffset; 04464 char sndfile[256], nextmsg[256]; 04465 04466 if (format == NULL) 04467 format = "AdB 'digits/at' IMp"; 04468 04469 ast_localtime(&time,&tm,timezone); 04470 04471 for (offset=0 ; format[offset] != '\0' ; offset++) { 04472 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 04473 switch (format[offset]) { 04474 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 04475 case '\'': 04476 /* Literal name of a sound file */ 04477 sndoffset=0; 04478 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 04479 sndfile[sndoffset] = format[offset]; 04480 sndfile[sndoffset] = '\0'; 04481 res = wait_file(chan,ints,sndfile,lang); 04482 break; 04483 case 'A': 04484 case 'a': 04485 /* Sunday - Saturday */ 04486 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 04487 res = wait_file(chan,ints,nextmsg,lang); 04488 break; 04489 case 'B': 04490 case 'b': 04491 case 'h': 04492 /* January - December */ 04493 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 04494 res = wait_file(chan,ints,nextmsg,lang); 04495 break; 04496 case 'm': 04497 /* First - Twelfth */ 04498 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1); 04499 res = wait_file(chan,ints,nextmsg,lang); 04500 break; 04501 case 'd': 04502 case 'e': 04503 /* First day of the month is spelled as ordinal */ 04504 if (tm.tm_mday == 1) { 04505 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday); 04506 res = wait_file(chan,ints,nextmsg,lang); 04507 } else { 04508 if (!res) { 04509 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 04510 } 04511 } 04512 break; 04513 case 'Y': 04514 /* Year */ 04515 if (tm.tm_year > 99) { 04516 res = wait_file(chan,ints, "digits/ore-2000",lang); 04517 if (tm.tm_year > 100) { 04518 if (!res) { 04519 /* This works until the end of 2021 */ 04520 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year - 100); 04521 res = wait_file(chan,ints,nextmsg,lang); 04522 } 04523 } 04524 } else { 04525 if (tm.tm_year < 1) { 04526 /* I'm not going to handle 1900 and prior */ 04527 /* We'll just be silent on the year, instead of bombing out. */ 04528 } else { 04529 res = wait_file(chan,ints, "digits/ore-1900",lang); 04530 if ((!res) && (tm.tm_year != 0)) { 04531 if (tm.tm_year <= 21) { 04532 /* 1910 - 1921 */ 04533 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year); 04534 res = wait_file(chan,ints,nextmsg,lang); 04535 } else { 04536 /* 1922 - 1999, but sounds badly in 1928, 1931, 1938, etc... */ 04537 int ten, one; 04538 ten = tm.tm_year / 10; 04539 one = tm.tm_year % 10; 04540 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten * 10); 04541 res = wait_file(chan,ints,nextmsg,lang); 04542 if (!res) { 04543 if (one != 0) { 04544 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one); 04545 res = wait_file(chan,ints,nextmsg,lang); 04546 } 04547 } 04548 } 04549 } 04550 } 04551 } 04552 break; 04553 case 'I': 04554 case 'l': 04555 /* 12-Hour */ 04556 if (tm.tm_hour == 0) 04557 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 04558 else if (tm.tm_hour > 12) 04559 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 04560 else 04561 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 04562 res = wait_file(chan,ints,nextmsg,lang); 04563 break; 04564 case 'H': 04565 case 'k': 04566 /* 24-Hour */ 04567 if (tm.tm_hour == 0) { 04568 res = wait_file(chan,ints, "digits/ore-mezzanotte",lang); 04569 } else if (tm.tm_hour == 1) { 04570 res = wait_file(chan,ints, "digits/ore-una",lang); 04571 } else { 04572 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); 04573 } 04574 break; 04575 case 'M': 04576 /* Minute */ 04577 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 04578 break; 04579 case 'P': 04580 case 'p': 04581 /* AM/PM */ 04582 if (tm.tm_hour > 11) 04583 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 04584 else 04585 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 04586 res = wait_file(chan,ints,nextmsg,lang); 04587 break; 04588 case 'Q': 04589 /* Shorthand for "Today", "Yesterday", or ABdY */ 04590 /* XXX As emphasized elsewhere, this should the native way in your 04591 * language to say the date, with changes in what you say, depending 04592 * upon how recent the date is. XXX */ 04593 { 04594 struct timeval now; 04595 struct tm tmnow; 04596 time_t beg_today, tt; 04597 04598 gettimeofday(&now,NULL); 04599 tt = now.tv_sec; 04600 ast_localtime(&tt,&tmnow,timezone); 04601 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04602 /* In any case, it saves not having to do ast_mktime() */ 04603 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04604 if (beg_today < time) { 04605 /* Today */ 04606 res = wait_file(chan,ints, "digits/today",lang); 04607 } else if (beg_today - 86400 < time) { 04608 /* Yesterday */ 04609 res = wait_file(chan,ints, "digits/yesterday",lang); 04610 } else { 04611 res = ast_say_date_with_format_it(chan, time, ints, lang, "AdB", timezone); 04612 } 04613 } 04614 break; 04615 case 'q': 04616 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */ 04617 { 04618 struct timeval now; 04619 struct tm tmnow; 04620 time_t beg_today, tt; 04621 04622 gettimeofday(&now,NULL); 04623 tt = now.tv_sec; 04624 ast_localtime(&tt,&tmnow,timezone); 04625 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04626 /* In any case, it saves not having to do ast_mktime() */ 04627 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04628 if (beg_today < time) { 04629 /* Today */ 04630 } else if ((beg_today - 86400) < time) { 04631 /* Yesterday */ 04632 res = wait_file(chan,ints, "digits/yesterday",lang); 04633 } else if (beg_today - 86400 * 6 < time) { 04634 /* Within the last week */ 04635 res = ast_say_date_with_format_it(chan, time, ints, lang, "A", timezone); 04636 } else { 04637 res = ast_say_date_with_format_it(chan, time, ints, lang, "AdB", timezone); 04638 } 04639 } 04640 break; 04641 case 'R': 04642 res = ast_say_date_with_format_it(chan, time, ints, lang, "HM", timezone); 04643 break; 04644 case 'S': 04645 /* Seconds */ 04646 if (tm.tm_sec == 0) { 04647 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec); 04648 res = wait_file(chan,ints,nextmsg,lang); 04649 } else if (tm.tm_sec < 10) { 04650 res = wait_file(chan,ints, "digits/oh",lang); 04651 if (!res) { 04652 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec); 04653 res = wait_file(chan,ints,nextmsg,lang); 04654 } 04655 } else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) { 04656 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec); 04657 res = wait_file(chan,ints,nextmsg,lang); 04658 } else { 04659 int ten, one; 04660 ten = (tm.tm_sec / 10) * 10; 04661 one = (tm.tm_sec % 10); 04662 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten); 04663 res = wait_file(chan,ints,nextmsg,lang); 04664 if (!res) { 04665 /* Fifty, not fifty-zero */ 04666 if (one != 0) { 04667 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one); 04668 res = wait_file(chan,ints,nextmsg,lang); 04669 } 04670 } 04671 } 04672 break; 04673 case 'T': 04674 res = ast_say_date_with_format_it(chan, time, ints, lang, "HMS", timezone); 04675 break; 04676 case ' ': 04677 case ' ': 04678 /* Just ignore spaces and tabs */ 04679 break; 04680 default: 04681 /* Unknown character */ 04682 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 04683 } 04684 /* Jump out on DTMF */ 04685 if (res) { 04686 break; 04687 } 04688 } 04689 return res; 04690 }
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 4693 of file say.c.
References ast_localtime(), ast_log(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
04694 { 04695 struct tm tm; 04696 int res=0, offset, sndoffset; 04697 char sndfile[256], nextmsg[256]; 04698 04699 if (format == NULL) 04700 format = "ABdY 'digits/at' IMp"; 04701 04702 ast_localtime(&time,&tm,timezone); 04703 04704 for (offset=0 ; format[offset] != '\0' ; offset++) { 04705 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 04706 switch (format[offset]) { 04707 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 04708 case '\'': 04709 /* Literal name of a sound file */ 04710 sndoffset=0; 04711 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 04712 sndfile[sndoffset] = format[offset]; 04713 sndfile[sndoffset] = '\0'; 04714 res = wait_file(chan,ints,sndfile,lang); 04715 break; 04716 case 'A': 04717 case 'a': 04718 /* Sunday - Saturday */ 04719 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 04720 res = wait_file(chan,ints,nextmsg,lang); 04721 break; 04722 case 'B': 04723 case 'b': 04724 case 'h': 04725 /* January - December */ 04726 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 04727 res = wait_file(chan,ints,nextmsg,lang); 04728 break; 04729 case 'm': 04730 /* First - Twelfth */ 04731 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1); 04732 res = wait_file(chan,ints,nextmsg,lang); 04733 break; 04734 case 'd': 04735 case 'e': 04736 /* First - Thirtyfirst */ 04737 res = ast_say_number(chan, tm.tm_mday, ints, lang, NULL); 04738 break; 04739 case 'Y': 04740 /* Year */ 04741 if (tm.tm_year > 99) { 04742 res = wait_file(chan,ints, "digits/2",lang); 04743 if (!res) { 04744 res = wait_file(chan,ints, "digits/thousand",lang); 04745 } 04746 if (tm.tm_year > 100) { 04747 if (!res) { 04748 /* This works until the end of 2020 */ 04749 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year - 100); 04750 res = wait_file(chan,ints,nextmsg,lang); 04751 } 04752 } 04753 } else { 04754 if (tm.tm_year < 1) { 04755 /* I'm not going to handle 1900 and prior */ 04756 /* We'll just be silent on the year, instead of bombing out. */ 04757 } else { 04758 res = wait_file(chan,ints, "digits/19",lang); 04759 if (!res) { 04760 if (tm.tm_year <= 9) { 04761 /* 1901 - 1909 */ 04762 res = wait_file(chan,ints, "digits/oh",lang); 04763 if (!res) { 04764 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year); 04765 res = wait_file(chan,ints,nextmsg,lang); 04766 } 04767 } else if (tm.tm_year <= 20) { 04768 /* 1910 - 1920 */ 04769 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year); 04770 res = wait_file(chan,ints,nextmsg,lang); 04771 } else { 04772 /* 1921 - 1999 */ 04773 int ten, one; 04774 ten = tm.tm_year / 10; 04775 one = tm.tm_year % 10; 04776 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten * 10); 04777 res = wait_file(chan,ints,nextmsg,lang); 04778 if (!res) { 04779 if (one != 0) { 04780 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one); 04781 res = wait_file(chan,ints,nextmsg,lang); 04782 } 04783 } 04784 } 04785 } 04786 } 04787 } 04788 break; 04789 case 'I': 04790 case 'l': 04791 /* 12-Hour */ 04792 if (tm.tm_hour == 0) 04793 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 04794 else if (tm.tm_hour > 12) 04795 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 04796 else 04797 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 04798 res = wait_file(chan,ints,nextmsg,lang); 04799 break; 04800 case 'H': 04801 case 'k': 04802 /* 24-Hour */ 04803 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); 04804 if (!res) { 04805 res = wait_file(chan,ints, "digits/nl-uur",lang); 04806 } 04807 break; 04808 case 'M': 04809 /* Minute */ 04810 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 04811 break; 04812 case 'P': 04813 case 'p': 04814 /* AM/PM */ 04815 if (tm.tm_hour > 11) 04816 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 04817 else 04818 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 04819 res = wait_file(chan,ints,nextmsg,lang); 04820 break; 04821 case 'Q': 04822 /* Shorthand for "Today", "Yesterday", or ABdY */ 04823 /* XXX As emphasized elsewhere, this should the native way in your 04824 * language to say the date, with changes in what you say, depending 04825 * upon how recent the date is. XXX */ 04826 { 04827 struct timeval now; 04828 struct tm tmnow; 04829 time_t beg_today, tt; 04830 04831 gettimeofday(&now,NULL); 04832 tt = now.tv_sec; 04833 ast_localtime(&tt,&tmnow,timezone); 04834 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04835 /* In any case, it saves not having to do ast_mktime() */ 04836 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04837 if (beg_today < time) { 04838 /* Today */ 04839 res = wait_file(chan,ints, "digits/today",lang); 04840 } else if (beg_today - 86400 < time) { 04841 /* Yesterday */ 04842 res = wait_file(chan,ints, "digits/yesterday",lang); 04843 } else { 04844 res = ast_say_date_with_format_nl(chan, time, ints, lang, "ABdY", timezone); 04845 } 04846 } 04847 break; 04848 case 'q': 04849 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */ 04850 { 04851 struct timeval now; 04852 struct tm tmnow; 04853 time_t beg_today, tt; 04854 04855 gettimeofday(&now,NULL); 04856 tt = now.tv_sec; 04857 ast_localtime(&tt,&tmnow,timezone); 04858 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 04859 /* In any case, it saves not having to do ast_mktime() */ 04860 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 04861 if (beg_today < time) { 04862 /* Today */ 04863 } else if ((beg_today - 86400) < time) { 04864 /* Yesterday */ 04865 res = wait_file(chan,ints, "digits/yesterday",lang); 04866 } else if (beg_today - 86400 * 6 < time) { 04867 /* Within the last week */ 04868 res = ast_say_date_with_format_nl(chan, time, ints, lang, "A", timezone); 04869 } else { 04870 res = ast_say_date_with_format_nl(chan, time, ints, lang, "ABdY", timezone); 04871 } 04872 } 04873 break; 04874 case 'R': 04875 res = ast_say_date_with_format_nl(chan, time, ints, lang, "HM", timezone); 04876 break; 04877 case 'S': 04878 /* Seconds */ 04879 res = ast_say_number(chan, tm.tm_sec, ints, lang, (char *) NULL); 04880 break; 04881 case 'T': 04882 res = ast_say_date_with_format_nl(chan, time, ints, lang, "HMS", timezone); 04883 break; 04884 case ' ': 04885 case ' ': 04886 /* Just ignore spaces and tabs */ 04887 break; 04888 default: 04889 /* Unknown character */ 04890 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 04891 } 04892 /* Jump out on DTMF */ 04893 if (res) { 04894 break; 04895 } 04896 } 04897 return res; 04898 }
int ast_say_date_with_format_pl | ( | struct ast_channel * | chan, | |
time_t | time, | |||
const char * | ints, | |||
const char * | lang, | |||
const char * | format, | |||
const char * | timezone | |||
) | [static] |
Definition at line 4901 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 say_date_with_format().
04902 { 04903 struct tm tm; 04904 int res=0, offset, sndoffset; 04905 char sndfile[256], nextmsg[256]; 04906 04907 ast_localtime(&thetime, &tm, timezone); 04908 04909 for (offset = 0 ; format[offset] != '\0' ; offset++) { 04910 int remainder; 04911 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 04912 switch (format[offset]) { 04913 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 04914 case '\'': 04915 /* Literal name of a sound file */ 04916 sndoffset = 0; 04917 for (sndoffset = 0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 04918 sndfile[sndoffset] = format[offset]; 04919 sndfile[sndoffset] = '\0'; 04920 res = wait_file(chan, ints, sndfile, lang); 04921 break; 04922 case 'A': 04923 case 'a': 04924 /* Sunday - Saturday */ 04925 snprintf(nextmsg, sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 04926 res = wait_file(chan, ints, nextmsg, lang); 04927 break; 04928 case 'B': 04929 case 'b': 04930 case 'h': 04931 /* January - December */ 04932 snprintf(nextmsg, sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 04933 res = wait_file(chan, ints, nextmsg, lang); 04934 break; 04935 case 'm': 04936 /* Month enumerated */ 04937 res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, NULL); 04938 break; 04939 case 'd': 04940 case 'e': 04941 /* First - Thirtyfirst */ 04942 remainder = tm.tm_mday; 04943 if (tm.tm_mday > 30) { 04944 res = wait_file(chan, ints, "digits/h-30", lang); 04945 remainder -= 30; 04946 } 04947 if (tm.tm_mday > 20 && tm.tm_mday < 30) { 04948 res = wait_file(chan, ints, "digits/h-20", lang); 04949 remainder -= 20; 04950 } 04951 if (!res) { 04952 snprintf(nextmsg, sizeof(nextmsg), "digits/h-%d", remainder); 04953 res = wait_file(chan, ints, nextmsg, lang); 04954 } 04955 break; 04956 case 'Y': 04957 /* Year */ 04958 if (tm.tm_year > 100) { 04959 res = wait_file(chan, ints, "digits/2", lang); 04960 if (!res) 04961 res = wait_file(chan, ints, "digits/1000.2",lang); 04962 if (tm.tm_year > 100) { 04963 if (!res) 04964 res = ast_say_enumeration(chan, tm.tm_year - 100, ints, lang, NULL); 04965 } 04966 } else if (tm.tm_year == 100) { 04967 res = wait_file(chan, ints, "digits/h-2000", lang); 04968 } else { 04969 if (tm.tm_year < 1) { 04970 /* I'm not going to handle 1900 and prior */ 04971 /* We'll just be silent on the year, instead of bombing out. */ 04972 break; 04973 } else { 04974 res = wait_file(chan, ints, "digits/1000", lang); 04975 if (!res) { 04976 wait_file(chan, ints, "digits/900", lang); 04977 res = ast_say_enumeration(chan, tm.tm_year, ints, lang, NULL); 04978 } 04979 } 04980 } 04981 if (!res) 04982 wait_file(chan, ints, "digits/year", lang); 04983 break; 04984 case 'I': 04985 case 'l': 04986 /* 12-Hour */ 04987 if (tm.tm_hour == 0) 04988 snprintf(nextmsg, sizeof(nextmsg), "digits/t-12"); 04989 else if (tm.tm_hour > 12) 04990 snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour - 12); 04991 else 04992 snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour); 04993 04994 res = wait_file(chan, ints, nextmsg, lang); 04995 break; 04996 case 'H': 04997 case 'k': 04998 /* 24-Hour */ 04999 if (tm.tm_hour != 0) { 05000 snprintf(nextmsg, sizeof(nextmsg), "digits/t-%d", tm.tm_hour); 05001 res = wait_file(chan, ints, nextmsg, lang); 05002 } else 05003 res = wait_file(chan, ints, "digits/t-24", lang); 05004 break; 05005 case 'M': 05006 case 'N': 05007 /* Minute */ 05008 if (tm.tm_min == 0) { 05009 if (format[offset] == 'M') { 05010 res = wait_file(chan, ints, "digits/oclock", lang); 05011 } else { 05012 res = wait_file(chan, ints, "digits/100", lang); 05013 } 05014 } else 05015 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 05016 break; 05017 case 'P': 05018 case 'p': 05019 /* AM/PM */ 05020 if (tm.tm_hour > 11) 05021 snprintf(nextmsg, sizeof(nextmsg), "digits/p-m"); 05022 else 05023 snprintf(nextmsg, sizeof(nextmsg), "digits/a-m"); 05024 res = wait_file(chan, ints, nextmsg, lang); 05025 break; 05026 case 'Q': 05027 /* Shorthand for "Today", "Yesterday", or AdBY */ 05028 { 05029 time_t tv_sec = time(NULL); 05030 struct tm tmnow; 05031 time_t beg_today; 05032 05033 ast_localtime(&tv_sec,&tmnow, timezone); 05034 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 05035 /* In any case, it saves not having to do ast_mktime() */ 05036 beg_today = tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 05037 if (beg_today < thetime) { 05038 /* Today */ 05039 res = wait_file(chan, ints, "digits/today", lang); 05040 } else if (beg_today - 86400 < thetime) { 05041 /* Yesterday */ 05042 res = wait_file(chan, ints, "digits/yesterday", lang); 05043 } else { 05044 res = ast_say_date_with_format(chan, thetime, ints, lang, "AdBY", timezone); 05045 } 05046 } 05047 break; 05048 case 'q': 05049 /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */ 05050 { 05051 time_t tv_sec = time(NULL); 05052 struct tm tmnow; 05053 time_t beg_today; 05054 05055 ast_localtime(&tv_sec, &tmnow, timezone); 05056 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 05057 /* In any case, it saves not having to do ast_mktime() */ 05058 beg_today = tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 05059 if (beg_today < thetime) { 05060 /* Today */ 05061 } else if ((beg_today - 86400) < thetime) { 05062 /* Yesterday */ 05063 res = wait_file(chan, ints, "digits/yesterday", lang); 05064 } else if (beg_today - 86400 * 6 < thetime) { 05065 /* Within the last week */ 05066 res = ast_say_date_with_format(chan, thetime, ints, lang, "A", timezone); 05067 } else { 05068 res = ast_say_date_with_format(chan, thetime, ints, lang, "AdBY", timezone); 05069 } 05070 } 05071 break; 05072 case 'R': 05073 res = ast_say_date_with_format(chan, thetime, ints, lang, "HM", timezone); 05074 break; 05075 case 'S': 05076 /* Seconds */ 05077 res = wait_file(chan, ints, "digits/and", lang); 05078 if (!res) { 05079 if (tm.tm_sec == 1) { 05080 res = wait_file(chan, ints, "digits/1z", lang); 05081 if (!res) 05082 res = wait_file(chan, ints, "digits/second-a", lang); 05083 } else { 05084 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 05085 if (!res) { 05086 int ten, one; 05087 ten = tm.tm_sec / 10; 05088 one = tm.tm_sec % 10; 05089 05090 if (one > 1 && one < 5 && ten != 1) 05091 res = wait_file(chan,ints, "digits/seconds",lang); 05092 else 05093 res = wait_file(chan,ints, "digits/second",lang); 05094 } 05095 } 05096 } 05097 break; 05098 case 'T': 05099 res = ast_say_date_with_format(chan, thetime, ints, lang, "HMS", timezone); 05100 break; 05101 case ' ': 05102 case ' ': 05103 /* Just ignore spaces and tabs */ 05104 break; 05105 default: 05106 /* Unknown character */ 05107 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 05108 } 05109 /* Jump out on DTMF */ 05110 if (res) 05111 break; 05112 } 05113 return res; 05114 }
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 5117 of file say.c.
References ast_localtime(), ast_log(), ast_say_number(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
05118 { 05119 struct tm tm; 05120 int res=0, offset, sndoffset; 05121 char sndfile[256], nextmsg[256]; 05122 05123 if (format == NULL) 05124 format = "Ad 'digits/pt-de' B 'digits/pt-de' Y I 'digits/pt-e' Mp"; 05125 05126 ast_localtime(&time,&tm,timezone); 05127 05128 for (offset=0 ; format[offset] != '\0' ; offset++) { 05129 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 05130 switch (format[offset]) { 05131 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 05132 case '\'': 05133 /* Literal name of a sound file */ 05134 sndoffset=0; 05135 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 05136 sndfile[sndoffset] = format[offset]; 05137 sndfile[sndoffset] = '\0'; 05138 snprintf(nextmsg,sizeof(nextmsg), "%s", sndfile); 05139 res = wait_file(chan,ints,nextmsg,lang); 05140 break; 05141 case 'A': 05142 case 'a': 05143 /* Sunday - Saturday */ 05144 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 05145 res = wait_file(chan,ints,nextmsg,lang); 05146 break; 05147 case 'B': 05148 case 'b': 05149 case 'h': 05150 /* January - December */ 05151 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 05152 res = wait_file(chan,ints,nextmsg,lang); 05153 break; 05154 case 'm': 05155 /* First - Twelfth */ 05156 if (!strcasecmp(lang, "pt_BR")) { 05157 res = ast_say_number(chan, tm.tm_mon+1, ints, lang, (char *) NULL); 05158 } else { 05159 snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1); 05160 res = wait_file(chan,ints,nextmsg,lang); 05161 } 05162 break; 05163 case 'd': 05164 case 'e': 05165 /* First - Thirtyfirst */ 05166 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 05167 break; 05168 case 'Y': 05169 /* Year */ 05170 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 05171 break; 05172 case 'I': 05173 case 'l': 05174 /* 12-Hour */ 05175 if (tm.tm_hour == 0) { 05176 if (format[offset] == 'I') 05177 res = wait_file(chan, ints, "digits/pt-a", lang); 05178 if (!res) 05179 res = wait_file(chan, ints, "digits/pt-meianoite", lang); 05180 } else if (tm.tm_hour == 12) { 05181 if (format[offset] == 'I') 05182 res = wait_file(chan, ints, "digits/pt-ao", lang); 05183 if (!res) 05184 res = wait_file(chan, ints, "digits/pt-meiodia", lang); 05185 } else { 05186 if (format[offset] == 'I') { 05187 if ((tm.tm_hour % 12) != 1) 05188 res = wait_file(chan, ints, "digits/pt-as", lang); 05189 else 05190 res = wait_file(chan, ints, "digits/pt-a", lang); 05191 } 05192 if (!res) 05193 res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f"); 05194 } 05195 break; 05196 case 'H': 05197 case 'k': 05198 /* 24-Hour */ 05199 res = ast_say_number(chan, tm.tm_hour, ints, lang, "f"); 05200 if ((!res) && (format[offset] == 'H')) { 05201 if (tm.tm_hour > 1) { 05202 res = wait_file(chan,ints,"digits/hours",lang); 05203 } else { 05204 res = wait_file(chan,ints,"digits/hour",lang); 05205 } 05206 } 05207 break; 05208 case 'M': 05209 /* Minute */ 05210 res = ast_say_number(chan, tm.tm_min, ints, lang, NULL); 05211 if (!res) { 05212 if (tm.tm_min > 1) { 05213 res = wait_file(chan,ints,"digits/minutes",lang); 05214 } else { 05215 res = wait_file(chan,ints,"digits/minute",lang); 05216 } 05217 } 05218 break; 05219 case 'P': 05220 case 'p': 05221 /* AM/PM */ 05222 if (!strcasecmp(lang, "pt_BR")) { 05223 if ((tm.tm_hour != 0) && (tm.tm_hour != 12)) { 05224 res = wait_file(chan, ints, "digits/pt-da", lang); 05225 if (!res) { 05226 if ((tm.tm_hour >= 0) && (tm.tm_hour < 12)) 05227 res = wait_file(chan, ints, "digits/morning", lang); 05228 else if ((tm.tm_hour >= 12) && (tm.tm_hour < 18)) 05229 res = wait_file(chan, ints, "digits/afternoon", lang); 05230 else res = wait_file(chan, ints, "digits/night", lang); 05231 } 05232 } 05233 } else { 05234 if (tm.tm_hour > 12) 05235 res = wait_file(chan, ints, "digits/p-m", lang); 05236 else if (tm.tm_hour && tm.tm_hour < 12) 05237 res = wait_file(chan, ints, "digits/a-m", lang); 05238 } 05239 break; 05240 case 'Q': 05241 /* Shorthand for "Today", "Yesterday", or ABdY */ 05242 /* XXX As emphasized elsewhere, this should the native way in your 05243 * language to say the date, with changes in what you say, depending 05244 * upon how recent the date is. XXX */ 05245 { 05246 struct timeval now; 05247 struct tm tmnow; 05248 time_t beg_today, tt; 05249 05250 gettimeofday(&now,NULL); 05251 tt = now.tv_sec; 05252 ast_localtime(&tt,&tmnow,timezone); 05253 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 05254 /* In any case, it saves not having to do ast_mktime() */ 05255 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 05256 if (beg_today < time) { 05257 /* Today */ 05258 res = wait_file(chan,ints, "digits/today",lang); 05259 } else if (beg_today - 86400 < time) { 05260 /* Yesterday */ 05261 res = wait_file(chan,ints, "digits/yesterday",lang); 05262 } else { 05263 res = ast_say_date_with_format_pt(chan, time, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", timezone); 05264 } 05265 } 05266 break; 05267 case 'q': 05268 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */ 05269 /* XXX As emphasized elsewhere, this should the native way in your 05270 * language to say the date, with changes in what you say, depending 05271 * upon how recent the date is. XXX */ 05272 { 05273 struct timeval now; 05274 struct tm tmnow; 05275 time_t beg_today, tt; 05276 05277 gettimeofday(&now,NULL); 05278 tt = now.tv_sec; 05279 ast_localtime(&tt,&tmnow,timezone); 05280 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 05281 /* In any case, it saves not having to do ast_mktime() */ 05282 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 05283 if (beg_today < time) { 05284 /* Today */ 05285 } else if ((beg_today - 86400) < time) { 05286 /* Yesterday */ 05287 res = wait_file(chan,ints, "digits/yesterday",lang); 05288 } else if (beg_today - 86400 * 6 < time) { 05289 /* Within the last week */ 05290 res = ast_say_date_with_format_pt(chan, time, ints, lang, "A", timezone); 05291 } else { 05292 res = ast_say_date_with_format_pt(chan, time, ints, lang, "Ad 'digits/pt-de' B 'digits/pt-de' Y", timezone); 05293 } 05294 } 05295 break; 05296 case 'R': 05297 res = ast_say_date_with_format_pt(chan, time, ints, lang, "H 'digits/and' M", timezone); 05298 break; 05299 case 'S': 05300 /* Seconds */ 05301 res = ast_say_number(chan, tm.tm_sec, ints, lang, NULL); 05302 if (!res) { 05303 if (tm.tm_sec > 1) { 05304 res = wait_file(chan,ints,"digits/seconds",lang); 05305 } else { 05306 res = wait_file(chan,ints,"digits/second",lang); 05307 } 05308 } 05309 break; 05310 case 'T': 05311 res = ast_say_date_with_format_pt(chan, time, ints, lang, "HMS", timezone); 05312 break; 05313 case ' ': 05314 case ' ': 05315 /* Just ignore spaces and tabs */ 05316 break; 05317 default: 05318 /* Unknown character */ 05319 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 05320 } 05321 /* Jump out on DTMF */ 05322 if (res) { 05323 break; 05324 } 05325 } 05326 return res; 05327 }
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 5330 of file say.c.
References ast_localtime(), ast_log(), LOG_DEBUG, LOG_WARNING, offset, and wait_file().
Referenced by say_date_with_format().
05331 { 05332 struct tm tm; 05333 int res=0, offset, sndoffset; 05334 char sndfile[256], nextmsg[256]; 05335 05336 if (format == NULL) 05337 format = "YBdAkM"; 05338 05339 ast_localtime(&time,&tm,timezone); 05340 05341 for (offset=0 ; format[offset] != '\0' ; offset++) { 05342 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 05343 switch (format[offset]) { 05344 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 05345 case '\'': 05346 /* Literal name of a sound file */ 05347 sndoffset=0; 05348 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 05349 sndfile[sndoffset] = format[offset]; 05350 sndfile[sndoffset] = '\0'; 05351 res = wait_file(chan,ints,sndfile,lang); 05352 break; 05353 case 'A': 05354 case 'a': 05355 /* Sunday - Saturday */ 05356 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 05357 res = wait_file(chan,ints,nextmsg,lang); 05358 break; 05359 case 'B': 05360 case 'b': 05361 case 'h': 05362 case 'm': 05363 /* January - December */ 05364 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 05365 res = wait_file(chan,ints,nextmsg,lang); 05366 break; 05367 case 'd': 05368 case 'e': 05369 /* First - Thirtyfirst */ 05370 if (!(tm.tm_mday % 10) || (tm.tm_mday < 10)) { 05371 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday); 05372 res = wait_file(chan,ints,nextmsg,lang); 05373 } else { 05374 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday - (tm.tm_mday % 10)); 05375 res = wait_file(chan,ints,nextmsg,lang); 05376 if (!res) { 05377 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday % 10); 05378 res = wait_file(chan,ints,nextmsg,lang); 05379 } 05380 } 05381 if (!res) res = wait_file(chan,ints,"digits/day",lang); 05382 break; 05383 case 'Y': 05384 /* Year */ 05385 if (tm.tm_year > 99) { 05386 res = wait_file(chan,ints, "digits/2",lang); 05387 if (!res) { 05388 res = wait_file(chan,ints, "digits/thousand",lang); 05389 } 05390 if (tm.tm_year > 100) { 05391 if (!res) { 05392 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) / 10); 05393 res = wait_file(chan,ints,nextmsg,lang); 05394 if (!res) { 05395 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) % 10); 05396 res = wait_file(chan,ints,nextmsg,lang); 05397 } 05398 } 05399 } 05400 if (!res) { 05401 res = wait_file(chan,ints, "digits/year",lang); 05402 } 05403 } else { 05404 if (tm.tm_year < 1) { 05405 /* I'm not going to handle 1900 and prior */ 05406 /* We'll just be silent on the year, instead of bombing out. */ 05407 } else { 05408 res = wait_file(chan,ints, "digits/1",lang); 05409 if (!res) { 05410 res = wait_file(chan,ints, "digits/9",lang); 05411 } 05412 if (!res) { 05413 if (tm.tm_year <= 9) { 05414 /* 1901 - 1909 */ 05415 res = wait_file(chan,ints, "digits/0",lang); 05416 if (!res) { 05417 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year); 05418 res = wait_file(chan,ints,nextmsg,lang); 05419 } 05420 } else { 05421 /* 1910 - 1999 */ 05422 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year / 10); 05423 res = wait_file(chan,ints,nextmsg,lang); 05424 if (!res) { 05425 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year % 10); 05426 res = wait_file(chan,ints,nextmsg,lang); 05427 } 05428 } 05429 } 05430 } 05431 if (!res) { 05432 res = wait_file(chan,ints, "digits/year",lang); 05433 } 05434 } 05435 break; 05436 case 'I': 05437 case 'l': 05438 /* 12-Hour */ 05439 if (tm.tm_hour == 0) 05440 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 05441 else if (tm.tm_hour > 12) 05442 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 05443 else 05444 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 05445 res = wait_file(chan,ints,nextmsg,lang); 05446 if (!res) { 05447 res = wait_file(chan,ints, "digits/oclock",lang); 05448 } 05449 break; 05450 case 'H': 05451 if (tm.tm_hour < 10) { 05452 res = wait_file(chan, ints, "digits/0", lang); 05453 } 05454 case 'k': 05455 /* 24-Hour */ 05456 if (!(tm.tm_hour % 10) || tm.tm_hour < 10) { 05457 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 05458 res = wait_file(chan,ints,nextmsg,lang); 05459 } else { 05460 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - (tm.tm_hour % 10)); 05461 res = wait_file(chan,ints,nextmsg,lang); 05462 if (!res) { 05463 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour % 10); 05464 res = wait_file(chan,ints,nextmsg,lang); 05465 } 05466 } 05467 if (!res) { 05468 res = wait_file(chan,ints, "digits/oclock",lang); 05469 } 05470 break; 05471 case 'M': 05472 /* Minute */ 05473 if (!(tm.tm_min % 10) || tm.tm_min < 10) { 05474 if (tm.tm_min < 10) { 05475 res = wait_file(chan, ints, "digits/0", lang); 05476 } 05477 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min); 05478 res = wait_file(chan,ints,nextmsg,lang); 05479 } else { 05480 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min - (tm.tm_min % 10)); 05481 res = wait_file(chan,ints,nextmsg,lang); 05482 if (!res) { 05483 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min % 10); 05484 res = wait_file(chan,ints,nextmsg,lang); 05485 } 05486 } 05487 if (!res) { 05488 res = wait_file(chan,ints, "digits/minute",lang); 05489 } 05490 break; 05491 case 'P': 05492 case 'p': 05493 /* AM/PM */ 05494 if (tm.tm_hour > 11) 05495 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 05496 else 05497 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 05498 res = wait_file(chan,ints,nextmsg,lang); 05499 break; 05500 case 'Q': 05501 /* Shorthand for "Today", "Yesterday", or ABdY */ 05502 /* XXX As emphasized elsewhere, this should the native way in your 05503 * language to say the date, with changes in what you say, depending 05504 * upon how recent the date is. XXX */ 05505 { 05506 struct timeval now; 05507 struct tm tmnow; 05508 time_t beg_today, tt; 05509 05510 gettimeofday(&now,NULL); 05511 tt = now.tv_sec; 05512 ast_localtime(&tt,&tmnow,timezone); 05513 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 05514 /* In any case, it saves not having to do ast_mktime() */ 05515 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 05516 if (beg_today < time) { 05517 /* Today */ 05518 res = wait_file(chan,ints, "digits/today",lang); 05519 } else if (beg_today - 86400 < time) { 05520 /* Yesterday */ 05521 res = wait_file(chan,ints, "digits/yesterday",lang); 05522 } else { 05523 res = ast_say_date_with_format_tw(chan, time, ints, lang, "YBdA", timezone); 05524 } 05525 } 05526 break; 05527 case 'q': 05528 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */ 05529 /* XXX As emphasized elsewhere, this should the native way in your 05530 * language to say the date, with changes in what you say, depending 05531 * upon how recent the date is. XXX */ 05532 { 05533 struct timeval now; 05534 struct tm tmnow; 05535 time_t beg_today, tt; 05536 05537 gettimeofday(&now,NULL); 05538 tt = now.tv_sec; 05539 ast_localtime(&tt,&tmnow,timezone); 05540 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 05541 /* In any case, it saves not having to do ast_mktime() */ 05542 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 05543 if (beg_today < time) { 05544 /* Today */ 05545 } else if ((beg_today - 86400) < time) { 05546 /* Yesterday */ 05547 res = wait_file(chan,ints, "digits/yesterday",lang); 05548 } else if (beg_today - 86400 * 6 < time) { 05549 /* Within the last week */ 05550 res = ast_say_date_with_format_tw(chan, time, ints, lang, "A", timezone); 05551 } else { 05552 res = ast_say_date_with_format_tw(chan, time, ints, lang, "YBdA", timezone); 05553 } 05554 } 05555 break; 05556 case 'R': 05557 res = ast_say_date_with_format_tw(chan, time, ints, lang, "kM", timezone); 05558 break; 05559 case 'S': 05560 /* Seconds */ 05561 if (!(tm.tm_sec % 10) || tm.tm_sec < 10) { 05562 if (tm.tm_sec < 10) { 05563 res = wait_file(chan, ints, "digits/0", lang); 05564 } 05565 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec); 05566 res = wait_file(chan,ints,nextmsg,lang); 05567 } else { 05568 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec - (tm.tm_sec % 10)); 05569 res = wait_file(chan,ints,nextmsg,lang); 05570 if (!res) { 05571 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec % 10); 05572 res = wait_file(chan,ints,nextmsg,lang); 05573 } 05574 } 05575 if (!res) { 05576 res = wait_file(chan,ints, "digits/second",lang); 05577 } 05578 break; 05579 case 'T': 05580 res = ast_say_date_with_format_tw(chan, time, ints, lang, "HMS", timezone); 05581 break; 05582 case ' ': 05583 case ' ': 05584 /* Just ignore spaces and tabs */ 05585 break; 05586 default: 05587 /* Unknown character */ 05588 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 05589 } 05590 /* Jump out on DTMF */ 05591 if (res) { 05592 break; 05593 } 05594 } 05595 return res; 05596 }
int ast_say_datetime_de | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5991 of file say.c.
References ast_localtime(), ast_say_date, and ast_say_time.
Referenced by say_datetime().
05992 { 05993 struct tm tm; 05994 int res = 0; 05995 05996 ast_localtime(&t, &tm, NULL); 05997 res = ast_say_date(chan, t, ints, lang); 05998 if (!res) 05999 ast_say_time(chan, t, ints, lang); 06000 return res; 06001 06002 }
int ast_say_datetime_en | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5925 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_datetime().
05926 { 05927 struct tm tm; 05928 char fn[256]; 05929 int res = 0; 05930 int hour, pm=0; 05931 05932 ast_localtime(&t, &tm, NULL); 05933 if (!res) { 05934 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 05935 res = ast_streamfile(chan, fn, lang); 05936 if (!res) 05937 res = ast_waitstream(chan, ints); 05938 } 05939 if (!res) { 05940 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 05941 res = ast_streamfile(chan, fn, lang); 05942 if (!res) 05943 res = ast_waitstream(chan, ints); 05944 } 05945 if (!res) 05946 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 05947 05948 hour = tm.tm_hour; 05949 if (!hour) 05950 hour = 12; 05951 else if (hour == 12) 05952 pm = 1; 05953 else if (hour > 12) { 05954 hour -= 12; 05955 pm = 1; 05956 } 05957 if (!res) 05958 res = ast_say_number(chan, hour, ints, lang, (char *) NULL); 05959 05960 if (tm.tm_min > 9) { 05961 if (!res) 05962 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05963 } else if (tm.tm_min) { 05964 if (!res) 05965 res = ast_streamfile(chan, "digits/oh", lang); 05966 if (!res) 05967 res = ast_waitstream(chan, ints); 05968 if (!res) 05969 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05970 } else { 05971 if (!res) 05972 res = ast_streamfile(chan, "digits/oclock", lang); 05973 if (!res) 05974 res = ast_waitstream(chan, ints); 05975 } 05976 if (pm) { 05977 if (!res) 05978 res = ast_streamfile(chan, "digits/p-m", lang); 05979 } else { 05980 if (!res) 05981 res = ast_streamfile(chan, "digits/a-m", lang); 05982 } 05983 if (!res) 05984 res = ast_waitstream(chan, ints); 05985 if (!res) 05986 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 05987 return res; 05988 }
int ast_say_datetime_fr | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6005 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_datetime().
06006 { 06007 struct tm tm; 06008 char fn[256]; 06009 int res = 0; 06010 06011 ast_localtime(&t, &tm, NULL); 06012 06013 if (!res) 06014 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 06015 06016 if (!res) { 06017 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06018 res = ast_streamfile(chan, fn, lang); 06019 if (!res) 06020 res = ast_waitstream(chan, ints); 06021 } 06022 if (!res) { 06023 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06024 res = ast_streamfile(chan, fn, lang); 06025 if (!res) 06026 res = ast_waitstream(chan, ints); 06027 } 06028 06029 if (!res) 06030 res = ast_say_number(chan, tm.tm_hour, ints, lang, "f"); 06031 if (!res) 06032 res = ast_streamfile(chan, "digits/oclock", lang); 06033 if (tm.tm_min > 0) { 06034 if (!res) 06035 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 06036 } 06037 if (!res) 06038 res = ast_waitstream(chan, ints); 06039 if (!res) 06040 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 06041 return res; 06042 }
int ast_say_datetime_from_now_en | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6283 of file say.c.
References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), and ast_waitstream().
Referenced by say_datetime_from_now().
06284 { 06285 int res=0; 06286 time_t nowt; 06287 int daydiff; 06288 struct tm tm; 06289 struct tm now; 06290 char fn[256]; 06291 06292 time(&nowt); 06293 06294 ast_localtime(&t, &tm, NULL); 06295 ast_localtime(&nowt,&now, NULL); 06296 daydiff = now.tm_yday - tm.tm_yday; 06297 if ((daydiff < 0) || (daydiff > 6)) { 06298 /* Day of month and month */ 06299 if (!res) { 06300 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06301 res = ast_streamfile(chan, fn, lang); 06302 if (!res) 06303 res = ast_waitstream(chan, ints); 06304 } 06305 if (!res) 06306 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 06307 06308 } else if (daydiff) { 06309 /* Just what day of the week */ 06310 if (!res) { 06311 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06312 res = ast_streamfile(chan, fn, lang); 06313 if (!res) 06314 res = ast_waitstream(chan, ints); 06315 } 06316 } /* Otherwise, it was today */ 06317 if (!res) 06318 res = ast_say_time(chan, t, ints, lang); 06319 return res; 06320 }
int ast_say_datetime_from_now_fr | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6323 of file say.c.
References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), and ast_waitstream().
Referenced by say_datetime_from_now().
06324 { 06325 int res=0; 06326 time_t nowt; 06327 int daydiff; 06328 struct tm tm; 06329 struct tm now; 06330 char fn[256]; 06331 06332 time(&nowt); 06333 06334 ast_localtime(&t, &tm, NULL); 06335 ast_localtime(&nowt, &now, NULL); 06336 daydiff = now.tm_yday - tm.tm_yday; 06337 if ((daydiff < 0) || (daydiff > 6)) { 06338 /* Day of month and month */ 06339 if (!res) { 06340 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06341 res = ast_streamfile(chan, fn, lang); 06342 if (!res) 06343 res = ast_waitstream(chan, ints); 06344 } 06345 if (!res) 06346 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 06347 06348 } else if (daydiff) { 06349 /* Just what day of the week */ 06350 if (!res) { 06351 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06352 res = ast_streamfile(chan, fn, lang); 06353 if (!res) 06354 res = ast_waitstream(chan, ints); 06355 } 06356 } /* Otherwise, it was today */ 06357 if (!res) 06358 res = ast_say_time(chan, t, ints, lang); 06359 return res; 06360 }
static int ast_say_datetime_from_now_ge | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 7207 of file say.c.
References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), and ast_waitstream().
Referenced by say_datetime_from_now().
07208 { 07209 int res=0; 07210 time_t nowt; 07211 int daydiff; 07212 struct tm tm; 07213 struct tm now; 07214 char fn[256]; 07215 07216 time(&nowt); 07217 07218 ast_localtime(&t, &tm, NULL); 07219 ast_localtime(&nowt, &now, NULL); 07220 daydiff = now.tm_yday - tm.tm_yday; 07221 if ((daydiff < 0) || (daydiff > 6)) { 07222 /* Day of month and month */ 07223 if (!res) 07224 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 07225 if (!res) { 07226 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 07227 res = ast_streamfile(chan, fn, lang); 07228 if (!res) 07229 res = ast_waitstream(chan, ints); 07230 } 07231 07232 } else if (daydiff) { 07233 /* Just what day of the week */ 07234 if (!res) { 07235 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 07236 res = ast_streamfile(chan, fn, lang); 07237 if (!res) 07238 res = ast_waitstream(chan, ints); 07239 } 07240 } /* Otherwise, it was today */ 07241 if (!res) 07242 res = ast_say_time(chan, t, ints, lang); 07243 07244 return res; 07245 }
int ast_say_datetime_from_now_he | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6405 of file say.c.
References ast_localtime(), ast_say_number(), ast_say_time, ast_streamfile(), and ast_waitstream().
Referenced by say_datetime_from_now().
06406 { 06407 int res = 0; 06408 time_t nowt; 06409 int daydiff; 06410 struct tm tm; 06411 struct tm now; 06412 char fn[256]; 06413 06414 time(&nowt); 06415 06416 ast_localtime(&t, &tm, NULL); 06417 ast_localtime(&nowt, &now, NULL); 06418 daydiff = now.tm_yday - tm.tm_yday; 06419 if ((daydiff < 0) || (daydiff > 6)) { 06420 /* Day of month and month */ 06421 if (!res) { 06422 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06423 res = ast_streamfile(chan, fn, lang); 06424 if (!res) 06425 res = ast_waitstream(chan, ints); 06426 } 06427 if (!res) { 06428 res = ast_say_number(chan, tm.tm_mday, ints, lang, "f"); 06429 } 06430 } else if (daydiff) { 06431 /* Just what day of the week */ 06432 if (!res) { 06433 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06434 res = ast_streamfile(chan, fn, lang); 06435 if (!res) { 06436 res = ast_waitstream(chan, ints); 06437 } 06438 } 06439 } /* Otherwise, it was today */ 06440 if (!res) { 06441 res = ast_say_time(chan, t, ints, lang); 06442 } 06443 return res; 06444 }
int ast_say_datetime_from_now_pt | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6363 of file say.c.
References ast_localtime(), ast_say_number(), ast_say_time, and wait_file().
Referenced by say_datetime_from_now().
06364 { 06365 int res=0; 06366 time_t nowt; 06367 int daydiff; 06368 struct tm tm; 06369 struct tm now; 06370 char fn[256]; 06371 06372 time(&nowt); 06373 06374 ast_localtime(&t, &tm, NULL); 06375 ast_localtime(&nowt, &now, NULL); 06376 daydiff = now.tm_yday - tm.tm_yday; 06377 if ((daydiff < 0) || (daydiff > 6)) { 06378 /* Day of month and month */ 06379 if (!res) 06380 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 06381 if (!res) 06382 res = wait_file(chan, ints, "digits/pt-de", lang); 06383 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06384 if (!res) 06385 res = wait_file(chan, ints, fn, lang); 06386 06387 } else if (daydiff) { 06388 /* Just what day of the week */ 06389 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06390 if (!res) 06391 res = wait_file(chan, ints, fn, lang); 06392 } /* Otherwise, it was today */ 06393 if (tm.tm_hour > 1) 06394 snprintf(fn, sizeof(fn), "digits/pt-as"); 06395 else 06396 snprintf(fn, sizeof(fn), "digits/pt-a"); 06397 if (!res) 06398 res = wait_file(chan, ints, fn, lang); 06399 if (!res) 06400 res = ast_say_time(chan, t, ints, lang); 06401 return res; 06402 }
static int ast_say_datetime_ge | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 7190 of file say.c.
References ast_localtime(), ast_say_date, and ast_say_time.
Referenced by say_datetime().
07191 { 07192 struct tm tm; 07193 int res = 0; 07194 07195 ast_localtime(&t, &tm, NULL); 07196 res = ast_say_date(chan, t, ints, lang); 07197 if (!res) 07198 ast_say_time(chan, t, ints, lang); 07199 return res; 07200 07201 }
static int ast_say_datetime_gr | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6668 of file say.c.
References ast_localtime(), ast_say_time_gr(), ast_streamfile(), ast_waitstream(), and gr_say_number_female().
Referenced by say_datetime().
06669 { 06670 struct tm tm; 06671 char fn[256]; 06672 int res = 0; 06673 06674 ast_localtime(&t, &tm, NULL); 06675 06676 06677 /* W E E K - D A Y */ 06678 if (!res) { 06679 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06680 res = ast_streamfile(chan, fn, lang); 06681 if (!res) 06682 res = ast_waitstream(chan, ints); 06683 } 06684 /* D A Y */ 06685 if (!res) { 06686 gr_say_number_female(tm.tm_mday, chan, ints, lang); 06687 } 06688 /* M O N T H */ 06689 if (!res) { 06690 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06691 res = ast_streamfile(chan, fn, lang); 06692 if (!res) 06693 res = ast_waitstream(chan, ints); 06694 } 06695 06696 res = ast_say_time_gr(chan, t, ints, lang); 06697 return res; 06698 }
int ast_say_datetime_he | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6201 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_datetime().
06202 { 06203 struct tm tm; 06204 char fn[256]; 06205 int res = 0; 06206 int hour; 06207 06208 ast_localtime(&t, &tm, NULL); 06209 if (!res) { 06210 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06211 res = ast_streamfile(chan, fn, lang); 06212 if (!res) { 06213 res = ast_waitstream(chan, ints); 06214 } 06215 } 06216 if (!res) { 06217 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06218 res = ast_streamfile(chan, fn, lang); 06219 if (!res) { 06220 res = ast_waitstream(chan, ints); 06221 } 06222 } 06223 if (!res) { 06224 res = ast_say_number(chan, tm.tm_mday, ints, lang, "f"); 06225 } 06226 06227 hour = tm.tm_hour; 06228 if (!hour) { 06229 hour = 12; 06230 } 06231 06232 if (!res) { 06233 res = ast_say_number(chan, hour, ints, lang, "f"); 06234 } 06235 06236 if (tm.tm_min > 9) { 06237 if (!res) { 06238 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 06239 } 06240 } else if (tm.tm_min) { 06241 if (!res) { 06242 /* say a leading zero if needed */ 06243 res = ast_say_number(chan, 0, ints, lang, "f"); 06244 } 06245 if (!res) { 06246 res = ast_waitstream(chan, ints); 06247 } 06248 if (!res) { 06249 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 06250 } 06251 } else { 06252 if (!res) { 06253 res = ast_waitstream(chan, ints); 06254 } 06255 } 06256 if (!res) { 06257 res = ast_waitstream(chan, ints); 06258 } 06259 if (!res) { 06260 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, "f"); 06261 } 06262 return res; 06263 }
int ast_say_datetime_nl | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6045 of file say.c.
References ast_localtime(), ast_say_date, ast_say_time, ast_streamfile(), and ast_waitstream().
Referenced by say_datetime().
06046 { 06047 struct tm tm; 06048 int res = 0; 06049 06050 ast_localtime(&t, &tm, NULL); 06051 res = ast_say_date(chan, t, ints, lang); 06052 if (!res) { 06053 res = ast_streamfile(chan, "digits/nl-om", lang); 06054 if (!res) 06055 res = ast_waitstream(chan, ints); 06056 } 06057 if (!res) 06058 ast_say_time(chan, t, ints, lang); 06059 return res; 06060 }
int ast_say_datetime_pt | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6063 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_datetime().
06064 { 06065 struct tm tm; 06066 char fn[256]; 06067 int res = 0; 06068 int hour, pm=0; 06069 06070 ast_localtime(&t, &tm, NULL); 06071 if (!res) { 06072 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06073 res = ast_streamfile(chan, fn, lang); 06074 if (!res) 06075 res = ast_waitstream(chan, ints); 06076 } 06077 if (!res) { 06078 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06079 res = ast_streamfile(chan, fn, lang); 06080 if (!res) 06081 res = ast_waitstream(chan, ints); 06082 } 06083 if (!res) 06084 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 06085 06086 hour = tm.tm_hour; 06087 if (!hour) 06088 hour = 12; 06089 else if (hour == 12) 06090 pm = 1; 06091 else if (hour > 12) { 06092 hour -= 12; 06093 pm = 1; 06094 } 06095 if (!res) 06096 res = ast_say_number(chan, hour, ints, lang, (char *) NULL); 06097 06098 if (tm.tm_min > 9) { 06099 if (!res) 06100 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 06101 } else if (tm.tm_min) { 06102 if (!res) 06103 res = ast_streamfile(chan, "digits/oh", lang); 06104 if (!res) 06105 res = ast_waitstream(chan, ints); 06106 if (!res) 06107 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 06108 } else { 06109 if (!res) 06110 res = ast_streamfile(chan, "digits/oclock", lang); 06111 if (!res) 06112 res = ast_waitstream(chan, ints); 06113 } 06114 if (pm) { 06115 if (!res) 06116 res = ast_streamfile(chan, "digits/p-m", lang); 06117 } else { 06118 if (!res) 06119 res = ast_streamfile(chan, "digits/a-m", lang); 06120 } 06121 if (!res) 06122 res = ast_waitstream(chan, ints); 06123 if (!res) 06124 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 06125 return res; 06126 }
int ast_say_datetime_pt_BR | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6129 of file say.c.
References ast_localtime(), ast_say_date, and ast_say_time.
Referenced by say_datetime().
06130 { 06131 struct tm tm; 06132 int res = 0; 06133 06134 ast_localtime(&t, &tm, NULL); 06135 res = ast_say_date(chan, t, ints, lang); 06136 if (!res) 06137 res = ast_say_time(chan, t, ints, lang); 06138 return res; 06139 }
int ast_say_datetime_tw | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6142 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_datetime().
06143 { 06144 struct tm tm; 06145 char fn[256]; 06146 int res = 0; 06147 int hour, pm=0; 06148 06149 ast_localtime(&t, &tm, NULL); 06150 if (!res) 06151 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 06152 if (!res) { 06153 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06154 res = ast_streamfile(chan, fn, lang); 06155 if (!res) 06156 res = ast_waitstream(chan, ints); 06157 } 06158 if (!res) 06159 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 06160 if (!res) { 06161 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06162 res = ast_streamfile(chan, fn, lang); 06163 if (!res) 06164 res = ast_waitstream(chan, ints); 06165 } 06166 06167 hour = tm.tm_hour; 06168 if (!hour) 06169 hour = 12; 06170 else if (hour == 12) 06171 pm = 1; 06172 else if (hour > 12) { 06173 hour -= 12; 06174 pm = 1; 06175 } 06176 if (pm) { 06177 if (!res) 06178 res = ast_streamfile(chan, "digits/p-m", lang); 06179 } else { 06180 if (!res) 06181 res = ast_streamfile(chan, "digits/a-m", lang); 06182 } 06183 if (!res) 06184 res = ast_waitstream(chan, ints); 06185 if (!res) 06186 res = ast_say_number(chan, hour, ints, lang, (char *) NULL); 06187 if (!res) 06188 res = ast_streamfile(chan, "digits/oclock", lang); 06189 if (!res) 06190 res = ast_waitstream(chan, ints); 06191 if (!res) 06192 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 06193 if (!res) 06194 res = ast_streamfile(chan, "digits/minute", lang); 06195 if (!res) 06196 res = ast_waitstream(chan, ints); 06197 return res; 06198 }
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 2498 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 say_enumeration_full().
02499 { 02500 /* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */ 02501 int res = 0, t = 0; 02502 char fn[256] = "", fna[256] = ""; 02503 char *gender; 02504 02505 if (options && !strncasecmp(options, "f",1)) { 02506 gender = "F"; 02507 } else if (options && !strncasecmp(options, "n",1)) { 02508 gender = "N"; 02509 } else { 02510 gender = ""; 02511 } 02512 02513 if (!num) 02514 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 02515 02516 while (!res && num) { 02517 if (num < 0) { 02518 snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */ 02519 if ( num > INT_MIN ) { 02520 num = -num; 02521 } else { 02522 num = 0; 02523 } 02524 } else if (num < 100 && t) { 02525 snprintf(fn, sizeof(fn), "digits/and"); 02526 t = 0; 02527 } else if (num < 20) { 02528 snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender); 02529 num = 0; 02530 } else if (num < 100) { 02531 int ones = num % 10; 02532 if (ones) { 02533 snprintf(fn, sizeof(fn), "digits/%d-and", ones); 02534 num -= ones; 02535 } else { 02536 snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender); 02537 num = 0; 02538 } 02539 } else if (num == 100 && t == 0) { 02540 snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender); 02541 num = 0; 02542 } else if (num < 1000) { 02543 int hundreds = num / 100; 02544 num = num % 100; 02545 if (hundreds == 1) { 02546 snprintf(fn, sizeof(fn), "digits/1N"); 02547 } else { 02548 snprintf(fn, sizeof(fn), "digits/%d", hundreds); 02549 } 02550 if (num) { 02551 snprintf(fna, sizeof(fna), "digits/hundred"); 02552 } else { 02553 snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender); 02554 } 02555 t = 1; 02556 } else if (num < 1000000) { 02557 int thousands = num / 1000; 02558 num = num % 1000; 02559 if (thousands == 1) { 02560 if (num) { 02561 snprintf(fn, sizeof(fn), "digits/1N"); 02562 snprintf(fna, sizeof(fna), "digits/thousand"); 02563 } else { 02564 if (t) { 02565 snprintf(fn, sizeof(fn), "digits/1N"); 02566 snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender); 02567 } else { 02568 snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender); 02569 } 02570 } 02571 } else { 02572 res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd); 02573 if (res) { 02574 return res; 02575 } 02576 if (num) { 02577 snprintf(fn, sizeof(fn), "digits/thousand"); 02578 } else { 02579 snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender); 02580 } 02581 } 02582 t = 1; 02583 } else if (num < 1000000000) { 02584 int millions = num / 1000000; 02585 num = num % 1000000; 02586 if (millions == 1) { 02587 if (num) { 02588 snprintf(fn, sizeof(fn), "digits/1F"); 02589 snprintf(fna, sizeof(fna), "digits/million"); 02590 } else { 02591 snprintf(fn, sizeof(fn), "digits/1N"); 02592 snprintf(fna, sizeof(fna), "digits/h-million%s", gender); 02593 } 02594 } else { 02595 res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd); 02596 if (res) { 02597 return res; 02598 } 02599 if (num) { 02600 snprintf(fn, sizeof(fn), "digits/millions"); 02601 } else { 02602 snprintf(fn, sizeof(fn), "digits/h-million%s", gender); 02603 } 02604 } 02605 t = 1; 02606 } else if (num < INT_MAX) { 02607 int billions = num / 1000000000; 02608 num = num % 1000000000; 02609 if (billions == 1) { 02610 if (num) { 02611 snprintf(fn, sizeof(fn), "digits/1F"); 02612 snprintf(fna, sizeof(fna), "digits/milliard"); 02613 } else { 02614 snprintf(fn, sizeof(fn), "digits/1N"); 02615 snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender); 02616 } 02617 } else { 02618 res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd); 02619 if (res) 02620 return res; 02621 if (num) { 02622 snprintf(fn, sizeof(fna), "digits/milliards"); 02623 } else { 02624 snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender); 02625 } 02626 } 02627 t = 1; 02628 } else if (num == INT_MAX) { 02629 snprintf(fn, sizeof(fn), "digits/h-last%s", gender); 02630 num = 0; 02631 } else { 02632 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 02633 res = -1; 02634 } 02635 02636 if (!res) { 02637 if (!ast_streamfile(chan, fn, language)) { 02638 if ((audiofd > -1) && (ctrlfd > -1)) 02639 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02640 else 02641 res = ast_waitstream(chan, ints); 02642 } 02643 ast_stopstream(chan); 02644 if (!res) { 02645 if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) { 02646 if ((audiofd > -1) && (ctrlfd > -1)) { 02647 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02648 } else { 02649 res = ast_waitstream(chan, ints); 02650 } 02651 } 02652 ast_stopstream(chan); 02653 strcpy(fna, ""); 02654 } 02655 } 02656 } 02657 return res; 02658 }
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 2661 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 say_enumeration_full().
02662 { 02663 /* options can be: '' or 'm' male gender; 'f' female gender; 'n' neuter gender; 'p' plural */ 02664 int res = 0, t = 0; 02665 char fn[256] = "", fna[256] = ""; 02666 char *gender; 02667 02668 if (options && !strncasecmp(options, "f",1)) { 02669 gender = "F"; 02670 } else if (options && !strncasecmp(options, "n",1)) { 02671 gender = "N"; 02672 } else { 02673 gender = ""; 02674 } 02675 02676 if (!num) 02677 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 02678 02679 while (!res && num) { 02680 if (num < 0) { 02681 snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */ 02682 if ( num > INT_MIN ) { 02683 num = -num; 02684 } else { 02685 num = 0; 02686 } 02687 } else if (num < 100 && t) { 02688 snprintf(fn, sizeof(fn), "digits/and"); 02689 t = 0; 02690 } else if (num < 20) { 02691 snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender); 02692 num = 0; 02693 } else if (num < 100) { 02694 int ones = num % 10; 02695 if (ones) { 02696 snprintf(fn, sizeof(fn), "digits/%d-and", ones); 02697 num -= ones; 02698 } else { 02699 snprintf(fn, sizeof(fn), "digits/h-%d%s", num, gender); 02700 num = 0; 02701 } 02702 } else if (num == 100 && t == 0) { 02703 snprintf(fn, sizeof(fn), "digits/h-hundred%s", gender); 02704 num = 0; 02705 } else if (num < 1000) { 02706 int hundreds = num / 100; 02707 num = num % 100; 02708 if (hundreds == 1) { 02709 snprintf(fn, sizeof(fn), "digits/1N"); 02710 } else { 02711 snprintf(fn, sizeof(fn), "digits/%d", hundreds); 02712 } 02713 if (num) { 02714 snprintf(fna, sizeof(fna), "digits/hundred"); 02715 } else { 02716 snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender); 02717 } 02718 t = 1; 02719 } else if (num < 1000000) { 02720 int thousands = num / 1000; 02721 num = num % 1000; 02722 if (thousands == 1) { 02723 if (num) { 02724 snprintf(fn, sizeof(fn), "digits/1N"); 02725 snprintf(fna, sizeof(fna), "digits/thousand"); 02726 } else { 02727 if (t) { 02728 snprintf(fn, sizeof(fn), "digits/1N"); 02729 snprintf(fna, sizeof(fna), "digits/h-thousand%s", gender); 02730 } else { 02731 snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender); 02732 } 02733 } 02734 } else { 02735 res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd); 02736 if (res) { 02737 return res; 02738 } 02739 if (num) { 02740 snprintf(fn, sizeof(fn), "digits/thousand"); 02741 } else { 02742 snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender); 02743 } 02744 } 02745 t = 1; 02746 } else if (num < 1000000000) { 02747 int millions = num / 1000000; 02748 num = num % 1000000; 02749 if (millions == 1) { 02750 if (num) { 02751 snprintf(fn, sizeof(fn), "digits/1F"); 02752 snprintf(fna, sizeof(fna), "digits/million"); 02753 } else { 02754 snprintf(fn, sizeof(fn), "digits/1N"); 02755 snprintf(fna, sizeof(fna), "digits/h-million%s", gender); 02756 } 02757 } else { 02758 res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd); 02759 if (res) { 02760 return res; 02761 } 02762 if (num) { 02763 snprintf(fn, sizeof(fn), "digits/millions"); 02764 } else { 02765 snprintf(fn, sizeof(fn), "digits/h-million%s", gender); 02766 } 02767 } 02768 t = 1; 02769 } else if (num < INT_MAX) { 02770 int billions = num / 1000000000; 02771 num = num % 1000000000; 02772 if (billions == 1) { 02773 if (num) { 02774 snprintf(fn, sizeof(fn), "digits/1F"); 02775 snprintf(fna, sizeof(fna), "digits/milliard"); 02776 } else { 02777 snprintf(fn, sizeof(fn), "digits/1N"); 02778 snprintf(fna, sizeof(fna), "digits/h-milliard%s", gender); 02779 } 02780 } else { 02781 res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd); 02782 if (res) 02783 return res; 02784 if (num) { 02785 snprintf(fn, sizeof(fna), "digits/milliards"); 02786 } else { 02787 snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender); 02788 } 02789 } 02790 t = 1; 02791 } else if (num == INT_MAX) { 02792 snprintf(fn, sizeof(fn), "digits/h-last%s", gender); 02793 num = 0; 02794 } else { 02795 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 02796 res = -1; 02797 } 02798 02799 if (!res) { 02800 if (!ast_streamfile(chan, fn, language)) { 02801 if ((audiofd > -1) && (ctrlfd > -1)) 02802 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02803 else 02804 res = ast_waitstream(chan, ints); 02805 } 02806 ast_stopstream(chan); 02807 if (!res) { 02808 if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) { 02809 if ((audiofd > -1) && (ctrlfd > -1)) { 02810 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02811 } else { 02812 res = ast_waitstream(chan, ints); 02813 } 02814 } 02815 ast_stopstream(chan); 02816 strcpy(fna, ""); 02817 } 02818 } 02819 } 02820 return res; 02821 }
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 2400 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 say_enumeration_full().
02401 { 02402 int res = 0, t = 0; 02403 char fn[256] = ""; 02404 02405 while (!res && num) { 02406 if (num < 0) { 02407 snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */ 02408 if ( num > INT_MIN ) { 02409 num = -num; 02410 } else { 02411 num = 0; 02412 } 02413 } else if (num < 20) { 02414 snprintf(fn, sizeof(fn), "digits/h-%d", num); 02415 num = 0; 02416 } else if (num < 100) { 02417 int tens = num / 10; 02418 num = num % 10; 02419 if (num == 0) { 02420 snprintf(fn, sizeof(fn), "digits/h-%d", (tens * 10)); 02421 } else { 02422 snprintf(fn, sizeof(fn), "digits/%d", (tens * 10)); 02423 } 02424 } else if (num < 1000) { 02425 int hundreds = num / 100; 02426 num = num % 100; 02427 if (hundreds > 1 || t == 1) { 02428 res = ast_say_number_full_en(chan, hundreds, ints, language, audiofd, ctrlfd); 02429 } 02430 if (res) 02431 return res; 02432 if (num) { 02433 snprintf(fn, sizeof(fn), "digits/hundred"); 02434 } else { 02435 snprintf(fn, sizeof(fn), "digits/h-hundred"); 02436 } 02437 } else if (num < 1000000) { 02438 int thousands = num / 1000; 02439 num = num % 1000; 02440 if (thousands > 1 || t == 1) { 02441 res = ast_say_number_full_en(chan, thousands, ints, language, audiofd, ctrlfd); 02442 } 02443 if (res) 02444 return res; 02445 if (num) { 02446 snprintf(fn, sizeof(fn), "digits/thousand"); 02447 } else { 02448 snprintf(fn, sizeof(fn), "digits/h-thousand"); 02449 } 02450 t = 1; 02451 } else if (num < 1000000000) { 02452 int millions = num / 1000000; 02453 num = num % 1000000; 02454 t = 1; 02455 res = ast_say_number_full_en(chan, millions, ints, language, audiofd, ctrlfd); 02456 if (res) 02457 return res; 02458 if (num) { 02459 snprintf(fn, sizeof(fn), "digits/million"); 02460 } else { 02461 snprintf(fn, sizeof(fn), "digits/h-million"); 02462 } 02463 } else if (num < INT_MAX) { 02464 int billions = num / 1000000000; 02465 num = num % 1000000000; 02466 t = 1; 02467 res = ast_say_number_full_en(chan, billions, ints, language, audiofd, ctrlfd); 02468 if (res) 02469 return res; 02470 if (num) { 02471 snprintf(fn, sizeof(fn), "digits/billion"); 02472 } else { 02473 snprintf(fn, sizeof(fn), "digits/h-billion"); 02474 } 02475 } else if (num == INT_MAX) { 02476 snprintf(fn, sizeof(fn), "digits/h-last"); 02477 num = 0; 02478 } else { 02479 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 02480 res = -1; 02481 } 02482 02483 if (!res) { 02484 if (!ast_streamfile(chan, fn, language)) { 02485 if ((audiofd > -1) && (ctrlfd > -1)) { 02486 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02487 } else { 02488 res = ast_waitstream(chan, ints); 02489 } 02490 } 02491 ast_stopstream(chan); 02492 } 02493 } 02494 return res; 02495 }
static int ast_say_enumeration_full_he | ( | struct ast_channel * | chan, | |
int | num, | |||
const char * | ints, | |||
const char * | language, | |||
const char * | options, | |||
int | audiofd, | |||
int | ctrlfd | |||
) | [static] |
Definition at line 2823 of file say.c.
References ast_log(), ast_say_number_full_he(), ast_stopstream(), ast_streamfile(), ast_verbose(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, and VERBOSE_PREFIX_3.
Referenced by say_enumeration_full().
02824 { 02825 int res = 0; 02826 char fn[256] = ""; 02827 int mf = -1; /* +1 = Masculin; -1 = Feminin */ 02828 ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options); 02829 02830 if (options && !strncasecmp(options, "m", 1)) { 02831 mf = -1; 02832 } 02833 02834 ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, options=\"%s\", mf=%d\n", num, options, mf); 02835 02836 while (!res && num) { 02837 if (num < 0) { 02838 snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */ 02839 if (num > INT_MIN) { 02840 num = -num; 02841 } else { 02842 num = 0; 02843 } 02844 } else if (num < 21) { 02845 if (mf < 0) { 02846 if (num < 10) { 02847 snprintf(fn, sizeof(fn), "digits/f-0%d", num); 02848 } else { 02849 snprintf(fn, sizeof(fn), "digits/f-%d", num); 02850 } 02851 } else { 02852 if (num < 10) { 02853 snprintf(fn, sizeof(fn), "digits/m-0%d", num); 02854 } else { 02855 snprintf(fn, sizeof(fn), "digits/m-%d", num); 02856 } 02857 } 02858 num = 0; 02859 } else if ((num < 100) && num >= 20) { 02860 snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10); 02861 num = num % 10; 02862 } else if ((num >= 100) && (num < 1000)) { 02863 int tmpnum = num / 100; 02864 snprintf(fn, sizeof(fn), "digits/%d00", tmpnum); 02865 num = num - (tmpnum * 100); 02866 } else if ((num >= 1000) && (num < 10000)) { 02867 int tmpnum = num / 1000; 02868 snprintf(fn, sizeof(fn), "digits/%dk", tmpnum); 02869 num = num - (tmpnum * 1000); 02870 } else if (num < 20000) { 02871 snprintf(fn, sizeof(fn), "digits/m-%d", (num / 1000)); 02872 num = num % 1000; 02873 } else if (num < 1000000) { 02874 res = ast_say_number_full_he(chan, num / 1000, ints, language, "m", audiofd, ctrlfd); 02875 if (res) { 02876 return res; 02877 } 02878 snprintf(fn, sizeof(fn), "digits/1k"); 02879 num = num % 1000; 02880 } else if (num < 2000000) { 02881 snprintf(fn, sizeof(fn), "digits/1m"); 02882 num = num % 1000000; 02883 } else if (num < 3000000) { 02884 snprintf(fn, sizeof(fn), "digits/2m"); 02885 num = num - 2000000; 02886 } else if (num < 1000000000) { 02887 res = ast_say_number_full_he(chan, num / 1000000, ints, language, "m", audiofd, ctrlfd); 02888 if (res) { 02889 return res; 02890 } 02891 snprintf(fn, sizeof(fn), "digits/1m"); 02892 num = num % 1000000; 02893 } else { 02894 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 02895 res = -1; 02896 } 02897 if (!res) { 02898 if (!ast_streamfile(chan, fn, language)) { 02899 if ((audiofd > -1) && (ctrlfd > -1)) { 02900 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02901 } else { 02902 res = ast_waitstream(chan, ints); 02903 } 02904 } 02905 ast_stopstream(chan); 02906 } 02907 } 02908 return res; 02909 }
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 564 of file say.c.
References ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and exp10_int().
Referenced by say_number_full().
00565 { 00566 int res = 0; 00567 int playh = 0; 00568 char fn[256] = ""; 00569 00570 int hundered = 0; 00571 int left = 0; 00572 int length = 0; 00573 00574 /* options - w = woman, m = man, n = neutral. Defaultl is woman */ 00575 if (!options) 00576 options = "w"; 00577 00578 if (!num) 00579 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 00580 00581 while (!res && (num || playh)) { 00582 if (num < 0) { 00583 snprintf(fn, sizeof(fn), "digits/minus"); 00584 if ( num > INT_MIN ) { 00585 num = -num; 00586 } else { 00587 num = 0; 00588 } 00589 } else if (num < 3 ) { 00590 snprintf(fn, sizeof(fn), "digits/%d%c",num,options[0]); 00591 playh = 0; 00592 num = 0; 00593 } else if (num < 20) { 00594 snprintf(fn, sizeof(fn), "digits/%d",num); 00595 playh = 0; 00596 num = 0; 00597 } else if (num < 100) { 00598 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 00599 num -= ((num / 10) * 10); 00600 } else if (num < 1000) { 00601 hundered = num / 100; 00602 if ( hundered == 1 ) { 00603 snprintf(fn, sizeof(fn), "digits/1sto"); 00604 } else if ( hundered == 2 ) { 00605 snprintf(fn, sizeof(fn), "digits/2ste"); 00606 } else { 00607 res = ast_say_number_full_cz(chan,hundered,ints,language,options,audiofd,ctrlfd); 00608 if (res) 00609 return res; 00610 if (hundered == 3 || hundered == 4) { 00611 snprintf(fn, sizeof(fn), "digits/sta"); 00612 } else if ( hundered > 4 ) { 00613 snprintf(fn, sizeof(fn), "digits/set"); 00614 } 00615 } 00616 num -= (hundered * 100); 00617 } else { /* num > 1000 */ 00618 length = (int)log10(num)+1; 00619 while ( (length % 3 ) != 1 ) { 00620 length--; 00621 } 00622 left = num / (exp10_int(length-1)); 00623 if ( left == 2 ) { 00624 switch (length-1) { 00625 case 9: options = "w"; /* 1,000,000,000 gender female */ 00626 break; 00627 default : options = "m"; /* others are male */ 00628 } 00629 } 00630 if ( left > 1 ) { /* we dont say "one thousand" but only thousand */ 00631 res = ast_say_number_full_cz(chan,left,ints,language,options,audiofd,ctrlfd); 00632 if (res) 00633 return res; 00634 } 00635 if ( left >= 5 ) { /* >= 5 have the same declesion */ 00636 snprintf(fn, sizeof(fn), "digits/5_E%d",length-1); 00637 } else if ( left >= 2 && left <= 4 ) { 00638 snprintf(fn, sizeof(fn), "digits/2-4_E%d",length-1); 00639 } else { /* left == 1 */ 00640 snprintf(fn, sizeof(fn), "digits/1_E%d",length-1); 00641 } 00642 num -= left * (exp10_int(length-1)); 00643 } 00644 if (!res) { 00645 if (!ast_streamfile(chan, fn, language)) { 00646 if ((audiofd > -1) && (ctrlfd > -1)) { 00647 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00648 } else { 00649 res = ast_waitstream(chan, ints); 00650 } 00651 } 00652 ast_stopstream(chan); 00653 } 00654 } 00655 return res; 00656 }
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 662 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 say_number_full().
00663 { 00664 int res = 0; 00665 int playh = 0; 00666 int playa = 0; 00667 int cn = 1; /* +1 = commune; -1 = neuter */ 00668 char fn[256] = ""; 00669 if (!num) 00670 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 00671 00672 if (options && !strncasecmp(options, "n",1)) cn = -1; 00673 00674 while (!res && (num || playh || playa )) { 00675 /* The grammar for Danish numbers is the same as for English except 00676 * for the following: 00677 * - 1 exists in both commune ("en", file "1N") and neuter ("et", file "1") 00678 * - numbers 20 through 99 are said in reverse order, i.e. 21 is 00679 * "one-and twenty" and 68 is "eight-and sixty". 00680 * - "million" is different in singular and plural form 00681 * - numbers > 1000 with zero as the third digit from last have an 00682 * "and" before the last two digits, i.e. 2034 is "two thousand and 00683 * four-and thirty" and 1000012 is "one million and twelve". 00684 */ 00685 if (num < 0) { 00686 snprintf(fn, sizeof(fn), "digits/minus"); 00687 if ( num > INT_MIN ) { 00688 num = -num; 00689 } else { 00690 num = 0; 00691 } 00692 } else if (playh) { 00693 snprintf(fn, sizeof(fn), "digits/hundred"); 00694 playh = 0; 00695 } else if (playa) { 00696 snprintf(fn, sizeof(fn), "digits/and"); 00697 playa = 0; 00698 } else if (num == 1 && cn == -1) { 00699 snprintf(fn, sizeof(fn), "digits/1N"); 00700 num = 0; 00701 } else if (num < 20) { 00702 snprintf(fn, sizeof(fn), "digits/%d", num); 00703 num = 0; 00704 } else if (num < 100) { 00705 int ones = num % 10; 00706 if (ones) { 00707 snprintf(fn, sizeof(fn), "digits/%d-and", ones); 00708 num -= ones; 00709 } else { 00710 snprintf(fn, sizeof(fn), "digits/%d", num); 00711 num = 0; 00712 } 00713 } else { 00714 if (num < 1000) { 00715 int hundreds = num / 100; 00716 if (hundreds == 1) 00717 snprintf(fn, sizeof(fn), "digits/1N"); 00718 else 00719 snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); 00720 00721 playh++; 00722 num -= 100 * hundreds; 00723 if (num) 00724 playa++; 00725 00726 } else { 00727 if (num < 1000000) { 00728 res = ast_say_number_full_da(chan, num / 1000, ints, language, "n", audiofd, ctrlfd); 00729 if (res) 00730 return res; 00731 num = num % 1000; 00732 snprintf(fn, sizeof(fn), "digits/thousand"); 00733 } else { 00734 if (num < 1000000000) { 00735 int millions = num / 1000000; 00736 res = ast_say_number_full_da(chan, millions, ints, language, "c", audiofd, ctrlfd); 00737 if (res) 00738 return res; 00739 if (millions == 1) 00740 snprintf(fn, sizeof(fn), "digits/million"); 00741 else 00742 snprintf(fn, sizeof(fn), "digits/millions"); 00743 num = num % 1000000; 00744 } else { 00745 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 00746 res = -1; 00747 } 00748 } 00749 if (num && num < 100) 00750 playa++; 00751 } 00752 } 00753 if (!res) { 00754 if (!ast_streamfile(chan, fn, language)) { 00755 if ((audiofd > -1) && (ctrlfd > -1)) 00756 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00757 else 00758 res = ast_waitstream(chan, ints); 00759 } 00760 ast_stopstream(chan); 00761 } 00762 } 00763 return res; 00764 }
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 775 of file say.c.
References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, and t.
Referenced by ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), and say_number_full().
00776 { 00777 int res = 0, t = 0; 00778 int mf = 1; /* +1 = male and neuter; -1 = female */ 00779 char fn[256] = ""; 00780 char fna[256] = ""; 00781 if (!num) 00782 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 00783 00784 if (options && (!strncasecmp(options, "f",1))) 00785 mf = -1; 00786 00787 while (!res && num) { 00788 /* The grammar for German numbers is the same as for English except 00789 * for the following: 00790 * - numbers 20 through 99 are said in reverse order, i.e. 21 is 00791 * "one-and twenty" and 68 is "eight-and sixty". 00792 * - "one" varies according to gender 00793 * - 100 is 'hundert', however all other instances are 'ein hundert' 00794 * - 1000 is 'tausend', however all other instances are 'ein tausend' 00795 * - 1000000 is always 'eine million' 00796 * - "million" is different in singular and plural form 00797 */ 00798 if (num < 0) { 00799 snprintf(fn, sizeof(fn), "digits/minus"); 00800 if ( num > INT_MIN ) { 00801 num = -num; 00802 } else { 00803 num = 0; 00804 } 00805 } else if (num < 100 && t) { 00806 snprintf(fn, sizeof(fn), "digits/and"); 00807 t = 0; 00808 } else if (num == 1 && mf == -1) { 00809 snprintf(fn, sizeof(fn), "digits/%dF", num); 00810 num = 0; 00811 } else if (num < 20) { 00812 snprintf(fn, sizeof(fn), "digits/%d", num); 00813 num = 0; 00814 } else if (num < 100) { 00815 int ones = num % 10; 00816 if (ones) { 00817 snprintf(fn, sizeof(fn), "digits/%d-and", ones); 00818 num -= ones; 00819 } else { 00820 snprintf(fn, sizeof(fn), "digits/%d", num); 00821 num = 0; 00822 } 00823 } else if (num == 100 && t == 0) { 00824 snprintf(fn, sizeof(fn), "digits/hundred"); 00825 num = 0; 00826 } else if (num < 1000) { 00827 int hundreds = num / 100; 00828 num = num % 100; 00829 if (hundreds == 1) { 00830 snprintf(fn, sizeof(fn), "digits/1N"); 00831 } else { 00832 snprintf(fn, sizeof(fn), "digits/%d", hundreds); 00833 } 00834 snprintf(fna, sizeof(fna), "digits/hundred"); 00835 t = 1; 00836 } else if (num == 1000 && t == 0) { 00837 snprintf(fn, sizeof(fn), "digits/thousand"); 00838 num = 0; 00839 } else if (num < 1000000) { 00840 int thousands = num / 1000; 00841 num = num % 1000; 00842 t = 1; 00843 if (thousands == 1) { 00844 snprintf(fn, sizeof(fn), "digits/1N"); 00845 snprintf(fna, sizeof(fna), "digits/thousand"); 00846 } else { 00847 res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd); 00848 if (res) 00849 return res; 00850 snprintf(fn, sizeof(fn), "digits/thousand"); 00851 } 00852 } else if (num < 1000000000) { 00853 int millions = num / 1000000; 00854 num = num % 1000000; 00855 t = 1; 00856 if (millions == 1) { 00857 snprintf(fn, sizeof(fn), "digits/1F"); 00858 snprintf(fna, sizeof(fna), "digits/million"); 00859 } else { 00860 res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd); 00861 if (res) 00862 return res; 00863 snprintf(fn, sizeof(fn), "digits/millions"); 00864 } 00865 } else if (num <= INT_MAX) { 00866 int billions = num / 1000000000; 00867 num = num % 1000000000; 00868 t = 1; 00869 if (billions == 1) { 00870 snprintf(fn, sizeof(fn), "digits/1F"); 00871 snprintf(fna, sizeof(fna), "digits/milliard"); 00872 } else { 00873 res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd); 00874 if (res) { 00875 return res; 00876 } 00877 snprintf(fn, sizeof(fn), "digits/milliards"); 00878 } 00879 } else { 00880 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 00881 res = -1; 00882 } 00883 if (!res) { 00884 if (!ast_streamfile(chan, fn, language)) { 00885 if ((audiofd > -1) && (ctrlfd > -1)) 00886 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00887 else 00888 res = ast_waitstream(chan, ints); 00889 } 00890 ast_stopstream(chan); 00891 if (!res) { 00892 if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) { 00893 if ((audiofd > -1) && (ctrlfd > -1)) 00894 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00895 else 00896 res = ast_waitstream(chan, ints); 00897 } 00898 ast_stopstream(chan); 00899 strcpy(fna, ""); 00900 } 00901 } 00902 } 00903 return res; 00904 }
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 471 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(), and say_number_full().
00472 { 00473 int res = 0; 00474 int playh = 0; 00475 char fn[256] = ""; 00476 if (!num) 00477 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 00478 00479 while (!res && (num || playh)) { 00480 if (num < 0) { 00481 snprintf(fn, sizeof(fn), "digits/minus"); 00482 if ( num > INT_MIN ) { 00483 num = -num; 00484 } else { 00485 num = 0; 00486 } 00487 } else if (playh) { 00488 snprintf(fn, sizeof(fn), "digits/hundred"); 00489 playh = 0; 00490 } else if (num < 20) { 00491 snprintf(fn, sizeof(fn), "digits/%d", num); 00492 num = 0; 00493 } else if (num < 100) { 00494 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 00495 num -= ((num / 10) * 10); 00496 } else { 00497 if (num < 1000){ 00498 snprintf(fn, sizeof(fn), "digits/%d", (num/100)); 00499 playh++; 00500 num -= ((num / 100) * 100); 00501 } else { 00502 if (num < 1000000) { /* 1,000,000 */ 00503 res = ast_say_number_full_en(chan, num / 1000, ints, language, audiofd, ctrlfd); 00504 if (res) 00505 return res; 00506 num = num % 1000; 00507 snprintf(fn, sizeof(fn), "digits/thousand"); 00508 } else { 00509 if (num < 1000000000) { /* 1,000,000,000 */ 00510 res = ast_say_number_full_en(chan, num / 1000000, ints, language, audiofd, ctrlfd); 00511 if (res) 00512 return res; 00513 num = num % 1000000; 00514 snprintf(fn, sizeof(fn), "digits/million"); 00515 } else { 00516 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 00517 res = -1; 00518 } 00519 } 00520 } 00521 } 00522 if (!res) { 00523 if (!ast_streamfile(chan, fn, language)) { 00524 if ((audiofd > -1) && (ctrlfd > -1)) 00525 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00526 else 00527 res = ast_waitstream(chan, ints); 00528 } 00529 ast_stopstream(chan); 00530 } 00531 } 00532 return res; 00533 }
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 910 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 say_number_full().
00911 { 00912 int res = 0; 00913 int playh = 0; 00914 int playa = 0; 00915 char fn[256] = ""; 00916 if (!num) 00917 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 00918 00919 while (!res && (num || playh || playa )) { 00920 if (num < 0) { 00921 snprintf(fn, sizeof(fn), "digits/minus"); 00922 if ( num > INT_MIN ) { 00923 num = -num; 00924 } else { 00925 num = 0; 00926 } 00927 } else if (playh) { 00928 snprintf(fn, sizeof(fn), "digits/hundred"); 00929 playh = 0; 00930 } else if (playa) { 00931 snprintf(fn, sizeof(fn), "digits/and"); 00932 playa = 0; 00933 } else if (num < 20) { 00934 snprintf(fn, sizeof(fn), "digits/%d", num); 00935 num = 0; 00936 } else if (num < 100) { 00937 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 00938 num -= ((num / 10) * 10); 00939 } else if (num < 1000) { 00940 int hundreds = num / 100; 00941 snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); 00942 00943 playh++; 00944 num -= 100 * hundreds; 00945 if (num) 00946 playa++; 00947 } else if (num < 1000000) { 00948 res = ast_say_number_full_en_GB(chan, num / 1000, ints, language, audiofd, ctrlfd); 00949 if (res) 00950 return res; 00951 snprintf(fn, sizeof(fn), "digits/thousand"); 00952 num = num % 1000; 00953 if (num && num < 100) 00954 playa++; 00955 } else if (num < 1000000000) { 00956 int millions = num / 1000000; 00957 res = ast_say_number_full_en_GB(chan, millions, ints, language, audiofd, ctrlfd); 00958 if (res) 00959 return res; 00960 snprintf(fn, sizeof(fn), "digits/million"); 00961 num = num % 1000000; 00962 if (num && num < 100) 00963 playa++; 00964 } else { 00965 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 00966 res = -1; 00967 } 00968 00969 if (!res) { 00970 if (!ast_streamfile(chan, fn, language)) { 00971 if ((audiofd > -1) && (ctrlfd > -1)) 00972 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00973 else 00974 res = ast_waitstream(chan, ints); 00975 } 00976 ast_stopstream(chan); 00977 } 00978 } 00979 return res; 00980 }
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 988 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 say_number_full().
00989 { 00990 int res = 0; 00991 int playa = 0; 00992 int mf = 0; /* +1 = male; -1 = female */ 00993 char fn[256] = ""; 00994 if (!num) 00995 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 00996 00997 if (options) { 00998 if (!strncasecmp(options, "f",1)) 00999 mf = -1; 01000 else if (!strncasecmp(options, "m", 1)) 01001 mf = 1; 01002 } 01003 01004 while (!res && num) { 01005 if (num < 0) { 01006 snprintf(fn, sizeof(fn), "digits/minus"); 01007 if ( num > INT_MIN ) { 01008 num = -num; 01009 } else { 01010 num = 0; 01011 } 01012 } else if (playa) { 01013 snprintf(fn, sizeof(fn), "digits/and"); 01014 playa = 0; 01015 } else if (num == 1) { 01016 if (mf < 0) 01017 snprintf(fn, sizeof(fn), "digits/%dF", num); 01018 else if (mf > 0) 01019 snprintf(fn, sizeof(fn), "digits/%dM", num); 01020 else 01021 snprintf(fn, sizeof(fn), "digits/%d", num); 01022 num = 0; 01023 } else if (num < 31) { 01024 snprintf(fn, sizeof(fn), "digits/%d", num); 01025 num = 0; 01026 } else if (num < 100) { 01027 snprintf(fn, sizeof(fn), "digits/%d", (num/10)*10); 01028 num -= ((num/10)*10); 01029 if (num) 01030 playa++; 01031 } else if (num == 100) { 01032 snprintf(fn, sizeof(fn), "digits/100"); 01033 num = 0; 01034 } else if (num < 200) { 01035 snprintf(fn, sizeof(fn), "digits/100-and"); 01036 num -= 100; 01037 } else { 01038 if (num < 1000) { 01039 snprintf(fn, sizeof(fn), "digits/%d", (num/100)*100); 01040 num -= ((num/100)*100); 01041 } else if (num < 2000) { 01042 num = num % 1000; 01043 snprintf(fn, sizeof(fn), "digits/thousand"); 01044 } else { 01045 if (num < 1000000) { 01046 res = ast_say_number_full_es(chan, num / 1000, ints, language, options, audiofd, ctrlfd); 01047 if (res) 01048 return res; 01049 num = num % 1000; 01050 snprintf(fn, sizeof(fn), "digits/thousand"); 01051 } else { 01052 if (num < 2147483640) { 01053 if ((num/1000000) == 1) { 01054 res = ast_say_number_full_es(chan, num / 1000000, ints, language, "M", audiofd, ctrlfd); 01055 if (res) 01056 return res; 01057 snprintf(fn, sizeof(fn), "digits/million"); 01058 } else { 01059 res = ast_say_number_full_es(chan, num / 1000000, ints, language, options, audiofd, ctrlfd); 01060 if (res) 01061 return res; 01062 snprintf(fn, sizeof(fn), "digits/millions"); 01063 } 01064 num = num % 1000000; 01065 } else { 01066 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 01067 res = -1; 01068 } 01069 } 01070 } 01071 } 01072 01073 if (!res) { 01074 if (!ast_streamfile(chan, fn, language)) { 01075 if ((audiofd > -1) && (ctrlfd > -1)) 01076 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 01077 else 01078 res = ast_waitstream(chan, ints); 01079 } 01080 ast_stopstream(chan); 01081 01082 } 01083 01084 } 01085 return res; 01086 }
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 1092 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 say_number_full().
01093 { 01094 int res = 0; 01095 int playh = 0; 01096 int playa = 0; 01097 int mf = 1; /* +1 = male; -1 = female */ 01098 char fn[256] = ""; 01099 if (!num) 01100 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 01101 01102 if (options && !strncasecmp(options, "f",1)) 01103 mf = -1; 01104 01105 while (!res && (num || playh || playa)) { 01106 if (num < 0) { 01107 snprintf(fn, sizeof(fn), "digits/minus"); 01108 if ( num > INT_MIN ) { 01109 num = -num; 01110 } else { 01111 num = 0; 01112 } 01113 } else if (playh) { 01114 snprintf(fn, sizeof(fn), "digits/hundred"); 01115 playh = 0; 01116 } else if (playa) { 01117 snprintf(fn, sizeof(fn), "digits/et"); 01118 playa = 0; 01119 } else if (num == 1) { 01120 if (mf < 0) 01121 snprintf(fn, sizeof(fn), "digits/%dF", num); 01122 else 01123 snprintf(fn, sizeof(fn), "digits/%d", num); 01124 num = 0; 01125 } else if (num < 21) { 01126 snprintf(fn, sizeof(fn), "digits/%d", num); 01127 num = 0; 01128 } else if (num < 70) { 01129 snprintf(fn, sizeof(fn), "digits/%d", (num/10)*10); 01130 if ((num % 10) == 1) playa++; 01131 num = num % 10; 01132 } else if (num < 80) { 01133 snprintf(fn, sizeof(fn), "digits/60"); 01134 if ((num % 10) == 1) playa++; 01135 num = num - 60; 01136 } else if (num < 100) { 01137 snprintf(fn, sizeof(fn), "digits/80"); 01138 num = num - 80; 01139 } else if (num < 200) { 01140 snprintf(fn, sizeof(fn), "digits/hundred"); 01141 num = num - 100; 01142 } else if (num < 1000) { 01143 snprintf(fn, sizeof(fn), "digits/%d", (num/100)); 01144 playh++; 01145 num = num % 100; 01146 } else if (num < 2000) { 01147 snprintf(fn, sizeof(fn), "digits/thousand"); 01148 num = num - 1000; 01149 } else if (num < 1000000) { 01150 res = ast_say_number_full_fr(chan, num / 1000, ints, language, options, audiofd, ctrlfd); 01151 if (res) 01152 return res; 01153 snprintf(fn, sizeof(fn), "digits/thousand"); 01154 num = num % 1000; 01155 } else if (num < 1000000000) { 01156 res = ast_say_number_full_fr(chan, num / 1000000, ints, language, options, audiofd, ctrlfd); 01157 if (res) 01158 return res; 01159 snprintf(fn, sizeof(fn), "digits/million"); 01160 num = num % 1000000; 01161 } else { 01162 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 01163 res = -1; 01164 } 01165 if (!res) { 01166 if (!ast_streamfile(chan, fn, language)) { 01167 if ((audiofd > -1) && (ctrlfd > -1)) 01168 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 01169 else 01170 res = ast_waitstream(chan, ints); 01171 } 01172 ast_stopstream(chan); 01173 } 01174 } 01175 return res; 01176 }
static int ast_say_number_full_ge | ( | struct ast_channel * | chan, | |
int | num, | |||
const char * | ints, | |||
const char * | language, | |||
const char * | options, | |||
int | audiofd, | |||
int | ctrlfd | |||
) | [static] |
ast_say_number_full_ge: Georgian syntax
Definition at line 7043 of file say.c.
References ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_translate_number_ge(), ast_waitstream(), ast_waitstream_full(), free, len(), malloc, and s.
Referenced by say_number_full().
07044 { 07045 int res = 0; 07046 char fn[512] = ""; 07047 char* s = 0; 07048 const char* remainder = fn; 07049 07050 if (!num) 07051 return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd); 07052 07053 07054 ast_translate_number_ge(num, fn, 512); 07055 07056 07057 07058 while (res == 0 && (s = strstr(remainder, " "))) { 07059 size_t len = s - remainder; 07060 char* new_string = malloc(len + 1 + strlen("digits/")); 07061 07062 sprintf(new_string, "digits/"); 07063 strncat(new_string, remainder, len); /* we can't sprintf() it, it's not null-terminated. */ 07064 /* new_string[len + strlen("digits/")] = '\0'; */ 07065 07066 if (!ast_streamfile(chan, new_string, language)) { 07067 if ((audiofd > -1) && (ctrlfd > -1)) 07068 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 07069 else 07070 res = ast_waitstream(chan, ints); 07071 } 07072 ast_stopstream(chan); 07073 07074 free(new_string); 07075 07076 remainder = s + 1; /* position just after the found space char. */ 07077 while (*remainder == ' ') /* skip multiple spaces */ 07078 remainder++; 07079 } 07080 07081 07082 /* the last chunk. */ 07083 if (res == 0 && *remainder) { 07084 07085 char* new_string = malloc(strlen(remainder) + 1 + strlen("digits/")); 07086 sprintf(new_string, "digits/%s", remainder); 07087 07088 if (!ast_streamfile(chan, new_string, language)) { 07089 if ((audiofd > -1) && (ctrlfd > -1)) 07090 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 07091 else 07092 res = ast_waitstream(chan, ints); 07093 } 07094 ast_stopstream(chan); 07095 07096 free(new_string); 07097 07098 } 07099 07100 07101 return res; 07102 07103 }
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 6498 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 say_number_full().
06499 { 06500 int res = 0; 06501 char fn[256] = ""; 06502 int i=0; 06503 06504 06505 if (!num) { 06506 snprintf(fn, sizeof(fn), "digits/0"); 06507 res = ast_streamfile(chan, fn, chan->language); 06508 if (!res) 06509 return ast_waitstream(chan, ints); 06510 } 06511 06512 while (!res && num ) { 06513 i++; 06514 if (num < 13) { 06515 snprintf(fn, sizeof(fn), "digits/%d", num); 06516 num = 0; 06517 } else if (num <= 100) { 06518 /* 13 < num <= 100 */ 06519 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 06520 num -= ((num / 10) * 10); 06521 } else if (num < 200) { 06522 /* 100 < num < 200 */ 06523 snprintf(fn, sizeof(fn), "digits/hundred-100"); 06524 num -= ((num / 100) * 100); 06525 } else if (num < 1000) { 06526 /* 200 < num < 1000 */ 06527 snprintf(fn, sizeof(fn), "digits/hundred-%d", (num/100)*100); 06528 num -= ((num / 100) * 100); 06529 } else if (num < 2000){ 06530 snprintf(fn, sizeof(fn), "digits/xilia"); 06531 num -= ((num / 1000) * 1000); 06532 } else { 06533 /* num > 1000 */ 06534 if (num < 1000000) { 06535 res = ast_say_number_full_gr(chan, (num / 1000), ints, chan->language, audiofd, ctrlfd); 06536 if (res) 06537 return res; 06538 num = num % 1000; 06539 snprintf(fn, sizeof(fn), "digits/thousands"); 06540 } else { 06541 if (num < 1000000000) { /* 1,000,000,000 */ 06542 res = ast_say_number_full_gr(chan, (num / 1000000), ints, chan->language ,audiofd, ctrlfd); 06543 if (res) 06544 return res; 06545 num = num % 1000000; 06546 snprintf(fn, sizeof(fn), "digits/millions"); 06547 } else { 06548 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 06549 res = -1; 06550 } 06551 } 06552 } 06553 if (!res) { 06554 if (!ast_streamfile(chan, fn, language)) { 06555 if ((audiofd > -1) && (ctrlfd > -1)) 06556 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 06557 else 06558 res = ast_waitstream(chan, ints); 06559 } 06560 ast_stopstream(chan); 06561 } 06562 } 06563 return res; 06564 }
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 1184 of file say.c.
References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_verbose(), ast_waitstream(), ast_waitstream_full(), LOG_DEBUG, SAY_NUM_BUF_SIZE, and VERBOSE_PREFIX_3.
Referenced by ast_say_date_with_format_he(), ast_say_enumeration_full_he(), ast_say_time_he(), and say_number_full().
01185 { 01186 int res = 0; 01187 int state = 0; /* no need to save anything */ 01188 int mf = -1; /* +1 = Masculin; -1 = Feminin */ 01189 int tmpnum = 0; 01190 01191 char fn[SAY_NUM_BUF_SIZE] = ""; 01192 01193 ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options); 01194 01195 if (!num) { 01196 return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd); 01197 } 01198 if (options && !strncasecmp(options, "m", 1)) { 01199 mf = 1; 01200 } 01201 ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d\n", num, state, options, mf); 01202 01203 /* Do we have work to do? */ 01204 while (!res && (num || (state > 0))) { 01205 /* first type of work: play a second sound. In this loop 01206 * we can only play one sound file at a time. Thus playing 01207 * a second one requires repeating the loop just for the 01208 * second file. The variable 'state' remembers where we were. 01209 * state==0 is the normal mode and it means that we continue 01210 * to check if the number num has yet anything left. 01211 */ 01212 ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d, tmpnum=%d\n", num, state, options, mf, tmpnum); 01213 01214 if (state == 1) { 01215 state = 0; 01216 } else if (state == 2) { 01217 if ((num >= 11) && (num < 21)) { 01218 if (mf < 0) { 01219 snprintf(fn, sizeof(fn), "digits/ve"); 01220 } else { 01221 snprintf(fn, sizeof(fn), "digits/uu"); 01222 } 01223 } else { 01224 switch (num) { 01225 case 1: 01226 snprintf(fn, sizeof(fn), "digits/ve"); 01227 break; 01228 case 2: 01229 snprintf(fn, sizeof(fn), "digits/uu"); 01230 break; 01231 case 3: 01232 if (mf < 0) { 01233 snprintf(fn, sizeof(fn), "digits/ve"); 01234 } else { 01235 snprintf(fn, sizeof(fn), "digits/uu"); 01236 } 01237 break; 01238 case 4: 01239 snprintf(fn, sizeof(fn), "digits/ve"); 01240 break; 01241 case 5: 01242 snprintf(fn, sizeof(fn), "digits/ve"); 01243 break; 01244 case 6: 01245 snprintf(fn, sizeof(fn), "digits/ve"); 01246 break; 01247 case 7: 01248 snprintf(fn, sizeof(fn), "digits/ve"); 01249 break; 01250 case 8: 01251 snprintf(fn, sizeof(fn), "digits/uu"); 01252 break; 01253 case 9: 01254 snprintf(fn, sizeof(fn), "digits/ve"); 01255 break; 01256 case 10: 01257 snprintf(fn, sizeof(fn), "digits/ve"); 01258 break; 01259 } 01260 } 01261 state = 0; 01262 } else if (state == 3) { 01263 snprintf(fn, sizeof(fn), "digits/1k"); 01264 state = 0; 01265 } else if (num < 0) { 01266 snprintf(fn, sizeof(fn), "digits/minus"); 01267 num = (-1) * num; 01268 } else if (num < 20) { 01269 if (mf < 0) { 01270 snprintf(fn, sizeof(fn), "digits/%d", num); 01271 } else { 01272 snprintf(fn, sizeof(fn), "digits/%dm", num); 01273 } 01274 num = 0; 01275 } else if ((num < 100) && (num >= 20)) { 01276 snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10); 01277 num = num % 10; 01278 if (num > 0) { 01279 state = 2; 01280 } 01281 } else if ((num >= 100) && (num < 1000)) { 01282 tmpnum = num / 100; 01283 snprintf(fn, sizeof(fn), "digits/%d00", tmpnum); 01284 num = num - (tmpnum * 100); 01285 if ((num > 0) && (num < 11)) { 01286 state = 2; 01287 } 01288 } else if ((num >= 1000) && (num < 10000)) { 01289 tmpnum = num / 1000; 01290 snprintf(fn, sizeof(fn), "digits/%dk", tmpnum); 01291 num = num - (tmpnum * 1000); 01292 if ((num > 0) && (num < 11)) { 01293 state = 2; 01294 } 01295 } else if (num < 20000) { 01296 snprintf(fn, sizeof(fn), "digits/%dm", (num / 1000)); 01297 num = num % 1000; 01298 state = 3; 01299 } else if (num < 1000000) { 01300 res = ast_say_number_full_he(chan, num / 1000, ints, language, "m", audiofd, ctrlfd); 01301 if (res) { 01302 return res; 01303 } 01304 snprintf(fn, sizeof(fn), "digits/1k"); 01305 num = num % 1000; 01306 if ((num > 0) && (num < 11)) { 01307 state = 2; 01308 } 01309 } else if (num < 2000000) { 01310 snprintf(fn, sizeof(fn), "digits/million"); 01311 num = num % 1000000; 01312 if ((num > 0) && (num < 11)) { 01313 state = 2; 01314 } 01315 } else if (num < 3000000) { 01316 snprintf(fn, sizeof(fn), "digits/twomillion"); 01317 num = num - 2000000; 01318 if ((num > 0) && (num < 11)) { 01319 state = 2; 01320 } 01321 } else if (num < 1000000000) { 01322 res = ast_say_number_full_he(chan, num / 1000000, ints, language, "m", audiofd, ctrlfd); 01323 if (res) { 01324 return res; 01325 } 01326 snprintf(fn, sizeof(fn), "digits/million"); 01327 num = num % 1000000; 01328 if ((num > 0) && (num < 11)) { 01329 state = 2; 01330 } 01331 } else { 01332 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 01333 res = -1; 01334 } 01335 tmpnum = 0; 01336 if (!res) { 01337 if (!ast_streamfile(chan, fn, language)) { 01338 if ((audiofd > -1) && (ctrlfd > -1)) { 01339 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 01340 } else { 01341 res = ast_waitstream(chan, ints); 01342 } 01343 } 01344 ast_stopstream(chan); 01345 } 01346 } 01347 return res; 01348 }
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 1351 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 say_number_full().
01352 { 01353 int res = 0; 01354 int playh = 0; 01355 int tempnum = 0; 01356 char fn[256] = ""; 01357 01358 if (!num) 01359 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 01360 01361 /* 01362 Italian support 01363 01364 Like english, numbers up to 20 are a single 'word', and others 01365 compound, but with exceptions. 01366 For example 21 is not twenty-one, but there is a single word in 'it'. 01367 Idem for 28 (ie when a the 2nd part of a compund number 01368 starts with a vowel) 01369 01370 There are exceptions also for hundred, thousand and million. 01371 In english 100 = one hundred, 200 is two hundred. 01372 In italian 100 = cento , like to say hundred (without one), 01373 200 and more are like english. 01374 01375 Same applies for thousand: 01376 1000 is one thousand in en, 2000 is two thousand. 01377 In it we have 1000 = mille , 2000 = 2 mila 01378 01379 For million(s) we use the plural, if more than one 01380 Also, one million is abbreviated in it, like on-million, 01381 or 'un milione', not 'uno milione'. 01382 So the right file is provided. 01383 */ 01384 01385 while (!res && (num || playh)) { 01386 if (num < 0) { 01387 snprintf(fn, sizeof(fn), "digits/minus"); 01388 if ( num > INT_MIN ) { 01389 num = -num; 01390 } else { 01391 num = 0; 01392 } 01393 } else if (playh) { 01394 snprintf(fn, sizeof(fn), "digits/hundred"); 01395 playh = 0; 01396 } else if (num < 20) { 01397 snprintf(fn, sizeof(fn), "digits/%d", num); 01398 num = 0; 01399 } else if (num == 21) { 01400 snprintf(fn, sizeof(fn), "digits/%d", num); 01401 num = 0; 01402 } else if (num == 28) { 01403 snprintf(fn, sizeof(fn), "digits/%d", num); 01404 num = 0; 01405 } else if (num == 31) { 01406 snprintf(fn, sizeof(fn), "digits/%d", num); 01407 num = 0; 01408 } else if (num == 38) { 01409 snprintf(fn, sizeof(fn), "digits/%d", num); 01410 num = 0; 01411 } else if (num == 41) { 01412 snprintf(fn, sizeof(fn), "digits/%d", num); 01413 num = 0; 01414 } else if (num == 48) { 01415 snprintf(fn, sizeof(fn), "digits/%d", num); 01416 num = 0; 01417 } else if (num == 51) { 01418 snprintf(fn, sizeof(fn), "digits/%d", num); 01419 num = 0; 01420 } else if (num == 58) { 01421 snprintf(fn, sizeof(fn), "digits/%d", num); 01422 num = 0; 01423 } else if (num == 61) { 01424 snprintf(fn, sizeof(fn), "digits/%d", num); 01425 num = 0; 01426 } else if (num == 68) { 01427 snprintf(fn, sizeof(fn), "digits/%d", num); 01428 num = 0; 01429 } else if (num == 71) { 01430 snprintf(fn, sizeof(fn), "digits/%d", num); 01431 num = 0; 01432 } else if (num == 78) { 01433 snprintf(fn, sizeof(fn), "digits/%d", num); 01434 num = 0; 01435 } else if (num == 81) { 01436 snprintf(fn, sizeof(fn), "digits/%d", num); 01437 num = 0; 01438 } else if (num == 88) { 01439 snprintf(fn, sizeof(fn), "digits/%d", num); 01440 num = 0; 01441 } else if (num == 91) { 01442 snprintf(fn, sizeof(fn), "digits/%d", num); 01443 num = 0; 01444 } else if (num == 98) { 01445 snprintf(fn, sizeof(fn), "digits/%d", num); 01446 num = 0; 01447 } else if (num < 100) { 01448 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 01449 num -= ((num / 10) * 10); 01450 } else { 01451 if (num < 1000) { 01452 if ((num / 100) > 1) { 01453 snprintf(fn, sizeof(fn), "digits/%d", (num/100)); 01454 playh++; 01455 } else { 01456 snprintf(fn, sizeof(fn), "digits/hundred"); 01457 } 01458 num -= ((num / 100) * 100); 01459 } else { 01460 if (num < 1000000) { /* 1,000,000 */ 01461 if ((num/1000) > 1) 01462 res = ast_say_number_full_it(chan, num / 1000, ints, language, audiofd, ctrlfd); 01463 if (res) 01464 return res; 01465 tempnum = num; 01466 num = num % 1000; 01467 if ((tempnum / 1000) < 2) 01468 snprintf(fn, sizeof(fn), "digits/thousand"); 01469 else /* for 1000 it says mille, for >1000 (eg 2000) says mila */ 01470 snprintf(fn, sizeof(fn), "digits/thousands"); 01471 } else { 01472 if (num < 1000000000) { /* 1,000,000,000 */ 01473 if ((num / 1000000) > 1) 01474 res = ast_say_number_full_it(chan, num / 1000000, ints, language, audiofd, ctrlfd); 01475 if (res) 01476 return res; 01477 tempnum = num; 01478 num = num % 1000000; 01479 if ((tempnum / 1000000) < 2) 01480 snprintf(fn, sizeof(fn), "digits/million"); 01481 else 01482 snprintf(fn, sizeof(fn), "digits/millions"); 01483 } else { 01484 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 01485 res = -1; 01486 } 01487 } 01488 } 01489 } 01490 if (!res) { 01491 if (!ast_streamfile(chan, fn, language)) { 01492 if ((audiofd > -1) && (ctrlfd > -1)) 01493 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 01494 else 01495 res = ast_waitstream(chan, ints); 01496 } 01497 ast_stopstream(chan); 01498 } 01499 } 01500 return res; 01501 }
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 1506 of file say.c.
References ast_copy_string(), ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.
Referenced by say_number_full().
01507 { 01508 int res = 0; 01509 int playh = 0; 01510 int units = 0; 01511 char fn[256] = ""; 01512 if (!num) 01513 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 01514 while (!res && (num || playh )) { 01515 if (num < 0) { 01516 snprintf(fn, sizeof(fn), "digits/minus"); 01517 if ( num > INT_MIN ) { 01518 num = -num; 01519 } else { 01520 num = 0; 01521 } 01522 } else if (playh) { 01523 snprintf(fn, sizeof(fn), "digits/hundred"); 01524 playh = 0; 01525 } else if (num < 20) { 01526 snprintf(fn, sizeof(fn), "digits/%d", num); 01527 num = 0; 01528 } else if (num < 100) { 01529 units = num % 10; 01530 if (units > 0) { 01531 res = ast_say_number_full_nl(chan, units, ints, language, audiofd, ctrlfd); 01532 if (res) 01533 return res; 01534 num = num - units; 01535 snprintf(fn, sizeof(fn), "digits/nl-en"); 01536 } else { 01537 snprintf(fn, sizeof(fn), "digits/%d", num - units); 01538 num = 0; 01539 } 01540 } else if (num < 200) { 01541 /* hundred, not one-hundred */ 01542 ast_copy_string(fn, "digits/hundred", sizeof(fn)); 01543 num -= ((num / 100) * 100); 01544 } else if (num < 1000) { 01545 snprintf(fn, sizeof(fn), "digits/%d", num / 100); 01546 playh++; 01547 num -= ((num / 100) * 100); 01548 } else { 01549 if (num < 1100) { 01550 /* thousand, not one-thousand */ 01551 num = num % 1000; 01552 ast_copy_string(fn, "digits/thousand", sizeof(fn)); 01553 } else if (num < 10000) { /* 1,100 to 9,9999 */ 01554 res = ast_say_number_full_nl(chan, num / 100, ints, language, audiofd, ctrlfd); 01555 if (res) 01556 return res; 01557 num = num % 100; 01558 ast_copy_string(fn, "digits/hundred", sizeof(fn)); 01559 } else { 01560 if (num < 1000000) { /* 1,000,000 */ 01561 res = ast_say_number_full_nl(chan, num / 1000, ints, language, audiofd, ctrlfd); 01562 if (res) 01563 return res; 01564 num = num % 1000; 01565 snprintf(fn, sizeof(fn), "digits/thousand"); 01566 } else { 01567 if (num < 1000000000) { /* 1,000,000,000 */ 01568 res = ast_say_number_full_nl(chan, num / 1000000, ints, language, audiofd, ctrlfd); 01569 if (res) 01570 return res; 01571 num = num % 1000000; 01572 snprintf(fn, sizeof(fn), "digits/million"); 01573 } else { 01574 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 01575 res = -1; 01576 } 01577 } 01578 } 01579 } 01580 01581 if (!res) { 01582 if (!ast_streamfile(chan, fn, language)) { 01583 if ((audiofd > -1) && (ctrlfd > -1)) 01584 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 01585 else 01586 res = ast_waitstream(chan, ints); 01587 } 01588 ast_stopstream(chan); 01589 } 01590 } 01591 return res; 01592 }
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 1598 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 say_number_full().
01599 { 01600 int res = 0; 01601 int playh = 0; 01602 int playa = 0; 01603 int cn = 1; /* +1 = commune; -1 = neuter */ 01604 char fn[256] = ""; 01605 01606 if (!num) 01607 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 01608 01609 if (options && !strncasecmp(options, "n",1)) cn = -1; 01610 01611 while (!res && (num || playh || playa )) { 01612 /* The grammar for Norwegian numbers is the same as for English except 01613 * for the following: 01614 * - 1 exists in both commune ("en", file "1") and neuter ("ett", file "1N") 01615 * "and" before the last two digits, i.e. 2034 is "two thousand and 01616 * thirty-four" and 1000012 is "one million and twelve". 01617 */ 01618 if (num < 0) { 01619 snprintf(fn, sizeof(fn), "digits/minus"); 01620 if ( num > INT_MIN ) { 01621 num = -num; 01622 } else { 01623 num = 0; 01624 } 01625 } else if (playh) { 01626 snprintf(fn, sizeof(fn), "digits/hundred"); 01627 playh = 0; 01628 } else if (playa) { 01629 snprintf(fn, sizeof(fn), "digits/and"); 01630 playa = 0; 01631 } else if (num == 1 && cn == -1) { 01632 snprintf(fn, sizeof(fn), "digits/1N"); 01633 num = 0; 01634 } else if (num < 20) { 01635 snprintf(fn, sizeof(fn), "digits/%d", num); 01636 num = 0; 01637 } else if (num < 100) { 01638 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 01639 num -= ((num / 10) * 10); 01640 } else if (num < 1000) { 01641 int hundreds = num / 100; 01642 if (hundreds == 1) 01643 snprintf(fn, sizeof(fn), "digits/1N"); 01644 else 01645 snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); 01646 01647 playh++; 01648 num -= 100 * hundreds; 01649 if (num) 01650 playa++; 01651 } else if (num < 1000000) { 01652 res = ast_say_number_full_no(chan, num / 1000, ints, language, "n", audiofd, ctrlfd); 01653 if (res) 01654 return res; 01655 snprintf(fn, sizeof(fn), "digits/thousand"); 01656 num = num % 1000; 01657 if (num && num < 100) 01658 playa++; 01659 } else if (num < 1000000000) { 01660 int millions = num / 1000000; 01661 res = ast_say_number_full_no(chan, millions, ints, language, "c", audiofd, ctrlfd); 01662 if (res) 01663 return res; 01664 snprintf(fn, sizeof(fn), "digits/million"); 01665 num = num % 1000000; 01666 if (num && num < 100) 01667 playa++; 01668 } else { 01669 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 01670 res = -1; 01671 } 01672 01673 if (!res) { 01674 if (!ast_streamfile(chan, fn, language)) { 01675 if ((audiofd > -1) && (ctrlfd > -1)) 01676 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 01677 else 01678 res = ast_waitstream(chan, ints); 01679 } 01680 ast_stopstream(chan); 01681 } 01682 } 01683 return res; 01684 }
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 1800 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 say_number_full().
01802 : 01803 0 zero 01804 1 jeden 01805 10 dziesiec 01806 100 sto 01807 1000 tysiac 01808 1000000 milion 01809 1000000000 miliard 01810 1000000000.2 miliardy 01811 1000000000.5 miliardow 01812 1000000.2 miliony 01813 1000000.5 milionow 01814 1000.2 tysiace 01815 1000.5 tysiecy 01816 100m stu 01817 10m dziesieciu 01818 11 jedenascie 01819 11m jedenastu 01820 12 dwanascie 01821 12m dwunastu 01822 13 trzynascie 01823 13m trzynastu 01824 14 czternascie 01825 14m czternastu 01826 15 pietnascie 01827 15m pietnastu 01828 16 szesnascie 01829 16m szesnastu 01830 17 siedemnascie 01831 17m siedemnastu 01832 18 osiemnascie 01833 18m osiemnastu 01834 19 dziewietnascie 01835 19m dziewietnastu 01836 1z jedna 01837 2 dwa 01838 20 dwadziescia 01839 200 dwiescie 01840 200m dwustu 01841 20m dwudziestu 01842 2-1m dwaj 01843 2-2m dwoch 01844 2z dwie 01845 3 trzy 01846 30 trzydziesci 01847 300 trzysta 01848 300m trzystu 01849 30m trzydziestu 01850 3-1m trzej 01851 3-2m trzech 01852 4 cztery 01853 40 czterdziesci 01854 400 czterysta 01855 400m czterystu 01856 40m czterdziestu 01857 4-1m czterej 01858 4-2m czterech 01859 5 piec 01860 50 piecdziesiat 01861 500 piecset 01862 500m pieciuset 01863 50m piedziesieciu 01864 5m pieciu 01865 6 szesc 01866 60 szescdziesiat 01867 600 szescset 01868 600m szesciuset 01869 60m szescdziesieciu 01870 6m szesciu 01871 7 siedem 01872 70 siedemdziesiat 01873 700 siedemset 01874 700m siedmiuset 01875 70m siedemdziesieciu 01876 7m siedmiu 01877 8 osiem 01878 80 osiemdziesiat 01879 800 osiemset 01880 800m osmiuset 01881 80m osiemdziesieciu 01882 8m osmiu 01883 9 dziewiec 01884 90 dziewiecdziesiat 01885 900 dziewiecset 01886 900m dziewieciuset 01887 90m dziewiedziesieciu 01888 9m dziewieciu 01889 and combinations of eg.: 20_1, 30m_3m, etc... 01890 01891 */ 01892 { 01893 char *zenski_cyfry[] = {"0","1z", "2z", "3", "4", "5", "6", "7", "8", "9"}; 01894 01895 char *zenski_cyfry2[] = {"0","1", "2z", "3", "4", "5", "6", "7", "8", "9"}; 01896 01897 char *meski_cyfry[] = {"0","1", "2-1m", "3-1m", "4-1m", "5m", /*"2-1mdwaj"*/ "6m", "7m", "8m", "9m"}; 01898 01899 char *meski_cyfry2[] = {"0","1", "2-2m", "3-2m", "4-2m", "5m", "6m", "7m", "8m", "9m"}; 01900 01901 char *meski_setki[] = {"", "100m", "200m", "300m", "400m", "500m", "600m", "700m", "800m", "900m"}; 01902 01903 char *meski_dziesiatki[] = {"", "10m", "20m", "30m", "40m", "50m", "60m", "70m", "80m", "90m"}; 01904 01905 char *meski_nastki[] = {"", "11m", "12m", "13m", "14m", "15m", "16m", "17m", "18m", "19m"}; 01906 01907 char *nijaki_cyfry[] = {"0","1", "2", "3", "4", "5", "6", "7", "8", "9"}; 01908 01909 char *nijaki_cyfry2[] = {"0","1", "2", "3", "4", "5", "6", "7", "8", "9"}; 01910 01911 char *nijaki_setki[] = {"", "100", "200", "300", "400", "500", "600", "700", "800", "900"}; 01912 01913 char *nijaki_dziesiatki[] = {"", "10", "20", "30", "40", "50", "60", "70", "80", "90"}; 01914 01915 char *nijaki_nastki[] = {"", "11", "12", "13", "14", "15", "16", "17", "18", "19"}; 01916 01917 char *rzedy[][3] = { {"1000", "1000.2", "1000.5"}, {"1000000", "1000000.2", "1000000.5"}, {"1000000000", "1000000000.2", "1000000000.5"}}; 01918 01919 /* Initialise variables to allow compilation on Debian-stable, etc */ 01920 odmiana *o; 01921 01922 static odmiana *odmiana_nieosobowa = NULL; 01923 static odmiana *odmiana_meska = NULL; 01924 static odmiana *odmiana_zenska = NULL; 01925 01926 if (odmiana_nieosobowa == NULL) { 01927 odmiana_nieosobowa = (odmiana *) malloc(sizeof(odmiana)); 01928 01929 odmiana_nieosobowa->separator_dziesiatek = " "; 01930 01931 memcpy(odmiana_nieosobowa->cyfry, nijaki_cyfry, sizeof(odmiana_nieosobowa->cyfry)); 01932 memcpy(odmiana_nieosobowa->cyfry2, nijaki_cyfry2, sizeof(odmiana_nieosobowa->cyfry)); 01933 memcpy(odmiana_nieosobowa->setki, nijaki_setki, sizeof(odmiana_nieosobowa->setki)); 01934 memcpy(odmiana_nieosobowa->dziesiatki, nijaki_dziesiatki, sizeof(odmiana_nieosobowa->dziesiatki)); 01935 memcpy(odmiana_nieosobowa->nastki, nijaki_nastki, sizeof(odmiana_nieosobowa->nastki)); 01936 memcpy(odmiana_nieosobowa->rzedy, rzedy, sizeof(odmiana_nieosobowa->rzedy)); 01937 } 01938 01939 if (odmiana_zenska == NULL) { 01940 odmiana_zenska = (odmiana *) malloc(sizeof(odmiana)); 01941 01942 odmiana_zenska->separator_dziesiatek = " "; 01943 01944 memcpy(odmiana_zenska->cyfry, zenski_cyfry, sizeof(odmiana_zenska->cyfry)); 01945 memcpy(odmiana_zenska->cyfry2, zenski_cyfry2, sizeof(odmiana_zenska->cyfry)); 01946 memcpy(odmiana_zenska->setki, nijaki_setki, sizeof(odmiana_zenska->setki)); 01947 memcpy(odmiana_zenska->dziesiatki, nijaki_dziesiatki, sizeof(odmiana_zenska->dziesiatki)); 01948 memcpy(odmiana_zenska->nastki, nijaki_nastki, sizeof(odmiana_zenska->nastki)); 01949 memcpy(odmiana_zenska->rzedy, rzedy, sizeof(odmiana_zenska->rzedy)); 01950 } 01951 01952 if (odmiana_meska == NULL) { 01953 odmiana_meska = (odmiana *) malloc(sizeof(odmiana)); 01954 01955 odmiana_meska->separator_dziesiatek = " "; 01956 01957 memcpy(odmiana_meska->cyfry, meski_cyfry, sizeof(odmiana_meska->cyfry)); 01958 memcpy(odmiana_meska->cyfry2, meski_cyfry2, sizeof(odmiana_meska->cyfry)); 01959 memcpy(odmiana_meska->setki, meski_setki, sizeof(odmiana_meska->setki)); 01960 memcpy(odmiana_meska->dziesiatki, meski_dziesiatki, sizeof(odmiana_meska->dziesiatki)); 01961 memcpy(odmiana_meska->nastki, meski_nastki, sizeof(odmiana_meska->nastki)); 01962 memcpy(odmiana_meska->rzedy, rzedy, sizeof(odmiana_meska->rzedy)); 01963 } 01964 01965 if (options) { 01966 if (strncasecmp(options, "f", 1) == 0) 01967 o = odmiana_zenska; 01968 else if (strncasecmp(options, "m", 1) == 0) 01969 o = odmiana_meska; 01970 else 01971 o = odmiana_nieosobowa; 01972 } else 01973 o = odmiana_nieosobowa; 01974 01975 powiedz(chan, language, audiofd, ctrlfd, ints, o, 0, num); 01976 return 0; 01977 }
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 1985 of file say.c.
References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), LOG_WARNING, and wait_file().
Referenced by say_number_full().
01986 { 01987 int res = 0; 01988 int playh = 0; 01989 int mf = 1; /* +1 = male; -1 = female */ 01990 char fn[256] = ""; 01991 01992 if (!num) 01993 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 01994 01995 if (options && !strncasecmp(options, "f",1)) 01996 mf = -1; 01997 01998 while (!res && num ) { 01999 if (num < 0) { 02000 snprintf(fn, sizeof(fn), "digits/minus"); 02001 if ( num > INT_MIN ) { 02002 num = -num; 02003 } else { 02004 num = 0; 02005 } 02006 } else if (num < 20) { 02007 if ((num == 1 || num == 2) && (mf < 0)) 02008 snprintf(fn, sizeof(fn), "digits/%dF", num); 02009 else 02010 snprintf(fn, sizeof(fn), "digits/%d", num); 02011 num = 0; 02012 } else if (num < 100) { 02013 snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10); 02014 if (num % 10) 02015 playh = 1; 02016 num = num % 10; 02017 } else if (num < 1000) { 02018 if (num == 100) 02019 snprintf(fn, sizeof(fn), "digits/100"); 02020 else if (num < 200) 02021 snprintf(fn, sizeof(fn), "digits/100E"); 02022 else { 02023 if (mf < 0 && num > 199) 02024 snprintf(fn, sizeof(fn), "digits/%dF", (num / 100) * 100); 02025 else 02026 snprintf(fn, sizeof(fn), "digits/%d", (num / 100) * 100); 02027 if (num % 100) 02028 playh = 1; 02029 } 02030 num = num % 100; 02031 } else if (num < 1000000) { 02032 if (num > 1999) { 02033 res = ast_say_number_full_pt(chan, (num / 1000) * mf, ints, language, options, audiofd, ctrlfd); 02034 if (res) 02035 return res; 02036 } 02037 snprintf(fn, sizeof(fn), "digits/1000"); 02038 if ((num % 1000) && ((num % 1000) < 100 || !(num % 100))) 02039 playh = 1; 02040 num = num % 1000; 02041 } else if (num < 1000000000) { 02042 res = ast_say_number_full_pt(chan, (num / 1000000), ints, language, options, audiofd, ctrlfd ); 02043 if (res) 02044 return res; 02045 if (num < 2000000) 02046 snprintf(fn, sizeof(fn), "digits/1000000"); 02047 else 02048 snprintf(fn, sizeof(fn), "digits/1000000S"); 02049 02050 if ((num % 1000000) && 02051 /* no thousands */ 02052 ((!((num / 1000) % 1000) && ((num % 1000) < 100 || !(num % 100))) || 02053 /* no hundreds and below */ 02054 (!(num % 1000) && (((num / 1000) % 1000) < 100 || !((num / 1000) % 100))) ) ) 02055 playh = 1; 02056 num = num % 1000000; 02057 } else { 02058 /* number is too big */ 02059 ast_log(LOG_WARNING, "Number '%d' is too big to say.", num); 02060 res = -1; 02061 } 02062 if (!res) { 02063 if (!ast_streamfile(chan, fn, language)) { 02064 if ((audiofd > -1) && (ctrlfd > -1)) 02065 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02066 else 02067 res = ast_waitstream(chan, ints); 02068 } 02069 ast_stopstream(chan); 02070 } 02071 if (!res && playh) { 02072 res = wait_file(chan, ints, "digits/and", language); 02073 ast_stopstream(chan); 02074 playh = 0; 02075 } 02076 } 02077 return res; 02078 }
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 2301 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 say_number_full().
02302 { 02303 int res = 0; 02304 int lastdigits = 0; 02305 char fn[256] = ""; 02306 if (!num) 02307 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 02308 02309 while (!res && (num)) { 02310 if (num < 0) { 02311 snprintf(fn, sizeof(fn), "digits/minus"); 02312 if ( num > INT_MIN ) { 02313 num = -num; 02314 } else { 02315 num = 0; 02316 } 02317 } else if (num < 20) { 02318 if (options && strlen(options) == 1 && num < 3) { 02319 snprintf(fn, sizeof(fn), "digits/%d%s", num, options); 02320 } else { 02321 snprintf(fn, sizeof(fn), "digits/%d", num); 02322 } 02323 num = 0; 02324 } else if (num < 100) { 02325 snprintf(fn, sizeof(fn), "digits/%d", num - (num % 10)); 02326 num %= 10; 02327 } else if (num < 1000){ 02328 snprintf(fn, sizeof(fn), "digits/%d", num - (num % 100)); 02329 num %= 100; 02330 } else if (num < 1000000) { /* 1,000,000 */ 02331 lastdigits = get_lastdigits_ru(num / 1000); 02332 /* say thousands */ 02333 if (lastdigits < 3) { 02334 res = ast_say_number_full_ru(chan, num / 1000, ints, language, "f", audiofd, ctrlfd); 02335 } else { 02336 res = ast_say_number_full_ru(chan, num / 1000, ints, language, NULL, audiofd, ctrlfd); 02337 } 02338 if (res) 02339 return res; 02340 if (lastdigits == 1) { 02341 snprintf(fn, sizeof(fn), "digits/thousand"); 02342 } else if (lastdigits > 1 && lastdigits < 5) { 02343 snprintf(fn, sizeof(fn), "digits/thousands-i"); 02344 } else { 02345 snprintf(fn, sizeof(fn), "digits/thousands"); 02346 } 02347 num %= 1000; 02348 } else if (num < 1000000000) { /* 1,000,000,000 */ 02349 lastdigits = get_lastdigits_ru(num / 1000000); 02350 /* say millions */ 02351 res = ast_say_number_full_ru(chan, num / 1000000, ints, language, NULL, audiofd, ctrlfd); 02352 if (res) 02353 return res; 02354 if (lastdigits == 1) { 02355 snprintf(fn, sizeof(fn), "digits/million"); 02356 } else if (lastdigits > 1 && lastdigits < 5) { 02357 snprintf(fn, sizeof(fn), "digits/million-a"); 02358 } else { 02359 snprintf(fn, sizeof(fn), "digits/millions"); 02360 } 02361 num %= 1000000; 02362 } else { 02363 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 02364 res = -1; 02365 } 02366 if (!res) { 02367 if (!ast_streamfile(chan, fn, language)) { 02368 if ((audiofd > -1) && (ctrlfd > -1)) 02369 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02370 else 02371 res = ast_waitstream(chan, ints); 02372 } 02373 ast_stopstream(chan); 02374 } 02375 } 02376 return res; 02377 }
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 2081 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 say_number_full().
02082 { 02083 int res = 0; 02084 int playh = 0; 02085 char fn[256] = ""; 02086 int cn = 1; /* +1 = commune; -1 = neuter */ 02087 if (!num) 02088 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 02089 if (options && !strncasecmp(options, "n",1)) cn = -1; 02090 02091 while (!res && (num || playh)) { 02092 if (num < 0) { 02093 snprintf(fn, sizeof(fn), "digits/minus"); 02094 if ( num > INT_MIN ) { 02095 num = -num; 02096 } else { 02097 num = 0; 02098 } 02099 } else if (playh) { 02100 snprintf(fn, sizeof(fn), "digits/hundred"); 02101 playh = 0; 02102 } else if (num < 20) { 02103 snprintf(fn, sizeof(fn), "digits/%d", num); 02104 num = 0; 02105 } else if (num < 100) { 02106 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 02107 num -= ((num / 10) * 10); 02108 } else if (num == 1 && cn == -1) { /* En eller ett? */ 02109 snprintf(fn, sizeof(fn), "digits/1N"); 02110 num = 0; 02111 } else { 02112 if (num < 1000){ 02113 snprintf(fn, sizeof(fn), "digits/%d", (num/100)); 02114 playh++; 02115 num -= ((num / 100) * 100); 02116 } else { 02117 if (num < 1000000) { /* 1,000,000 */ 02118 res = ast_say_number_full_se(chan, num / 1000, ints, language, options, audiofd, ctrlfd); 02119 if (res) { 02120 return res; 02121 } 02122 num = num % 1000; 02123 snprintf(fn, sizeof(fn), "digits/thousand"); 02124 } else { 02125 if (num < 1000000000) { /* 1,000,000,000 */ 02126 res = ast_say_number_full_se(chan, num / 1000000, ints, language, options, audiofd, ctrlfd); 02127 if (res) { 02128 return res; 02129 } 02130 num = num % 1000000; 02131 snprintf(fn, sizeof(fn), "digits/million"); 02132 } else { 02133 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 02134 res = -1; 02135 } 02136 } 02137 } 02138 } 02139 if (!res) { 02140 if (!ast_streamfile(chan, fn, language)) { 02141 if ((audiofd > -1) && (ctrlfd > -1)) 02142 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02143 else 02144 res = ast_waitstream(chan, ints); 02145 ast_stopstream(chan); 02146 } 02147 } 02148 } 02149 return res; 02150 }
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 / Chinese syntax
Definition at line 2153 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 say_number_full().
02154 { 02155 int res = 0; 02156 int playh = 0; 02157 int playt = 0; 02158 int playz = 0; 02159 int last_length = 0; 02160 char buf[20] = ""; 02161 char fn[256] = ""; 02162 if (!num) 02163 return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd); 02164 02165 while (!res && (num || playh || playt || playz)) { 02166 if (num < 0) { 02167 snprintf(fn, sizeof(fn), "digits/minus"); 02168 if ( num > INT_MIN ) { 02169 num = -num; 02170 } else { 02171 num = 0; 02172 } 02173 } else if (playz) { 02174 snprintf(fn, sizeof(fn), "digits/0"); 02175 last_length = 0; 02176 playz = 0; 02177 } else if (playh) { 02178 snprintf(fn, sizeof(fn), "digits/hundred"); 02179 playh = 0; 02180 } else if (playt) { 02181 snprintf(fn, sizeof(fn), "digits/thousand"); 02182 playt = 0; 02183 } else if (num < 10) { 02184 snprintf(buf, 10, "%d", num); 02185 if (last_length - strlen(buf) > 1 && last_length != 0) { 02186 last_length = strlen(buf); 02187 playz++; 02188 continue; 02189 } 02190 if (strcasecmp(language,"twz") == 0) 02191 snprintf(fn, sizeof(fn), "digits/%d", num); 02192 else 02193 snprintf(fn, sizeof(fn), "digits/%d", num); 02194 num = 0; 02195 } else if (num < 100) { 02196 snprintf(buf, 10, "%d", num); 02197 if (last_length - strlen(buf) > 1 && last_length != 0) { 02198 last_length = strlen(buf); 02199 playz++; 02200 continue; 02201 } 02202 last_length = strlen(buf); 02203 snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10); 02204 num -= ((num / 10) * 10); 02205 } else { 02206 if (num < 1000){ 02207 snprintf(buf, 10, "%d", num); 02208 if (last_length - strlen(buf) > 1 && last_length != 0) { 02209 last_length = strlen(buf); 02210 playz++; 02211 continue; 02212 } 02213 snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); 02214 playh++; 02215 snprintf(buf, 10, "%d", num); 02216 ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length); 02217 last_length = strlen(buf); 02218 num -= ((num / 100) * 100); 02219 } else if (num < 10000){ 02220 snprintf(buf, 10, "%d", num); 02221 if (last_length - strlen(buf) > 1 && last_length != 0 && last_length % strlen(buf) > 0) { 02222 last_length = strlen(buf); 02223 playz++; 02224 continue; 02225 } 02226 snprintf(fn, sizeof(fn), "digits/%d", (num / 1000)); 02227 playt++; 02228 snprintf(buf, 10, "%d", num); 02229 ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length); 02230 last_length = strlen(buf); 02231 num -= ((num / 1000) * 1000); 02232 } else if (num < 100000000) { /* 100,000,000 */ 02233 res = ast_say_number_full_tw(chan, num / 10000, ints, language, audiofd, ctrlfd); 02234 if (res) 02235 return res; 02236 if (((num / 10000) % (num/100000)) == 0) 02237 playz++; 02238 02239 snprintf(buf, 10, "%d", num); 02240 ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length); 02241 num -= ((num / 10000) * 10000); 02242 last_length = strlen(buf); 02243 snprintf(fn, sizeof(fn), "digits/wan"); 02244 } else { 02245 if (num < 1000000000) { /* 1000,000,000 */ 02246 res = ast_say_number_full_tw(chan, num / 100000000, ints, language, audiofd, ctrlfd); 02247 if (res) 02248 return res; 02249 snprintf(buf, 10, "%d", num); 02250 ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length); 02251 last_length = strlen(buf); 02252 num -= ((num / 100000000) * 100000000); 02253 snprintf(fn, sizeof(fn), "digits/yi"); 02254 } else { 02255 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 02256 res = -1; 02257 } 02258 } 02259 } 02260 if (!res) { 02261 if (!ast_streamfile(chan, fn, language)) { 02262 if ((audiofd > -1) && (ctrlfd > -1)) 02263 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 02264 else 02265 res = ast_waitstream(chan, ints); 02266 } 02267 ast_stopstream(chan); 02268 } 02269 } 02270 return res; 02271 }
int ast_say_time_de | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5678 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_time().
05679 { 05680 struct tm tm; 05681 int res = 0; 05682 05683 ast_localtime(&t, &tm, NULL); 05684 if (!res) 05685 res = ast_say_number(chan, tm.tm_hour, ints, lang, "n"); 05686 if (!res) 05687 res = ast_streamfile(chan, "digits/oclock", lang); 05688 if (!res) 05689 res = ast_waitstream(chan, ints); 05690 if (!res) 05691 if (tm.tm_min > 0) 05692 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 05693 return res; 05694 }
int ast_say_time_en | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5631 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_time().
05632 { 05633 struct tm tm; 05634 int res = 0; 05635 int hour, pm=0; 05636 05637 ast_localtime(&t, &tm, NULL); 05638 hour = tm.tm_hour; 05639 if (!hour) 05640 hour = 12; 05641 else if (hour == 12) 05642 pm = 1; 05643 else if (hour > 12) { 05644 hour -= 12; 05645 pm = 1; 05646 } 05647 if (!res) 05648 res = ast_say_number(chan, hour, ints, lang, (char *) NULL); 05649 if (tm.tm_min > 9) { 05650 if (!res) 05651 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05652 } else if (tm.tm_min) { 05653 if (!res) 05654 res = ast_streamfile(chan, "digits/oh", lang); 05655 if (!res) 05656 res = ast_waitstream(chan, ints); 05657 if (!res) 05658 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05659 } else { 05660 if (!res) 05661 res = ast_streamfile(chan, "digits/oclock", lang); 05662 if (!res) 05663 res = ast_waitstream(chan, ints); 05664 } 05665 if (pm) { 05666 if (!res) 05667 res = ast_streamfile(chan, "digits/p-m", lang); 05668 } else { 05669 if (!res) 05670 res = ast_streamfile(chan, "digits/a-m", lang); 05671 } 05672 if (!res) 05673 res = ast_waitstream(chan, ints); 05674 return res; 05675 }
int ast_say_time_es | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5697 of file say.c.
References ast_localtime(), ast_say_number(), and wait_file().
Referenced by say_time().
05698 { 05699 struct tm tm; 05700 int res = 0; 05701 ast_localtime(&t, &tm, NULL); 05702 05703 res = ast_say_number(chan, tm.tm_hour, ints, lang, "f"); 05704 if (!res) { 05705 if (tm.tm_hour != 1) 05706 res = wait_file(chan, ints, "digits/hours", lang); 05707 else 05708 res = wait_file(chan, ints, "digits/hour", lang); 05709 } 05710 if ((!res) && (tm.tm_min)) { 05711 res = wait_file(chan, ints, "digits/and", lang); 05712 if (!res) 05713 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05714 if (!res) { 05715 if (tm.tm_min > 1) 05716 res = wait_file(chan, ints, "digits/minutes", lang); 05717 else 05718 res = wait_file(chan, ints, "digits/minute", lang); 05719 } 05720 } 05721 return res; 05722 }
int ast_say_time_fr | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5725 of file say.c.
References ast_localtime(), ast_say_number(), and ast_streamfile().
Referenced by say_time().
05726 { 05727 struct tm tm; 05728 int res = 0; 05729 05730 ast_localtime(&t, &tm, NULL); 05731 05732 res = ast_say_number(chan, tm.tm_hour, ints, lang, "f"); 05733 if (!res) 05734 res = ast_streamfile(chan, "digits/oclock", lang); 05735 if (tm.tm_min) { 05736 if (!res) 05737 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05738 } 05739 return res; 05740 }
static int ast_say_time_ge | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 7159 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_time().
07160 { 07161 struct tm tm; 07162 int res = 0; 07163 07164 ast_localtime(&t, &tm, NULL); 07165 07166 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char*)NULL); 07167 if (!res) { 07168 res = ast_streamfile(chan, "digits/saati_da", lang); 07169 if (!res) 07170 res = ast_waitstream(chan, ints); 07171 } 07172 07173 if (tm.tm_min) { 07174 if (!res) { 07175 res = ast_say_number(chan, tm.tm_min, ints, lang, (char*)NULL); 07176 07177 if (!res) { 07178 res = ast_streamfile(chan, "digits/tsuti", lang); 07179 if (!res) 07180 res = ast_waitstream(chan, ints); 07181 } 07182 } 07183 } 07184 return res; 07185 }
static int ast_say_time_gr | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6621 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), and gr_say_number_female().
Referenced by ast_say_datetime_gr(), and say_time().
06622 { 06623 06624 struct tm tm; 06625 int res = 0; 06626 int hour, pm=0; 06627 06628 ast_localtime(&t, &tm, NULL); 06629 hour = tm.tm_hour; 06630 06631 if (!hour) 06632 hour = 12; 06633 else if (hour == 12) 06634 pm = 1; 06635 else if (hour > 12) { 06636 hour -= 12; 06637 pm = 1; 06638 } 06639 06640 res = gr_say_number_female(hour, chan, ints, lang); 06641 if (tm.tm_min) { 06642 if (!res) 06643 res = ast_streamfile(chan, "digits/kai", lang); 06644 if (!res) 06645 res = ast_waitstream(chan, ints); 06646 if (!res) 06647 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 06648 } else { 06649 if (!res) 06650 res = ast_streamfile(chan, "digits/hwra", lang); 06651 if (!res) 06652 res = ast_waitstream(chan, ints); 06653 } 06654 if (pm) { 06655 if (!res) 06656 res = ast_streamfile(chan, "digits/p-m", lang); 06657 } else { 06658 if (!res) 06659 res = ast_streamfile(chan, "digits/a-m", lang); 06660 } 06661 if (!res) 06662 res = ast_waitstream(chan, ints); 06663 return res; 06664 }
int ast_say_time_he | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5861 of file say.c.
References ast_localtime(), ast_say_number_full_he(), and ast_waitstream().
Referenced by say_time().
05862 { 05863 struct tm tm; 05864 int res = 0; 05865 int hour; 05866 05867 ast_localtime(&t, &tm, NULL); 05868 hour = tm.tm_hour; 05869 if (!hour) 05870 hour = 12; 05871 05872 if (!res) 05873 res = ast_say_number_full_he(chan, hour, ints, lang, "f", -1, -1); 05874 05875 if (tm.tm_min > 9) { 05876 if (!res) 05877 res = ast_say_number_full_he(chan, tm.tm_min, ints, lang, "f", -1, -1); 05878 } else if (tm.tm_min) { 05879 if (!res) { /* say a leading zero if needed */ 05880 res = ast_say_number_full_he(chan, 0, ints, lang, "f", -1, -1); 05881 } 05882 if (!res) 05883 res = ast_waitstream(chan, ints); 05884 if (!res) 05885 res = ast_say_number_full_he(chan, tm.tm_min, ints, lang, "f", -1, -1); 05886 } else { 05887 if (!res) 05888 res = ast_waitstream(chan, ints); 05889 } 05890 if (!res) 05891 res = ast_waitstream(chan, ints); 05892 return res; 05893 }
int ast_say_time_nl | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5743 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_time().
05744 { 05745 struct tm tm; 05746 int res = 0; 05747 05748 ast_localtime(&t, &tm, NULL); 05749 if (!res) 05750 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); 05751 if (!res) 05752 res = ast_streamfile(chan, "digits/nl-uur", lang); 05753 if (!res) 05754 res = ast_waitstream(chan, ints); 05755 if (!res) 05756 if (tm.tm_min > 0) 05757 res = ast_say_number(chan, tm.tm_min, ints, lang, NULL); 05758 return res; 05759 }
int ast_say_time_pt | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5762 of file say.c.
References ast_localtime(), ast_say_number(), and wait_file().
Referenced by say_time().
05763 { 05764 struct tm tm; 05765 int res = 0; 05766 int hour; 05767 05768 ast_localtime(&t, &tm, NULL); 05769 hour = tm.tm_hour; 05770 if (!res) 05771 res = ast_say_number(chan, hour, ints, lang, "f"); 05772 if (tm.tm_min) { 05773 if (!res) 05774 res = wait_file(chan, ints, "digits/and", lang); 05775 if (!res) 05776 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05777 } else { 05778 if (!res) { 05779 if (tm.tm_hour == 1) 05780 res = wait_file(chan, ints, "digits/hour", lang); 05781 else 05782 res = wait_file(chan, ints, "digits/hours", lang); 05783 } 05784 } 05785 if (!res) 05786 res = ast_say_number(chan, hour, ints, lang, (char *) NULL); 05787 return res; 05788 }
int ast_say_time_pt_BR | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5791 of file say.c.
References ast_localtime(), ast_say_number(), and wait_file().
Referenced by say_time().
05792 { 05793 struct tm tm; 05794 int res = 0; 05795 05796 ast_localtime(&t, &tm, NULL); 05797 05798 res = ast_say_number(chan, tm.tm_hour, ints, lang, "f"); 05799 if (!res) { 05800 if (tm.tm_hour > 1) 05801 res = wait_file(chan, ints, "digits/hours", lang); 05802 else 05803 res = wait_file(chan, ints, "digits/hour", lang); 05804 } 05805 if ((!res) && (tm.tm_min)) { 05806 res = wait_file(chan, ints, "digits/and", lang); 05807 if (!res) 05808 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05809 if (!res) { 05810 if (tm.tm_min > 1) 05811 res = wait_file(chan, ints, "digits/minutes", lang); 05812 else 05813 res = wait_file(chan, ints, "digits/minute", lang); 05814 } 05815 } 05816 return res; 05817 }
int ast_say_time_tw | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5820 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_time().
05821 { 05822 struct tm tm; 05823 int res = 0; 05824 int hour, pm=0; 05825 05826 ast_localtime(&t, &tm, NULL); 05827 hour = tm.tm_hour; 05828 if (!hour) 05829 hour = 12; 05830 else if (hour == 12) 05831 pm = 1; 05832 else if (hour > 12) { 05833 hour -= 12; 05834 pm = 1; 05835 } 05836 if (pm) { 05837 if (!res) 05838 res = ast_streamfile(chan, "digits/p-m", lang); 05839 } else { 05840 if (!res) 05841 res = ast_streamfile(chan, "digits/a-m", lang); 05842 } 05843 if (!res) 05844 res = ast_waitstream(chan, ints); 05845 if (!res) 05846 res = ast_say_number(chan, hour, ints, lang, (char *) NULL); 05847 if (!res) 05848 res = ast_streamfile(chan, "digits/oclock", lang); 05849 if (!res) 05850 res = ast_waitstream(chan, ints); 05851 if (!res) 05852 res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); 05853 if (!res) 05854 res = ast_streamfile(chan, "digits/minute", lang); 05855 if (!res) 05856 res = ast_waitstream(chan, ints); 05857 return res; 05858 }
static char* ast_translate_number_ge | ( | int | num, | |
char * | res, | |||
int | res_len | |||
) | [static] |
Definition at line 6901 of file say.c.
Referenced by ast_say_number_full_ge().
06902 { 06903 char buf[256]; 06904 int digit = 0; 06905 int remainder = 0; 06906 06907 06908 if (num < 0) { 06909 strncat(res, "minus ", res_len - strlen(res) - 1); 06910 if ( num > INT_MIN ) { 06911 num = -num; 06912 } else { 06913 num = 0; 06914 } 06915 } 06916 06917 06918 /* directly read the numbers */ 06919 if (num <= 20 || num == 40 || num == 60 || num == 80 || num == 100) { 06920 snprintf(buf, sizeof(buf), "%d", num); 06921 strncat(res, buf, res_len - strlen(res) - 1); 06922 return res; 06923 } 06924 06925 06926 if (num < 40) { /* ocda... */ 06927 strncat(res, "20_ ", res_len - strlen(res) - 1); 06928 return ast_translate_number_ge(num - 20, res, res_len); 06929 } 06930 06931 if (num < 60) { /* ormocda... */ 06932 strncat(res, "40_ ", res_len - strlen(res) - 1); 06933 return ast_translate_number_ge(num - 40, res, res_len); 06934 } 06935 06936 if (num < 80) { /* samocda... */ 06937 strncat(res, "60_ ", res_len - strlen(res) - 1); 06938 return ast_translate_number_ge(num - 60, res, res_len); 06939 } 06940 06941 if (num < 100) { /* otxmocda... */ 06942 strncat(res, "80_ ", res_len - strlen(res) - 1); 06943 return ast_translate_number_ge(num - 80, res, res_len); 06944 } 06945 06946 06947 if (num < 1000) { /* as, oras, samas, ..., cxraas. asi, orasi, ..., cxraasi. */ 06948 remainder = num % 100; 06949 digit = (num - remainder) / 100; 06950 06951 if (remainder == 0) { 06952 snprintf(buf, sizeof(buf), "%d", num); 06953 strncat(res, buf, res_len - strlen(res) - 1); 06954 return res; 06955 } else { 06956 snprintf(buf, sizeof(buf), "%d_ ", digit*100); 06957 strncat(res, buf, res_len - strlen(res) - 1); 06958 return ast_translate_number_ge(remainder, res, res_len); 06959 } 06960 } 06961 06962 06963 if (num == 1000) { 06964 strncat(res, "1000", res_len - strlen(res) - 1); 06965 return res; 06966 } 06967 06968 06969 if (num < 1000000) { 06970 remainder = num % 1000; 06971 digit = (num - remainder) / 1000; 06972 06973 if (remainder == 0) { 06974 ast_translate_number_ge(digit, res, res_len); 06975 strncat(res, " 1000", res_len - strlen(res) - 1); 06976 return res; 06977 } 06978 06979 if (digit == 1) { 06980 strncat(res, "1000_ ", res_len - strlen(res) - 1); 06981 return ast_translate_number_ge(remainder, res, res_len); 06982 } 06983 06984 ast_translate_number_ge(digit, res, res_len); 06985 strncat(res, " 1000_ ", res_len - strlen(res) - 1); 06986 return ast_translate_number_ge(remainder, res, res_len); 06987 06988 } 06989 06990 06991 if (num == 1000000) { 06992 strncat(res, "1 1000000", res_len - strlen(res) - 1); 06993 return res; 06994 } 06995 06996 06997 if (num < 1000000000) { 06998 remainder = num % 1000000; 06999 digit = (num - remainder) / 1000000; 07000 07001 if (remainder == 0) { 07002 ast_translate_number_ge(digit, res, res_len); 07003 strncat(res, " 1000000", res_len - strlen(res) - 1); 07004 return res; 07005 } 07006 07007 ast_translate_number_ge(digit, res, res_len); 07008 strncat(res, " 1000000_ ", res_len - strlen(res) - 1); 07009 return ast_translate_number_ge(remainder, res, res_len); 07010 07011 } 07012 07013 07014 if (num == 1000000000) { 07015 strncat(res, "1 1000000000", res_len - strlen(res) - 1); 07016 return res; 07017 } 07018 07019 07020 if (num > 1000000000) { 07021 remainder = num % 1000000000; 07022 digit = (num - remainder) / 1000000000; 07023 07024 if (remainder == 0) { 07025 ast_translate_number_ge(digit, res, res_len); 07026 strncat(res, " 1000000000", res_len - strlen(res) - 1); 07027 return res; 07028 } 07029 07030 ast_translate_number_ge(digit, res, res_len); 07031 strncat(res, " 1000000000_ ", res_len - strlen(res) - 1); 07032 return ast_translate_number_ge(remainder, res, res_len); 07033 07034 } 07035 07036 return res; 07037 07038 }
static int exp10_int | ( | int | power | ) | [static] |
static int get_lastdigits_ru | ( | int | num | ) | [static] |
determine last digits for thousands/millions (ru)
Definition at line 2275 of file say.c.
Referenced by ast_say_number_full_ru().
02275 { 02276 if (num < 20) { 02277 return num; 02278 } else if (num < 100) { 02279 return get_lastdigits_ru(num % 10); 02280 } else if (num < 1000) { 02281 return get_lastdigits_ru(num % 100); 02282 } 02283 return 0; /* number too big */ 02284 }
static int gr_say_number_female | ( | int | num, | |
struct ast_channel * | chan, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6452 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().
06452 { 06453 int tmp; 06454 int left; 06455 int res; 06456 char fn[256] = ""; 06457 06458 /* ast_log(LOG_DEBUG, "\n\n Saying number female %s %d \n\n",lang, num); */ 06459 if (num < 5) { 06460 snprintf(fn, sizeof(fn), "digits/female-%d", num); 06461 res = wait_file(chan, ints, fn, lang); 06462 } else if (num < 13) { 06463 res = ast_say_number(chan, num, ints, lang, (char *) NULL); 06464 } else if (num <100 ) { 06465 tmp = (num/10) * 10; 06466 left = num - tmp; 06467 snprintf(fn, sizeof(fn), "digits/%d", tmp); 06468 res = ast_streamfile(chan, fn, lang); 06469 if (!res) 06470 res = ast_waitstream(chan, ints); 06471 if (left) 06472 gr_say_number_female(left, chan, ints, lang); 06473 06474 } else { 06475 return -1; 06476 } 06477 return res; 06478 }
static char* pl_append | ( | char * | buffer, | |
char * | str | |||
) | [static] |
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 1716 of file say.c.
References ast_log(), ast_stopstream(), ast_streamfile(), ast_waitstream(), ast_waitstream_full(), and LOG_DEBUG.
Referenced by powiedz().
01717 { 01718 char file_name[255] = "digits/"; 01719 strcat(file_name, fn); 01720 ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name); 01721 if (!ast_streamfile(chan, file_name, language)) { 01722 if ((audiofd > -1) && (ctrlfd > -1)) 01723 ast_waitstream_full(chan, ints, audiofd, ctrlfd); 01724 else 01725 ast_waitstream(chan, ints); 01726 } 01727 ast_stopstream(chan); 01728 }
static char* pl_rzad_na_tekst | ( | odmiana * | odm, | |
int | i, | |||
int | rzad | |||
) | [static] |
Definition at line 1696 of file say.c.
References odmiana::rzedy.
Referenced by powiedz().
01697 { 01698 if (rzad==0) 01699 return ""; 01700 01701 if (i==1) 01702 return odm->rzedy[rzad - 1][0]; 01703 if ((i > 21 || i < 11) && i%10 > 1 && i%10 < 5) 01704 return odm->rzedy[rzad - 1][1]; 01705 else 01706 return odm->rzedy[rzad - 1][2]; 01707 }
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 1730 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().
01731 { 01732 /* Initialise variables to allow compilation on Debian-stable, etc */ 01733 int m1000E6 = 0; 01734 int i1000E6 = 0; 01735 int m1000E3 = 0; 01736 int i1000E3 = 0; 01737 int m1000 = 0; 01738 int i1000 = 0; 01739 int m100 = 0; 01740 int i100 = 0; 01741 01742 if (i == 0 && rzad > 0) { 01743 return; 01744 } 01745 if (i == 0) { 01746 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry[0]); 01747 return; 01748 } 01749 01750 m1000E6 = i % 1000000000; 01751 i1000E6 = i / 1000000000; 01752 01753 powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+3, i1000E6); 01754 01755 m1000E3 = m1000E6 % 1000000; 01756 i1000E3 = m1000E6 / 1000000; 01757 01758 powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+2, i1000E3); 01759 01760 m1000 = m1000E3 % 1000; 01761 i1000 = m1000E3 / 1000; 01762 01763 powiedz(chan, language, audiofd, ctrlfd, ints, odm, rzad+1, i1000); 01764 01765 m100 = m1000 % 100; 01766 i100 = m1000 / 100; 01767 01768 if (i100>0) 01769 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->setki[i100]); 01770 01771 if ( m100 > 0 && m100 <=9 ) { 01772 if (m1000>0) 01773 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry2[m100]); 01774 else 01775 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry[m100]); 01776 } else if (m100 % 10 == 0) { 01777 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->dziesiatki[m100 / 10]); 01778 } else if (m100 <= 19 ) { 01779 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->nastki[m100 % 10]); 01780 } else if (m100 != 0) { 01781 if (odm->separator_dziesiatek[0]==' ') { 01782 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->dziesiatki[m100 / 10]); 01783 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, odm->cyfry2[m100 % 10]); 01784 } else { 01785 char buf[10]; 01786 char *b = buf; 01787 b = pl_append(b, odm->dziesiatki[m100 / 10]); 01788 b = pl_append(b, odm->separator_dziesiatek); 01789 b = pl_append(b, odm->cyfry2[m100 % 10]); 01790 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, buf); 01791 } 01792 } 01793 01794 if (rzad > 0) { 01795 pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, pl_rzad_na_tekst(odm, i, rzad)); 01796 } 01797 }
static int say_character_str_full | ( | struct ast_channel * | chan, | |
const char * | str, | |||
const char * | ints, | |||
const char * | lang, | |||
int | audiofd, | |||
int | ctrlfd | |||
) | [static] |
Definition at line 62 of file say.c.
References ast_fileexists(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().
Referenced by __say_init().
00063 { 00064 const char *fn; 00065 char fnbuf[256]; 00066 char ltr; 00067 int num = 0; 00068 int res = 0; 00069 00070 while (str[num] && !res) { 00071 fn = NULL; 00072 switch (str[num]) { 00073 case ('*'): 00074 fn = "digits/star"; 00075 break; 00076 case ('#'): 00077 fn = "digits/pound"; 00078 break; 00079 case ('!'): 00080 fn = "letters/exclaimation-point"; 00081 break; 00082 case ('@'): 00083 fn = "letters/at"; 00084 break; 00085 case ('$'): 00086 fn = "letters/dollar"; 00087 break; 00088 case ('-'): 00089 fn = "letters/dash"; 00090 break; 00091 case ('.'): 00092 fn = "letters/dot"; 00093 break; 00094 case ('='): 00095 fn = "letters/equals"; 00096 break; 00097 case ('+'): 00098 fn = "letters/plus"; 00099 break; 00100 case ('/'): 00101 fn = "letters/slash"; 00102 break; 00103 case (' '): 00104 fn = "letters/space"; 00105 break; 00106 case ('0'): 00107 case ('1'): 00108 case ('2'): 00109 case ('3'): 00110 case ('4'): 00111 case ('5'): 00112 case ('6'): 00113 case ('7'): 00114 case ('8'): 00115 case ('9'): 00116 snprintf(fnbuf, sizeof(fnbuf), "digits/X%s", ((!strncasecmp(lang, "es", 2) && (str[num] == '1')) ? "M" : "")); 00117 fnbuf[7] = str[num]; 00118 fn = fnbuf; 00119 break; 00120 default: 00121 ltr = str[num]; 00122 if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */ 00123 strcpy(fnbuf, "letters/X"); 00124 fnbuf[8] = ltr; 00125 fn = fnbuf; 00126 } 00127 if (fn && ast_fileexists(fn, NULL, lang) > 0) { 00128 res = ast_streamfile(chan, fn, lang); 00129 if (!res) { 00130 if ((audiofd > -1) && (ctrlfd > -1)) 00131 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00132 else 00133 res = ast_waitstream(chan, ints); 00134 } 00135 ast_stopstream(chan); 00136 } 00137 num++; 00138 } 00139 00140 return res; 00141 }
static int say_date | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 2911 of file say.c.
References ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_es(), ast_say_date_fr(), ast_say_date_ge(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_nl(), and ast_say_date_pt().
Referenced by __say_init().
02912 { 02913 if (!strncasecmp(lang, "en", 2)) { /* English syntax */ 02914 return(ast_say_date_en(chan, t, ints, lang)); 02915 } else if (!strncasecmp(lang, "da", 2)) { /* Danish syntax */ 02916 return(ast_say_date_da(chan, t, ints, lang)); 02917 } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ 02918 return(ast_say_date_de(chan, t, ints, lang)); 02919 } else if (!strncasecmp(lang, "es", 2)) { /* Spanish syntax */ 02920 return(ast_say_date_es(chan, t, ints, lang)); 02921 } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ 02922 return(ast_say_date_fr(chan, t, ints, lang)); 02923 } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ 02924 return(ast_say_date_nl(chan, t, ints, lang)); 02925 } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ 02926 return(ast_say_date_pt(chan, t, ints, lang)); 02927 } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ 02928 return(ast_say_date_gr(chan, t, ints, lang)); 02929 } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ 02930 return(ast_say_date_ge(chan, t, ints, lang)); 02931 } else if (!strcasecmp(lang, "he")) { /* Hebrew syntax */ 02932 return (ast_say_date_he(chan, t, ints, lang)); 02933 } 02934 02935 /* Default to English */ 02936 return(ast_say_date_en(chan, t, ints, lang)); 02937 }
static int say_date_with_format | ( | struct ast_channel * | chan, | |
time_t | time, | |||
const char * | ints, | |||
const char * | lang, | |||
const char * | format, | |||
const char * | timezone | |||
) | [static] |
Definition at line 3209 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_pl(), ast_say_date_with_format_pt(), and ast_say_date_with_format_tw().
Referenced by __say_init().
03210 { 03211 if (!strncasecmp(lang, "en", 2)) { /* English syntax */ 03212 return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone)); 03213 } else if (!strncasecmp(lang, "da", 2)) { /* Danish syntax */ 03214 return(ast_say_date_with_format_da(chan, time, ints, lang, format, timezone)); 03215 } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ 03216 return(ast_say_date_with_format_de(chan, time, ints, lang, format, timezone)); 03217 } else if (!strncasecmp(lang, "es", 2)) { /* Spanish syntax */ 03218 return (ast_say_date_with_format_es(chan, time, ints, lang, format, timezone)); 03219 } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ 03220 return (ast_say_date_with_format_he(chan, time, ints, lang, format, timezone)); 03221 } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ 03222 return (ast_say_date_with_format_fr(chan, time, ints, lang, format, timezone)); 03223 } else if (!strncasecmp(lang, "it", 2)) { /* Italian syntax */ 03224 return (ast_say_date_with_format_it(chan, time, ints, lang, format, timezone)); 03225 } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ 03226 return (ast_say_date_with_format_nl(chan, time, ints, lang, format, timezone)); 03227 } else if (!strncasecmp(lang, "pl", 2)) { /* Polish syntax */ 03228 return (ast_say_date_with_format_pl(chan, time, ints, lang, format, timezone)); 03229 } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ 03230 return(ast_say_date_with_format_pt(chan, time, ints, lang, format, timezone)); 03231 } else if (!strncasecmp(lang, "tw", 2) || !strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */ 03232 return(ast_say_date_with_format_tw(chan, time, ints, lang, format, timezone)); 03233 } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ 03234 return(ast_say_date_with_format_gr(chan, time, ints, lang, format, timezone)); 03235 } 03236 03237 /* Default to English */ 03238 return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone)); 03239 }
static int say_datetime | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5894 of file say.c.
References ast_say_datetime_de(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_ge(), ast_say_datetime_gr(), ast_say_datetime_he(), ast_say_datetime_nl(), ast_say_datetime_pt(), ast_say_datetime_pt_BR(), and ast_say_datetime_tw().
Referenced by __say_init().
05895 { 05896 if (!strncasecmp(lang, "en", 2)) { /* English syntax */ 05897 return(ast_say_datetime_en(chan, t, ints, lang)); 05898 } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ 05899 return(ast_say_datetime_de(chan, t, ints, lang)); 05900 } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ 05901 return(ast_say_datetime_fr(chan, t, ints, lang)); 05902 } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ 05903 return(ast_say_datetime_nl(chan, t, ints, lang)); 05904 } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ 05905 if (!strcasecmp(lang, "pt_BR") ) { /* Brazilian Portuguese syntax */ 05906 return(ast_say_datetime_pt_BR(chan, t, ints, lang)); 05907 } else { 05908 return(ast_say_datetime_pt(chan, t, ints, lang)); 05909 } 05910 } else if (!strncasecmp(lang, "tw", 2) || !strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */ 05911 return(ast_say_datetime_tw(chan, t, ints, lang)); 05912 } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ 05913 return(ast_say_datetime_gr(chan, t, ints, lang)); 05914 } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ 05915 return(ast_say_datetime_ge(chan, t, ints, lang)); 05916 } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ 05917 return (ast_say_datetime_he(chan, t, ints, lang)); 05918 } 05919 05920 /* Default to English */ 05921 return(ast_say_datetime_en(chan, t, ints, lang)); 05922 }
static int say_datetime_from_now | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 6264 of file say.c.
References ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_ge(), ast_say_datetime_from_now_he(), and ast_say_datetime_from_now_pt().
Referenced by __say_init().
06265 { 06266 if (!strncasecmp(lang, "en", 2)) { /* English syntax */ 06267 return(ast_say_datetime_from_now_en(chan, t, ints, lang)); 06268 } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ 06269 return(ast_say_datetime_from_now_fr(chan, t, ints, lang)); 06270 } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ 06271 return(ast_say_datetime_from_now_pt(chan, t, ints, lang)); 06272 } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ 06273 return(ast_say_datetime_from_now_ge(chan, t, ints, lang)); 06274 } else if (!strncasecmp(lang, "he", 2)) { /* Georgian syntax */ 06275 return (ast_say_datetime_from_now_he(chan, t, ints, lang)); 06276 } 06277 06278 /* Default to English */ 06279 return(ast_say_datetime_from_now_en(chan, t, ints, lang)); 06280 }
static int say_digit_str_full | ( | struct ast_channel * | chan, | |
const char * | str, | |||
const char * | ints, | |||
const char * | lang, | |||
int | audiofd, | |||
int | ctrlfd | |||
) | [static] |
Definition at line 223 of file say.c.
References ast_fileexists(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().
Referenced by __say_init().
00224 { 00225 const char *fn; 00226 char fnbuf[256]; 00227 int num = 0; 00228 int res = 0; 00229 00230 while (str[num] && !res) { 00231 fn = NULL; 00232 switch (str[num]) { 00233 case ('*'): 00234 fn = "digits/star"; 00235 break; 00236 case ('#'): 00237 fn = "digits/pound"; 00238 break; 00239 case ('-'): 00240 fn = "digits/minus"; 00241 break; 00242 case '0': 00243 case '1': 00244 case '2': 00245 case '3': 00246 case '4': 00247 case '5': 00248 case '6': 00249 case '7': 00250 case '8': 00251 case '9': 00252 snprintf(fnbuf, sizeof(fnbuf), "digits/X%s", ((!strncasecmp(lang, "es", 2) && (str[num] == '1')) ? "M" : "")); 00253 fnbuf[7] = str[num]; 00254 fn = fnbuf; 00255 break; 00256 } 00257 if (fn && ast_fileexists(fn, NULL, lang) > 0) { 00258 res = ast_streamfile(chan, fn, lang); 00259 if (!res) { 00260 if ((audiofd > -1) && (ctrlfd > -1)) 00261 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00262 else 00263 res = ast_waitstream(chan, ints); 00264 } 00265 ast_stopstream(chan); 00266 } 00267 num++; 00268 } 00269 00270 return res; 00271 }
static int say_enumeration_full | ( | struct ast_channel * | chan, | |
int | num, | |||
const char * | ints, | |||
const char * | language, | |||
const char * | options, | |||
int | audiofd, | |||
int | ctrlfd | |||
) | [static] |
ast_say_enumeration_full: call language-specific functions
Definition at line 2382 of file say.c.
References ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), and ast_say_enumeration_full_he().
Referenced by __say_init().
02383 { 02384 if (!strncasecmp(language, "en", 2)) { /* English syntax */ 02385 return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd)); 02386 } else if (!strncasecmp(language, "da", 2)) { /* Danish syntax */ 02387 return(ast_say_enumeration_full_da(chan, num, ints, language, options, audiofd, ctrlfd)); 02388 } else if (!strncasecmp(language, "de", 2)) { /* German syntax */ 02389 return(ast_say_enumeration_full_de(chan, num, ints, language, options, audiofd, ctrlfd)); 02390 } else if (!strcasecmp(language, "he")) { /* Hebrew syntax */ 02391 return (ast_say_enumeration_full_he(chan, num, ints, language, options, audiofd, ctrlfd)); 02392 } 02393 02394 /* Default to english */ 02395 return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd)); 02396 }
static int say_number_full | ( | struct ast_channel * | chan, | |
int | num, | |||
const char * | ints, | |||
const char * | language, | |||
const char * | options, | |||
int | audiofd, | |||
int | ctrlfd | |||
) | [static] |
ast_say_number_full: call language-specific functions
Definition at line 424 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_ge(), 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 __say_init().
00425 { 00426 if (!strncasecmp(language, "en", 2)) { /* Default english syntax */ 00427 if (!strcasecmp(language, "en_GB")) /* British syntax */ 00428 return(ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd)); 00429 else 00430 return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd)); 00431 } else if (!strncasecmp(language, "cz", 2)) { /* Czech syntax */ 00432 return(ast_say_number_full_cz(chan, num, ints, language, options, audiofd, ctrlfd)); 00433 } else if (!strncasecmp(language, "da", 2)) { /* Danish syntax */ 00434 return(ast_say_number_full_da(chan, num, ints, language, options, audiofd, ctrlfd)); 00435 } else if (!strncasecmp(language, "de", 2)) { /* German syntax */ 00436 return(ast_say_number_full_de(chan, num, ints, language, options, audiofd, ctrlfd)); 00437 } else if (!strncasecmp(language, "no", 2)) { /* Norwegian syntax */ 00438 return(ast_say_number_full_no(chan, num, ints, language, options, audiofd, ctrlfd)); 00439 } else if (!strncasecmp(language, "es", 2)) { /* Spanish syntax */ 00440 return(ast_say_number_full_es(chan, num, ints, language, options, audiofd, ctrlfd)); 00441 } else if (!strncasecmp(language, "fr", 2)) { /* French syntax */ 00442 return(ast_say_number_full_fr(chan, num, ints, language, options, audiofd, ctrlfd)); 00443 } else if (!strncasecmp(language, "he", 2)) { /* Hebrew syntax */ 00444 return(ast_say_number_full_he(chan, num, ints, language, options, audiofd, ctrlfd)); 00445 } else if (!strncasecmp(language, "it", 2)) { /* Italian syntax */ 00446 return(ast_say_number_full_it(chan, num, ints, language, audiofd, ctrlfd)); 00447 } else if (!strncasecmp(language, "nl", 2)) { /* Dutch syntax */ 00448 return(ast_say_number_full_nl(chan, num, ints, language, audiofd, ctrlfd)); 00449 } else if (!strncasecmp(language, "pl", 2)) { /* Polish syntax */ 00450 return(ast_say_number_full_pl(chan, num, ints, language, options, audiofd, ctrlfd)); 00451 } else if (!strncasecmp(language, "pt", 2)) { /* Portuguese syntax */ 00452 return(ast_say_number_full_pt(chan, num, ints, language, options, audiofd, ctrlfd)); 00453 } else if (!strncasecmp(language, "se", 2)) { /* Swedish syntax */ 00454 return(ast_say_number_full_se(chan, num, ints, language, options, audiofd, ctrlfd)); 00455 } else if (!strncasecmp(language, "tw", 2) || !strncasecmp(language, "zh", 2) ) { /* Taiwanese / Chinese syntax */ 00456 return(ast_say_number_full_tw(chan, num, ints, language, audiofd, ctrlfd)); 00457 } else if (!strncasecmp(language, "gr", 2)) { /* Greek syntax */ 00458 return(ast_say_number_full_gr(chan, num, ints, language, audiofd, ctrlfd)); 00459 } else if (!strncasecmp(language, "ru", 2)) { /* Russian syntax */ 00460 return(ast_say_number_full_ru(chan, num, ints, language, options, audiofd, ctrlfd)); 00461 } else if (!strncasecmp(language, "ge", 2)) { /* Georgian syntax */ 00462 return(ast_say_number_full_ge(chan, num, ints, language, options, audiofd, ctrlfd)); 00463 } 00464 00465 /* Default to english */ 00466 return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd)); 00467 }
static int say_phonetic_str_full | ( | struct ast_channel * | chan, | |
const char * | str, | |||
const char * | ints, | |||
const char * | lang, | |||
int | audiofd, | |||
int | ctrlfd | |||
) | [static] |
Definition at line 143 of file say.c.
References ast_fileexists(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and ast_waitstream_full().
Referenced by __say_init().
00144 { 00145 const char *fn; 00146 char fnbuf[256]; 00147 char ltr; 00148 int num = 0; 00149 int res = 0; 00150 00151 while (str[num] && !res) { 00152 fn = NULL; 00153 switch (str[num]) { 00154 case ('*'): 00155 fn = "digits/star"; 00156 break; 00157 case ('#'): 00158 fn = "digits/pound"; 00159 break; 00160 case ('!'): 00161 fn = "letters/exclaimation-point"; 00162 break; 00163 case ('@'): 00164 fn = "letters/at"; 00165 break; 00166 case ('$'): 00167 fn = "letters/dollar"; 00168 break; 00169 case ('-'): 00170 fn = "letters/dash"; 00171 break; 00172 case ('.'): 00173 fn = "letters/dot"; 00174 break; 00175 case ('='): 00176 fn = "letters/equals"; 00177 break; 00178 case ('+'): 00179 fn = "letters/plus"; 00180 break; 00181 case ('/'): 00182 fn = "letters/slash"; 00183 break; 00184 case (' '): 00185 fn = "letters/space"; 00186 break; 00187 case ('0'): 00188 case ('1'): 00189 case ('2'): 00190 case ('3'): 00191 case ('4'): 00192 case ('5'): 00193 case ('6'): 00194 case ('7'): 00195 case ('8'): 00196 snprintf(fnbuf, sizeof(fnbuf), "digits/X%s", ((!strncasecmp(lang, "es", 2) && (str[num] == '1')) ? "M" : "")); 00197 fnbuf[7] = str[num]; 00198 fn = fnbuf; 00199 break; 00200 default: /* '9' falls here... */ 00201 ltr = str[num]; 00202 if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */ 00203 strcpy(fnbuf, "phonetic/X_p"); 00204 fnbuf[9] = ltr; 00205 fn = fnbuf; 00206 } 00207 if (fn && ast_fileexists(fn, NULL, lang) > 0) { 00208 res = ast_streamfile(chan, fn, lang); 00209 if (!res) { 00210 if ((audiofd > -1) && (ctrlfd > -1)) 00211 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00212 else 00213 res = ast_waitstream(chan, ints); 00214 } 00215 ast_stopstream(chan); 00216 } 00217 num++; 00218 } 00219 00220 return res; 00221 }
static int say_time | ( | struct ast_channel * | chan, | |
time_t | t, | |||
const char * | ints, | |||
const char * | lang | |||
) | [static] |
Definition at line 5598 of file say.c.
References ast_say_time_de(), ast_say_time_en(), ast_say_time_es(), ast_say_time_fr(), ast_say_time_ge(), ast_say_time_gr(), ast_say_time_he(), ast_say_time_nl(), ast_say_time_pt(), ast_say_time_pt_BR(), and ast_say_time_tw().
Referenced by __say_init().
05599 { 05600 if (!strncasecmp(lang, "en", 2)) { /* English syntax */ 05601 return(ast_say_time_en(chan, t, ints, lang)); 05602 } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ 05603 return(ast_say_time_de(chan, t, ints, lang)); 05604 } else if (!strncasecmp(lang, "es", 2)) { /* Spanish syntax */ 05605 return(ast_say_time_es(chan, t, ints, lang)); 05606 } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ 05607 return(ast_say_time_fr(chan, t, ints, lang)); 05608 } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ 05609 return(ast_say_time_nl(chan, t, ints, lang)); 05610 } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ 05611 if (!strcasecmp(lang, "pt_BR") ) { /* Brazilian Portuguese syntax */ 05612 return(ast_say_time_pt_BR(chan, t, ints, lang)); 05613 } else { /* Default Portuguese syntax */ 05614 return(ast_say_time_pt(chan, t, ints, lang)); 05615 } 05616 } else if (!strncasecmp(lang, "tw", 2) || !strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */ 05617 return(ast_say_time_tw(chan, t, ints, lang)); 05618 } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ 05619 return(ast_say_time_gr(chan, t, ints, lang)); 05620 } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ 05621 return(ast_say_time_ge(chan, t, ints, lang)); 05622 } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ 05623 return (ast_say_time_he(chan, t, ints, lang)); 05624 } 05625 05626 /* Default to English */ 05627 return(ast_say_time_en(chan, t, ints, lang)); 05628 }
static int wait_file | ( | struct ast_channel * | chan, | |
const char * | ints, | |||
const char * | file, | |||
const char * | lang | |||
) | [static] |
Definition at line 412 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_es(), 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_pl(), 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_es(), ast_say_time_pt(), ast_say_time_pt_BR(), gr_say_number_female(), and play_message().
00413 { 00414 int res; 00415 if ((res = ast_streamfile(chan, file, lang))) 00416 ast_log(LOG_WARNING, "Unable to play message %s\n", file); 00417 if (!res) 00418 res = ast_waitstream(chan, ints); 00419 return res; 00420 }