#include <sys/types.h>
#include <asterisk/file.h>
#include <asterisk/channel.h>
#include <asterisk/logger.h>
#include <asterisk/say.h>
#include <stdio.h>
Go to the source code of this file.
Functions | |
int | ast_say_digit_str (struct ast_channel *chan, char *fn2, char *ints, char *lang) |
says digits of a string | |
int | ast_say_digit_str_full (struct ast_channel *chan, char *fn2, char *ints, char *lang, int audiofd, int ctrlfd) |
int | ast_say_digits (struct ast_channel *chan, int num, char *ints, char *lang) |
says digits | |
int | ast_say_digits_full (struct ast_channel *chan, int num, char *ints, char *lang, int audiofd, int ctrlfd) |
int | ast_say_number_full (struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd) |
int | ast_say_number (struct ast_channel *chan, int num, char *ints, char *language) |
says a number | |
int | ast_say_date (struct ast_channel *chan, time_t t, char *ints, char *lang) |
int | ast_say_time (struct ast_channel *chan, time_t t, char *ints, char *lang) |
int | ast_say_datetime (struct ast_channel *chan, time_t t, char *ints, char *lang) |
int | ast_say_datetime_from_now (struct ast_channel *chan, time_t t, char *ints, char *lang) |
|
Definition at line 202 of file say.c. References ast_log(), ast_say_number(), ast_streamfile(), ast_waitstream(), and LOG_WARNING.
00203 { 00204 struct tm tm; 00205 char fn[256]; 00206 int res = 0; 00207 localtime_r(&t,&tm); 00208 if (!&tm) { 00209 ast_log(LOG_WARNING, "Unable to derive local time\n"); 00210 return -1; 00211 } 00212 if (!res) { 00213 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 00214 res = ast_streamfile(chan, fn, lang); 00215 if (!res) 00216 res = ast_waitstream(chan, ints); 00217 } 00218 if (!res) { 00219 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 00220 res = ast_streamfile(chan, fn, lang); 00221 if (!res) 00222 res = ast_waitstream(chan, ints); 00223 } 00224 if (!res) 00225 res = ast_say_number(chan, tm.tm_mday, ints, lang); 00226 00227 if (!res) 00228 res = ast_waitstream(chan, ints); 00229 if (!res) 00230 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang); 00231 return res; 00232 } |
|
Definition at line 284 of file say.c. References ast_log(), ast_say_number(), ast_streamfile(), ast_waitstream(), and LOG_WARNING.
00285 { 00286 struct tm tm; 00287 char fn[256]; 00288 int res = 0; 00289 int hour, pm=0; 00290 localtime_r(&t,&tm); 00291 if (!&tm) { 00292 ast_log(LOG_WARNING, "Unable to derive local time\n"); 00293 return -1; 00294 } 00295 if (!res) { 00296 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 00297 res = ast_streamfile(chan, fn, lang); 00298 if (!res) 00299 res = ast_waitstream(chan, ints); 00300 } 00301 if (!res) { 00302 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 00303 res = ast_streamfile(chan, fn, lang); 00304 if (!res) 00305 res = ast_waitstream(chan, ints); 00306 } 00307 if (!res) 00308 res = ast_say_number(chan, tm.tm_mday, ints, lang); 00309 00310 hour = tm.tm_hour; 00311 if (!hour) 00312 hour = 12; 00313 else if (hour == 12) 00314 pm = 1; 00315 else if (hour > 12) { 00316 hour -= 12; 00317 pm = 1; 00318 } 00319 if (!res) 00320 res = ast_say_number(chan, hour, ints, lang); 00321 00322 if (tm.tm_min > 9) { 00323 if (!res) 00324 res = ast_say_number(chan, tm.tm_min, ints, lang); 00325 } else if (tm.tm_min) { 00326 if (!res) 00327 res = ast_streamfile(chan, "digits/oh", lang); 00328 if (!res) 00329 res = ast_waitstream(chan, ints); 00330 if (!res) 00331 res = ast_say_number(chan, tm.tm_min, ints, lang); 00332 } else { 00333 if (!res) 00334 res = ast_streamfile(chan, "digits/oclock", lang); 00335 if (!res) 00336 res = ast_waitstream(chan, ints); 00337 } 00338 if (pm) { 00339 if (!res) 00340 res = ast_streamfile(chan, "digits/p-m", lang); 00341 } else { 00342 if (!res) 00343 res = ast_streamfile(chan, "digits/a-m", lang); 00344 } 00345 if (!res) 00346 res = ast_waitstream(chan, ints); 00347 if (!res) 00348 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang); 00349 return res; 00350 } |
|
Definition at line 352 of file say.c. References ast_log(), ast_say_number(), ast_say_time(), ast_streamfile(), ast_waitstream(), and LOG_WARNING.
00353 { 00354 int res=0; 00355 time_t nowt; 00356 int daydiff; 00357 struct tm tm; 00358 struct tm now; 00359 char fn[256]; 00360 00361 time(&nowt); 00362 00363 localtime_r(&t,&tm); 00364 if (!&tm) { 00365 ast_log(LOG_WARNING, "Unable to derive local time\n"); 00366 return -1; 00367 } 00368 localtime_r(&nowt,&now); 00369 daydiff = now.tm_yday - tm.tm_yday; 00370 if ((daydiff < 0) || (daydiff > 6)) { 00371 /* Day of month and month */ 00372 if (!res) { 00373 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); 00374 res = ast_streamfile(chan, fn, lang); 00375 if (!res) 00376 res = ast_waitstream(chan, ints); 00377 } 00378 if (!res) 00379 res = ast_say_number(chan, tm.tm_mday, ints, lang); 00380 00381 } else if (daydiff) { 00382 /* Just what day of the week */ 00383 if (!res) { 00384 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); 00385 res = ast_streamfile(chan, fn, lang); 00386 if (!res) 00387 res = ast_waitstream(chan, ints); 00388 } 00389 } /* Otherwise, it was today */ 00390 if (!res) 00391 res = ast_say_time(chan, t, ints, lang); 00392 return res; 00393 } |
|
says digits of a string
Definition at line 21 of file say.c. References ast_stopstream(), ast_streamfile(), and ast_waitstream(). Referenced by ast_say_digits().
00022 { 00023 /* XXX Merge with full version? XXX */ 00024 char fn[256] = ""; 00025 int num = 0; 00026 int res = 0; 00027 while(fn2[num] && !res) { 00028 switch (fn2[num]) { 00029 case ('*'): 00030 snprintf(fn, sizeof(fn), "digits/star"); 00031 break; 00032 case ('#'): 00033 snprintf(fn, sizeof(fn), "digits/pound"); 00034 break; 00035 default: 00036 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00037 } 00038 res = ast_streamfile(chan, fn, lang); 00039 if (!res) 00040 res = ast_waitstream(chan, ints); 00041 ast_stopstream(chan); 00042 num++; 00043 } 00044 return res; 00045 } |
|
Definition at line 47 of file say.c. References ast_stopstream(), ast_streamfile(), and ast_waitstream_full(). Referenced by ast_say_digits_full().
00048 { 00049 char fn[256] = ""; 00050 int num = 0; 00051 int res = 0; 00052 while(fn2[num] && !res) { 00053 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00054 res = ast_streamfile(chan, fn, lang); 00055 if (!res) 00056 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00057 ast_stopstream(chan); 00058 num++; 00059 } 00060 return res; 00061 } |
|
says digits
Definition at line 63 of file say.c. References ast_say_digit_str(). Referenced by ast_say_number().
00064 { 00065 /* XXX Should I be merged with say_digits_full XXX */ 00066 char fn2[256]; 00067 snprintf(fn2, sizeof(fn2), "%d", num); 00068 return ast_say_digit_str(chan, fn2, ints, lang); 00069 } |
|
Definition at line 71 of file say.c. References ast_say_digit_str_full(). Referenced by ast_say_number_full().
00072 { 00073 char fn2[256]; 00074 snprintf(fn2, sizeof(fn2), "%d", num); 00075 return ast_say_digit_str_full(chan, fn2, ints, lang, audiofd, ctrlfd); 00076 } |
|
says a number
Definition at line 140 of file say.c. References ast_log(), ast_say_digits(), ast_stopstream(), ast_streamfile(), ast_waitstream(), and LOG_DEBUG. Referenced by ast_say_date(), ast_say_datetime(), ast_say_datetime_from_now(), and ast_say_time().
00141 { 00142 /* XXX Should I be merged with ast_say_number_full XXX */ 00143 int res = 0; 00144 int playh = 0; 00145 char fn[256] = ""; 00146 if (!num) 00147 return ast_say_digits(chan, 0,ints, language); 00148 if (0) { 00149 /* XXX Only works for english XXX */ 00150 } else { 00151 /* Use english numbers */ 00152 language = "en"; 00153 while(!res && (num || playh)) { 00154 if (playh) { 00155 snprintf(fn, sizeof(fn), "digits/hundred"); 00156 playh = 0; 00157 } else 00158 if (num < 20) { 00159 snprintf(fn, sizeof(fn), "digits/%d", num); 00160 num = 0; 00161 } else 00162 if (num < 100) { 00163 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 00164 num -= ((num / 10) * 10); 00165 } else { 00166 if (num < 1000){ 00167 snprintf(fn, sizeof(fn), "digits/%d", (num/100)); 00168 playh++; 00169 num -= ((num / 100) * 100); 00170 } else { 00171 if (num < 1000000) { 00172 res = ast_say_number(chan, num / 1000, ints, language); 00173 if (res) 00174 return res; 00175 num = num % 1000; 00176 snprintf(fn, sizeof(fn), "digits/thousand"); 00177 } else { 00178 if (num < 1000000000) { 00179 res = ast_say_number(chan, num / 1000000, ints, language); 00180 if (res) 00181 return res; 00182 num = num % 1000000; 00183 snprintf(fn, sizeof(fn), "digits/million"); 00184 } else { 00185 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 00186 res = -1; 00187 } 00188 } 00189 } 00190 } 00191 if (!res) { 00192 res = ast_streamfile(chan, fn, language); 00193 if (!res) 00194 res = ast_waitstream(chan, ints); 00195 ast_stopstream(chan); 00196 } 00197 00198 } 00199 } 00200 return res; 00201 } |
|
Definition at line 78 of file say.c. References ast_log(), ast_say_digits_full(), ast_stopstream(), ast_streamfile(), ast_waitstream_full(), and LOG_DEBUG.
00079 { 00080 int res = 0; 00081 int playh = 0; 00082 char fn[256] = ""; 00083 if (!num) 00084 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); 00085 if (0) { 00086 /* XXX Only works for english XXX */ 00087 } else { 00088 /* Use english numbers */ 00089 language = "en"; 00090 while(!res && (num || playh)) { 00091 if (playh) { 00092 snprintf(fn, sizeof(fn), "digits/hundred"); 00093 playh = 0; 00094 } else 00095 if (num < 20) { 00096 snprintf(fn, sizeof(fn), "digits/%d", num); 00097 num = 0; 00098 } else 00099 if (num < 100) { 00100 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); 00101 num -= ((num / 10) * 10); 00102 } else { 00103 if (num < 1000){ 00104 snprintf(fn, sizeof(fn), "digits/%d", (num/100)); 00105 playh++; 00106 num -= ((num / 100) * 100); 00107 } else { 00108 if (num < 1000000) { 00109 res = ast_say_number_full(chan, num / 1000, ints, language, audiofd, ctrlfd); 00110 if (res) 00111 return res; 00112 num = num % 1000; 00113 snprintf(fn, sizeof(fn), "digits/thousand"); 00114 } else { 00115 if (num < 1000000000) { 00116 res = ast_say_number_full(chan, num / 1000000, ints, language, audiofd, ctrlfd); 00117 if (res) 00118 return res; 00119 num = num % 1000000; 00120 snprintf(fn, sizeof(fn), "digits/million"); 00121 } else { 00122 ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); 00123 res = -1; 00124 } 00125 } 00126 } 00127 } 00128 if (!res) { 00129 res = ast_streamfile(chan, fn, language); 00130 if (!res) 00131 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00132 ast_stopstream(chan); 00133 } 00134 00135 } 00136 } 00137 return res; 00138 } |
|
Definition at line 234 of file say.c. References ast_log(), ast_say_number(), ast_streamfile(), ast_waitstream(), and LOG_WARNING. Referenced by ast_say_datetime_from_now().
00235 { 00236 struct tm tm; 00237 int res = 0; 00238 int hour, pm=0; 00239 localtime_r(&t,&tm); 00240 if (!&tm) { 00241 ast_log(LOG_WARNING, "Unable to derive local time\n"); 00242 return -1; 00243 } 00244 hour = tm.tm_hour; 00245 if (!hour) 00246 hour = 12; 00247 else if (hour == 12) 00248 pm = 1; 00249 else if (hour > 12) { 00250 hour -= 12; 00251 pm = 1; 00252 } 00253 if (!res) 00254 res = ast_say_number(chan, hour, ints, lang); 00255 00256 if (tm.tm_min > 9) { 00257 if (!res) 00258 res = ast_say_number(chan, tm.tm_min, ints, lang); 00259 } else if (tm.tm_min) { 00260 if (!res) 00261 res = ast_streamfile(chan, "digits/oh", lang); 00262 if (!res) 00263 res = ast_waitstream(chan, ints); 00264 if (!res) 00265 res = ast_say_number(chan, tm.tm_min, ints, lang); 00266 } else { 00267 if (!res) 00268 res = ast_streamfile(chan, "digits/oclock", lang); 00269 if (!res) 00270 res = ast_waitstream(chan, ints); 00271 } 00272 if (pm) { 00273 if (!res) 00274 res = ast_streamfile(chan, "digits/p-m", lang); 00275 } else { 00276 if (!res) 00277 res = ast_streamfile(chan, "digits/a-m", lang); 00278 } 00279 if (!res) 00280 res = ast_waitstream(chan, ints); 00281 return res; 00282 } |