Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

say.c File Reference

#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <time.h>
#include <ctype.h>
#include <asterisk/file.h>
#include <asterisk/channel.h>
#include <asterisk/logger.h>
#include <asterisk/say.h>
#include <asterisk/lock.h>
#include <asterisk/localtime.h>
#include <asterisk/utils.h>
#include "asterisk.h"
#include <stdio.h>

Include dependency graph for say.c:

Include dependency graph

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_character_str (struct ast_channel *chan, char *fn2, char *ints, char *lang)
int ast_say_phonetic_str (struct ast_channel *chan, char *fn2, char *ints, char *lang)
int ast_say_digit_str_full (struct ast_channel *chan, char *fn2, char *ints, char *lang, int audiofd, int ctrlfd)
int ast_say_character_str_full (struct ast_channel *chan, char *fn2, char *ints, char *lang, int audiofd, int ctrlfd)
int ast_say_phonetic_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, char *options, int audiofd, int ctrlfd)
int ast_say_number (struct ast_channel *chan, int num, char *ints, char *language, char *options)
 says a number

int ast_say_date (struct ast_channel *chan, time_t t, char *ints, char *lang)
int ast_say_date_with_format (struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone)
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)


Function Documentation

int ast_say_character_str struct ast_channel chan,
char *  fn2,
char *  ints,
char *  lang
 

Definition at line 65 of file say.c.

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

00066 { 00067 /* XXX Merge with full version? XXX */ 00068 char fn[256] = ""; 00069 char ltr; 00070 int num = 0; 00071 int res = 0; 00072 while(fn2[num] && !res) { 00073 fn[0] = '\0'; 00074 switch (fn2[num]) { 00075 case ('*'): 00076 snprintf(fn, sizeof(fn), "digits/star"); 00077 break; 00078 case ('#'): 00079 snprintf(fn, sizeof(fn), "digits/pound"); 00080 break; 00081 case ('0'): 00082 case ('1'): 00083 case ('2'): 00084 case ('3'): 00085 case ('4'): 00086 case ('5'): 00087 case ('6'): 00088 case ('7'): 00089 case ('8'): 00090 case ('9'): 00091 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00092 break; 00093 case ('!'): 00094 strncpy(fn, "letters/exclaimation-point", sizeof(fn)); 00095 break; 00096 case ('@'): 00097 strncpy(fn, "letters/at", sizeof(fn)); 00098 break; 00099 case ('$'): 00100 strncpy(fn, "letters/dollar", sizeof(fn)); 00101 break; 00102 case ('-'): 00103 strncpy(fn, "letters/dash", sizeof(fn)); 00104 break; 00105 case ('.'): 00106 strncpy(fn, "letters/dot", sizeof(fn)); 00107 break; 00108 case ('='): 00109 strncpy(fn, "letters/equals", sizeof(fn)); 00110 break; 00111 case ('+'): 00112 strncpy(fn, "letters/plus", sizeof(fn)); 00113 break; 00114 case ('/'): 00115 strncpy(fn, "letters/slash", sizeof(fn)); 00116 break; 00117 case (' '): 00118 strncpy(fn, "letters/space", sizeof(fn)); 00119 break; 00120 default: 00121 ltr = fn2[num]; 00122 if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */ 00123 snprintf(fn, sizeof(fn), "letters/%c", ltr); 00124 } 00125 if(!ast_strlen_zero(fn)) { /* if length == 0, then skip this digit as it is invalid */ 00126 res = ast_streamfile(chan, fn, lang); 00127 if (!res) 00128 res = ast_waitstream(chan, ints); 00129 } ast_stopstream(chan); 00130 num++; 00131 } 00132 return res; 00133 }

int ast_say_character_str_full struct ast_channel chan,
char *  fn2,
char *  ints,
char *  lang,
int  audiofd,
int  ctrlfd
 

Definition at line 253 of file say.c.

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

00254 { 00255 char fn[256] = ""; 00256 char ltr; 00257 int num = 0; 00258 int res = 0; 00259 while(fn2[num] && !res) { 00260 switch (fn2[num]) { 00261 case ('*'): 00262 snprintf(fn, sizeof(fn), "digits/star"); 00263 break; 00264 case ('#'): 00265 snprintf(fn, sizeof(fn), "digits/pound"); 00266 break; 00267 case ('0'): 00268 case ('1'): 00269 case ('2'): 00270 case ('3'): 00271 case ('4'): 00272 case ('5'): 00273 case ('6'): 00274 case ('7'): 00275 case ('8'): 00276 case ('9'): 00277 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00278 break; 00279 case ('!'): 00280 strncpy(fn, "exclaimation-point", sizeof(fn)); 00281 break; 00282 case ('@'): 00283 strncpy(fn, "at", sizeof(fn)); 00284 break; 00285 case ('$'): 00286 strncpy(fn, "dollar", sizeof(fn)); 00287 break; 00288 case ('-'): 00289 strncpy(fn, "dash", sizeof(fn)); 00290 break; 00291 case ('.'): 00292 strncpy(fn, "dot", sizeof(fn)); 00293 break; 00294 case ('='): 00295 strncpy(fn, "equals", sizeof(fn)); 00296 break; 00297 case ('+'): 00298 strncpy(fn, "plus", sizeof(fn)); 00299 break; 00300 case ('/'): 00301 strncpy(fn, "slash", sizeof(fn)); 00302 break; 00303 case (' '): 00304 strncpy(fn, "space", sizeof(fn)); 00305 break; 00306 default: 00307 ltr = fn2[num]; 00308 if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */ 00309 snprintf(fn, sizeof(fn), "letters/%c", ltr); 00310 } 00311 /* snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); */ 00312 res = ast_streamfile(chan, fn, lang); 00313 if (!res) 00314 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00315 ast_stopstream(chan); 00316 num++; 00317 } 00318 return res; 00319 }

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

Definition at line 1704 of file say.c.

01705 { 01706 if (!strcasecmp(lang,"en") ) { /* English syntax */ 01707 return(ast_say_date_en(chan, t, ints, lang)); 01708 } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */ 01709 return(ast_say_date_nl(chan, t, ints, lang)); 01710 } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */ 01711 return(ast_say_date_pt(chan, t, ints, lang)); 01712 } 01713 01714 /* Default to English */ 01715 return(ast_say_date_en(chan, t, ints, lang)); 01716 }

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

Definition at line 1800 of file say.c.

01801 { 01802 if (!strcasecmp(lang, "en") ) { /* English syntax */ 01803 return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone)); 01804 } else if (!strcasecmp(lang, "de") ) { /* German syntax */ 01805 return(ast_say_date_with_format_de(chan, time, ints, lang, format, timezone)); 01806 } else if (!strcasecmp(lang, "es") || !strcasecmp(lang, "mx")) { /* Spanish syntax */ 01807 return(ast_say_date_with_format_es(chan, time, ints, lang, format, timezone)); 01808 } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */ 01809 return(ast_say_date_with_format_nl(chan, time, ints, lang, format, timezone)); 01810 } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */ 01811 return(ast_say_date_with_format_pt(chan, time, ints, lang, format, timezone)); 01812 } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */ 01813 return(ast_say_date_with_format_tw(chan, time, ints, lang, format, timezone)); 01814 } 01815 01816 /* Default to English */ 01817 return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone)); 01818 }

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

Definition at line 3406 of file say.c.

03407 { 03408 if (!strcasecmp(lang, "en") ) { /* English syntax */ 03409 return(ast_say_datetime_en(chan, t, ints, lang)); 03410 } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */ 03411 return(ast_say_datetime_nl(chan, t, ints, lang)); 03412 } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */ 03413 return(ast_say_datetime_pt(chan, t, ints, lang)); 03414 } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */ 03415 return(ast_say_datetime_tw(chan, t, ints, lang)); 03416 } 03417 03418 /* Default to English */ 03419 return(ast_say_datetime_en(chan, t, ints, lang)); 03420 }

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

Definition at line 3628 of file say.c.

03629 { 03630 if (!strcasecmp(lang, "en") ) { /* English syntax */ 03631 return(ast_say_datetime_from_now_en(chan, t, ints, lang)); 03632 } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */ 03633 return(ast_say_datetime_from_now_pt(chan, t, ints, lang)); 03634 } 03635 03636 /* Default to English */ 03637 return(ast_say_datetime_from_now_en(chan, t, ints, lang)); 03638 }

int ast_say_digit_str struct ast_channel chan,
char *  num,
char *  ints,
char *  lang
 

says digits of a string

Parameters:
chan channel to act upon
num string to speak
ints which dtmf to interrupt on
lang language to speak in Vocally says the digits of a given string Returns 0 on success, dtmf if interrupted, -1 on failure

Definition at line 34 of file say.c.

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

Referenced by ast_say_digits().

00035 { 00036 /* XXX Merge with full version? XXX */ 00037 char fn[256] = ""; 00038 int num = 0; 00039 int res = 0; 00040 while(fn2[num] && !res) { 00041 fn[0] = '\0'; 00042 switch (fn2[num]) { 00043 case ('*'): 00044 snprintf(fn, sizeof(fn), "digits/star"); 00045 break; 00046 case ('#'): 00047 snprintf(fn, sizeof(fn), "digits/pound"); 00048 break; 00049 default: 00050 if((fn2[num] >= '0') && (fn2[num] <= '9')){ /* Must be in {0-9} */ 00051 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00052 } 00053 } 00054 if(!ast_strlen_zero(fn)){ /* if length == 0, then skip this digit as it is invalid */ 00055 res = ast_streamfile(chan, fn, lang); 00056 if (!res) 00057 res = ast_waitstream(chan, ints); 00058 ast_stopstream(chan); 00059 } 00060 num++; 00061 } 00062 return res; 00063 }

int ast_say_digit_str_full struct ast_channel chan,
char *  fn2,
char *  ints,
char *  lang,
int  audiofd,
int  ctrlfd
 

Definition at line 237 of file say.c.

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

Referenced by ast_say_digits_full().

00238 { 00239 char fn[256] = ""; 00240 int num = 0; 00241 int res = 0; 00242 while(fn2[num] && !res) { 00243 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00244 res = ast_streamfile(chan, fn, lang); 00245 if (!res) 00246 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00247 ast_stopstream(chan); 00248 num++; 00249 } 00250 return res; 00251 }

int ast_say_digits struct ast_channel chan,
int  num,
char *  ints,
char *  lang
 

says digits

Parameters:
chan channel to act upon
num number to speak
ints which dtmf to interrupt on
lang language to speak Vocally says digits of a given number Returns 0 on success, dtmf if interrupted, -1 on failure

Definition at line 388 of file say.c.

References ast_say_digit_str().

00389 { 00390 /* XXX Should I be merged with say_digits_full XXX */ 00391 char fn2[256]; 00392 snprintf(fn2, sizeof(fn2), "%d", num); 00393 return ast_say_digit_str(chan, fn2, ints, lang); 00394 }

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

Definition at line 396 of file say.c.

References ast_say_digit_str_full().

00397 { 00398 char fn2[256]; 00399 snprintf(fn2, sizeof(fn2), "%d", num); 00400 return ast_say_digit_str_full(chan, fn2, ints, lang, audiofd, ctrlfd); 00401 }

int ast_say_number struct ast_channel chan,
int  num,
char *  ints,
char *  lang,
char *  options
 

says a number

Parameters:
chan channel to say them number on
num number to say on the channel
ints which dtmf to interrupt on
lang language to speak the number
options set to 'f' for female, 'm' for masculine (used in portuguese) Vocally says a number on a given channel Returns 0 on success, DTMF digit on interrupt, -1 on failure

Definition at line 525 of file say.c.

References ast_say_number_full().

00526 { 00527 return(ast_say_number_full(chan, num, ints, language, options, -1, -1)); 00528 }

int ast_say_number_full struct ast_channel chan,
int  num,
char *  ints,
char *  language,
char *  options,
int  audiofd,
int  ctrlfd
 

Definition at line 494 of file say.c.

Referenced by ast_say_number().

00495 { 00496 if (!strcasecmp(language,"en") ) { /* English syntax */ 00497 return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd)); 00498 } else if (!strcasecmp(language, "da") ) { /* Danish syntax */ 00499 return(ast_say_number_full_da(chan, num, ints, language, options, audiofd, ctrlfd)); 00500 } else if (!strcasecmp(language, "de") ) { /* German syntax */ 00501 return(ast_say_number_full_de(chan, num, ints, language, options, audiofd, ctrlfd)); 00502 } else if (!strcasecmp(language, "es") || !strcasecmp(language, "mx")) { /* Spanish syntax */ 00503 return(ast_say_number_full_es(chan, num, ints, language, options, audiofd, ctrlfd)); 00504 } else if (!strcasecmp(language, "fr") ) { /* French syntax */ 00505 return(ast_say_number_full_fr(chan, num, ints, language, options, audiofd, ctrlfd)); 00506 } else if (!strcasecmp(language, "it") ) { /* Italian syntax */ 00507 return(ast_say_number_full_it(chan, num, ints, language, audiofd, ctrlfd)); 00508 } else if (!strcasecmp(language, "nl") ) { /* Dutch syntax */ 00509 return(ast_say_number_full_nl(chan, num, ints, language, audiofd, ctrlfd)); 00510 } else if (!strcasecmp(language, "pl") ) { /* Polish syntax */ 00511 return(ast_say_number_full_pl(chan, num, ints, language, options, audiofd, ctrlfd)); 00512 } else if (!strcasecmp(language, "pt") ) { /* Portuguese syntax */ 00513 return(ast_say_number_full_pt(chan, num, ints, language, options, audiofd, ctrlfd)); 00514 } else if (!strcasecmp(language, "se") ) { /* Swedish syntax */ 00515 return(ast_say_number_full_se(chan, num, ints, language, options, audiofd, ctrlfd)); 00516 } else if (!strcasecmp(language, "tw")) { /* Taiwanese syntax */ 00517 return(ast_say_number_full_tw(chan, num, ints, language, audiofd, ctrlfd)); 00518 } 00519 00520 /* Default to english */ 00521 return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd)); 00522 }

int ast_say_phonetic_str struct ast_channel chan,
char *  fn2,
char *  ints,
char *  lang
 

Definition at line 135 of file say.c.

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

00136 { 00137 /* XXX Merge with full version? XXX */ 00138 char fn[256] = ""; 00139 char ltr; 00140 int num = 0; 00141 int res = 0; 00142 int temp; 00143 int play; 00144 char hex[3]; 00145 /* while(fn2[num] && !res) { */ 00146 while(fn2[num]) { 00147 play=1; 00148 switch (fn2[num]) { 00149 case ('*'): 00150 snprintf(fn, sizeof(fn), "digits/star"); 00151 break; 00152 case ('#'): 00153 snprintf(fn, sizeof(fn), "digits/pound"); 00154 break; 00155 case ('0'): 00156 case ('1'): 00157 case ('2'): 00158 case ('3'): 00159 case ('4'): 00160 case ('5'): 00161 case ('6'): 00162 case ('7'): 00163 case ('8'): 00164 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00165 break; 00166 case ('!'): 00167 strncpy(fn, "exclaimation-point", sizeof(fn)); 00168 break; 00169 case ('@'): 00170 strncpy(fn, "at", sizeof(fn)); 00171 break; 00172 case ('$'): 00173 strncpy(fn, "dollar", sizeof(fn)); 00174 break; 00175 case ('-'): 00176 strncpy(fn, "dash", sizeof(fn)); 00177 break; 00178 case ('.'): 00179 strncpy(fn, "dot", sizeof(fn)); 00180 break; 00181 case ('='): 00182 strncpy(fn, "equals", sizeof(fn)); 00183 break; 00184 case ('+'): 00185 strncpy(fn, "plus", sizeof(fn)); 00186 break; 00187 case ('/'): 00188 strncpy(fn, "slash", sizeof(fn)); 00189 break; 00190 case (' '): 00191 strncpy(fn, "space", sizeof(fn)); 00192 break; 00193 case ('%'): 00194 play=0; 00195 /* check if we have 2 chars after the % */ 00196 if (strlen(fn2) > num+2) 00197 { 00198 hex[0]=fn2[num+1]; 00199 hex[1]=fn2[num+2]; 00200 hex[2]='\0'; 00201 if (sscanf(hex,"%x", &temp)) 00202 { /* Hex to char convertion successfull */ 00203 fn2[num+2]=temp; 00204 num++; 00205 if (temp==37) 00206 { /* If it is a percent, play it now */ 00207 strncpy(fn, "percent", sizeof(fn)); 00208 num++; 00209 play=1; 00210 } 00211 /* check for invalid characters */ 00212 if ((temp<32) || (temp>126)) 00213 { 00214 num++; 00215 } 00216 } 00217 } 00218 else 00219 num++; 00220 break; 00221 default: /* '9' falls through to here, too */ 00222 ltr = tolower(fn2[num]); 00223 snprintf(fn, sizeof(fn), "phonetic/%c_p", ltr); 00224 } 00225 if (play) 00226 { 00227 res = ast_streamfile(chan, fn, lang); 00228 if (!res) 00229 res = ast_waitstream(chan, ints); 00230 ast_stopstream(chan); 00231 } 00232 num++; 00233 } 00234 return res; 00235 }

int ast_say_phonetic_str_full struct ast_channel chan,
char *  fn2,
char *  ints,
char *  lang,
int  audiofd,
int  ctrlfd
 

Definition at line 321 of file say.c.

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

00322 { 00323 char fn[256] = ""; 00324 char ltr; 00325 int num = 0; 00326 int res = 0; 00327 while(fn2[num] && !res) { 00328 switch (fn2[num]) { 00329 case ('*'): 00330 snprintf(fn, sizeof(fn), "digits/star"); 00331 break; 00332 case ('#'): 00333 snprintf(fn, sizeof(fn), "digits/pound"); 00334 break; 00335 case ('0'): 00336 case ('1'): 00337 case ('2'): 00338 case ('3'): 00339 case ('4'): 00340 case ('5'): 00341 case ('6'): 00342 case ('7'): 00343 case ('8'): 00344 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); 00345 break; 00346 case ('!'): 00347 strncpy(fn, "exclaimation-point", sizeof(fn)); 00348 break; 00349 case ('@'): 00350 strncpy(fn, "at", sizeof(fn)); 00351 break; 00352 case ('$'): 00353 strncpy(fn, "dollar", sizeof(fn)); 00354 break; 00355 case ('-'): 00356 strncpy(fn, "dash", sizeof(fn)); 00357 break; 00358 case ('.'): 00359 strncpy(fn, "dot", sizeof(fn)); 00360 break; 00361 case ('='): 00362 strncpy(fn, "equals", sizeof(fn)); 00363 break; 00364 case ('+'): 00365 strncpy(fn, "plus", sizeof(fn)); 00366 break; 00367 case ('/'): 00368 strncpy(fn, "slash", sizeof(fn)); 00369 break; 00370 case (' '): 00371 strncpy(fn, "space", sizeof(fn)); 00372 break; 00373 default: /* '9' falls here... */ 00374 ltr = fn2[num]; 00375 if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */ 00376 snprintf(fn, sizeof(fn), "phonetic/%c", ltr); 00377 } 00378 /* snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); */ 00379 res = ast_streamfile(chan, fn, lang); 00380 if (!res) 00381 res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); 00382 ast_stopstream(chan); 00383 num++; 00384 } 00385 return res; 00386 }

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

Definition at line 3254 of file say.c.

03255 { 03256 if (!strcasecmp(lang, "en") ) { /* English syntax */ 03257 return(ast_say_time_en(chan, t, ints, lang)); 03258 } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */ 03259 return(ast_say_time_nl(chan, t, ints, lang)); 03260 } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */ 03261 return(ast_say_time_pt(chan, t, ints, lang)); 03262 } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */ 03263 return(ast_say_time_tw(chan, t, ints, lang)); 03264 } 03265 03266 /* Default to English */ 03267 return(ast_say_time_en(chan, t, ints, lang)); 03268 }


Generated on Sat Jun 12 16:41:46 2004 for Asterisk by doxygen 1.3.7