Index: channels/Makefile =================================================================== --- channels/Makefile (revision 8513) +++ channels/Makefile (working copy) @@ -108,7 +108,7 @@ SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib endif CFLAGS+=-DIAX_TRUNKING - CHANNEL_LIBS+=chan_zap.so + #CHANNEL_LIBS+=chan_zap.so endif endif # WITHOUT_ZAPTEL Index: apps/app_say_number.c =================================================================== --- apps/app_say_number.c (revision 0) +++ apps/app_say_number.c (revision 0) @@ -0,0 +1,211 @@ +/* + * Asterisk -- A telephony toolkit for Linux. + * + * Play Digit in order and style of given Country + * + * Copyright (C) 2006, Crich + * + * Christian Richter cr@beronet.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License + */ + +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static char *tdesc = "Generic Number Saying Application"; + +static char *app = "Say_Number"; + +static char *synopsis = "Play Number"; + +static char *descrip = +" Say_Number(Number, Language): Plays the given Number to current channel, \n" +"in the given Language\n"; + + +STANDARD_LOCAL_USER; + +LOCAL_USER_DECL; + +static struct ast_config *cfg=NULL; + + +static int say(struct ast_channel *chan, char *lang, char *num) +{ + struct ast_variable *v=ast_variable_browse(cfg,lang); + + char *evaluated=calloc(256,sizeof(char)); + + pbx_builtin_setvar_helper(chan,"N",num); + + for (;v;v=v->next) { + if (ast_extension_match(v->name,num)) { + char *next; + + /*ast_log(LOG_NOTICE,"Patter:%s matches num %s we need to do: %s\n",v->name, num, v->value);*/ + + pbx_substitute_variables_helper(chan,ast_skip_blanks(v->value),evaluated,255); + for (next=strsep(&evaluated,","); + next; + next=strsep(&evaluated,",")) { + + if (!strncasecmp(next,"say",3)) { + /*recursion*/ + char *newpatt; + + newpatt=strsep(&next,"()"); + if (newpatt) + newpatt=strsep(&next,"()"); + + if (!newpatt) { + ast_log(LOG_WARNING,"Syntax error new Say in %s\n",v->value); + goto say_end; + } + + say(chan,lang,ast_skip_blanks(newpatt)); + + } else { + int r; + char playfile[10+strlen(next)]; + sprintf(playfile,"digits/%s",next); + + if (ast_fileexists(playfile,NULL,lang)<0) + r=ast_streamfile(chan,playfile,"en"); + else + r=ast_streamfile(chan,playfile,lang); + if (!r) { + r=ast_waitstream(chan, "" ); + } + ast_stopstream(chan); + } + } + } + } + +say_end: + free(evaluated); + return 0; +} + +static int say_number_exec(struct ast_channel *chan, void *data) +{ + int res=0; + struct localuser *u; + char *argv[2], *args; + char *number, *language; + int argc; + + LOCAL_USER_ADD(u); + + if (! (args=ast_strdupa(data))) { + ast_log(LOG_WARNING, "Say_Number requires saynumber.conf\n"); + LOCAL_USER_REMOVE(u); + return -1; + } + + argc=ast_app_separate_args(args,'|',argv,sizeof(argv)/sizeof(argv[0])); + if (argc <= 1 ) { + ast_log(LOG_WARNING, "Say_Number requires 1 Arg\n"); + LOCAL_USER_REMOVE(u); + return -1; + } + + number=argv[0]; + if (argc == 2) + language=argv[1]; + else + language=chan->language; + + if (!ast_category_exist(cfg,language)) { + ast_log(LOG_WARNING, "For the Language: %s, there is no definition\n", language); + res=-1; + goto end; + } + + if (*number == '-') { + char m[]="digits/minus"; + int r; + number++; + if (ast_fileexists(m,NULL,language)<0) + r=ast_streamfile(chan,m,"en"); + else + r=ast_streamfile(chan,m,language); + if (!r) { + r=ast_waitstream(chan, "" ); + } + ast_stopstream(chan); + } + res=say(chan, language, number); + +end: + LOCAL_USER_REMOVE(u); + return res; +} + + +static void say_reload(void) +{ + if (cfg) + ast_config_destroy(cfg); + + cfg=ast_config_load("saynumber.conf"); + + if (!cfg) { + ast_log(LOG_WARNING, "Say_Number requires saynumber.conf\n"); + } +} + + +int unload_module(void) +{ + if (cfg) + ast_config_destroy(cfg); + return ast_unregister_application(app); +} + +int load_module(void) +{ + say_reload(); + + return ast_register_application(app, say_number_exec, synopsis, descrip); +} + +int reload(void) +{ + say_reload(); + return 0; +} + +char *description(void) +{ + return tdesc; +} + +int usecount(void) +{ + int res; + STANDARD_USECOUNT(res); + return res; +} + +char *key() +{ + return ASTERISK_GPL_KEY; +} Index: apps/Makefile =================================================================== --- apps/Makefile (revision 8513) +++ apps/Makefile (working copy) @@ -25,7 +25,7 @@ app_stack.so app_system.so app_talkdetect.so app_test.so app_transfer.so \ app_userevent.so app_url.so app_verbose.so app_voicemail.so \ app_waitforring.so app_waitforsilence.so app_while.so app_zapateller.so \ - app_morsecode.so + app_morsecode.so app_say_number.so # # Obsolete things... Index: configs/saynumber.conf.sample =================================================================== --- configs/saynumber.conf.sample (revision 0) +++ configs/saynumber.conf.sample (revision 0) @@ -0,0 +1,22 @@ + +[de] +_X => ${N} +_XX => ${N:1}-and,${N:0:1}0 +_0X => ${N:1} +_XXX => ${N:0:1},hundred,Say(${N:1}) +_0XX => Say(${N:1}) +_XXXX => ${N:0:1},thousand,Say(${N:1}) +_0XXX => Say(${N:1}) +_XXXXX => Say(${N:0:2}),thousand,Say(${N:2}) +_0XXXX => Say(${N:1}) +_XXXXXX => Say(${N:0:3}),thousand,Say(${N:3}) +_0XXXXX => Say(${N:1}) +_XXXXXXX => Say(${N:0:1}),million,Say(${N:1}) + +[en] +_X => ${N} +_1X => ${N} +_XX => ${N:0:1}0,Say(${N:1}) +_XXX => ${N:0:1},hundred,Say(${N:1}) + +