| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2005-09-15 15:44:26 +00:00
										 |  |  |  * Asterisk -- An open source telephony toolkit. | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2002, Christos Ricudis | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2004-03-15 16:51:58 +00:00
										 |  |  |  * Christos Ricudis <ricudis@itc.auth.gr> | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-09-15 15:44:26 +00:00
										 |  |  |  * See http://www.asterisk.org for more information about
 | 
					
						
							|  |  |  |  * the Asterisk project. Please do not directly contact | 
					
						
							|  |  |  |  * any of the maintainers of this project for assistance; | 
					
						
							|  |  |  |  * the project provides a web site, mailing lists and IRC | 
					
						
							|  |  |  |  * channels for your use. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |  * This program is free software, distributed under the terms of | 
					
						
							| 
									
										
										
										
											2005-09-15 15:44:26 +00:00
										 |  |  |  * the GNU General Public License Version 2. See the LICENSE file | 
					
						
							|  |  |  |  * at the top of the source tree. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-24 20:12:06 +00:00
										 |  |  | /*! \file
 | 
					
						
							| 
									
										
										
										
											2005-09-15 15:44:26 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-10-24 20:12:06 +00:00
										 |  |  |  * \brief Connect to festival | 
					
						
							| 
									
										
										
										
											2005-12-30 21:18:06 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * \author Christos Ricudis <ricudis@itc.auth.gr> | 
					
						
							| 
									
										
										
										
											2005-09-15 15:44:26 +00:00
										 |  |  |  *  | 
					
						
							| 
									
										
										
										
											2005-11-06 15:09:47 +00:00
										 |  |  |  * \ingroup applications | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-07 18:54:56 +00:00
										 |  |  | #include "asterisk.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ASTERISK_FILE_VERSION(__FILE__, "$Revision$") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-23 19:09:13 +00:00
										 |  |  | #include <sys/types.h>
 | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <unistd.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <sys/types.h>
 | 
					
						
							|  |  |  | #include <sys/socket.h>
 | 
					
						
							|  |  |  | #include <netdb.h>
 | 
					
						
							|  |  |  | #include <netinet/in.h>
 | 
					
						
							|  |  |  | #include <arpa/inet.h>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <signal.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <unistd.h>
 | 
					
						
							|  |  |  | #include <fcntl.h>
 | 
					
						
							|  |  |  | #include <ctype.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-06-06 22:39:32 +00:00
										 |  |  | #include "asterisk/file.h"
 | 
					
						
							|  |  |  | #include "asterisk/logger.h"
 | 
					
						
							|  |  |  | #include "asterisk/channel.h"
 | 
					
						
							|  |  |  | #include "asterisk/pbx.h"
 | 
					
						
							|  |  |  | #include "asterisk/module.h"
 | 
					
						
							|  |  |  | #include "asterisk/md5.h"
 | 
					
						
							|  |  |  | #include "asterisk/config.h"
 | 
					
						
							|  |  |  | #include "asterisk/utils.h"
 | 
					
						
							|  |  |  | #include "asterisk/lock.h"
 | 
					
						
							| 
									
										
										
										
											2006-05-01 21:48:30 +00:00
										 |  |  | #include "asterisk/options.h"
 | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define FESTIVAL_CONFIG "festival.conf"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char *app = "Festival"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char *synopsis = "Say text to the user"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char *descrip =  | 
					
						
							| 
									
										
										
										
											2003-06-27 23:02:52 +00:00
										 |  |  | "  Festival(text[|intkeys]):  Connect to Festival, send the argument, get back the waveform," | 
					
						
							|  |  |  | "play it to the user, allowing any given interrupt keys to immediately terminate and return\n" | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | "the value, or 'any' to allow any number back (useful in dialplan)\n"; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static char *socket_receive_file_to_buff(int fd,int *size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /* Receive file (probably a waveform file) from socket using   */ | 
					
						
							|  |  |  |     /* Festival key stuff technique, but long winded I know, sorry */ | 
					
						
							|  |  |  |     /* but will receive any file without closeing the stream or    */ | 
					
						
							|  |  |  |     /* using OOB data                                              */ | 
					
						
							|  |  |  |     static char *file_stuff_key = "ft_StUfF_key"; /* must == Festival's key */ | 
					
						
							|  |  |  |     char *buff; | 
					
						
							|  |  |  |     int bufflen; | 
					
						
							|  |  |  |     int n,k,i; | 
					
						
							|  |  |  |     char c; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bufflen = 1024; | 
					
						
							| 
									
										
										
										
											2006-01-13 03:34:31 +00:00
										 |  |  |     if (!(buff = ast_malloc(bufflen))) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         /* TODO: Handle memory allocation failure */ | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     *size=0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (k=0; file_stuff_key[k] != '\0';) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         n = read(fd,&c,1); | 
					
						
							|  |  |  |         if (n==0) break;  /* hit stream eof before end of file */ | 
					
						
							|  |  |  |         if ((*size)+k+1 >= bufflen) | 
					
						
							|  |  |  |         {   /* +1 so you can add a NULL if you want */ | 
					
						
							|  |  |  |             bufflen += bufflen/4; | 
					
						
							| 
									
										
										
										
											2006-01-13 03:34:31 +00:00
										 |  |  |             if (!(buff = ast_realloc(buff, bufflen))) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 /* TODO: Handle memory allocation failure */ | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         if (file_stuff_key[k] == c) | 
					
						
							|  |  |  |             k++; | 
					
						
							|  |  |  |         else if ((c == 'X') && (file_stuff_key[k+1] == '\0')) | 
					
						
							|  |  |  |         {   /* It looked like the key but wasn't */ | 
					
						
							|  |  |  |             for (i=0; i < k; i++,(*size)++) | 
					
						
							|  |  |  |                 buff[*size] = file_stuff_key[i]; | 
					
						
							|  |  |  |             k=0; | 
					
						
							|  |  |  |             /* omit the stuffed 'X' */ | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             for (i=0; i < k; i++,(*size)++) | 
					
						
							|  |  |  |                 buff[*size] = file_stuff_key[i]; | 
					
						
							|  |  |  |             k=0; | 
					
						
							|  |  |  |             buff[*size] = c; | 
					
						
							|  |  |  |             (*size)++; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return buff; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int send_waveform_to_fd(char *waveform, int length, int fd) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int res; | 
					
						
							|  |  |  |         int x; | 
					
						
							| 
									
										
										
										
											2004-01-11 08:32:50 +00:00
										 |  |  | #ifdef __PPC__ 
 | 
					
						
							|  |  |  | 	char c; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |         res = fork(); | 
					
						
							|  |  |  |         if (res < 0) | 
					
						
							|  |  |  |                 ast_log(LOG_WARNING, "Fork failed\n"); | 
					
						
							|  |  |  |         if (res) | 
					
						
							|  |  |  |                 return res; | 
					
						
							|  |  |  |         for (x=0;x<256;x++) { | 
					
						
							|  |  |  |                 if (x != fd) | 
					
						
							|  |  |  |                         close(x); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2006-05-01 21:48:30 +00:00
										 |  |  | 	if (ast_opt_high_priority) | 
					
						
							|  |  |  | 		ast_set_priority(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-19 21:13:41 +00:00
										 |  |  | /*IAS */ | 
					
						
							| 
									
										
										
										
											2004-01-11 08:32:50 +00:00
										 |  |  | #ifdef __PPC__  
 | 
					
						
							|  |  |  | 	for( x=0; x<length; x+=2) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		c = *(waveform+x+1); | 
					
						
							|  |  |  | 		*(waveform+x+1)=*(waveform+x); | 
					
						
							|  |  |  | 		*(waveform+x)=c; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	write(fd,waveform,length); | 
					
						
							|  |  |  | 	close(fd); | 
					
						
							|  |  |  | 	exit(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length, char *intkeys) { | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	int res=0; | 
					
						
							|  |  |  | 	int fds[2]; | 
					
						
							|  |  |  | 	int ms = -1; | 
					
						
							|  |  |  | 	int pid = -1; | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 	int needed = 0; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	int owriteformat; | 
					
						
							|  |  |  | 	struct ast_frame *f; | 
					
						
							|  |  |  | 	struct myframe { | 
					
						
							|  |  |  | 		struct ast_frame f; | 
					
						
							|  |  |  | 		char offset[AST_FRIENDLY_OFFSET]; | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 		char frdata[2048]; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	} myf; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  |         if (pipe(fds)) { | 
					
						
							|  |  |  |                  ast_log(LOG_WARNING, "Unable to create pipe\n"); | 
					
						
							|  |  |  |         	return -1; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 	                                                 | 
					
						
							| 
									
										
										
										
											2004-04-16 02:51:47 +00:00
										 |  |  | 	/* Answer if it's not already going */ | 
					
						
							|  |  |  | 	if (chan->_state != AST_STATE_UP) | 
					
						
							|  |  |  | 		ast_answer(chan); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	ast_stopstream(chan); | 
					
						
							| 
									
										
										
										
											2006-01-17 20:16:18 +00:00
										 |  |  | 	ast_indicate(chan, -1); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	owriteformat = chan->writeformat; | 
					
						
							| 
									
										
										
										
											2004-04-06 22:17:32 +00:00
										 |  |  | 	res = ast_set_write_format(chan, AST_FORMAT_SLINEAR); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	if (res < 0) { | 
					
						
							|  |  |  | 		ast_log(LOG_WARNING, "Unable to set write format to signed linear\n"); | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	res=send_waveform_to_fd(waveform,length,fds[1]); | 
					
						
							|  |  |  | 	if (res >= 0) { | 
					
						
							|  |  |  | 		pid = res; | 
					
						
							|  |  |  | 		/* Order is important -- there's almost always going to be mp3...  we want to prioritize the
 | 
					
						
							|  |  |  | 		   user */ | 
					
						
							|  |  |  | 		for (;;) { | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 			ms = 1000; | 
					
						
							|  |  |  | 			res = ast_waitfor(chan, ms); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 			if (res < 1) { | 
					
						
							|  |  |  | 				res = -1; | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 			f = ast_read(chan); | 
					
						
							|  |  |  | 			if (!f) { | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 				ast_log(LOG_WARNING, "Null frame == hangup() detected\n"); | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 				res = -1; | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (f->frametype == AST_FRAME_DTMF) { | 
					
						
							|  |  |  | 				ast_log(LOG_DEBUG, "User pressed a key\n"); | 
					
						
							| 
									
										
										
										
											2003-08-15 22:45:26 +00:00
										 |  |  | 				if (intkeys && strchr(intkeys, f->subclass)) { | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | 					res = f->subclass; | 
					
						
							|  |  |  | 					ast_frfree(f); | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			if (f->frametype == AST_FRAME_VOICE) { | 
					
						
							|  |  |  | 				/* Treat as a generator */ | 
					
						
							| 
									
										
										
										
											2003-08-14 16:01:25 +00:00
										 |  |  | 				needed = f->samples * 2; | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 				if (needed > sizeof(myf.frdata)) { | 
					
						
							|  |  |  | 					ast_log(LOG_WARNING, "Only able to deliver %d of %d requested samples\n", | 
					
						
							| 
									
										
										
										
											2004-06-13 21:25:10 +00:00
										 |  |  | 						(int)sizeof(myf.frdata) / 2, needed/2); | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 					needed = sizeof(myf.frdata); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 				res = read(fds[0], myf.frdata, needed); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 				if (res > 0) { | 
					
						
							|  |  |  | 					myf.f.frametype = AST_FRAME_VOICE; | 
					
						
							|  |  |  | 					myf.f.subclass = AST_FORMAT_SLINEAR; | 
					
						
							|  |  |  | 					myf.f.datalen = res; | 
					
						
							| 
									
										
										
										
											2002-11-29 02:14:13 +00:00
										 |  |  | 					myf.f.samples = res / 2; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 					myf.f.mallocd = 0; | 
					
						
							|  |  |  | 					myf.f.offset = AST_FRIENDLY_OFFSET; | 
					
						
							|  |  |  | 					myf.f.src = __PRETTY_FUNCTION__; | 
					
						
							|  |  |  | 					myf.f.data = myf.frdata; | 
					
						
							|  |  |  | 					if (ast_write(chan, &myf.f) < 0) { | 
					
						
							|  |  |  | 						res = -1; | 
					
						
							| 
									
										
										
										
											2006-06-11 20:46:05 +00:00
										 |  |  | 						ast_frfree(f); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2004-12-19 21:13:41 +00:00
										 |  |  | 					if (res < needed) { /* last frame */ | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 						ast_log(LOG_DEBUG, "Last frame\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 						res=0; | 
					
						
							| 
									
										
										
										
											2006-06-11 20:46:05 +00:00
										 |  |  | 						ast_frfree(f); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 					ast_log(LOG_DEBUG, "No more waveform\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 					res = 0; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2003-08-14 15:58:55 +00:00
										 |  |  | 			ast_frfree(f); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	close(fds[0]); | 
					
						
							|  |  |  | 	close(fds[1]); | 
					
						
							| 
									
										
										
										
											2004-12-19 21:13:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*	if (pid > -1) */ | 
					
						
							|  |  |  | /*		kill(pid, SIGKILL); */ | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	if (!res && owriteformat) | 
					
						
							| 
									
										
										
										
											2004-04-06 22:17:32 +00:00
										 |  |  | 		ast_set_write_format(chan, owriteformat); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	return res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define MAXLEN 180
 | 
					
						
							|  |  |  | #define MAXFESTLEN 2048
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | static int festival_exec(struct ast_channel *chan, void *vdata) | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int usecache; | 
					
						
							|  |  |  | 	int res=0; | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	struct ast_module_user *u; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |  	struct sockaddr_in serv_addr; | 
					
						
							|  |  |  | 	struct hostent *serverhost; | 
					
						
							| 
									
										
										
										
											2004-04-22 00:20:34 +00:00
										 |  |  | 	struct ast_hostent ahp; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	int fd; | 
					
						
							|  |  |  | 	FILE *fs; | 
					
						
							|  |  |  | 	char *host; | 
					
						
							|  |  |  | 	char *cachedir; | 
					
						
							|  |  |  | 	char *temp; | 
					
						
							|  |  |  | 	char *festivalcommand; | 
					
						
							|  |  |  | 	int port=1314; | 
					
						
							|  |  |  | 	int n; | 
					
						
							|  |  |  | 	char ack[4]; | 
					
						
							|  |  |  | 	char *waveform; | 
					
						
							|  |  |  | 	int filesize; | 
					
						
							|  |  |  | 	int wave; | 
					
						
							|  |  |  | 	char bigstring[MAXFESTLEN]; | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 	struct MD5Context md5ctx; | 
					
						
							|  |  |  | 	unsigned char MD5Res[16]; | 
					
						
							| 
									
										
										
										
											2004-07-14 07:22:30 +00:00
										 |  |  | 	char MD5Hex[33] = ""; | 
					
						
							|  |  |  | 	char koko[4] = ""; | 
					
						
							|  |  |  | 	char cachefile[MAXFESTLEN]=""; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	int readcache=0; | 
					
						
							|  |  |  | 	int writecache=0; | 
					
						
							|  |  |  | 	int strln; | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | 	int fdesc = -1; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	char buffer[16384]; | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | 	int seekpos = 0;	 | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	char *data;	 | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | 	char *intstr; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	struct ast_config *cfg; | 
					
						
							| 
									
										
										
										
											2006-05-09 05:30:05 +00:00
										 |  |  | 	char *newfestivalcommand; | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-26 19:48:14 +00:00
										 |  |  | 	if (ast_strlen_zero(vdata)) { | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 		ast_log(LOG_WARNING, "festival requires an argument (text)\n"); | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	u = ast_module_user_add(chan); | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-01-25 06:10:20 +00:00
										 |  |  | 	cfg = ast_config_load(FESTIVAL_CONFIG); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	if (!cfg) { | 
					
						
							|  |  |  | 		ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG); | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 		ast_module_user_remove(u); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!(host = ast_variable_retrieve(cfg, "general", "host"))) { | 
					
						
							|  |  |  | 		host = "localhost"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!(temp = ast_variable_retrieve(cfg, "general", "port"))) { | 
					
						
							|  |  |  | 		port = 1314; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		port = atoi(temp); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!(temp = ast_variable_retrieve(cfg, "general", "usecache"))) { | 
					
						
							|  |  |  | 		usecache=0; | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2003-06-27 23:02:52 +00:00
										 |  |  | 		usecache = ast_true(temp); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (!(cachedir = ast_variable_retrieve(cfg, "general", "cachedir"))) { | 
					
						
							|  |  |  | 		cachedir = "/tmp/"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) { | 
					
						
							|  |  |  | 		festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n"; | 
					
						
							| 
									
										
										
										
											2006-05-09 05:30:05 +00:00
										 |  |  | 	} else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */ | 
					
						
							|  |  |  | 		int i, j; | 
					
						
							|  |  |  | 		newfestivalcommand = alloca(strlen(festivalcommand) + 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (i = 0, j = 0; i < strlen(festivalcommand); i++) { | 
					
						
							|  |  |  | 			if (festivalcommand[i] == '\\' && festivalcommand[i + 1] == 'n') { | 
					
						
							|  |  |  | 				newfestivalcommand[j++] = '\n'; | 
					
						
							|  |  |  | 				i++; | 
					
						
							|  |  |  | 			} else if (festivalcommand[i] == '\\') { | 
					
						
							|  |  |  | 				newfestivalcommand[j++] = festivalcommand[i + 1]; | 
					
						
							|  |  |  | 				i++; | 
					
						
							|  |  |  | 			} else | 
					
						
							|  |  |  | 				newfestivalcommand[j++] = festivalcommand[i]; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		newfestivalcommand[j] = '\0'; | 
					
						
							|  |  |  | 		festivalcommand = newfestivalcommand; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2006-05-10 13:22:15 +00:00
										 |  |  | 	data = ast_strdupa(vdata); | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	intstr = strchr(data, '|'); | 
					
						
							|  |  |  | 	if (intstr) {	 | 
					
						
							| 
									
										
										
										
											2003-08-15 04:38:39 +00:00
										 |  |  | 		*intstr = '\0'; | 
					
						
							|  |  |  | 		intstr++; | 
					
						
							|  |  |  | 		if (!strcasecmp(intstr, "any")) | 
					
						
							|  |  |  | 			intstr = AST_DIGIT_ANY; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 	ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	/* Connect to local festival server */ | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  |     	fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     	if (fd < 0) { | 
					
						
							|  |  |  | 		ast_log(LOG_WARNING,"festival_client: can't get socket\n"); | 
					
						
							| 
									
										
										
										
											2005-01-25 06:10:20 +00:00
										 |  |  | 		ast_config_destroy(cfg); | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 		ast_module_user_remove(u); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |         	return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  |         memset(&serv_addr, 0, sizeof(serv_addr)); | 
					
						
							|  |  |  |         if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) { | 
					
						
							|  |  |  | 	        /* its a name rather than an ipnum */ | 
					
						
							| 
									
										
										
										
											2004-04-22 00:20:34 +00:00
										 |  |  | 	        serverhost = ast_gethostbyname(host, &ahp); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	        if (serverhost == (struct hostent *)0) { | 
					
						
							|  |  |  |         	    	ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n"); | 
					
						
							| 
									
										
										
										
											2005-01-25 06:10:20 +00:00
										 |  |  | 			ast_config_destroy(cfg); | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 			ast_module_user_remove(u); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	            	return -1; | 
					
						
							|  |  |  |         	} | 
					
						
							|  |  |  | 	        memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length); | 
					
						
							|  |  |  |     	} | 
					
						
							|  |  |  | 	serv_addr.sin_family = AF_INET; | 
					
						
							|  |  |  | 	serv_addr.sin_port = htons(port); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) { | 
					
						
							|  |  |  | 		ast_log(LOG_WARNING,"festival_client: connect to server failed\n"); | 
					
						
							| 
									
										
										
										
											2005-01-25 06:10:20 +00:00
										 |  |  | 		ast_config_destroy(cfg); | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 		ast_module_user_remove(u); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |         	return -1; | 
					
						
							|  |  |  |     	} | 
					
						
							|  |  |  |     	 | 
					
						
							|  |  |  |     	/* Compute MD5 sum of string */ | 
					
						
							|  |  |  |     	MD5Init(&md5ctx); | 
					
						
							|  |  |  |     	MD5Update(&md5ctx,(unsigned char const *)data,strlen(data)); | 
					
						
							|  |  |  |     	MD5Final(MD5Res,&md5ctx); | 
					
						
							| 
									
										
										
										
											2004-07-14 07:22:30 +00:00
										 |  |  | 		MD5Hex[0] = '\0'; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     	 | 
					
						
							|  |  |  |     	/* Convert to HEX and look if there is any matching file in the cache 
 | 
					
						
							|  |  |  |     		directory */ | 
					
						
							|  |  |  |     	for (i=0;i<16;i++) { | 
					
						
							| 
									
										
										
										
											2004-07-14 07:22:30 +00:00
										 |  |  |     		snprintf(koko, sizeof(koko), "%X",MD5Res[i]); | 
					
						
							|  |  |  |     		strncat(MD5Hex, koko, sizeof(MD5Hex) - strlen(MD5Hex) - 1); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     	} | 
					
						
							|  |  |  |     	readcache=0; | 
					
						
							|  |  |  |     	writecache=0; | 
					
						
							| 
									
										
										
										
											2003-12-30 10:07:55 +00:00
										 |  |  |     	if (strlen(cachedir)+strlen(MD5Hex)+1<=MAXFESTLEN && (usecache==-1)) { | 
					
						
							| 
									
										
										
										
											2004-07-14 07:22:30 +00:00
										 |  |  |     		snprintf(cachefile, sizeof(cachefile), "%s/%s", cachedir, MD5Hex); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     		fdesc=open(cachefile,O_RDWR); | 
					
						
							|  |  |  |     		if (fdesc==-1) { | 
					
						
							| 
									
										
										
										
											2004-08-31 14:59:58 +00:00
										 |  |  |     			fdesc=open(cachefile,O_CREAT|O_RDWR,0777); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     			if (fdesc!=-1) { | 
					
						
							|  |  |  |     				writecache=1; | 
					
						
							|  |  |  |     				strln=strlen((char *)data); | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  |     				ast_log(LOG_DEBUG,"line length : %d\n",strln); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     				write(fdesc,&strln,sizeof(int)); | 
					
						
							|  |  |  |     				write(fdesc,data,strln); | 
					
						
							|  |  |  | 				seekpos=lseek(fdesc,0,SEEK_CUR); | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 				ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     			} | 
					
						
							|  |  |  |     		} else { | 
					
						
							|  |  |  |     			read(fdesc,&strln,sizeof(int)); | 
					
						
							| 
									
										
										
										
											2004-06-13 21:25:10 +00:00
										 |  |  |     			ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data)); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     			if (strlen((char *)data)==strln) { | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  |     				ast_log(LOG_DEBUG,"Size OK\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     				read(fdesc,&bigstring,strln); | 
					
						
							| 
									
										
										
										
											2004-03-24 22:50:43 +00:00
										 |  |  | 	    			bigstring[strln] = 0; | 
					
						
							|  |  |  | 				if (strcmp(bigstring,data)==0) {  | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	    				readcache=1; | 
					
						
							|  |  |  | 	    			} else { | 
					
						
							|  |  |  | 	    				ast_log(LOG_WARNING,"Strings do not match\n"); | 
					
						
							|  |  |  | 	    			} | 
					
						
							|  |  |  | 	    		} else { | 
					
						
							|  |  |  | 	    			ast_log(LOG_WARNING,"Size mismatch\n"); | 
					
						
							|  |  |  | 	    		} | 
					
						
							|  |  |  | 	    	} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  |     			 | 
					
						
							|  |  |  | 	if (readcache==1) { | 
					
						
							|  |  |  | 		close(fd); | 
					
						
							|  |  |  | 		fd=fdesc; | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 		ast_log(LOG_DEBUG,"Reading from cache...\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 		ast_log(LOG_DEBUG,"Passing text to festival...\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  |     		fs=fdopen(dup(fd),"wb"); | 
					
						
							|  |  |  | 		fprintf(fs,festivalcommand,(char *)data); | 
					
						
							|  |  |  | 		fflush(fs); | 
					
						
							|  |  |  | 		fclose(fs); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* Write to cache and then pass it down */ | 
					
						
							|  |  |  | 	if (writecache==1) { | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 		ast_log(LOG_DEBUG,"Writing result to cache...\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 		while ((strln=read(fd,buffer,16384))!=0) { | 
					
						
							|  |  |  | 			write(fdesc,buffer,strln); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		close(fd); | 
					
						
							|  |  |  | 		close(fdesc); | 
					
						
							|  |  |  | 		fd=open(cachefile,O_RDWR); | 
					
						
							|  |  |  | 		lseek(fd,seekpos,SEEK_SET); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 	ast_log(LOG_DEBUG,"Passing data to channel...\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* Read back info from server */ | 
					
						
							|  |  |  | 	/* This assumes only one waveform will come back, also LP is unlikely */ | 
					
						
							|  |  |  | 	wave = 0; | 
					
						
							|  |  |  | 	do { | 
					
						
							| 
									
										
											  
											
												Merged revisions 7265-7266,7268-7275 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r7265 | oej | 2005-12-01 17:18:14 -0600 (Thu, 01 Dec 2005) | 2 lines
Changing bug report address to the Asterisk issue tracker
........
r7266 | kpfleming | 2005-12-01 17:18:29 -0600 (Thu, 01 Dec 2005) | 3 lines
Makefile 'update' target now supports updating from Subversion repositories (issue #5875)
remove support for 'patches' subdirectory, it's no longer useful
........
r7268 | kpfleming | 2005-12-01 17:34:58 -0600 (Thu, 01 Dec 2005) | 2 lines
ensure channel's scheduling context is freed (issue #5788)
........
r7269 | kpfleming | 2005-12-01 17:49:44 -0600 (Thu, 01 Dec 2005) | 2 lines
don't block waiting for the Festival server forever when it goes away (issue #5882)
........
r7270 | kpfleming | 2005-12-01 18:26:12 -0600 (Thu, 01 Dec 2005) | 2 lines
allow variables to exist on both 'halves' of the Local channel (issue #5810)
........
r7271 | kpfleming | 2005-12-01 18:28:48 -0600 (Thu, 01 Dec 2005) | 2 lines
protect agent_bridgedchannel() from segfaulting when there is no bridged channel (issue #5879)
........
r7272 | kpfleming | 2005-12-01 18:39:00 -0600 (Thu, 01 Dec 2005) | 3 lines
properly handle password changes when mailbox is last line of config file and not followed by a newline (issue #5870)
reformat password changing code to conform to coding guidelines (issue #5870)
........
r7273 | kpfleming | 2005-12-01 18:42:40 -0600 (Thu, 01 Dec 2005) | 2 lines
allow previous context-searching behavior to be used if desired (issue #5899)
........
r7274 | kpfleming | 2005-12-01 18:51:15 -0600 (Thu, 01 Dec 2005) | 2 lines
inherit channel variables into channels created by Page() application (issue #5888)
........
r7275 | oej | 2005-12-01 18:52:13 -0600 (Thu, 01 Dec 2005) | 2 lines
Bug #5907. Improve SIP INFO DTMF debugging output. (1.2 & Trunk)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7276 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2005-12-02 01:01:11 +00:00
										 |  |  |                int read_data; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 		for (n=0; n < 3; ) | 
					
						
							| 
									
										
											  
											
												Merged revisions 7265-7266,7268-7275 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r7265 | oej | 2005-12-01 17:18:14 -0600 (Thu, 01 Dec 2005) | 2 lines
Changing bug report address to the Asterisk issue tracker
........
r7266 | kpfleming | 2005-12-01 17:18:29 -0600 (Thu, 01 Dec 2005) | 3 lines
Makefile 'update' target now supports updating from Subversion repositories (issue #5875)
remove support for 'patches' subdirectory, it's no longer useful
........
r7268 | kpfleming | 2005-12-01 17:34:58 -0600 (Thu, 01 Dec 2005) | 2 lines
ensure channel's scheduling context is freed (issue #5788)
........
r7269 | kpfleming | 2005-12-01 17:49:44 -0600 (Thu, 01 Dec 2005) | 2 lines
don't block waiting for the Festival server forever when it goes away (issue #5882)
........
r7270 | kpfleming | 2005-12-01 18:26:12 -0600 (Thu, 01 Dec 2005) | 2 lines
allow variables to exist on both 'halves' of the Local channel (issue #5810)
........
r7271 | kpfleming | 2005-12-01 18:28:48 -0600 (Thu, 01 Dec 2005) | 2 lines
protect agent_bridgedchannel() from segfaulting when there is no bridged channel (issue #5879)
........
r7272 | kpfleming | 2005-12-01 18:39:00 -0600 (Thu, 01 Dec 2005) | 3 lines
properly handle password changes when mailbox is last line of config file and not followed by a newline (issue #5870)
reformat password changing code to conform to coding guidelines (issue #5870)
........
r7273 | kpfleming | 2005-12-01 18:42:40 -0600 (Thu, 01 Dec 2005) | 2 lines
allow previous context-searching behavior to be used if desired (issue #5899)
........
r7274 | kpfleming | 2005-12-01 18:51:15 -0600 (Thu, 01 Dec 2005) | 2 lines
inherit channel variables into channels created by Page() application (issue #5888)
........
r7275 | oej | 2005-12-01 18:52:13 -0600 (Thu, 01 Dec 2005) | 2 lines
Bug #5907. Improve SIP INFO DTMF debugging output. (1.2 & Trunk)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7276 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2005-12-02 01:01:11 +00:00
										 |  |  |                { | 
					
						
							|  |  |  |                        read_data = read(fd,ack+n,3-n); | 
					
						
							|  |  |  |                        /* this avoids falling in infinite loop
 | 
					
						
							|  |  |  |                         * in case that festival server goes down | 
					
						
							|  |  |  |                         * */ | 
					
						
							|  |  |  |                        if ( read_data == -1 ) | 
					
						
							|  |  |  |                        { | 
					
						
							|  |  |  |                                ast_log(LOG_WARNING,"Unable to read from cache/festival fd"); | 
					
						
							| 
									
										
										
										
											2006-06-13 04:21:10 +00:00
										 |  |  | 			       close(fd); | 
					
						
							|  |  |  | 			       ast_config_destroy(cfg); | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 			       ast_module_user_remove(u); | 
					
						
							| 
									
										
											  
											
												Merged revisions 7265-7266,7268-7275 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r7265 | oej | 2005-12-01 17:18:14 -0600 (Thu, 01 Dec 2005) | 2 lines
Changing bug report address to the Asterisk issue tracker
........
r7266 | kpfleming | 2005-12-01 17:18:29 -0600 (Thu, 01 Dec 2005) | 3 lines
Makefile 'update' target now supports updating from Subversion repositories (issue #5875)
remove support for 'patches' subdirectory, it's no longer useful
........
r7268 | kpfleming | 2005-12-01 17:34:58 -0600 (Thu, 01 Dec 2005) | 2 lines
ensure channel's scheduling context is freed (issue #5788)
........
r7269 | kpfleming | 2005-12-01 17:49:44 -0600 (Thu, 01 Dec 2005) | 2 lines
don't block waiting for the Festival server forever when it goes away (issue #5882)
........
r7270 | kpfleming | 2005-12-01 18:26:12 -0600 (Thu, 01 Dec 2005) | 2 lines
allow variables to exist on both 'halves' of the Local channel (issue #5810)
........
r7271 | kpfleming | 2005-12-01 18:28:48 -0600 (Thu, 01 Dec 2005) | 2 lines
protect agent_bridgedchannel() from segfaulting when there is no bridged channel (issue #5879)
........
r7272 | kpfleming | 2005-12-01 18:39:00 -0600 (Thu, 01 Dec 2005) | 3 lines
properly handle password changes when mailbox is last line of config file and not followed by a newline (issue #5870)
reformat password changing code to conform to coding guidelines (issue #5870)
........
r7273 | kpfleming | 2005-12-01 18:42:40 -0600 (Thu, 01 Dec 2005) | 2 lines
allow previous context-searching behavior to be used if desired (issue #5899)
........
r7274 | kpfleming | 2005-12-01 18:51:15 -0600 (Thu, 01 Dec 2005) | 2 lines
inherit channel variables into channels created by Page() application (issue #5888)
........
r7275 | oej | 2005-12-01 18:52:13 -0600 (Thu, 01 Dec 2005) | 2 lines
Bug #5907. Improve SIP INFO DTMF debugging output. (1.2 & Trunk)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7276 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2005-12-02 01:01:11 +00:00
										 |  |  |                                return -1; | 
					
						
							|  |  |  |                        } | 
					
						
							|  |  |  |                        n += read_data; | 
					
						
							|  |  |  |                } | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 		ack[3] = '\0'; | 
					
						
							|  |  |  | 		if (strcmp(ack,"WV\n") == 0) {         /* receive a waveform */ | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 			ast_log(LOG_DEBUG,"Festival WV command\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 			waveform = socket_receive_file_to_buff(fd,&filesize); | 
					
						
							| 
									
										
										
										
											2003-08-15 21:28:04 +00:00
										 |  |  | 			res = send_waveform_to_channel(chan,waveform,filesize, intstr); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 			free(waveform); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (strcmp(ack,"LP\n") == 0) {   /* receive an s-expr */ | 
					
						
							| 
									
										
										
										
											2003-09-27 02:31:07 +00:00
										 |  |  | 			ast_log(LOG_DEBUG,"Festival LP command\n"); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 			waveform = socket_receive_file_to_buff(fd,&filesize); | 
					
						
							|  |  |  | 			waveform[filesize]='\0'; | 
					
						
							|  |  |  | 			ast_log(LOG_WARNING,"Festival returned LP : %s\n",waveform); | 
					
						
							|  |  |  | 			free(waveform); | 
					
						
							|  |  |  | 		} else if (strcmp(ack,"ER\n") == 0) {    /* server got an error */ | 
					
						
							|  |  |  | 			ast_log(LOG_WARNING,"Festival returned ER\n"); | 
					
						
							|  |  |  | 			res=-1; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  |     		} | 
					
						
							|  |  |  | 	} while (strcmp(ack,"OK\n") != 0); | 
					
						
							|  |  |  | 	close(fd); | 
					
						
							| 
									
										
										
										
											2005-01-25 06:10:20 +00:00
										 |  |  | 	ast_config_destroy(cfg); | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	ast_module_user_remove(u); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	return res; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int unload_module(void) | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2005-10-18 22:52:21 +00:00
										 |  |  | 	int res; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	res = ast_unregister_application(app); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	ast_module_user_hangup_all(); | 
					
						
							| 
									
										
										
										
											2005-10-18 22:52:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return res; | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int load_module(void) | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-08-31 21:00:20 +00:00
										 |  |  | 	struct ast_config *cfg = ast_config_load(FESTIVAL_CONFIG); | 
					
						
							|  |  |  | 	if (!cfg) { | 
					
						
							|  |  |  | 		ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG); | 
					
						
							|  |  |  | 		return AST_MODULE_LOAD_DECLINE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ast_config_destroy(cfg); | 
					
						
							| 
									
										
										
										
											2002-09-11 17:09:48 +00:00
										 |  |  | 	return ast_register_application(app, festival_exec, synopsis, descrip); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Simple Festival Interface"); |