[asterisk-commits] branch bweschke/bug_6047 - r8067 in
/team/bweschke/bug_6047: ./ apps/ channel...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Jan 13 13:50:21 CST 2006
Author: bweschke
Date: Fri Jan 13 13:50:15 2006
New Revision: 8067
URL: http://svn.digium.com/view/asterisk?rev=8067&view=rev
Log:
SVNMerge: Bringing this branch up to date with /trunk
Modified:
team/bweschke/bug_6047/ (props changed)
team/bweschke/bug_6047/apps/app_dial.c
team/bweschke/bug_6047/apps/app_directed_pickup.c
team/bweschke/bug_6047/apps/app_festival.c
team/bweschke/bug_6047/apps/app_macro.c
team/bweschke/bug_6047/apps/app_meetme.c
team/bweschke/bug_6047/apps/app_milliwatt.c
team/bweschke/bug_6047/apps/app_mixmonitor.c
team/bweschke/bug_6047/apps/app_morsecode.c
team/bweschke/bug_6047/apps/app_page.c
team/bweschke/bug_6047/apps/app_parkandannounce.c
team/bweschke/bug_6047/apps/app_queue.c
team/bweschke/bug_6047/apps/app_rpt.c
team/bweschke/bug_6047/apps/app_voicemail.c
team/bweschke/bug_6047/asterisk.c
team/bweschke/bug_6047/channels/chan_agent.c
team/bweschke/bug_6047/channels/chan_local.c
team/bweschke/bug_6047/channels/chan_sip.c
team/bweschke/bug_6047/configs/agents.conf.sample
team/bweschke/bug_6047/configs/queues.conf.sample
team/bweschke/bug_6047/doc/CODING-GUIDELINES
team/bweschke/bug_6047/doc/README.variables
team/bweschke/bug_6047/doc/manager.txt
team/bweschke/bug_6047/doc/queuelog.txt
team/bweschke/bug_6047/include/asterisk/app.h
team/bweschke/bug_6047/include/asterisk/utils.h
team/bweschke/bug_6047/pbx.c
team/bweschke/bug_6047/udptl.c
Propchange: team/bweschke/bug_6047/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jan 13 13:50:15 2006
@@ -1,1 +1,1 @@
-/trunk:1-8025
+/trunk:1-8066
Modified: team/bweschke/bug_6047/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_dial.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_dial.c (original)
+++ team/bweschke/bug_6047/apps/app_dial.c Fri Jan 13 13:50:15 2006
@@ -449,13 +449,15 @@
char tmpchan[256];
char *stuff;
char *tech;
+ char *forward_context;
ast_copy_string(tmpchan, o->chan->call_forward, sizeof(tmpchan));
if ((stuff = strchr(tmpchan, '/'))) {
*stuff = '\0';
stuff++;
tech = tmpchan;
} else {
- snprintf(tmpchan, sizeof(tmpchan), "%s@%s", o->chan->call_forward, o->chan->context);
+ forward_context = pbx_builtin_getvar_helper(o->chan, "FORWARD_CONTEXT");
+ snprintf(tmpchan, sizeof(tmpchan), "%s@%s", o->chan->call_forward, forward_context ? forward_context : o->chan->context);
stuff = tmpchan;
tech = "Local";
}
Modified: team/bweschke/bug_6047/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_directed_pickup.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_directed_pickup.c (original)
+++ team/bweschke/bug_6047/apps/app_directed_pickup.c Fri Jan 13 13:50:15 2006
@@ -46,7 +46,7 @@
static const char *app = "Pickup";
static const char *synopsis = "Directed Call Pickup";
static const char *descrip =
-" Pickup(extension[@context]): This application can pickup any ringing channel\n"
+" Pickup(extension[@context][&extension2 at context...]): This application can pickup any ringing channel\n"
"that is calling the specified extension. If no context is specified, the current\n"
"context will be used.\n";
@@ -59,7 +59,7 @@
int res = 0;
struct localuser *u = NULL;
struct ast_channel *origin = NULL, *target = NULL;
- char *tmp = NULL, *exten = NULL, *context = NULL;
+ char *tmp = NULL, *exten = NULL, *context = NULL, *rest=data;
char workspace[256] = "";
if (ast_strlen_zero(data)) {
@@ -69,64 +69,65 @@
LOCAL_USER_ADD(u);
- /* Get the extension and context if present */
- exten = data;
- context = strchr(data, '@');
- if (context) {
- *context = '\0';
- context++;
- }
+ while (!target && (exten = rest) ) {
+ res = 0;
+ rest = strchr(exten, '&');
+ if (rest)
+ *rest++ = 0;
- /* Find a channel to pickup */
- origin = ast_get_channel_by_exten_locked(exten, context);
- if (origin && origin->cdr) {
- ast_cdr_getvar(origin->cdr, "dstchannel", &tmp, workspace,
- sizeof(workspace), 0);
- if (tmp) {
- /* We have a possible channel... now we need to find it! */
- target = ast_get_channel_by_name_locked(tmp);
+ /* Get the extension and context if present */
+ context = strchr(exten, '@');
+ if (context)
+ *context++ = '\0';
+
+ /* Find a channel to pickup */
+ origin = ast_get_channel_by_exten_locked(exten, context);
+ if (origin) {
+ ast_cdr_getvar(origin->cdr, "dstchannel", &tmp, workspace,
+ sizeof(workspace), 0);
+ if (tmp) {
+ /* We have a possible channel... now we need to find it! */
+ target = ast_get_channel_by_name_locked(tmp);
+ } else {
+ ast_log(LOG_NOTICE, "No target channel found for %s.\n", exten);
+ res = -1;
+ }
+ ast_mutex_unlock(&origin->lock);
+
} else {
- ast_log(LOG_DEBUG, "No target channel found.\n");
+ ast_log(LOG_DEBUG, "No originating channel found.\n");
+ }
+
+ if (res)
+ continue;
+
+ if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING) ) ) {
+ ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
+ chan->name);
+ res = ast_answer(chan);
+ if (res) {
+ ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
+ res = -1;
+ break;
+ }
+ res = ast_queue_control(chan, AST_CONTROL_ANSWER);
+ if (res) {
+ ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n",
+ chan->name);
+ res = -1;
+ break;
+ }
+ res = ast_channel_masquerade(target, chan);
+ if (res) {
+ ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, target->name);
+ res = -1;
+ break;
+ }
+ } else {
+ ast_log(LOG_NOTICE, "No call pickup possible for %s...\n", exten);
res = -1;
}
- ast_mutex_unlock(&origin->lock);
- } else {
- if (origin)
- ast_mutex_unlock(&origin->lock);
- ast_log(LOG_DEBUG, "No originating channel found.\n");
}
-
- if (res)
- goto out;
-
- if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING))) {
- ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
- chan->name);
- res = ast_answer(chan);
- if (res) {
- ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
- res = -1;
- goto out;
- }
- res = ast_queue_control(chan, AST_CONTROL_ANSWER);
- if (res) {
- ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n",
- chan->name);
- res = -1;
- goto out;
- }
- res = ast_channel_masquerade(target, chan);
- if (res) {
- ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, target->name);
- res = -1;
- goto out;
- }
- } else {
- ast_log(LOG_DEBUG, "No call pickup possible...\n");
- res = -1;
- }
- /* Done */
- out:
if (target)
ast_mutex_unlock(&target->lock);
Modified: team/bweschke/bug_6047/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_festival.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_festival.c (original)
+++ team/bweschke/bug_6047/apps/app_festival.c Fri Jan 13 13:50:15 2006
@@ -86,7 +86,10 @@
char c;
bufflen = 1024;
- buff = (char *)malloc(bufflen);
+ if (!(buff = ast_malloc(bufflen)))
+ {
+ /* TODO: Handle memory allocation failure */
+ }
*size=0;
for (k=0; file_stuff_key[k] != '\0';)
@@ -96,7 +99,10 @@
if ((*size)+k+1 >= bufflen)
{ /* +1 so you can add a NULL if you want */
bufflen += bufflen/4;
- buff = (char *)realloc(buff,bufflen);
+ if (!(buff = ast_realloc(buff, bufflen)))
+ {
+ /* TODO: Handle memory allocation failure */
+ }
}
if (file_stuff_key[k] == c)
k++;
Modified: team/bweschke/bug_6047/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_macro.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_macro.c (original)
+++ team/bweschke/bug_6047/apps/app_macro.c Fri Jan 13 13:50:15 2006
@@ -88,11 +88,6 @@
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
-
-static char *safe_strdup(const char *s)
-{
- return s ? strdup(s) : NULL;
-}
static int macro_exec(struct ast_channel *chan, void *data)
{
@@ -169,17 +164,17 @@
}
argc = 1;
/* Save old macro variables */
- save_macro_exten = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_EXTEN"));
+ save_macro_exten = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_EXTEN"));
pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", oldexten);
- save_macro_context = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"));
+ save_macro_context = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"));
pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", oldcontext);
- save_macro_priority = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY"));
+ save_macro_priority = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY"));
snprintf(pc, sizeof(pc), "%d", oldpriority);
pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", pc);
- save_macro_offset = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"));
+ save_macro_offset = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"));
pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", NULL);
/* Setup environment for new run */
Modified: team/bweschke/bug_6047/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_meetme.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_meetme.c (original)
+++ team/bweschke/bug_6047/apps/app_meetme.c Fri Jan 13 13:50:15 2006
@@ -474,8 +474,7 @@
if (!cnf && (make || dynamic)) {
/* Make a new one */
- cnf = calloc(1, sizeof(*cnf));
- if (cnf) {
+ if ((cnf = ast_calloc(1, sizeof(*cnf)))) {
ast_mutex_init(&cnf->playlock);
ast_mutex_init(&cnf->listenlock);
ast_copy_string(cnf->confno, confno, sizeof(cnf->confno));
@@ -535,8 +534,7 @@
ast_verbose(VERBOSE_PREFIX_3 "Created MeetMe conference %d for conference '%s'\n", cnf->zapconf, cnf->confno);
cnf->next = confs;
confs = cnf;
- } else
- ast_log(LOG_WARNING, "Out of memory\n");
+ }
}
cnfout:
ast_mutex_unlock(&conflock);
@@ -851,7 +849,7 @@
static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int confflags)
{
- struct ast_conf_user *user = calloc(1, sizeof(*user));
+ struct ast_conf_user *user = NULL;
struct ast_conf_user *usr = NULL;
int fd;
struct zt_confinfo ztc, ztc_empty;
@@ -887,9 +885,8 @@
ZT_BUFFERINFO bi;
char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
char *buf = __buf + AST_FRIENDLY_OFFSET;
-
- if (!user) {
- ast_log(LOG_ERROR, "Out of memory\n");
+
+ if (!(user = ast_calloc(1, sizeof(*user)))) {
return ret;
}
Modified: team/bweschke/bug_6047/apps/app_milliwatt.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_milliwatt.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_milliwatt.c (original)
+++ team/bweschke/bug_6047/apps/app_milliwatt.c Fri Jan 13 13:50:15 2006
@@ -41,6 +41,7 @@
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
+#include "asterisk/utils.h"
static char *tdesc = "Digital Milliwatt (mu-law) Test Application";
@@ -59,11 +60,7 @@
static void *milliwatt_alloc(struct ast_channel *chan, void *params)
{
-int *indexp;
- indexp = ast_malloc(sizeof(*indexp));
- if (indexp == NULL) return(NULL);
- *indexp = 0;
- return(indexp);
+ return ast_calloc(1, sizeof(int));
}
static void milliwatt_release(struct ast_channel *chan, void *data)
Modified: team/bweschke/bug_6047/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_mixmonitor.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_mixmonitor.c (original)
+++ team/bweschke/bug_6047/apps/app_mixmonitor.c Fri Jan 13 13:50:15 2006
@@ -53,6 +53,7 @@
#include "asterisk/options.h"
#include "asterisk/app.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/utils.h"
#define get_volfactor(x) x ? ((x > 0) ? (1 << x) : ((1 << abs(x)) * -1)) : 0
@@ -292,8 +293,7 @@
if (!ast_strlen_zero(post_process))
len += strlen(post_process) + 1;
- if (!(mixmonitor = calloc(1, len))) {
- ast_log(LOG_ERROR, "Memory Error!\n");
+ if (!(mixmonitor = ast_calloc(1, len))) {
return;
}
Modified: team/bweschke/bug_6047/apps/app_morsecode.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_morsecode.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_morsecode.c (original)
+++ team/bweschke/bug_6047/apps/app_morsecode.c Fri Jan 13 13:50:15 2006
@@ -55,12 +55,8 @@
LOCAL_USER_DECL;
-#define TONE 440
-#define DITLEN 100
-#define DAHLEN 250
-#define DITDAHSEPLEN 50
-#define CHARSEPLEN 200
-/* Pause between words will be twice CHARSEPLEN plus DITDAHSEPLEN - 450 */
+#define TONE 800
+#define DITLEN 80
static char *morsecode[] = {
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0-15 */
@@ -109,9 +105,9 @@
static void playtone(struct ast_channel *chan, int tone, int len)
{
char dtmf[20];
- snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, len);
+ snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, DITLEN * len);
ast_playtones_start(chan, 0, dtmf, 0);
- ast_safe_sleep(chan, len);
+ ast_safe_sleep(chan, DITLEN * len);
ast_playtones_stop(chan);
}
@@ -136,18 +132,19 @@
}
for (dahdit = morsecode[(int)*digit]; *dahdit; dahdit++) {
if (*dahdit == '-') {
- playtone(chan, TONE, DAHLEN);
+ playtone(chan, TONE, 3);
} else if (*dahdit == '.') {
- playtone(chan, TONE, DITLEN);
+ playtone(chan, TONE, 1);
} else {
- playtone(chan, TONE, CHARSEPLEN);
+ /* Account for ditlen of silence immediately following */
+ playtone(chan, 0, 2);
}
/* Pause slightly between each dit and dah */
- playtone(chan, 0, DITDAHSEPLEN);
+ playtone(chan, 0, 1);
}
/* Pause between characters */
- playtone(chan, 0, CHARSEPLEN);
+ playtone(chan, 0, 2);
}
LOCAL_USER_REMOVE(u);
Modified: team/bweschke/bug_6047/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_page.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_page.c (original)
+++ team/bweschke/bug_6047/apps/app_page.c Fri Jan 13 13:50:15 2006
@@ -43,7 +43,7 @@
#include "asterisk/file.h"
#include "asterisk/app.h"
#include "asterisk/chanvars.h"
-
+#include "asterisk/utils.h"
static const char *tdesc = "Page Multiple Phones";
@@ -100,8 +100,7 @@
struct ast_var_t *varptr;
pthread_t t;
pthread_attr_t attr;
- cd = ast_calloc(1, sizeof(*cd));
- if (cd) {
+ if ((cd = ast_calloc(1, sizeof(*cd)))) {
ast_copy_string(cd->cidnum, chan->cid.cid_num ? chan->cid.cid_num : "", sizeof(cd->cidnum));
ast_copy_string(cd->cidname, chan->cid.cid_name ? chan->cid.cid_name : "", sizeof(cd->cidname));
ast_copy_string(cd->tech, tech, sizeof(cd->tech));
Modified: team/bweschke/bug_6047/apps/app_parkandannounce.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_parkandannounce.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_parkandannounce.c (original)
+++ team/bweschke/bug_6047/apps/app_parkandannounce.c Fri Jan 13 13:50:15 2006
@@ -49,6 +49,7 @@
#include "asterisk/logger.h"
#include "asterisk/say.h"
#include "asterisk/lock.h"
+#include "asterisk/utils.h"
static char *tdesc = "Call Parking and Announce Application";
@@ -94,10 +95,8 @@
LOCAL_USER_ADD(u);
- l=strlen(data)+2;
- orig_s=malloc(l);
- if(!orig_s) {
- ast_log(LOG_WARNING, "Out of memory\n");
+ l=strlen(data)+2;
+ if (!(orig_s = ast_malloc(l))) {
LOCAL_USER_REMOVE(u);
return -1;
}
Modified: team/bweschke/bug_6047/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_queue.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_queue.c (original)
+++ team/bweschke/bug_6047/apps/app_queue.c Fri Jan 13 13:50:15 2006
@@ -317,18 +317,18 @@
char moh[80]; /*!< Music On Hold class to be used */
char announce[80]; /*!< Announcement to play when call is answered */
char context[AST_MAX_CONTEXT]; /*!< Exit context */
- unsigned int monjoin:1;
- unsigned int dead:1;
- unsigned int joinempty:2;
- unsigned int eventwhencalled:1;
- unsigned int leavewhenempty:2;
- unsigned int reportholdtime:1;
- unsigned int wrapped:1;
- unsigned int timeoutrestart:1;
- unsigned int announceholdtime:2;
- unsigned int strategy:3;
- unsigned int maskmemberstatus:1;
- unsigned int realtime:1;
+ unsigned int monjoin:1;
+ unsigned int dead:1;
+ unsigned int joinempty:2;
+ unsigned int eventwhencalled:1;
+ unsigned int leavewhenempty:2;
+ unsigned int reportholdtime:1;
+ unsigned int wrapped:1;
+ unsigned int timeoutrestart:1;
+ unsigned int announceholdtime:2;
+ unsigned int strategy:3;
+ unsigned int maskmemberstatus:1;
+ unsigned int realtime:1;
int announcefrequency; /*!< How often to announce their position */
int periodicannouncefrequency; /*!< How often to play periodic announcement */
int roundingseconds; /*!< How many seconds do we round to? */
@@ -356,11 +356,13 @@
int retry; /*!< Retry calling everyone after this amount of time */
int timeout; /*!< How long to wait for an answer */
int weight; /*!< Respective weight */
-
+ int autopause; /*!< Auto pause queue members if they fail to answer */
+
/* Queue strategy things */
int rrpos; /*!< Round Robin - position */
int memberdelay; /*!< Seconds to delay connecting member to caller */
-
+ int autofill; /*!< Ignore the head call status and ring an available agent */
+
struct member *members; /*!< Head of the list of members */
struct queue_ent *head; /*!< Head of the list of callers */
struct ast_call_queue *next; /*!< Next call queue */
@@ -368,6 +370,8 @@
static struct ast_call_queue *queues = NULL;
AST_MUTEX_DEFINE_STATIC(qlock);
+
+static int set_member_paused(char *queuename, char *interface, int paused);
static void set_queue_result(struct ast_channel *chan, enum queue_result res)
{
@@ -514,9 +518,8 @@
struct statechange *sc;
pthread_t t;
pthread_attr_t attr;
-
- sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1);
- if (sc) {
+
+ if ((sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1))) {
sc->state = state;
strcpy(sc->dev, dev);
pthread_attr_init(&attr);
@@ -535,9 +538,7 @@
/* Add a new member */
- cur = ast_calloc(1, sizeof(*cur));
-
- if (cur) {
+ if ((cur = ast_calloc(1, sizeof(*cur)))) {
cur->penalty = penalty;
cur->paused = paused;
ast_copy_string(cur->interface, interface, sizeof(cur->interface));
@@ -553,8 +554,7 @@
{
struct ast_call_queue *q;
- q = ast_calloc(1, sizeof(*q));
- if (q) {
+ if ((q = ast_calloc(1, sizeof(*q)))) {
ast_mutex_init(&q->lock);
ast_copy_string(q->name, queuename, sizeof(q->name));
}
@@ -670,6 +670,10 @@
q->retry = DEFAULT_RETRY;
} else if (!strcasecmp(param, "wrapuptime")) {
q->wrapuptime = atoi(val);
+ } else if (!strcasecmp(param, "autofill")) {
+ q->autofill = ast_true(val);
+ } else if (!strcasecmp(param, "autopause")) {
+ q->autopause = ast_true(val);
} else if (!strcasecmp(param, "maxlen")) {
q->maxlen = atoi(val);
if (q->maxlen < 0)
@@ -827,8 +831,7 @@
/* Create a new queue if an in-core entry does not exist yet. */
if (!q) {
- q = alloc_queue(queuename);
- if (!q)
+ if (!(q = alloc_queue(queuename)))
return NULL;
ast_mutex_lock(&q->lock);
clear_queue(q);
@@ -1612,6 +1615,7 @@
static struct localuser *wait_for_answer(struct queue_ent *qe, struct localuser *outgoing, int *to, char *digit, int prebusies, int caller_disconnect)
{
char *queue = qe->parent->name;
+ char on[256] = "";
struct localuser *o;
int found;
int numlines;
@@ -1655,6 +1659,7 @@
peer = o;
}
} else if (o->chan && (o->chan == winner)) {
+ ast_copy_string(on, o->member->interface, sizeof(on));
if (!ast_strlen_zero(o->chan->call_forward)) {
char tmpchan[256]="";
char *stuff;
@@ -1704,11 +1709,7 @@
if (in->cid.cid_ani) {
if (o->chan->cid.cid_ani)
free(o->chan->cid.cid_ani);
- o->chan->cid.cid_ani = ast_calloc(1, strlen(in->cid.cid_ani) + 1);
- if (o->chan->cid.cid_ani)
- strncpy(o->chan->cid.cid_ani, in->cid.cid_ani, strlen(in->cid.cid_ani) + 1);
- else
- ast_log(LOG_WARNING, "Out of memory\n");
+ o->chan->cid.cid_ani = ast_strdup(in->cid.cid_ani);
}
if (o->chan->cid.cid_rdnis)
free(o->chan->cid.cid_rdnis);
@@ -1833,8 +1834,19 @@
}
ast_frfree(f);
}
- if (!*to && (option_verbose > 2))
- ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig);
+ if (!*to) {
+ if (option_verbose > 2)
+ ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig);
+ if (qe->parent->autopause) {
+ if (!set_member_paused(qe->parent->name, on, 1)) {
+ if (option_verbose > 2)
+ ast_verbose( VERBOSE_PREFIX_3 "Auto-Pausing Queue Member %s in queue %s since they failed to answer.\n", on, qe->parent->name);
+ } else {
+ if (option_verbose > 2)
+ ast_verbose( VERBOSE_PREFIX_3 "Failed to pause Queue Member %s in queue %s!\n", on, qe->parent->name);
+ }
+ }
+ }
}
return peer;
@@ -1849,7 +1861,7 @@
/* Atomically read the parent head -- does not need a lock */
ch = qe->parent->head;
/* If we are now at the top of the head, break out */
- if (ch == qe) {
+ if ((ch == qe) || (qe->parent->autofill)) {
if (option_debug)
ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name);
res = 1;
@@ -2060,12 +2072,10 @@
announce = announceoverride;
while(cur) {
- tmp = ast_calloc(1, sizeof(*tmp));
- if (!tmp) {
+ if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
ast_mutex_unlock(&qe->parent->lock);
if (use_weight)
ast_mutex_unlock(&qlock);
- ast_log(LOG_WARNING, "Out of memory\n");
goto out;
}
tmp->stillgoing = -1;
@@ -3204,7 +3214,9 @@
}
if (!q) {
/* Make one then */
- q = alloc_queue(cat);
+ if (!(q = alloc_queue(cat))) {
+ /* TODO: Handle memory allocation failure */
+ }
new = 1;
} else
new = 0;
@@ -3681,8 +3693,8 @@
}
case 7:
if (state < 100) { /* 0-99 */
- char *num = ast_malloc(3);
- if (num) {
+ char *num;
+ if ((num = ast_malloc(3))) {
sprintf(num, "%d", state);
}
return num;
Modified: team/bweschke/bug_6047/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_rpt.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_rpt.c (original)
+++ team/bweschke/bug_6047/apps/app_rpt.c Fri Jan 13 13:50:15 2006
@@ -1041,8 +1041,7 @@
/* allocate a pseudo-channel thru asterisk */
- mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!mychannel)
+ if (!(mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_mutex_lock(&myrpt->lock);
@@ -1312,11 +1311,9 @@
{
l = l->next;
continue;
- }
- m = ast_malloc(sizeof(*m));
- if (!m)
+ }
+ if (!(m = ast_malloc(sizeof(*m))))
{
- ast_log(LOG_WARNING, "Cannot alloc memory on %s\n", mychannel->name);
ast_mutex_lock(&myrpt->lock);
remque((struct qelem *)mytele);
ast_mutex_unlock(&myrpt->lock);
@@ -1563,16 +1560,12 @@
struct rpt_tele *tele;
struct rpt_link *mylink = (struct rpt_link *) data;
pthread_attr_t attr;
-
- tele = ast_malloc(sizeof(*tele));
- if (!tele)
- {
- ast_log(LOG_WARNING, "Unable to allocate memory\n");
+
+ if (!(tele = ast_calloc(1, sizeof(*tele))))
+ {
pthread_exit(NULL);
return;
}
- /* zero it out */
- memset((char *)tele,0,sizeof(struct rpt_tele));
tele->rpt = myrpt;
tele->mode = mode;
ast_mutex_lock(&myrpt->lock);
@@ -1605,8 +1598,7 @@
myrpt->mydtmf = 0;
/* allocate a pseudo-channel thru asterisk */
- mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!mychannel)
+ if (!(mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
pthread_exit(NULL);
@@ -1624,8 +1616,7 @@
pthread_exit(NULL);
}
/* allocate a pseudo-channel thru asterisk */
- genchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!genchannel)
+ if (!(genchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_hangup(mychannel);
@@ -1951,10 +1942,8 @@
} else
ast_mutex_unlock(&myrpt->lock);
strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
- /* establish call in monitor mode */
- l = ast_calloc(1, sizeof(*l));
- if (!l){
- ast_log(LOG_WARNING, "Unable to malloc\n");
+ /* establish call in monitor mode */
+ if (!(l = ast_calloc(1, sizeof(*l)))) {
return DC_ERROR;
}
/* zero the silly thing */
@@ -1993,8 +1982,7 @@
return DC_ERROR;
}
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!l->pchan){
+ if (!(l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL))) {
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_hangup(l->chan);
free(l);
@@ -2065,9 +2053,7 @@
ast_mutex_unlock(&myrpt->lock);
strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
/* establish call in tranceive mode */
- l = ast_calloc(1, sizeof(*l));
- if (!l){
- ast_log(LOG_WARNING, "Unable to malloc\n");
+ if (!(l = ast_calloc(1, sizeof(*l)))) {
return(DC_ERROR);
}
l->mode = 1;
@@ -2107,8 +2093,7 @@
return DC_ERROR;
}
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!l->pchan){
+ if (!(l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL))) {
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_hangup(l->chan);
free(l);
@@ -4711,8 +4696,7 @@
ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_KEY);
ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_UNKEY);
/* allocate a pseudo-channel thru asterisk */
- myrpt->pchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!myrpt->pchannel)
+ if (!(myrpt->pchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_mutex_unlock(&myrpt->lock);
@@ -4760,8 +4744,7 @@
/* save pseudo channel conference number */
myrpt->conf = ci.confno;
/* allocate a pseudo-channel thru asterisk */
- myrpt->txpchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!myrpt->txpchannel)
+ if (!(myrpt->txpchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
ast_mutex_unlock(&myrpt->lock);
@@ -6014,9 +5997,7 @@
}
l=strlen(options)+2;
- orig_s=ast_malloc(l);
- if(!orig_s) {
- ast_log(LOG_WARNING, "Out of memory\n");
+ if (!(orig_s = ast_malloc(l))) {
return -1;
}
s=orig_s;
@@ -6226,10 +6207,8 @@
} else
ast_mutex_unlock(&myrpt->lock);
/* establish call in tranceive mode */
- l = ast_calloc(1, sizeof(*l));
- if (!l)
- {
- ast_log(LOG_WARNING, "Unable to malloc\n");
+ if (!(l = ast_calloc(1, sizeof(*l))))
+ {
pthread_exit(NULL);
}
l->mode = 1;
@@ -6242,8 +6221,7 @@
ast_set_read_format(l->chan,AST_FORMAT_SLINEAR);
ast_set_write_format(l->chan,AST_FORMAT_SLINEAR);
/* allocate a pseudo-channel thru asterisk */
- l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
- if (!l->pchan)
+ if (!(l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
{
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
pthread_exit(NULL);
Modified: team/bweschke/bug_6047/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_voicemail.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_voicemail.c (original)
+++ team/bweschke/bug_6047/apps/app_voicemail.c Fri Jan 13 13:50:15 2006
@@ -340,8 +340,8 @@
" g(#) - Use the specified amount of gain when recording a voicemail\n"
" message. The units are whole-number decibels (dB).\n"
" s - Skip checking the passcode for the mailbox.\n"
-" a(#) - Automatically play messages in the specified folder.\n"
-" Defaults to INBOX";
+" a(#) - Skip folder prompt and go directly to folder specified.\n"
+" Defaults to INBOX\n";
static char *synopsis_vm_box_exists =
"Check to see if Voicemail mailbox exists";
@@ -532,12 +532,7 @@
struct ast_variable *var, *tmp;
struct ast_vm_user *retval;
- if (ivm)
- retval=ivm;
- else
- retval=ast_calloc(1, sizeof(*retval));
-
- if (retval) {
+ if ((retval = (ivm ? ivm : ast_calloc(1, sizeof(*retval))))) {
if (!ivm)
ast_set_flag(retval, VM_ALLOCED);
else
@@ -596,12 +591,8 @@
cur=cur->next;
}
if (cur) {
- if (ivm)
- vmu = ivm;
- else
- /* Make a copy, so that on a reload, we have no race */
- vmu = ast_malloc(sizeof(*vmu));
- if (vmu) {
+ /* Make a copy, so that on a reload, we have no race */
+ if ((vmu = (ivm ? ivm : ast_malloc(sizeof(*vmu))))) {
memcpy(vmu, cur, sizeof(*vmu));
ast_set2_flag(vmu, !ivm, VM_ALLOCED);
vmu->next = NULL;
@@ -1462,7 +1453,7 @@
int txtsize = 0;
txtsize = (strlen(file) + 5)*sizeof(char);
- txt = (char *)alloca(txtsize);
+ txt = alloca(txtsize);
/* Sprintf here would safe because we alloca'd exactly the right length,
* but trying to eliminate all sprintf's anyhow
*/
@@ -1689,8 +1680,8 @@
strftime(date, sizeof(date), emaildateformat, &tm);
if (*fromstring) {
- struct ast_channel *ast = ast_channel_alloc(0);
- if (ast) {
+ struct ast_channel *ast;
+ if ((ast = ast_channel_alloc(0))) {
char *passdata;
int vmlen = strlen(fromstring)*3 + 200;
if ((passdata = alloca(vmlen))) {
@@ -1706,8 +1697,8 @@
fprintf(p, "To: %s <%s>\n", vmu->fullname, vmu->email);
if (emailsubject) {
- struct ast_channel *ast = ast_channel_alloc(0);
- if (ast) {
+ struct ast_channel *ast;
+ if ((ast = ast_channel_alloc(0))) {
char *passdata;
int vmlen = strlen(emailsubject)*3 + 200;
if ((passdata = alloca(vmlen))) {
@@ -1738,8 +1729,8 @@
}
fprintf(p, "Content-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n\n", charset);
if (emailbody) {
- struct ast_channel *ast = ast_channel_alloc(0);
- if (ast) {
+ struct ast_channel *ast;
+ if ((ast = ast_channel_alloc(0))) {
char *passdata;
int vmlen = strlen(emailbody)*3 + 200;
if ((passdata = alloca(vmlen))) {
@@ -1807,8 +1798,8 @@
fprintf(p, "Date: %s\n", date);
if (*pagerfromstring) {
- struct ast_channel *ast = ast_channel_alloc(0);
- if (ast) {
+ struct ast_channel *ast;
+ if ((ast = ast_channel_alloc(0))) {
char *passdata;
int vmlen = strlen(fromstring)*3 + 200;
if ((passdata = alloca(vmlen))) {
@@ -1824,8 +1815,8 @@
fprintf(p, "From: Asterisk PBX <%s>\n", who);
fprintf(p, "To: %s\n", pager);
if (pagersubject) {
- struct ast_channel *ast = ast_channel_alloc(0);
- if (ast) {
+ struct ast_channel *ast;
+ if ((ast = ast_channel_alloc(0))) {
char *passdata;
int vmlen = strlen(pagersubject)*3 + 200;
if ((passdata = alloca(vmlen))) {
@@ -1840,8 +1831,8 @@
fprintf(p, "Subject: New VM\n\n");
strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
if (pagerbody) {
- struct ast_channel *ast = ast_channel_alloc(0);
- if (ast) {
+ struct ast_channel *ast;
+ if ((ast = ast_channel_alloc(0))) {
char *passdata;
int vmlen = strlen(pagerbody)*3 + 200;
if ((passdata = alloca(vmlen))) {
@@ -5065,26 +5056,30 @@
}
if (ast_test_flag(&flags, OPT_RECORDGAIN)) {
int gain;
-
- if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
- ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
- LOCAL_USER_REMOVE(u);
- return -1;
+ if(opts[OPT_ARG_RECORDGAIN]) {
+ if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
+ ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
+ LOCAL_USER_REMOVE(u);
+ return -1;
+ } else {
+ record_gain = (signed char) gain;
+ }
} else {
- record_gain = (signed char) gain;
+ ast_log(LOG_WARNING, "Invalid Gain level set with option g\n");
}
}
if (ast_test_flag(&flags, OPT_AUTOPLAY) ) {
play_auto = 1;
- if (sscanf(opts[OPT_ARG_PLAYFOLDER], "%d", &play_folder) != 1) {
- ast_log(LOG_WARNING, "Invalid value '%s' provided for folder autoplay option\n", opts[OPT_ARG_PLAYFOLDER]);
- LOCAL_USER_REMOVE(u);
- return -1;
- }
- else if ( play_folder > 9 || play_folder < 0) {
+ if(opts[OPT_ARG_PLAYFOLDER]) {
+ if (sscanf(opts[OPT_ARG_PLAYFOLDER], "%d", &play_folder) != 1) {
+ ast_log(LOG_WARNING, "Invalid value '%s' provided for folder autoplay option\n", opts[OPT_ARG_PLAYFOLDER]);
+ }
+ } else {
+ ast_log(LOG_WARNING, "Invalid folder set with option a\n");
+ }
+ if ( play_folder > 9 || play_folder < 0) {
ast_log(LOG_WARNING, "Invalid value '%d' provided for folder autoplay option\n", play_folder);
- LOCAL_USER_REMOVE(u);
- return -1;
+ play_folder = 0;
}
}
} else {
@@ -5134,8 +5129,12 @@
if (!valid)
goto out;
- vms.deleted = calloc(vmu->maxmsg, sizeof(int));
- vms.heard = calloc(vmu->maxmsg, sizeof(int));
+ if (!(vms.deleted = ast_calloc(vmu->maxmsg, sizeof(int)))) {
+ /* TODO: Handle memory allocation failure */
+ }
+ if (!(vms.heard = ast_calloc(vmu->maxmsg, sizeof(int)))) {
+ /* TODO: Handle memory allocation failure */
+ }
/* Set language from config to override channel language */
if (!ast_strlen_zero(vmu->language))
@@ -5588,8 +5587,7 @@
struct ast_vm_user *vmu;
ast_copy_string(tmp, data, sizeof(tmp));
- vmu = ast_calloc(1, sizeof(*vmu));
- if (vmu) {
+ if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
ast_copy_string(vmu->context, context, sizeof(vmu->context));
ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
@@ -6125,8 +6123,7 @@
/* Timezones in this context */
while (var) {
struct vm_zone *z;
- z = ast_malloc(sizeof(*z));
- if (z != NULL) {
+ if ((z = ast_malloc(sizeof(*z)))) {
char *msg_format, *timezone;
msg_format = ast_strdupa(var->value);
if (msg_format != NULL) {
@@ -6152,8 +6149,7 @@
free(z);
return -1;
}
- } else {
- ast_log(LOG_WARNING, "Out of memory while reading voicemail config\n");
+ } else {
return -1;
}
var = var->next;
Modified: team/bweschke/bug_6047/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/asterisk.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/asterisk.c (original)
+++ team/bweschke/bug_6047/asterisk.c Fri Jan 13 13:50:15 2006
@@ -1096,6 +1096,7 @@
{
if (argc != 3)
return RESULT_SHOWUSAGE;
+ ast_cli(fd, "Waiting for inactivity to perform halt\n");
quit_handler(0, 2 /* really nicely */, 1 /* safely */, 0 /* don't restart */);
return RESULT_SUCCESS;
}
@@ -1120,6 +1121,7 @@
{
if (argc != 3)
return RESULT_SHOWUSAGE;
+ ast_cli(fd, "Waiting for inactivity to perform restart\n");
quit_handler(0, 2 /* really nicely */, 1 /* safely */, 1 /* restart */);
return RESULT_SUCCESS;
}
Modified: team/bweschke/bug_6047/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/channels/chan_agent.c?rev=8067&r1=8066&r2=8067&view=diff
==============================================================================
--- team/bweschke/bug_6047/channels/chan_agent.c (original)
+++ team/bweschke/bug_6047/channels/chan_agent.c Fri Jan 13 13:50:15 2006
@@ -105,7 +105,7 @@
static const char descrip3[] =
" AgentMonitorOutgoing([options]):\n"
"Tries to figure out the id of the agent who is placing outgoing call based on\n"
-"comparision of the callerid of the current interface and the global variable \n"
+"comparison of the callerid of the current interface and the global variable \n"
"placed by the AgentCallbackLogin application. That's why it should be used only\n"
"with the AgentCallbackLogin app. Uses the monitoring functions in chan_agent \n"
"instead of Monitor application. That have to be configured in the agents.conf file.\n"
@@ -147,7 +147,7 @@
/** Persistent Agents astdb family */
static const char pa_family[] = "/Agents";
-/** The maximum lengh of each persistent member agent database entry */
+/** The maximum length of each persistent member agent database entry */
#define PA_MAX_LEN 2048
/** queues.conf [general] option */
static int persistent_agents = 0;
@@ -158,6 +158,7 @@
static int wrapuptime;
static int ackcall;
static int multiplelogin = 1;
+static int autologoffunavail = 0;
static int maxlogintries = 3;
static char agentgoodbye[AST_MAX_FILENAME_LEN] = "vm-goodbye";
@@ -255,6 +256,7 @@
static int agent_indicate(struct ast_channel *ast, int condition);
static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
+static void set_agentbycallerid(const char *callerid, const char *agent);
static const struct ast_channel_tech agent_tech = {
.type = channeltype,
@@ -286,17 +288,17 @@
struct agent_pvt *p, *prev;
prev = NULL;
p = agents;
- // Iterate over all agents looking for the one.
+ /* Iterate over all agents looking for the one. */
while(p) {
if (p == agent) {
- // Once it wal found, check if it is the first one.
+ /* Once it was found, check if it is the first one. */
if (prev)
[... 509 lines stripped ...]
More information about the asterisk-commits
mailing list