#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"
Include dependency graph for say.c:

Go to the source code of this file.
Data Structures | |
| struct | odmiana |
Defines | |
| #define | IL_DATE_STR "AdBY" |
| #define | IL_DATE_STR_FULL IL_DATE_STR " 'digits/at' " IL_TIME_STR |
| #define | IL_TIME_STR "HM" |
| #define | SAY_NUM_BUF_SIZE 256 |
Functions | |
| static void | __attribute__ ((constructor)) |
| static int | ast_say_date_da (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
| static int | ast_say_date_de (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
| static int | ast_say_date_en (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
| static int | ast_say_date_fr (struct ast_channel *chan, time_t t, const char *ints, const char *lang) |
| static int | ast_say_date_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_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 3876 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 __attribute__ | ( | (constructor) | ) | [static] |
Definition at line 7273 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().
Referenced by get_unaligned_uint16(), get_unaligned_uint32(), parse_srv(), put_unaligned_uint16(), and put_unaligned_uint32().
07274 { 07275 ast_say_number_full = say_number_full; 07276 ast_say_enumeration_full = say_enumeration_full; 07277 ast_say_digit_str_full = say_digit_str_full; 07278 ast_say_character_str_full = say_character_str_full; 07279 ast_say_phonetic_str_full = say_phonetic_str_full; 07280 ast_say_datetime = say_datetime; 07281 ast_say_time = say_time; 07282 ast_say_date = say_date; 07283 ast_say_datetime_from_now = say_datetime_from_now; 07284 ast_say_date_with_format = say_date_with_format; 07285 }
| int ast_say_date_da | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 2963 of file say.c.
References ast_localtime(), ast_say_enumeration(), ast_say_number(), ast_streamfile(), ast_waitstream(), and wait_file().
Referenced by say_date().
02964 { 02965 struct tm tm; 02966 char fn[256]; 02967 int res = 0; 02968 ast_localtime(&t,&tm,NULL); 02969 if (!res) { 02970 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 02971 res = ast_streamfile(chan, fn, lang); 02972 if (!res) 02973 res = ast_waitstream(chan, ints); 02974 } 02975 if (!res) 02976 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL); 02977 if (!res) 02978 res = ast_waitstream(chan, ints); 02979 if (!res) { 02980 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 02981 res = ast_streamfile(chan, fn, lang); 02982 if (!res) 02983 res = ast_waitstream(chan, ints); 02984 } 02985 if (!res) { 02986 /* Year */ 02987 int year = tm.tm_year + 1900; 02988 if (year > 1999) { /* year 2000 and later */ 02989 res = ast_say_number(chan, year, ints, lang, (char *) NULL); 02990 } else { 02991 if (year < 1100) { 02992 /* I'm not going to handle 1100 and prior */ 02993 /* We'll just be silent on the year, instead of bombing out. */ 02994 } else { 02995 /* year 1100 to 1999. will anybody need this?!? */ 02996 snprintf(fn,sizeof(fn), "digits/%d", (year / 100) ); 02997 res = wait_file(chan, ints, fn, lang); 02998 if (!res) { 02999 res = wait_file(chan,ints, "digits/hundred", lang); 03000 if (!res && year % 100 != 0) { 03001 res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 03002 } 03003 } 03004 } 03005 } 03006 } 03007 return res; 03008 }
| int ast_say_date_de | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 3011 of file say.c.
References ast_localtime(), ast_say_enumeration(), ast_say_number(), ast_streamfile(), ast_waitstream(), and wait_file().
Referenced by say_date().
03012 { 03013 struct tm tm; 03014 char fn[256]; 03015 int res = 0; 03016 ast_localtime(&t,&tm,NULL); 03017 if (!res) { 03018 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03019 res = ast_streamfile(chan, fn, lang); 03020 if (!res) 03021 res = ast_waitstream(chan, ints); 03022 } 03023 if (!res) 03024 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, (char * ) NULL); 03025 if (!res) 03026 res = ast_waitstream(chan, ints); 03027 if (!res) { 03028 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03029 res = ast_streamfile(chan, fn, lang); 03030 if (!res) 03031 res = ast_waitstream(chan, ints); 03032 } 03033 if (!res) { 03034 /* Year */ 03035 int year = tm.tm_year + 1900; 03036 if (year > 1999) { /* year 2000 and later */ 03037 res = ast_say_number(chan, year, ints, lang, (char *) NULL); 03038 } else { 03039 if (year < 1100) { 03040 /* I'm not going to handle 1100 and prior */ 03041 /* We'll just be silent on the year, instead of bombing out. */ 03042 } else { 03043 /* year 1100 to 1999. will anybody need this?!? */ 03044 /* say 1967 as 'neunzehn hundert sieben und sechzig' */ 03045 snprintf(fn,sizeof(fn), "digits/%d", (year / 100) ); 03046 res = wait_file(chan, ints, fn, lang); 03047 if (!res) { 03048 res = wait_file(chan,ints, "digits/hundred", lang); 03049 if (!res && year % 100 != 0) { 03050 res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 03051 } 03052 } 03053 } 03054 } 03055 } 03056 return res; 03057 }
| int ast_say_date_en | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 2935 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
02936 { 02937 struct tm tm; 02938 char fn[256]; 02939 int res = 0; 02940 ast_localtime(&t,&tm,NULL); 02941 if (!res) { 02942 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 02943 res = ast_streamfile(chan, fn, lang); 02944 if (!res) 02945 res = ast_waitstream(chan, ints); 02946 } 02947 if (!res) { 02948 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 02949 res = ast_streamfile(chan, fn, lang); 02950 if (!res) 02951 res = ast_waitstream(chan, ints); 02952 } 02953 if (!res) 02954 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 02955 if (!res) 02956 res = ast_waitstream(chan, ints); 02957 if (!res) 02958 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 02959 return res; 02960 }
| int ast_say_date_fr | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 3060 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
03061 { 03062 struct tm tm; 03063 char fn[256]; 03064 int res = 0; 03065 ast_localtime(&t,&tm,NULL); 03066 if (!res) { 03067 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03068 res = ast_streamfile(chan, fn, lang); 03069 if (!res) 03070 res = ast_waitstream(chan, ints); 03071 } 03072 if (!res) 03073 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 03074 if (!res) 03075 res = ast_waitstream(chan, ints); 03076 if (!res) { 03077 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03078 res = ast_streamfile(chan, fn, lang); 03079 if (!res) 03080 res = ast_waitstream(chan, ints); 03081 } 03082 if (!res) 03083 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03084 return res; 03085 }
| static int ast_say_date_ge | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 7141 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
07142 { 07143 struct tm tm; 07144 char fn[256]; 07145 int res = 0; 07146 ast_localtime(&t,&tm,NULL); 07147 07148 if (!res) 07149 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 07150 07151 if (!res) { 07152 snprintf(fn, sizeof(fn), "digits/tslis %d", tm.tm_wday); 07153 res = ast_streamfile(chan, fn, lang); 07154 if (!res) 07155 res = ast_waitstream(chan, ints); 07156 } 07157 07158 if (!res) { 07159 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 07160 /* if (!res) 07161 res = ast_waitstream(chan, ints); 07162 */ 07163 } 07164 07165 if (!res) { 07166 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 07167 res = ast_streamfile(chan, fn, lang); 07168 if (!res) 07169 res = ast_waitstream(chan, ints); 07170 } 07171 return res; 07172 07173 }
| static int ast_say_date_gr | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 6599 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), ast_waitstream(), and gr_say_number_female().
Referenced by say_date().
06600 { 06601 struct tm tm; 06602 06603 char fn[256]; 06604 int res = 0; 06605 06606 06607 ast_localtime(&t,&tm,NULL); 06608 /* W E E K - D A Y */ 06609 if (!res) { 06610 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 06611 res = ast_streamfile(chan, fn, lang); 06612 if (!res) 06613 res = ast_waitstream(chan, ints); 06614 } 06615 /* D A Y */ 06616 if (!res) { 06617 gr_say_number_female(tm.tm_mday, chan, ints, lang); 06618 } 06619 /* M O N T H */ 06620 if (!res) { 06621 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 06622 res = ast_streamfile(chan, fn, lang); 06623 if (!res) 06624 res = ast_waitstream(chan, ints); 06625 } 06626 /* Y E A R */ 06627 if (!res) 06628 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 06629 return res; 06630 }
| int ast_say_date_he | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 3142 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
03143 { 03144 struct tm tm; 03145 char fn[256]; 03146 int res = 0; 03147 ast_localtime(&t, &tm, NULL); 03148 if (!res) { 03149 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03150 res = ast_streamfile(chan, fn, lang); 03151 if (!res) { 03152 res = ast_waitstream(chan, ints); 03153 } 03154 } 03155 if (!res) { 03156 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03157 res = ast_streamfile(chan, fn, lang); 03158 if (!res) { 03159 res = ast_waitstream(chan, ints); 03160 } 03161 } 03162 if (!res) { 03163 res = ast_say_number(chan, tm.tm_mday, ints, lang, "m"); 03164 } 03165 if (!res) { 03166 res = ast_waitstream(chan, ints); 03167 } 03168 if (!res) { 03169 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, "m"); 03170 } 03171 return res; 03172 }
| int ast_say_date_nl | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 3088 of file say.c.
References ast_localtime(), ast_say_number(), ast_streamfile(), and ast_waitstream().
Referenced by say_date().
03089 { 03090 struct tm tm; 03091 char fn[256]; 03092 int res = 0; 03093 ast_localtime(&t,&tm,NULL); 03094 if (!res) { 03095 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03096 res = ast_streamfile(chan, fn, lang); 03097 if (!res) 03098 res = ast_waitstream(chan, ints); 03099 } 03100 if (!res) 03101 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); 03102 if (!res) { 03103 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03104 res = ast_streamfile(chan, fn, lang); 03105 if (!res) 03106 res = ast_waitstream(chan, ints); 03107 } 03108 if (!res) 03109 res = ast_waitstream(chan, ints); 03110 if (!res) 03111 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03112 return res; 03113 }
| int ast_say_date_pt | ( | struct ast_channel * | chan, | |
| time_t | t, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) | [static] |
Definition at line 3116 of file say.c.
References ast_localtime(), ast_say_number(), and wait_file().
Referenced by say_date().
03117 { 03118 struct tm tm; 03119 char fn[256]; 03120 int res = 0; 03121 03122 ast_localtime(&t, &tm, NULL); 03123 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 03124 if (!res) 03125 res = wait_file(chan, ints, fn, lang); 03126 if (!res) 03127 res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); 03128 if (!res) 03129 res = wait_file(chan, ints, "digits/pt-de", lang); 03130 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 03131 if (!res) 03132 res = wait_file(chan, ints, fn, lang); 03133 if (!res) 03134 res = wait_file(chan, ints, "digits/pt-de", lang); 03135 if (!res) 03136 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); 03137 03138 return res; 03139 }
| 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 3449 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().
03450 { 03451 struct tm tm; 03452 int res=0, offset, sndoffset; 03453 char sndfile[256], nextmsg[256]; 03454 03455 if (!format) 03456 format = "A dBY HMS"; 03457 03458 ast_localtime(&time,&tm,timezone); 03459 03460 for (offset=0 ; format[offset] != '\0' ; offset++) { 03461 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); 03462 switch (format[offset]) { 03463 /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ 03464 case '\'': 03465 /* Literal name of a sound file */ 03466 sndoffset=0; 03467 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++) 03468 sndfile[sndoffset] = format[offset]; 03469 sndfile[sndoffset] = '\0'; 03470 res = wait_file(chan,ints,sndfile,lang); 03471 break; 03472 case 'A': 03473 case 'a': 03474 /* Sunday - Saturday */ 03475 snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday); 03476 res = wait_file(chan,ints,nextmsg,lang); 03477 break; 03478 case 'B': 03479 case 'b': 03480 case 'h': 03481 /* January - December */ 03482 snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon); 03483 res = wait_file(chan,ints,nextmsg,lang); 03484 break; 03485 case 'm': 03486 /* Month enumerated */ 03487 res = ast_say_enumeration(chan, (tm.tm_mon + 1), ints, lang, "m"); 03488 break; 03489 case 'd': 03490 case 'e': 03491 /* First - Thirtyfirst */ 03492 res = ast_say_enumeration(chan, tm.tm_mday, ints, lang, "m"); 03493 break; 03494 case 'Y': 03495 /* Year */ 03496 { 03497 int year = tm.tm_year + 1900; 03498 if (year > 1999) { /* year 2000 and later */ 03499 res = ast_say_number(chan, year, ints, lang, (char *) NULL); 03500 } else { 03501 if (year < 1100) { 03502 /* I'm not going to handle 1100 and prior */ 03503 /* We'll just be silent on the year, instead of bombing out. */ 03504 } else { 03505 /* year 1100 to 1999. will anybody need this?!? */ 03506 /* say 1967 as 'nineteen hundred seven and sixty' */ 03507 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (year / 100) ); 03508 res = wait_file(chan,ints,nextmsg,lang); 03509 if (!res) { 03510 res = wait_file(chan,ints, "digits/hundred",lang); 03511 if (!res && year % 100 != 0) { 03512 res = ast_say_number(chan, (year % 100), ints, lang, (char *) NULL); 03513 } 03514 } 03515 } 03516 } 03517 } 03518 break; 03519 case 'I': 03520 case 'l': 03521 /* 12-Hour */ 03522 res = wait_file(chan,ints,"digits/oclock",lang); 03523 if (tm.tm_hour == 0) 03524 snprintf(nextmsg,sizeof(nextmsg), "digits/12"); 03525 else if (tm.tm_hour > 12) 03526 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12); 03527 else 03528 snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour); 03529 if (!res) { 03530 res = wait_file(chan,ints,nextmsg,lang); 03531 } 03532 break; 03533 case 'H': 03534 /* 24-Hour, single digit hours preceeded by "oh" (0) */ 03535 if (tm.tm_hour < 10 && tm.tm_hour > 0) { 03536 res = wait_file(chan,ints, "digits/0",lang); 03537 } 03538 /* FALLTRHU */ 03539 case 'k': 03540 /* 24-Hour */ 03541 res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); 03542 break; 03543 case 'M': 03544 /* Minute */ 03545 if (tm.tm_min > 0 || format[offset+ 1 ] == 'S' ) { /* zero 'digits/0' only if seconds follow (kind of a hack) */ 03546 res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); 03547 } 03548 if ( !res && format[offset + 1] == 'S' ) { /* minutes only if seconds follow (kind of a hack) */ 03549 if (tm.tm_min == 1) { 03550 res = wait_file(chan,ints,"digits/minute",lang); 03551 } else { 03552 res = wait_file(chan,ints,"digits/minutes",lang); 03553 } 03554 } 03555 break; 03556 case 'P': 03557 case 'p': 03558 /* AM/PM */ 03559 if (tm.tm_hour > 11) 03560 snprintf(nextmsg,sizeof(nextmsg), "digits/p-m"); 03561 else 03562 snprintf(nextmsg,sizeof(nextmsg), "digits/a-m"); 03563 res = wait_file(chan,ints,nextmsg,lang); 03564 break; 03565 case 'Q': 03566 /* Shorthand for "Today", "Yesterday", or AdBY */ 03567 /* XXX As emphasized elsewhere, this should the native way in your 03568 * language to say the date, with changes in what you say, depending 03569 * upon how recent the date is. XXX */ 03570 { 03571 struct timeval now; 03572 struct tm tmnow; 03573 time_t beg_today, tt; 03574 03575 gettimeofday(&now,NULL); 03576 tt = now.tv_sec; 03577 ast_localtime(&tt,&tmnow,timezone); 03578 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03579 /* In any case, it saves not having to do ast_mktime() */ 03580 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03581 if (beg_today < time) { 03582 /* Today */ 03583 res = wait_file(chan,ints, "digits/today",lang); 03584 } else if (beg_today - 86400 < time) { 03585 /* Yesterday */ 03586 res = wait_file(chan,ints, "digits/yesterday",lang); 03587 } else { 03588 res = ast_say_date_with_format_da(chan, time, ints, lang, "AdBY", timezone); 03589 } 03590 } 03591 break; 03592 case 'q': 03593 /* Shorthand for "" (today), "Yesterday", A (weekday), or AdBY */ 03594 /* XXX As emphasized elsewhere, this should the native way in your 03595 * language to say the date, with changes in what you say, depending 03596 * upon how recent the date is. XXX */ 03597 { 03598 struct timeval now; 03599 struct tm tmnow; 03600 time_t beg_today, tt; 03601 03602 gettimeofday(&now,NULL); 03603 tt = now.tv_sec; 03604 ast_localtime(&tt,&tmnow,timezone); 03605 /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */ 03606 /* In any case, it saves not having to do ast_mktime() */ 03607 beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec); 03608 if (beg_today < time) { 03609 /* Today */ 03610 } else if ((beg_today - 86400) < time) { 03611 /* Yesterday */ 03612 res = wait_file(chan,ints, "digits/yesterday",lang); 03613 } else if (beg_today - 86400 * 6 < time) { 03614 /* Within the last week */ 03615 res = ast_say_date_with_format_da(chan, time, ints, lang, "A", timezone); 03616 } else { 03617 res = ast_say_date_with_format_da(chan, time, ints, lang, "AdBY", timezone); 03618 } 03619 } 03620 break; 03621 case 'R': 03622 res = ast_say_date_with_format_da(chan, time, ints, lang, "HM", timezone); 03623 break; 03624 case 'S': 03625 /* Seconds */ 03626 res = wait_file(chan,ints, "digits/and",lang); 03627 if (!res) { 03628 res = ast_say_number(chan, tm.tm_sec, ints, lang, "f"); 03629 if (!res) { 03630 res = wait_file(chan,ints, "digits/seconds",lang); 03631 } 03632 } 03633 break; 03634 case 'T': 03635 res = ast_say_date_with_format_da(chan, time, ints, lang, "HMS", timezone); 03636 break; 03637 case ' ': 03638 case ' ': 03639 /* Just ignore spaces and tabs */ 03640 break; 03641 default: 03642 /* Unknown character */ 03643 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset); 03644 } 03645 /* Jump out on DTMF */ 03646 if (res) { 03647 break; 03648 } 03649 } 03650 return res; 03651 }
| 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 3654 of file say.c.
References ast_localtime(), ast_log(), ast_say_enumeration(), ast_say_number(),