[asterisk-commits] branch rizzo/base r10193 - in /team/rizzo/base:
./ apps/ channels/ codecs/gsm...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Feb 15 05:12:20 MST 2006
Author: rizzo
Date: Wed Feb 15 06:12:00 2006
New Revision: 10193
URL: http://svn.digium.com/view/asterisk?rev=10193&view=rev
Log:
merge overnight changes
Modified:
team/rizzo/base/UPGRADE.txt
team/rizzo/base/acl.c
team/rizzo/base/app.c
team/rizzo/base/apps/app_meetme.c
team/rizzo/base/apps/app_queue.c
team/rizzo/base/apps/app_sayunixtime.c
team/rizzo/base/apps/app_voicemail.c
team/rizzo/base/asterisk.c
team/rizzo/base/astmm.c
team/rizzo/base/autoservice.c
team/rizzo/base/callerid.c
team/rizzo/base/cdr.c
team/rizzo/base/channel.c
team/rizzo/base/channels/chan_agent.c
team/rizzo/base/channels/chan_sip.c
team/rizzo/base/chanvars.c
team/rizzo/base/cli.c
team/rizzo/base/codecs/gsm/libgsm.vcproj
team/rizzo/base/codecs/ilbc/libilbc.vcproj
team/rizzo/base/codecs/lpc10/liblpc10.vcproj
team/rizzo/base/config.c
team/rizzo/base/configs/extensions.conf.sample
team/rizzo/base/configs/queues.conf.sample
team/rizzo/base/doc/asterisk-conf.txt
team/rizzo/base/doc/channelvariables.txt
team/rizzo/base/doc/enum.txt
team/rizzo/base/enum.c
team/rizzo/base/funcs/func_enum.c
team/rizzo/base/funcs/func_strings.c
team/rizzo/base/include/asterisk.h
team/rizzo/base/include/asterisk/cdr.h
team/rizzo/base/include/asterisk/channel.h
team/rizzo/base/include/asterisk/cli.h
team/rizzo/base/include/asterisk/linkedlists.h
team/rizzo/base/include/asterisk/strings.h
team/rizzo/base/loader.c
team/rizzo/base/pbx.c
team/rizzo/base/res/Makefile
team/rizzo/base/res/res_agi.c
team/rizzo/base/utils.c
Modified: team/rizzo/base/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/UPGRADE.txt?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/UPGRADE.txt (original)
+++ team/rizzo/base/UPGRADE.txt Wed Feb 15 06:12:00 2006
@@ -1,5 +1,12 @@
Information for Upgrading From Previous Asterisk Releases
=========================================================
+
+Command Line Interface:
+
+* 'show channels concise', designed to be used by applications that will parse
+ its output, previously used ':' characters to separate fields. However, some
+ of those fields can easily contain that character, making the output not
+ parseable. The delimiter has been changed to '!'.
Applications:
@@ -40,6 +47,11 @@
modules.conf file then you will need to explicitly load the modules that
contain the functions you want to use.
+* The ENUMLOOKUP() function no longer supplies a default zone for searching; instead,
+ it uses the default zone(s) defined in enum.conf. In addition, when the 'c'
+ option (for counting the number of records is specified), but the lookup fails
+ to match any records, the returned value will now be "0" instead of blank.
+
The SIP channel:
* The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.
Modified: team/rizzo/base/acl.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/acl.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/acl.c (original)
+++ team/rizzo/base/acl.c Wed Feb 15 06:12:00 2006
@@ -113,9 +113,12 @@
/* Create duplicate of ha structure */
static struct ast_ha *ast_duplicate_ha(struct ast_ha *original)
{
- struct ast_ha *new_ha = malloc(sizeof(struct ast_ha));
- /* Copy from original to new object */
- ast_copy_ha(original, new_ha);
+ struct ast_ha *new_ha;
+
+ if ((new_ha = ast_malloc(sizeof(*new_ha)))) {
+ /* Copy from original to new object */
+ ast_copy_ha(original, new_ha);
+ }
return new_ha;
}
@@ -144,19 +147,20 @@
struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path)
{
- struct ast_ha *ha = malloc(sizeof(struct ast_ha));
+ struct ast_ha *ha;
char *nm = "255.255.255.255";
char tmp[256];
struct ast_ha *prev = NULL;
struct ast_ha *ret;
int x, z;
unsigned int y;
+
ret = path;
while (path) {
prev = path;
path = path->next;
}
- if (ha) {
+ if ((ha = ast_malloc(sizeof(*ha)))) {
ast_copy_string(tmp, stuff, sizeof(tmp));
nm = strchr(tmp, '/');
if (!nm) {
Modified: team/rizzo/base/app.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/app.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/app.c (original)
+++ team/rizzo/base/app.c Wed Feb 15 06:12:00 2006
@@ -425,9 +425,7 @@
return -1;
}
}
- lin = malloc(sizeof(struct linear_state));
- if (lin) {
- memset(lin, 0, sizeof(lin));
+ if ((lin = ast_calloc(1, sizeof(*lin)))) {
lin->fd = fd;
lin->allowoverride = allowoverride;
lin->autoclose = autoclose;
@@ -1153,12 +1151,10 @@
char *fs;
int res;
int fd;
+ int lp = strlen(path);
time_t start;
- s = alloca(strlen(path) + 10);
- fs = alloca(strlen(path) + 20);
-
- if (!fs || !s) {
+ if (!(s = alloca(lp + 10)) || !(fs = alloca(lp + 20))) {
ast_log(LOG_WARNING, "Out of memory!\n");
return AST_LOCK_FAILURE;
}
@@ -1188,8 +1184,7 @@
int ast_unlock_path(const char *path)
{
char *s;
- s = alloca(strlen(path) + 10);
- if (!s)
+ if (!(s = alloca(strlen(path) + 10)))
return -1;
snprintf(s, strlen(path) + 9, "%s/%s", path, ".lock");
ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
@@ -1515,8 +1510,7 @@
ast_log(LOG_WARNING, "Cannot open file '%s' for reading: %s\n", filename, strerror(errno));
return NULL;
}
- output=(char *)malloc(count);
- if (output) {
+ if ((output = ast_malloc(count))) {
res = read(fd, output, count - 1);
if (res == count - 1) {
output[res] = '\0';
@@ -1525,8 +1519,7 @@
free(output);
output = NULL;
}
- } else
- ast_log(LOG_WARNING, "Out of memory!\n");
+ }
close(fd);
return output;
}
Modified: team/rizzo/base/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_meetme.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/apps/app_meetme.c (original)
+++ team/rizzo/base/apps/app_meetme.c Wed Feb 15 06:12:00 2006
@@ -1388,9 +1388,10 @@
if (!menu_active) {
menu_active = 1;
/* Record this sound! */
- if (!ast_streamfile(chan, "conf-adminmenu", chan->language))
+ if (!ast_streamfile(chan, "conf-adminmenu", chan->language)) {
dtmf = ast_waitstream(chan, AST_DIGIT_ANY);
- else
+ ast_stopstream(chan);
+ } else
dtmf = 0;
} else
dtmf = f->subclass;
@@ -1467,9 +1468,10 @@
/* User menu */
if (!menu_active) {
menu_active = 1;
- if (!ast_streamfile(chan, "conf-usermenu", chan->language))
+ if (!ast_streamfile(chan, "conf-usermenu", chan->language)) {
dtmf = ast_waitstream(chan, AST_DIGIT_ANY);
- else
+ ast_stopstream(chan);
+ } else
dtmf = 0;
} else
dtmf = f->subclass;
Modified: team/rizzo/base/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_queue.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/apps/app_queue.c (original)
+++ team/rizzo/base/apps/app_queue.c Wed Feb 15 06:12:00 2006
@@ -261,8 +261,8 @@
use it not only for keeping track of what is in use but
also for keeping track of who we're dialing. */
-struct queue_localuser {
- struct queue_localuser *q_next;
+struct callattempt {
+ struct callattempt *q_next;
struct ast_channel *chan;
char interface[256];
int stillgoing;
@@ -273,7 +273,6 @@
};
LOCAL_USER_DECL;
-
struct queue_ent {
struct ast_call_queue *parent; /*!< What queue is our parent */
@@ -325,6 +324,7 @@
unsigned int joinempty:2;
unsigned int eventwhencalled:1;
unsigned int leavewhenempty:2;
+ unsigned int ringinuse:1;
unsigned int reportholdtime:1;
unsigned int wrapped:1;
unsigned int timeoutrestart:1;
@@ -574,6 +574,7 @@
q->announceholdtime = 0;
q->roundingseconds = 0; /* Default - don't announce seconds */
q->servicelevel = 0;
+ q->ringinuse = 1;
q->moh[0] = '\0';
q->announce[0] = '\0';
q->context[0] = '\0';
@@ -625,6 +626,8 @@
q->timeout = atoi(val);
if (q->timeout < 0)
q->timeout = DEFAULT_TIMEOUT;
+ } else if (!strcasecmp(param, "ringinuse")) {
+ q->ringinuse = ast_true(val);
} else if (!strcasecmp(param, "monitor-join")) {
q->monjoin = ast_true(val);
} else if (!strcasecmp(param, "monitor-format")) {
@@ -1033,11 +1036,11 @@
q->count++;
res = 0;
manager_event(EVENT_FLAG_CALL, "Join",
- "Channel: %s\r\nCallerID: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\n",
+ "Channel: %s\r\nCallerID: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\nUniqueid: %s\r\n",
qe->chan->name,
qe->chan->cid.cid_num ? qe->chan->cid.cid_num : "unknown",
qe->chan->cid.cid_name ? qe->chan->cid.cid_name : "unknown",
- q->name, qe->pos, q->count );
+ q->name, qe->pos, q->count, qe->chan->uniqueid );
#if 0
ast_log(LOG_NOTICE, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
#endif
@@ -1262,9 +1265,9 @@
}
/* Hang up a list of outgoing calls */
-static void hangupcalls(struct queue_localuser *outgoing, struct ast_channel *exception)
-{
- struct queue_localuser *oo;
+static void hangupcalls(struct callattempt *outgoing, struct ast_channel *exception)
+{
+ struct callattempt *oo;
while(outgoing) {
/* Hangup any existing lines we have open */
@@ -1353,14 +1356,14 @@
}
/*! \brief common hangup actions */
-static void do_hang(struct queue_localuser *o)
+static void do_hang(struct callattempt *o)
{
o->stillgoing = 0;
ast_hangup(o->chan);
o->chan = NULL;
}
-static int ring_entry(struct queue_ent *qe, struct queue_localuser *tmp, int *busies)
+static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies)
{
int res;
int status;
@@ -1377,7 +1380,16 @@
(*busies)++;
return 0;
}
-
+
+ if (!qe->parent->ringinuse && (tmp->member->status == AST_DEVICE_INUSE)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s in use, can't receive call\n", tmp->interface);
+ if (qe->chan->cdr)
+ ast_cdr_busy(qe->chan->cdr);
+ tmp->stillgoing = 0;
+ return 0;
+ }
+
if (tmp->member->paused) {
if (option_debug)
ast_log(LOG_DEBUG, "%s paused, can't receive call\n", tmp->interface);
@@ -1471,9 +1483,9 @@
}
/*! \brief find the entry with the best metric, or NULL */
-static struct queue_localuser *find_best(struct queue_localuser *outgoing)
-{
- struct queue_localuser *best = NULL, *cur;
+static struct callattempt *find_best(struct callattempt *outgoing)
+{
+ struct callattempt *best = NULL, *cur;
for (cur = outgoing; cur; cur = cur->q_next) {
if (cur->stillgoing && /* Not already done */
@@ -1485,19 +1497,19 @@
return best;
}
-static int ring_one(struct queue_ent *qe, struct queue_localuser *outgoing, int *busies)
+static int ring_one(struct queue_ent *qe, struct callattempt *outgoing, int *busies)
{
int ret = 0;
while (ret == 0) {
- struct queue_localuser *best = find_best(outgoing);
+ struct callattempt *best = find_best(outgoing);
if (!best) {
if (option_debug)
ast_log(LOG_DEBUG, "Nobody left to try ringing in queue\n");
break;
}
if (!qe->parent->strategy) {
- struct queue_localuser *cur;
+ struct callattempt *cur;
/* Ring everyone who shares this best metric (for ringall) */
for (cur = outgoing; cur; cur = cur->q_next) {
if (cur->stillgoing && !cur->chan && cur->metric <= best->metric) {
@@ -1518,9 +1530,9 @@
return ret;
}
-static int store_next(struct queue_ent *qe, struct queue_localuser *outgoing)
-{
- struct queue_localuser *best = find_best(outgoing);
+static int store_next(struct queue_ent *qe, struct callattempt *outgoing)
+{
+ struct callattempt *best = find_best(outgoing);
if (best) {
/* Ring just the best channel */
@@ -1616,11 +1628,10 @@
#define AST_MAX_WATCHERS 256
-static struct queue_localuser *wait_for_answer(struct queue_ent *qe, struct queue_localuser *outgoing, int *to, char *digit, int prebusies, int caller_disconnect)
+static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callattempt *outgoing, int *to, char *digit, int prebusies, int caller_disconnect)
{
char *queue = qe->parent->name;
- struct queue_localuser *o;
- char on[256] = "";
+ struct callattempt *o;
int status;
int sentringing = 0;
int numbusies = prebusies;
@@ -1628,9 +1639,10 @@
int stillgoing = 0;
int orig = *to;
struct ast_frame *f;
- struct queue_localuser *peer = NULL;
+ struct callattempt *peer = NULL;
struct ast_channel *winner;
struct ast_channel *in = qe->chan;
+ char on[256] = "";
while(*to && !peer) {
int numlines, retry, pos = 1;
@@ -1844,7 +1856,6 @@
}
return peer;
-
}
static int is_our_turn(struct queue_ent *qe)
@@ -1940,7 +1951,7 @@
return 0;
}
-static int calc_metric(struct ast_call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct queue_localuser *tmp)
+static int calc_metric(struct ast_call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct callattempt *tmp)
{
if (mem->penalty > qe->max_penalty)
return -1;
@@ -1998,7 +2009,7 @@
static int try_calling(struct queue_ent *qe, const char *options, char *announceoverride, const char *url, int *go_on)
{
struct member *cur;
- struct queue_localuser *outgoing=NULL; /* the queue we are building */
+ struct callattempt *outgoing=NULL; /* the queue we are building */
int to;
char restofit[AST_MAX_EXTENSION];
char oldexten[AST_MAX_EXTENSION]="";
@@ -2007,7 +2018,7 @@
char *newnum;
struct ast_channel *peer;
struct ast_channel *which;
- struct queue_localuser *lpeer;
+ struct callattempt *lpeer;
struct member *member;
int res = 0, bridge = 0;
int numbusies = 0;
@@ -2066,7 +2077,7 @@
announce = announceoverride;
for (;cur; cur = cur->next) {
- struct queue_localuser *tmp = ast_calloc(1, sizeof(*tmp));
+ struct callattempt *tmp = ast_calloc(1, sizeof(*tmp));
if (!tmp) {
ast_mutex_unlock(&qe->parent->lock);
if (use_weight)
@@ -2123,7 +2134,6 @@
if (!peer) {
if (to) {
/* Must gotten hung up */
- record_abandoned(qe);
res = -1;
} else {
res = digit;
Modified: team/rizzo/base/apps/app_sayunixtime.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_sayunixtime.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/apps/app_sayunixtime.c (original)
+++ team/rizzo/base/apps/app_sayunixtime.c Wed Feb 15 06:12:00 2006
@@ -2,6 +2,7 @@
* Asterisk -- An open source telephony toolkit.
*
* Copyright (c) 2003 Tilghman Lesher. All rights reserved.
+ * Copyright (c) 2006 Digium, Inc.
*
* Tilghman Lesher <app_sayunixtime__200309 at the-tilghman.com>
*
@@ -40,7 +41,7 @@
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/say.h"
-
+#include "asterisk/app.h"
static char *tdesc = "Say time";
@@ -70,34 +71,39 @@
static int sayunixtime_exec(struct ast_channel *chan, void *data)
{
- int res=0;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(timeval);
+ AST_APP_ARG(timezone);
+ AST_APP_ARG(format);
+ );
+ char *parse;
+ int res = 0;
struct localuser *u;
- char *s,*zone=NULL,*timec,*format;
time_t unixtime;
- s = ast_strdupa(data);
- if (!s)
- return data ? -1 : 0;
+ if (!data)
+ return 0;
+
+ if (!(parse = ast_strdupa(data)))
+ return -1;
+
LOCAL_USER_ADD(u);
- format = "c"; /* default datetime */
+ args.format = "c"; /* default datetime */
- timec = strsep(&s,"|");
- ast_get_time_t(timec, &unixtime, time(NULL));
- if (s) {
- zone = strsep(&s,"|");
- if (ast_strlen_zero(zone))
- zone = NULL;
- }
- if (s) /* override format */
- format = s;
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ ast_get_time_t(args.timeval, &unixtime, time(NULL));
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
+
if (!res)
- res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY, chan->language, format, zone);
+ res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY,
+ chan->language, args.format, args.timezone);
LOCAL_USER_REMOVE(u);
+
return res;
}
Modified: team/rizzo/base/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_voicemail.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/apps/app_voicemail.c (original)
+++ team/rizzo/base/apps/app_voicemail.c Wed Feb 15 06:12:00 2006
@@ -240,7 +240,7 @@
unsigned int flags; /*!< VM_ flags */
int saydurationm;
int maxmsg; /*!< Maximum number of msgs per folder for this mailbox */
- struct ast_vm_user *next;
+ AST_LIST_ENTRY(ast_vm_user) list;
};
struct vm_zone {
@@ -386,9 +386,7 @@
static char *app3 = "MailboxExists";
static char *app4 = "VMAuthenticate";
-AST_MUTEX_DEFINE_STATIC(vmlock);
-struct ast_vm_user *users;
-struct ast_vm_user *usersl;
+static AST_LIST_HEAD_STATIC(users, ast_vm_user);
struct vm_zone *zones = NULL;
struct vm_zone *zonesl = NULL;
static int maxsilence;
@@ -584,29 +582,27 @@
{
/* This function could be made to generate one from a database, too */
struct ast_vm_user *vmu=NULL, *cur;
- ast_mutex_lock(&vmlock);
- cur = users;
+ AST_LIST_LOCK(&users);
if (!context && !ast_test_flag((&globalflags), VM_SEARCH))
context = "default";
- while (cur) {
+ AST_LIST_TRAVERSE(&users, cur, list) {
if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mailbox, cur->mailbox))
break;
if (context && (!strcasecmp(context, cur->context)) && (!strcasecmp(mailbox, cur->mailbox)))
break;
- cur=cur->next;
}
if (cur) {
/* 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;
+ ast_set2_flag(vmu, !ivm, VM_ALLOCED);
+ AST_LIST_NEXT(vmu, list) = NULL;
}
} else
vmu = find_user_realtime(ivm, context, mailbox);
- ast_mutex_unlock(&vmlock);
+ AST_LIST_UNLOCK(&users);
return vmu;
}
@@ -615,19 +611,17 @@
/* This function could be made to generate one from a database, too */
struct ast_vm_user *cur;
int res = -1;
- ast_mutex_lock(&vmlock);
- cur = users;
- while (cur) {
+ AST_LIST_LOCK(&users);
+ AST_LIST_TRAVERSE(&users, cur, list) {
if ((!context || !strcasecmp(context, cur->context)) &&
(!strcasecmp(mailbox, cur->mailbox)))
break;
- cur=cur->next;
}
if (cur) {
ast_copy_string(cur->password, newpass, sizeof(cur->password));
res = 0;
}
- ast_mutex_unlock(&vmlock);
+ AST_LIST_UNLOCK(&users);
return res;
}
@@ -3358,7 +3352,8 @@
char callerid[512];
char ext_context[256]="";
int res = 0, cmd = 0;
- struct ast_vm_user *receiver = NULL, *extensions = NULL, *vmtmp = NULL, *vmfree;
+ struct ast_vm_user *receiver = NULL, *vmtmp;
+ AST_LIST_HEAD_NOLOCK(extension, ast_vm_user) extensions;
char tmp[256];
char *stringp, *s;
int saved_messages = 0, found = 0;
@@ -3454,12 +3449,7 @@
while (s) {
/* find_user is going to ast_malloc since we have a NULL as first argument */
if ((receiver = find_user(NULL, context, s))) {
- if (!extensions)
- vmtmp = extensions = receiver;
- else {
- vmtmp->next = receiver;
- vmtmp = receiver;
- }
+ AST_LIST_INSERT_HEAD(&extensions, receiver, list);
found++;
} else {
valid_extensions = 0;
@@ -3474,9 +3464,8 @@
res = ast_play_and_wait(chan, "pbx-invalid");
}
/* check if we're clear to proceed */
- if (!extensions || !valid_extensions)
+ if (AST_LIST_EMPTY(&extensions) || !valid_extensions)
return res;
- vmtmp = extensions;
if (flag==1) {
struct leave_vm_options leave_options;
@@ -3490,7 +3479,7 @@
RETRIEVE(dir, curmsg);
cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context, record_gain);
if (!cmd) {
- while (!res && vmtmp) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) {
/* if (ast_play_and_wait(chan, "vm-savedto"))
break;
*/
@@ -3562,10 +3551,12 @@
run_externnotify(vmtmp->context, vmtmp->mailbox);
saved_messages++;
- vmfree = vmtmp;
- vmtmp = vmtmp->next;
- free_user(vmfree);
- }
+ AST_LIST_REMOVE_CURRENT(&extensions, list);
+ free_user(vmtmp);
+ if (res)
+ break;
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
if (saved_messages > 0) {
/* give confirmation that the message was saved */
/* commented out since we can't forward batches yet
@@ -5636,12 +5627,7 @@
if (stringp && (s = strsep(&stringp, ",")))
apply_options(vmu, s);
- vmu->next = NULL;
- if (usersl)
- usersl->next = vmu;
- else
- users = vmu;
- usersl = vmu;
+ AST_LIST_INSERT_TAIL(&users, vmu, list);
}
return 0;
}
@@ -5743,31 +5729,31 @@
static int handle_show_voicemail_users(int fd, int argc, char *argv[])
{
- struct ast_vm_user *vmu = users;
+ struct ast_vm_user *vmu;
char *output_format = "%-10s %-5s %-25s %-10s %6s\n";
if ((argc < 3) || (argc > 5) || (argc == 4)) return RESULT_SHOWUSAGE;
else if ((argc == 5) && strcmp(argv[3],"for")) return RESULT_SHOWUSAGE;
- if (vmu) {
+ AST_LIST_LOCK(&users);
+ if (!AST_LIST_EMPTY(&users)) {
if (argc == 3)
ast_cli(fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
else {
int count = 0;
- while (vmu) {
+ AST_LIST_TRAVERSE(&users, vmu, list) {
if (!strcmp(argv[4],vmu->context))
count++;
- vmu = vmu->next;
}
if (count) {
- vmu = users;
ast_cli(fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
} else {
ast_cli(fd, "No such voicemail context \"%s\"\n", argv[4]);
+ AST_LIST_UNLOCK(&users);
return RESULT_FAILURE;
}
}
- while (vmu) {
+ AST_LIST_TRAVERSE(&users, vmu, list) {
char dirname[256];
DIR *vmdir;
struct dirent *vment;
@@ -5786,12 +5772,13 @@
snprintf(count,sizeof(count),"%d",vmcount);
ast_cli(fd, output_format, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count);
}
- vmu = vmu->next;
}
} else {
ast_cli(fd, "There are no voicemail users currently defined\n");
+ AST_LIST_UNLOCK(&users);
return RESULT_FAILURE;
}
+ AST_LIST_UNLOCK(&users);
return RESULT_SUCCESS;
}
@@ -5828,7 +5815,7 @@
if (pos == 3)
return (state == 0) ? ast_strdup("for") : NULL;
wordlen = strlen(word);
- for (vmu = users; vmu; vmu = vmu->next) {
+ AST_LIST_TRAVERSE(&users, vmu, list) {
if (!strncasecmp(word, vmu->context, wordlen)) {
if (context && strcmp(context, vmu->context)) {
if (++which > state) {
@@ -5854,7 +5841,7 @@
static int load_config(void)
{
- struct ast_vm_user *cur, *l;
+ struct ast_vm_user *cur;
struct vm_zone *zcur, *zl;
struct ast_config *cfg;
char *cat;
@@ -5890,14 +5877,13 @@
int tmpadsi[4];
cfg = ast_config_load(VOICEMAIL_CONFIG);
- ast_mutex_lock(&vmlock);
- cur = users;
- while (cur) {
- l = cur;
- cur = cur->next;
- ast_set_flag(l, VM_ALLOCED);
- free_user(l);
- }
+ AST_LIST_LOCK(&users);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&users, cur, list) {
+ AST_LIST_REMOVE_CURRENT(&users, list);
+ ast_set_flag(cur, VM_ALLOCED);
+ free_user(cur);
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
zcur = zones;
while (zcur) {
zl = zcur;
@@ -5906,8 +5892,7 @@
}
zones = NULL;
zonesl = NULL;
- users = NULL;
- usersl = NULL;
+ AST_LIST_HEAD_INIT(&users);
memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
if (cfg) {
@@ -6298,11 +6283,11 @@
tmpread = tmpwrite+len;
}
}
- ast_mutex_unlock(&vmlock);
+ AST_LIST_UNLOCK(&users);
ast_config_destroy(cfg);
return 0;
} else {
- ast_mutex_unlock(&vmlock);
+ AST_LIST_UNLOCK(&users);
ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
return 0;
}
Modified: team/rizzo/base/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/asterisk.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/asterisk.c (original)
+++ team/rizzo/base/asterisk.c Wed Feb 15 06:12:00 2006
@@ -79,6 +79,10 @@
#endif
#include <regex.h>
+#ifdef linux
+#include <sys/prctl.h>
+#endif
+
#if defined(__FreeBSD__) || defined( __NetBSD__ ) || defined(SOLARIS)
#include <netdb.h>
#endif
@@ -213,6 +217,7 @@
char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH] = "\0";
char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH] = "\0";
char ast_config_AST_CTL[AST_CONFIG_MAX_PATH] = "asterisk.ctl";
+char ast_config_AST_SYSTEM_NAME[20]="";
static char *_argv[256];
static int shuttingdown = 0;
@@ -240,8 +245,7 @@
work = ast_strip(ast_strip_quoted(work, "$", "$"));
version_length = strlen(work) + 1;
- new = calloc(1, sizeof(*new) + version_length);
- if (!new)
+ if (!(new = ast_calloc(1, sizeof(*new) + version_length)))
return;
new->file = file;
@@ -416,10 +420,8 @@
int res = -1;
struct ast_atexit *ae;
ast_unregister_atexit(func);
- ae = malloc(sizeof(struct ast_atexit));
AST_LIST_LOCK(&atexits);
- if (ae) {
- memset(ae, 0, sizeof(struct ast_atexit));
+ if ((ae = ast_calloc(1, sizeof(*ae)))) { /* XXX prob. alloc outside the lock */
AST_LIST_INSERT_HEAD(&atexits, ae, list);
ae->func = func;
res = 0;
@@ -1411,7 +1413,7 @@
}
break;
case 'd': /* date */
- memset(&tm, 0, sizeof(struct tm));
+ memset(&tm, 0, sizeof(tm));
time(&ts);
if (localtime_r(&ts, &tm)) {
strftime(p, sizeof(prompt) - strlen(prompt), "%Y-%m-%d", &tm);
@@ -1468,7 +1470,7 @@
break;
#endif
case 't': /* time */
- memset(&tm, 0, sizeof(struct tm));
+ memset(&tm, 0, sizeof(tm));
time(&ts);
if (localtime_r(&ts, &tm)) {
strftime(p, sizeof(prompt) - strlen(prompt), "%H:%M:%S", &tm);
@@ -1528,7 +1530,9 @@
break;
if (matches + 1 >= match_list_len) {
match_list_len <<= 1;
- match_list = realloc(match_list, match_list_len * sizeof(char *));
+ if (!(match_list = ast_realloc(match_list, match_list_len * sizeof(char *)))) {
+ /* TODO: Handle memory allocation failure */
+ }
}
match_list[matches++] = strdup(retstr);
@@ -1537,8 +1541,11 @@
if (!match_list)
return (char **) NULL;
- if (matches>= match_list_len)
- match_list = realloc(match_list, (match_list_len + 1) * sizeof(char *));
+ if (matches >= match_list_len) {
+ if (!(match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(char *)))) {
+ /* TODO: Handle memory allocation failure */
+ }
+ }
match_list[matches] = (char *) NULL;
@@ -1640,8 +1647,7 @@
char *mbuf;
int mlen = 0, maxmbuf = 2048;
/* Start with a 2048 byte buffer */
- mbuf = malloc(maxmbuf);
- if (!mbuf)
+ if (!(mbuf = ast_malloc(maxmbuf)))
return (char *)(CC_ERROR);
snprintf(buf, sizeof(buf),"_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr);
fdprint(ast_consock, buf);
@@ -1651,8 +1657,7 @@
if (mlen + 1024 > maxmbuf) {
/* Every step increment buffer 1024 bytes */
maxmbuf += 1024;
- mbuf = realloc(mbuf, maxmbuf);
- if (!mbuf)
+ if (!(mbuf = ast_realloc(mbuf, maxmbuf)))
return (char *)(CC_ERROR);
}
/* Only read 1024 bytes at a time */
@@ -2045,6 +2050,8 @@
/* What group to run as */
} else if (!strcasecmp(v->name, "rungroup")) {
ast_copy_string(ast_config_AST_RUN_GROUP, v->value, sizeof(ast_config_AST_RUN_GROUP));
+ } else if (!strcasecmp(v->name, "systemname")) {
+ ast_copy_string(ast_config_AST_SYSTEM_NAME, v->value, sizeof(ast_config_AST_SYSTEM_NAME));
}
v = v->next;
}
@@ -2260,13 +2267,13 @@
#endif /* __CYGWIN__ */
+#ifdef linux
if (geteuid() && ast_opt_dump_core) {
-#ifdef linux
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) {
ast_log(LOG_WARNING, "Unable to set the process for core dumps after changing to a non-root user. %s\n", strerror(errno));
}
+ }
#endif
- }
term_init();
printf(term_end());
Modified: team/rizzo/base/astmm.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/astmm.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/astmm.c (original)
+++ team/rizzo/base/astmm.c Wed Feb 15 06:12:00 2006
@@ -41,13 +41,15 @@
#define SOME_PRIME 563
-#define FUNC_CALLOC 1
-#define FUNC_MALLOC 2
-#define FUNC_REALLOC 3
-#define FUNC_STRDUP 4
-#define FUNC_STRNDUP 5
-#define FUNC_VASPRINTF 6
-#define FUNC_ASPRINTF 7
+enum func_type {
+ FUNC_CALLOC = 1,
+ FUNC_MALLOC,
+ FUNC_REALLOC,
+ FUNC_STRDUP,
+ FUNC_STRNDUP,
+ FUNC_VASPRINTF,
+ FUNC_ASPRINTF
+};
/* Undefine all our macros */
#undef malloc
@@ -68,7 +70,7 @@
char file[40];
char func[40];
int lineno;
- int which;
+ enum func_type which;
size_t len;
unsigned int fence;
unsigned char data[0];
@@ -80,13 +82,13 @@
AST_MUTEX_DEFINE_STATIC(reglock);
AST_MUTEX_DEFINE_STATIC(showmemorylock);
-static inline void *__ast_alloc_region(size_t size, int which, const char *file, int lineno, const char *func)
+static inline void *__ast_alloc_region(size_t size, const enum func_type which, const char *file, int lineno, const char *func)
{
struct ast_region *reg;
void *ptr = NULL;
unsigned int *fence;
int hash;
- reg = malloc(size + sizeof(struct ast_region) + sizeof(unsigned int));
+ reg = malloc(size + sizeof(*reg) + sizeof(*fence));
ast_mutex_lock(®lock);
if (reg) {
ast_copy_string(reg->file, file, sizeof(reg->file));
@@ -106,9 +108,9 @@
}
ast_mutex_unlock(®lock);
if (!reg) {
- fprintf(stderr, "Out of memory :(\n");
+ fprintf(stderr, "Memory allocation failure\n");
if (mmlog) {
- fprintf(mmlog, "%ld - Out of memory\n", time(NULL));
+ fprintf(mmlog, "%ld - Memory allocation failure\n", time(NULL));
fflush(mmlog);
}
}
@@ -184,8 +186,7 @@
void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
{
void *ptr;
- ptr = __ast_alloc_region(size * nmemb, FUNC_CALLOC, file, lineno, func);
- if (ptr)
+ if ((ptr = __ast_alloc_region(size * nmemb, FUNC_CALLOC, file, lineno, func)))
memset(ptr, 0, size * nmemb);
return ptr;
}
@@ -204,19 +205,15 @@
{
void *tmp;
size_t len = 0;
- if (ptr) {
- len = __ast_sizeof_region(ptr);
- if (!len) {
- fprintf(stderr, "WARNING: Realloc of unalloced memory at %p, in %s of %s, line %d\n", ptr, func, file, lineno);
- if (mmlog) {
- fprintf(mmlog, "%ld - WARNING: Realloc of unalloced memory at %p, in %s of %s, line %d\n", time(NULL), ptr, func, file, lineno);
- fflush(mmlog);
- }
- return NULL;
- }
- }
- tmp = __ast_alloc_region(size, FUNC_REALLOC, file, lineno, func);
- if (tmp) {
+ if (ptr && !(len = __ast_sizeof_region(ptr))) {
+ fprintf(stderr, "WARNING: Realloc of unalloced memory at %p, in %s of %s, line %d\n", ptr, func, file, lineno);
+ if (mmlog) {
+ fprintf(mmlog, "%ld - WARNING: Realloc of unalloced memory at %p, in %s of %s, line %d\n", time(NULL), ptr, func, file, lineno);
+ fflush(mmlog);
+ }
+ return NULL;
+ }
+ if ((tmp = __ast_alloc_region(size, FUNC_REALLOC, file, lineno, func))) {
if (len > size)
len = size;
if (ptr) {
@@ -234,8 +231,7 @@
if (!s)
return NULL;
len = strlen(s) + 1;
- ptr = __ast_alloc_region(len, FUNC_STRDUP, file, lineno, func);
- if (ptr)
+ if ((ptr = __ast_alloc_region(len, FUNC_STRDUP, file, lineno, func)))
strcpy(ptr, s);
return ptr;
}
@@ -249,8 +245,7 @@
len = strlen(s) + 1;
if (len > n)
len = n;
- ptr = __ast_alloc_region(len, FUNC_STRNDUP, file, lineno, func);
- if (ptr)
+ if ((ptr = __ast_alloc_region(len, FUNC_STRNDUP, file, lineno, func)))
strcpy(ptr, s);
return ptr;
}
@@ -266,8 +261,7 @@
va_copy(ap2, ap);
size = vsnprintf(&s, 1, fmt, ap2);
va_end(ap2);
- *strp = __ast_alloc_region(size + 1, FUNC_ASPRINTF, file, lineno, func);
- if (!*strp) {
+ if (!(*strp = __ast_alloc_region(size + 1, FUNC_ASPRINTF, file, lineno, func))) {
va_end(ap);
return -1;
}
@@ -287,8 +281,7 @@
va_copy(ap2, ap);
size = vsnprintf(&s, 1, fmt, ap2);
va_end(ap2);
- *strp = __ast_alloc_region(size + 1, FUNC_VASPRINTF, file, lineno, func);
- if (!*strp) {
+ if (!(*strp = __ast_alloc_region(size + 1, FUNC_VASPRINTF, file, lineno, func))) {
va_end(ap);
return -1;
}
@@ -377,8 +370,8 @@
cur = cur->next;
}
if (!cur) {
- cur = alloca(sizeof(struct file_summary));
- memset(cur, 0, sizeof(struct file_summary));
+ cur = alloca(sizeof(*cur));
+ memset(cur, 0, sizeof(*cur));
ast_copy_string(cur->fn, fn ? reg->func : reg->file, sizeof(cur->fn));
cur->next = list;
list = cur;
Modified: team/rizzo/base/autoservice.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/autoservice.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/autoservice.c (original)
+++ team/rizzo/base/autoservice.c Wed Feb 15 06:12:00 2006
@@ -107,23 +107,20 @@
/* XXX if found, we return -1, why ??? */
/* If not, start autoservice on channel */
- if (!as) {
- as = calloc(1, sizeof(struct asent));
- if (as) {
- as->chan = chan;
- AST_LIST_INSERT_HEAD(&aslist, as, list);
- res = 0;
- if (asthread == AST_PTHREADT_NULL) { /* need start the thread */
- if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
- ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
- /* There will only be a single member in the list at this point,
- the one we just added. */
- AST_LIST_REMOVE(&aslist, as, list);
- free(as);
- res = -1;
- } else
- pthread_kill(asthread, SIGURG);
- }
+ if (!as && (as = ast_calloc(1, sizeof(*as)))) {
+ as->chan = chan;
+ AST_LIST_INSERT_HEAD(&aslist, as, list);
+ res = 0;
+ if (asthread == AST_PTHREADT_NULL) { /* need start the thread */
+ if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
+ ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
+ /* There will only be a single member in the list at this point,
+ the one we just added. */
+ AST_LIST_REMOVE(&aslist, as, list);
+ free(as);
+ res = -1;
+ } else
+ pthread_kill(asthread, SIGURG);
}
}
AST_LIST_UNLOCK(&aslist);
Modified: team/rizzo/base/callerid.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/callerid.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/callerid.c (original)
+++ team/rizzo/base/callerid.c Wed Feb 15 06:12:00 2006
@@ -131,32 +131,29 @@
struct callerid_state *callerid_new(int cid_signalling)
{
struct callerid_state *cid;
- cid = malloc(sizeof(struct callerid_state));
- if (cid) {
- memset(cid, 0, sizeof(struct callerid_state));
- cid->fskd.spb = 7; /* 1200 baud */
- cid->fskd.hdlc = 0; /* Async */
- cid->fskd.nbit = 8; /* 8 bits */
- cid->fskd.nstop = 1; /* 1 stop bit */
- cid->fskd.paridad = 0; /* No parity */
- cid->fskd.bw=1; /* Filter 800 Hz */
- if (cid_signalling == 2) { /* v23 signalling */
+
+ if ((cid = ast_calloc(1, sizeof(*cid)))) {
+ cid->fskd.spb = 7.0; /* 1200 baud */
+ /* cid->fskd.hdlc = 0; */ /* Async */
+ cid->fskd.nbit = 8; /* 8 bits */
+ cid->fskd.nstop = 1.0; /* 1 stop bit */
+ /* cid->fskd.paridad = 0; */ /* No parity */
+ cid->fskd.bw = 1; /* Filter 800 Hz */
+ if (cid_signalling == 2) { /* v23 signalling */
cid->fskd.f_mark_idx = 4; /* 1300 Hz */
cid->fskd.f_space_idx = 5; /* 2100 Hz */
- } else { /* Bell 202 signalling as default */
+ } else { /* Bell 202 signalling as default */
cid->fskd.f_mark_idx = 2; /* 1200 Hz */
cid->fskd.f_space_idx = 3; /* 2200 Hz */
}
- cid->fskd.pcola = 0; /* No clue */
- cid->fskd.cont = 0; /* Digital PLL reset */
- cid->fskd.x0 = 0.0;
- cid->fskd.state = 0;
- memset(cid->name, 0, sizeof(cid->name));
- memset(cid->number, 0, sizeof(cid->number));
+ /* cid->fskd.pcola = 0; */ /* No clue */
+ /* cid->fskd.cont = 0.0; */ /* Digital PLL reset */
+ /* cid->fskd.x0 = 0.0; */
+ /* cid->fskd.state = 0; */
cid->flags = CID_UNKNOWN_NAME | CID_UNKNOWN_NUMBER;
- cid->pos = 0;
- } else
- ast_log(LOG_WARNING, "Out of memory\n");
+ /* cid->pos = 0; */
+ }
+
return cid;
}
@@ -284,15 +281,14 @@
int b2 ;
int res;
int x;
- short *buf = malloc(2 * len + cid->oldlen);
- short *obuf = buf;
-
- if (!buf) {
- ast_log(LOG_WARNING, "Out of memory\n");
+ short *buf;
+ short *obuf;
+
+ if (!(buf = ast_calloc(1, 2 * len + cid->oldlen))) {
return -1;
}
- memset(buf, 0, 2 * len + cid->oldlen);
+ obuf = buf;
memcpy(buf, cid->oldstuff, cid->oldlen);
mylen += cid->oldlen/2;
@@ -534,15 +530,17 @@
int b = 'X';
int res;
int x;
- short *buf = malloc(2 * len + cid->oldlen);
- short *obuf = buf;
- if (!buf) {
- ast_log(LOG_WARNING, "Out of memory\n");
+ short *buf;
+ short *obuf;
+
+ if (!(buf = ast_calloc(1, 2 * len + cid->oldlen))) {
return -1;
}
- memset(buf, 0, 2 * len + cid->oldlen);
+
+ obuf = buf;
memcpy(buf, cid->oldstuff, cid->oldlen);
mylen += cid->oldlen/2;
+
for (x=0;x<len;x++)
buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
while(mylen >= 160) {
Modified: team/rizzo/base/cdr.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/cdr.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/cdr.c (original)
+++ team/rizzo/base/cdr.c Wed Feb 15 06:12:00 2006
@@ -129,8 +129,7 @@
return -1;
}
- i = ast_calloc(1, sizeof(*i));
- if (!i)
+ if (!(i = ast_calloc(1, sizeof(*i))))
return -1;
i->be = be;
@@ -171,7 +170,6 @@
struct ast_cdr *newcdr;
if (!(newcdr = ast_cdr_alloc())) {
- ast_log(LOG_ERROR, "Memory Error!\n");
return NULL;
}
@@ -869,9 +867,7 @@
static int init_batch(void)
{
/* This is the single meta-batch used to keep track of all CDRs during the entire life of the program */
- batch = malloc(sizeof(*batch));
- if (!batch) {
- ast_log(LOG_WARNING, "CDR: out of memory while trying to handle batched records, data will most likely be lost\n");
+ if (!(batch = ast_malloc(sizeof(*batch)))) {
return -1;
}
@@ -980,9 +976,7 @@
ast_log(LOG_DEBUG, "CDR detaching from this thread\n");
/* we'll need a new tail for every CDR */
- newtail = calloc(1, sizeof(*newtail));
- if (!newtail) {
- ast_log(LOG_WARNING, "CDR: out of memory while trying to detach, will try in this thread instead\n");
+ if (!(newtail = ast_calloc(1, sizeof(*newtail)))) {
post_cdr(cdr);
ast_cdr_free(cdr);
return;
Modified: team/rizzo/base/channel.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/channel.c?rev=10193&r1=10192&r2=10193&view=diff
==============================================================================
--- team/rizzo/base/channel.c (original)
+++ team/rizzo/base/channel.c Wed Feb 15 06:12:00 2006
@@ -621,12 +621,10 @@
return NULL;
}
- tmp = ast_calloc(1, sizeof(struct ast_channel));
- if (!tmp)
+ if (!(tmp = ast_calloc(1, sizeof(*tmp))))
return NULL;
- tmp->sched = sched_context_create();
- if (!tmp->sched) {
+ if (!(tmp->sched = sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
free(tmp);
return NULL;
@@ -682,7 +680,10 @@
tmp->fin = global_fin;
tmp->fout = global_fout;
ast_mutex_lock(&uniquelock);
[... 2937 lines stripped ...]
More information about the asterisk-commits
mailing list