mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
bug #8076 check option_debug before printing to debug channel.
patch provided in bugnote, with minor changes. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44253 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -210,7 +210,8 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
|
||||
break;
|
||||
}
|
||||
if (f->frametype == AST_FRAME_DTMF) {
|
||||
ast_log(LOG_DEBUG, "User pressed a key\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "User pressed a key\n");
|
||||
if (intkeys && strchr(intkeys, f->subclass)) {
|
||||
res = f->subclass;
|
||||
ast_frfree(f);
|
||||
@@ -241,13 +242,15 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
|
||||
break;
|
||||
}
|
||||
if (res < needed) { /* last frame */
|
||||
ast_log(LOG_DEBUG, "Last frame\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Last frame\n");
|
||||
res=0;
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_DEBUG, "No more waveform\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "No more waveform\n");
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
@@ -367,29 +370,34 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
intstr = AST_DIGIT_ANY;
|
||||
}
|
||||
|
||||
ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
|
||||
/* Connect to local festival server */
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (fd < 0) {
|
||||
if (fd < 0) {
|
||||
ast_log(LOG_WARNING,"festival_client: can't get socket\n");
|
||||
ast_config_destroy(cfg);
|
||||
ast_module_user_remove(u);
|
||||
return -1;
|
||||
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 */
|
||||
serverhost = ast_gethostbyname(host, &ahp);
|
||||
if (serverhost == (struct hostent *)0) {
|
||||
ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
|
||||
|
||||
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 */
|
||||
serverhost = ast_gethostbyname(host, &ahp);
|
||||
|
||||
if (serverhost == (struct hostent *)0) {
|
||||
ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
|
||||
ast_config_destroy(cfg);
|
||||
ast_module_user_remove(u);
|
||||
return -1;
|
||||
}
|
||||
memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -422,17 +430,21 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
if (fdesc!=-1) {
|
||||
writecache=1;
|
||||
strln=strlen((char *)data);
|
||||
ast_log(LOG_DEBUG,"line length : %d\n",strln);
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"line length : %d\n",strln);
|
||||
write(fdesc,&strln,sizeof(int));
|
||||
write(fdesc,data,strln);
|
||||
seekpos=lseek(fdesc,0,SEEK_CUR);
|
||||
ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
|
||||
}
|
||||
} else {
|
||||
read(fdesc,&strln,sizeof(int));
|
||||
ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
|
||||
if (strlen((char *)data)==strln) {
|
||||
ast_log(LOG_DEBUG,"Size OK\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Size OK\n");
|
||||
read(fdesc,&bigstring,strln);
|
||||
bigstring[strln] = 0;
|
||||
if (strcmp(bigstring,data)==0) {
|
||||
@@ -449,10 +461,12 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
if (readcache==1) {
|
||||
close(fd);
|
||||
fd=fdesc;
|
||||
ast_log(LOG_DEBUG,"Reading from cache...\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Reading from cache...\n");
|
||||
} else {
|
||||
ast_log(LOG_DEBUG,"Passing text to festival...\n");
|
||||
fs=fdopen(dup(fd),"wb");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Passing text to festival...\n");
|
||||
fs=fdopen(dup(fd),"wb");
|
||||
fprintf(fs,festivalcommand,(char *)data);
|
||||
fflush(fs);
|
||||
fclose(fs);
|
||||
@@ -460,7 +474,8 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
|
||||
/* Write to cache and then pass it down */
|
||||
if (writecache==1) {
|
||||
ast_log(LOG_DEBUG,"Writing result to cache...\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Writing result to cache...\n");
|
||||
while ((strln=read(fd,buffer,16384))!=0) {
|
||||
write(fdesc,buffer,strln);
|
||||
}
|
||||
@@ -470,7 +485,8 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
lseek(fd,seekpos,SEEK_SET);
|
||||
}
|
||||
|
||||
ast_log(LOG_DEBUG,"Passing data to channel...\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Passing data to channel...\n");
|
||||
|
||||
/* Read back info from server */
|
||||
/* This assumes only one waveform will come back, also LP is unlikely */
|
||||
@@ -495,14 +511,16 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
}
|
||||
ack[3] = '\0';
|
||||
if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */
|
||||
ast_log(LOG_DEBUG,"Festival WV command\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Festival WV command\n");
|
||||
waveform = socket_receive_file_to_buff(fd,&filesize);
|
||||
res = send_waveform_to_channel(chan,waveform,filesize, intstr);
|
||||
free(waveform);
|
||||
break;
|
||||
}
|
||||
else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */
|
||||
ast_log(LOG_DEBUG,"Festival LP command\n");
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG,"Festival LP command\n");
|
||||
waveform = socket_receive_file_to_buff(fd,&filesize);
|
||||
waveform[filesize]='\0';
|
||||
ast_log(LOG_WARNING,"Festival returned LP : %s\n",waveform);
|
||||
|
Reference in New Issue
Block a user