Main Page | Alphabetical List | Data Structures | Directories | 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 <math.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>

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

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

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

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

Definition at line 254 of file say.c.

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

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

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

Definition at line 1824 of file say.c.

01825 {
01826    if (!strcasecmp(lang,"en") ) {   /* English syntax */
01827       return(ast_say_date_en(chan, t, ints, lang));
01828    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
01829       return(ast_say_date_nl(chan, t, ints, lang));
01830    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
01831       return(ast_say_date_pt(chan, t, ints, lang));
01832    }
01833 
01834    /* Default to English */
01835    return(ast_say_date_en(chan, t, ints, lang));
01836 }

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

Definition at line 1920 of file say.c.

01921 {
01922    if (!strcasecmp(lang, "en") ) {  /* English syntax */
01923       return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone));
01924    } else if (!strcasecmp(lang, "de") ) { /* German syntax */
01925       return(ast_say_date_with_format_de(chan, time, ints, lang, format, timezone));
01926    } else if (!strcasecmp(lang, "es") || !strcasecmp(lang, "mx")) {  /* Spanish syntax */
01927       return(ast_say_date_with_format_es(chan, time, ints, lang, format, timezone));
01928    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
01929       return(ast_say_date_with_format_nl(chan, time, ints, lang, format, timezone));
01930    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
01931       return(ast_say_date_with_format_pt(chan, time, ints, lang, format, timezone));
01932    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
01933       return(ast_say_date_with_format_tw(chan, time, ints, lang, format, timezone));
01934    }
01935 
01936    /* Default to English */
01937    return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone));
01938 }

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

Definition at line 3522 of file say.c.

03523 {
03524    if (!strcasecmp(lang, "en") ) {  /* English syntax */
03525       return(ast_say_datetime_en(chan, t, ints, lang));
03526    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
03527       return(ast_say_datetime_nl(chan, t, ints, lang));
03528    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
03529       return(ast_say_datetime_pt(chan, t, ints, lang));
03530    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
03531       return(ast_say_datetime_tw(chan, t, ints, lang));
03532    }
03533 
03534    /* Default to English */
03535    return(ast_say_datetime_en(chan, t, ints, lang));
03536 }

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

Definition at line 3744 of file say.c.

03745 {
03746    if (!strcasecmp(lang, "en") ) {  /* English syntax */
03747       return(ast_say_datetime_from_now_en(chan, t, ints, lang));
03748    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
03749       return(ast_say_datetime_from_now_pt(chan, t, ints, lang));
03750    }
03751 
03752    /* Default to English */
03753    return(ast_say_datetime_from_now_en(chan, t, ints, lang));
03754 }

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

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

Referenced by ast_say_digits().

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

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

Definition at line 238 of file say.c.

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

Referenced by ast_say_digits_full().

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

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

References ast_say_digit_str().

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

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

Definition at line 397 of file say.c.

References ast_say_digit_str_full().

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

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

References ast_say_number_full().

00530 {
00531    return(ast_say_number_full(chan, num, ints, language, options, -1, -1));
00532 }

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

Definition at line 496 of file say.c.

Referenced by ast_say_number().

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

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

Definition at line 136 of file say.c.

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

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

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

Definition at line 322 of file say.c.

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

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

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

Definition at line 3370 of file say.c.

03371 {
03372    if (!strcasecmp(lang, "en") ) {  /* English syntax */
03373       return(ast_say_time_en(chan, t, ints, lang));
03374    } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
03375       return(ast_say_time_nl(chan, t, ints, lang));
03376    } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
03377       return(ast_say_time_pt(chan, t, ints, lang));
03378    } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
03379       return(ast_say_time_tw(chan, t, ints, lang));
03380    }
03381 
03382    /* Default to English */
03383    return(ast_say_time_en(chan, t, ints, lang));
03384 }


Generated on Thu Nov 29 22:50:28 2007 for Asterisk by  doxygen 1.4.2