aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-12 22:58:49 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-12 22:58:49 +0000
commit41df2e668668137091861464cabe91cf110f4302 (patch)
tree921cb941ba1a59df6cc1650b935d249fa0b73f84 /apps
parent476ed07a1111e6172eb4f860ad239d3ef7bb5f49 (diff)
manual update, since automerge is not running at this time
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2-netsec@48421 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_cut.c4
-rw-r--r--apps/app_db.c2
-rw-r--r--apps/app_dial.c3
-rw-r--r--apps/app_directory.c2
-rw-r--r--apps/app_externalivr.c14
-rw-r--r--apps/app_festival.c11
-rw-r--r--apps/app_ices.c18
-rw-r--r--apps/app_mp3.c16
-rw-r--r--apps/app_nbscat.c16
-rw-r--r--apps/app_sms.c2
-rw-r--r--apps/app_voicemail.c123
-rw-r--r--apps/app_zapras.c18
12 files changed, 169 insertions, 60 deletions
diff --git a/apps/app_cut.c b/apps/app_cut.c
index 46f934b89..a97405775 100644
--- a/apps/app_cut.c
+++ b/apps/app_cut.c
@@ -48,7 +48,7 @@ static char *app_cut = "Cut";
static char *cut_synopsis = "Splits a variable's contents using the specified delimiter";
static char *cut_descrip =
-" Cut(newvar=varname,delimiter,fieldspec): This applicaiton will split the\n"
+" Cut(newvar=varname,delimiter,fieldspec): This application will split the\n"
"contents of a variable based on the given delimeter and store the result in\n"
"a new variable.\n"
"Parameters:\n"
@@ -66,7 +66,7 @@ static char *app_sort_descrip =
" Sort(newvar=key1:val1[,key2:val2[[...],keyN:valN]]): This application will\n"
"sort the list provided in ascending order. The result will be stored in the\n"
"specified variable name.\n"
-" This applicaiton has been deprecated in favor of the SORT function.\n";
+" This application has been deprecated in favor of the SORT function.\n";
STANDARD_LOCAL_USER;
diff --git a/apps/app_db.c b/apps/app_db.c
index 245c8d3ca..0a66959bf 100644
--- a/apps/app_db.c
+++ b/apps/app_db.c
@@ -63,7 +63,7 @@ static char *p_descrip =
" This application has been deprecated in favor of the DB function.\n";
static char *d_descrip =
-" DBdel(family/key): This applicaiton will delete a key from the Asterisk\n"
+" DBdel(family/key): This application will delete a key from the Asterisk\n"
"database.\n";
static char *dt_descrip =
diff --git a/apps/app_dial.c b/apps/app_dial.c
index b214017bb..662a2142a 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -65,7 +65,7 @@ static char *synopsis = "Place a call and connect to the current channel";
static char *descrip =
" Dial(Technology/resource[&Tech2/resource2...][|timeout][|options][|URL]):\n"
-"This applicaiton will place calls to one or more specified channels. As soon\n"
+"This application will place calls to one or more specified channels. As soon\n"
"as one of the requested channels answers, the originating channel will be\n"
"answered, if it has not already been answered. These two channels will then\n"
"be active in a bridged call. All other channels that were requested will then\n"
@@ -1197,6 +1197,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
strcpy(status, "NOANSWER");
if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
moh=1;
+ ast_indicate(chan, AST_CONTROL_PROGRESS);
ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
} else if (ast_test_flag(outgoing, OPT_RINGBACK)) {
ast_indicate(chan, AST_CONTROL_RINGING);
diff --git a/apps/app_directory.c b/apps/app_directory.c
index b403cae4a..9caefc030 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -61,7 +61,7 @@ static char *descrip =
"the calling channel with a directory of extensions from which they can search\n"
"by name. The list of names and corresponding extensions is retrieved from the\n"
"voicemail configuration file, voicemail.conf.\n"
-" This applicaiton will immediate exit if one of the following DTMF digits are\n"
+" This application will immediately exit if one of the following DTMF digits are\n"
"received and the extension to jump to exists:\n"
" 0 - Jump to the 'o' extension, if it exists.\n"
" * - Jump to the 'a' extension, if it exists.\n\n"
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index fc5f34082..1d4a6f3fd 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
+#include <signal.h>
#include "asterisk.h"
@@ -152,7 +153,7 @@ static int gen_nextfile(struct gen_state *state)
if (state->current) {
file_to_stream = state->current->filename;
} else {
- file_to_stream = "silence-10";
+ file_to_stream = "silence/10";
u->playing_silence = 1;
}
@@ -258,9 +259,13 @@ static int app_exec(struct ast_channel *chan, void *data)
FILE *child_commands = NULL;
FILE *child_errors = NULL;
FILE *child_events = NULL;
+ sigset_t fullset, oldset;
LOCAL_USER_ADD(u);
-
+
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
AST_LIST_HEAD_INIT(&u->playlist);
AST_LIST_HEAD_INIT(&u->finishlist);
u->abort_current_sound = 0;
@@ -314,6 +319,9 @@ static int app_exec(struct ast_channel *chan, void *data)
/* child process */
int i;
+ signal(SIGPIPE, SIG_DFL);
+ pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
+
if (option_highpriority)
ast_set_priority(0);
@@ -337,6 +345,8 @@ static int app_exec(struct ast_channel *chan, void *data)
int waitfds[2] = { child_errors_fd, child_commands_fd };
struct ast_channel *rchan;
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+
close(child_stdin[0]);
child_stdin[0] = 0;
close(child_stdout[1]);
diff --git a/apps/app_festival.c b/apps/app_festival.c
index 7c69dc8b9..33f54aaf3 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -127,19 +127,26 @@ static int send_waveform_to_fd(char *waveform, int length, int fd) {
#ifdef __PPC__
char c;
#endif
+ sigset_t fullset, oldset;
+
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
res = fork();
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
- if (res)
+ if (res) {
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
+ }
for (x=0;x<256;x++) {
if (x != fd)
close(x);
}
if (option_highpriority)
ast_set_priority(0);
-
+ signal(SIGPIPE, SIG_DFL);
+ pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
/*IAS */
#ifdef __PPC__
for( x=0; x<length; x+=2)
diff --git a/apps/app_ices.c b/apps/app_ices.c
index b6b5ad3f7..5a9b9412d 100644
--- a/apps/app_ices.c
+++ b/apps/app_ices.c
@@ -68,15 +68,27 @@ static int icesencode(char *filename, int fd)
{
int res;
int x;
+ sigset_t fullset, oldset;
+
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
res = fork();
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
- if (res)
+ if (res) {
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
+ }
+
+ /* Stop ignoring PIPE */
+ signal(SIGPIPE, SIG_DFL);
+ pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
+
if (option_highpriority)
ast_set_priority(0);
dup2(fd, STDIN_FILENO);
- for (x=STDERR_FILENO + 1;x<256;x++) {
+ for (x=STDERR_FILENO + 1;x<1024;x++) {
if ((x != STDIN_FILENO) && (x != STDOUT_FILENO))
close(x);
}
@@ -87,7 +99,7 @@ static int icesencode(char *filename, int fd)
/* As a last-ditch effort, try to use PATH */
execlp("ices", "ices", filename, (char *)NULL);
ast_log(LOG_WARNING, "Execute of ices failed\n");
- return -1;
+ _exit(0);
}
static int ices_exec(struct ast_channel *chan, void *data)
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 31fc32096..1cba886bb 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -67,15 +67,25 @@ static int mp3play(char *filename, int fd)
{
int res;
int x;
+ sigset_t fullset, oldset;
+
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
res = fork();
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
- if (res)
+ if (res) {
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
+ }
if (option_highpriority)
ast_set_priority(0);
+ signal(SIGPIPE, SIG_DFL);
+ pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
+
dup2(fd, STDOUT_FILENO);
- for (x=0;x<256;x++) {
+ for (x=STDERR_FILENO + 1;x<256;x++) {
if (x != STDOUT_FILENO)
close(x);
}
@@ -97,7 +107,7 @@ static int mp3play(char *filename, int fd)
execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
}
ast_log(LOG_WARNING, "Execute of mpg123 failed\n");
- return -1;
+ _exit(0);
}
static int timed_read(int fd, void *data, int datalen, int timeout)
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index adc232373..004bde77b 100644
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -71,16 +71,26 @@ static int NBScatplay(int fd)
{
int res;
int x;
+ sigset_t fullset, oldset;
+
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
res = fork();
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
- if (res)
+ if (res) {
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
+ }
+ signal(SIGPIPE, SIG_DFL);
+ pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
+
if (option_highpriority)
ast_set_priority(0);
dup2(fd, STDOUT_FILENO);
- for (x=0;x<256;x++) {
+ for (x = STDERR_FILENO + 1; x < 1024; x++) {
if (x != STDOUT_FILENO)
close(x);
}
@@ -88,7 +98,7 @@ static int NBScatplay(int fd)
execl(NBSCAT, "nbscat8k", "-d", (char *)NULL);
execl(LOCAL_NBSCAT, "nbscat8k", "-d", (char *)NULL);
ast_log(LOG_WARNING, "Execute of nbscat8k failed\n");
- return -1;
+ _exit(0);
}
static int timed_read(int fd, void *data, int datalen)
diff --git a/apps/app_sms.c b/apps/app_sms.c
index 78ff4d143..3a7677601 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1050,7 +1050,7 @@ static void sms_nextoutgoing (sms_t * h)
unsigned char p = 2;
h->omsg[0] = 0x91; /* SMS_DATA */
if (h->smsc) { /* deliver */
- h->omsg[p++] = (more ? 4 : 0);
+ h->omsg[p++] = (more ? 4 : 0) + ((h->udhl > 0) ? 0x40 : 0);
p += packaddress (h->omsg + p, h->oa);
h->omsg[p++] = h->pid;
h->omsg[p++] = h->dcs;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index a2773dd7a..a8477724c 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -77,6 +77,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define COMMAND_TIMEOUT 5000
#define VOICEMAIL_DIR_MODE 0700
#define VOICEMAIL_FILE_MODE 0600
+#define CHUNKSIZE 65536
#define VOICEMAIL_CONFIG "voicemail.conf"
#define ASTERISK_USERNAME "asterisk"
@@ -925,6 +926,7 @@ static int retrieve_file(char *dir, int msgnum)
goto yuck;
}
if (!strcasecmp(coltitle, "recording")) {
+ off_t offset;
res = SQLGetData(stmt, x + 1, SQL_BINARY, NULL, 0, &colsize);
fdlen = colsize;
if (fd > -1) {
@@ -935,17 +937,25 @@ static int retrieve_file(char *dir, int msgnum)
fd = -1;
continue;
}
- if (fd > -1)
- fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- }
- if (fdm) {
- memset(fdm, 0, fdlen);
- res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, fdlen, &colsize);
- if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
- ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
- SQLFreeHandle (SQL_HANDLE_STMT, stmt);
- goto yuck;
+ /* Read out in small chunks */
+ for (offset = 0; offset < colsize; offset += CHUNKSIZE) {
+ /* +1 because SQLGetData likes null-terminating binary data */
+ if ((fdm = mmap(NULL, CHUNKSIZE + 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == -1) {
+ ast_log(LOG_WARNING, "Could not mmap the output file: %s (%d)\n", strerror(errno), errno);
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+ goto yuck;
+ } else {
+ res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, CHUNKSIZE + 1, NULL);
+ munmap(fdm, 0);
+ if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+ ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+ unlink(full_fn);
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+ goto yuck;
+ }
+ }
}
+ truncate(full_fn, fdlen);
}
} else {
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
@@ -964,8 +974,6 @@ static int retrieve_file(char *dir, int msgnum)
yuck:
if (f)
fclose(f);
- if (fdm)
- munmap(fdm, fdlen);
if (fd > -1)
close(fd);
return x - 1;
@@ -2749,7 +2757,7 @@ static int adsi_logo(unsigned char *buf)
{
int bytes = 0;
bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
- bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002 LSS, Inc.", "");
+ bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
return bytes;
}
@@ -3277,12 +3285,11 @@ static int get_folder2(struct ast_channel *chan, char *fn, int start)
return res;
}
-static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, char *curdir, int curmsg, char *vmfts,
- char *context, signed char record_gain)
+static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, char *curdir, int curmsg, char *vmfmts,
+ char *context, signed char record_gain, long *duration)
{
int cmd = 0;
int retries = 0;
- int duration = 0;
signed char zero_gain = 0;
while ((cmd >= 0) && (cmd != 't') && (cmd != '*')) {
@@ -3290,15 +3297,66 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
retries = 0;
switch (cmd) {
case '1':
- /* prepend a message to the current message and return */
+ /* prepend a message to the current message, update the metadata and return */
{
- char file[200];
- snprintf(file, sizeof(file), "%s/msg%04d", curdir, curmsg);
+ char msgfile[PATH_MAX];
+ char textfile[PATH_MAX];
+ int prepend_duration = 0;
+ struct ast_config *msg_cfg;
+ char *duration_str;
+
+ make_file(msgfile, sizeof(msgfile), curdir, curmsg);
+ strcpy(textfile, msgfile);
+ strncat(textfile, ".txt", sizeof(textfile) - 1);
+ *duration = 0;
+
+ /* if we can't read the message metadata, stop now */
+ if (!(msg_cfg = ast_config_load(textfile))) {
+ cmd = 0;
+ break;
+ }
+
if (record_gain)
ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
- cmd = ast_play_and_prepend(chan, NULL, file, 0, vmfmts, &duration, 1, silencethreshold, maxsilence);
+
+ cmd = ast_play_and_prepend(chan, NULL, msgfile, 0, vmfmts, &prepend_duration, 1, silencethreshold, maxsilence);
if (record_gain)
ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
+
+
+ if ((duration_str = ast_variable_retrieve(msg_cfg, "message", "duration")))
+ *duration = atoi(duration_str);
+
+ if (prepend_duration) {
+ struct ast_variable *var, *prev = NULL, *varlist;
+ struct ast_category *msg_cat;
+
+ *duration += prepend_duration;
+ msg_cat = ast_category_get(msg_cfg, "message");
+ varlist = ast_category_detach_variables(msg_cat);
+ for (var = varlist; var; prev = var, var = var->next) {
+ if (!strcmp(var->name, "duration")) {
+ if (!prev)
+ varlist = var->next;
+ else
+ prev->next = var->next;
+ free(var);
+ break;
+ }
+ }
+ /* need enough space for a maximum-length message duration */
+ duration_str = alloca(12);
+ snprintf(duration_str, 11, "%ld", *duration);
+ if ((var = ast_variable_new("duration", duration_str))) {
+ ast_variable_append(msg_cat, varlist);
+ ast_variable_append(msg_cat, var);
+ config_text_file_save(textfile, msg_cfg, "app_voicemail");
+ STORE(curdir, vmu->mailbox, context, curmsg);
+ }
+ }
+
+ ast_config_destroy(msg_cfg);
+
break;
}
case '2':
@@ -3509,11 +3567,13 @@ static int forward_message(struct ast_channel *chan, char *context, char *dir, i
cmd = leave_voicemail(chan, mailbox, &leave_options);
} else {
/* Forward VoiceMail */
+ long duration = 0;
+
RETRIEVE(dir, curmsg);
- cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context, record_gain);
+ cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context, record_gain, &duration);
if (!cmd) {
while (!res && vmtmp) {
- copy_message(chan, sender, 0, curmsg, 0, vmtmp, fmt);
+ copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt);
saved_messages++;
vmfree = vmtmp;
@@ -5711,22 +5771,13 @@ static int handle_show_voicemail_users(int fd, int argc, char *argv[])
}
}
while (vmu) {
- char dirname[256];
- DIR *vmdir;
- struct dirent *vment;
- int vmcount = 0;
- char count[12];
+ int newmsgs = 0, oldmsgs = 0;
+ char count[12], tmp[256] = "";
if ((argc == 3) || ((argc == 5) && !strcmp(argv[4],vmu->context))) {
- make_dir(dirname, 255, vmu->context, vmu->mailbox, "INBOX");
- if ((vmdir = opendir(dirname))) {
- /* No matter what the format of VM, there will always be a .txt file for each message. */
- while ((vment = readdir(vmdir)))
- if (strlen(vment->d_name) > 7 && !strncmp(vment->d_name + 7,".txt",4))
- vmcount++;
- closedir(vmdir);
- }
- snprintf(count,sizeof(count),"%d",vmcount);
+ snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context);
+ messagecount(tmp, &newmsgs, &oldmsgs);
+ snprintf(count,sizeof(count),"%d",newmsgs);
ast_cli(fd, output_format, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count);
}
vmu = vmu->next;
diff --git a/apps/app_zapras.c b/apps/app_zapras.c
index cf770f2b7..91336f5e4 100644
--- a/apps/app_zapras.c
+++ b/apps/app_zapras.c
@@ -87,11 +87,23 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
char *argv[PPP_MAX_ARGS];
int argc = 0;
char *stringp=NULL;
+ sigset_t fullset, oldset;
+
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
/* Start by forking */
pid = fork();
- if (pid)
+ if (pid) {
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return pid;
+ }
+
+ /* Restore original signal handlers */
+ for (x=0;x<NSIG;x++)
+ signal(x, SIG_DFL);
+
+ pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
/* Execute RAS on File handles */
dup2(chan->fds[0], STDIN_FILENO);
@@ -104,10 +116,6 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
for (x=STDERR_FILENO + 1;x<1024;x++)
close(x);
- /* Restore original signal handlers */
- for (x=0;x<NSIG;x++)
- signal(x, SIG_DFL);
-
/* Reset all arguments */
memset(argv, 0, sizeof(argv));