[svn-commits] murf: branch murf/fast-ast r53124 - in
/team/murf/fast-ast: apps/ channels/ i...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Fri Feb 2 11:03:38 MST 2007
Author: murf
Date: Fri Feb 2 12:03:37 2007
New Revision: 53124
URL: http://svn.digium.com/view/asterisk?view=rev&rev=53124
Log:
Uh, this experiment will be reverted if I can't get more speed out of it.
Removed:
team/murf/fast-ast/main/hashtab.h
team/murf/fast-ast/main/stringtab.h
Modified:
team/murf/fast-ast/apps/app_dial.c
team/murf/fast-ast/apps/app_directory.c
team/murf/fast-ast/apps/app_macro.c
team/murf/fast-ast/apps/app_parkandannounce.c
team/murf/fast-ast/apps/app_voicemail.c
team/murf/fast-ast/channels/chan_agent.c
team/murf/fast-ast/channels/chan_iax2.c
team/murf/fast-ast/channels/chan_local.c
team/murf/fast-ast/channels/chan_mgcp.c
team/murf/fast-ast/channels/chan_oss.c
team/murf/fast-ast/channels/chan_phone.c
team/murf/fast-ast/channels/chan_sip.c
team/murf/fast-ast/channels/chan_skinny.c
team/murf/fast-ast/channels/chan_zap.c
team/murf/fast-ast/include/asterisk/channel.h
team/murf/fast-ast/main/channel.c
team/murf/fast-ast/main/hashtab.c
team/murf/fast-ast/main/pbx.c
team/murf/fast-ast/main/stringtab.c
team/murf/fast-ast/main/test-hashtab.c
team/murf/fast-ast/res/res_agi.c
team/murf/fast-ast/res/res_features.c
Modified: team/murf/fast-ast/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/apps/app_dial.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/apps/app_dial.c (original)
+++ team/murf/fast-ast/apps/app_dial.c Fri Feb 2 12:03:37 2007
@@ -590,8 +590,8 @@
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
OPT_CALLEE_PARK | OPT_CALLER_PARK |
DIAL_NOFORWARDHTML);
- ast_copy_string(c->context, "", sizeof(c->context));
- ast_copy_string(c->exten, "", sizeof(c->exten));
+ ast_channel_setcontext(c,"");
+ ast_channel_setexten(c,"");
}
continue;
}
@@ -625,8 +625,8 @@
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
OPT_CALLEE_PARK | OPT_CALLER_PARK |
DIAL_NOFORWARDHTML);
- ast_copy_string(c->context, "", sizeof(c->context));
- ast_copy_string(c->exten, "", sizeof(c->exten));
+ ast_channel_setcontext(c,"");
+ ast_channel_setexten(c,"");
/* Setup early bridge if appropriate */
ast_channel_early_bridge(in, peer);
}
@@ -1369,8 +1369,9 @@
ast_app_group_set_channel(tmp->chan, outbound_group);
/* Inherit context and extension */
- ast_copy_string(tmp->chan->context, chan->context, sizeof(tmp->chan->context));
- ast_copy_string(tmp->chan->exten, chan->exten, sizeof(tmp->chan->exten));
+
+ tmp->chan->context = chan->context;
+ tmp->chan->exten = chan->exten;
/* Place the call, but don't wait on the answer */
res = ast_call(tmp->chan, numsubst, 0);
Modified: team/murf/fast-ast/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/apps/app_directory.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/apps/app_directory.c (original)
+++ team/murf/fast-ast/apps/app_directory.c Fri Feb 2 12:03:37 2007
@@ -313,7 +313,7 @@
if (res == '1') { /* Name selected */
if (fromappvm) {
/* We still want to set the exten though */
- ast_copy_string(chan->exten, ext, sizeof(chan->exten));
+ ast_channel_setexten(chan, ext);
} else {
if (ast_goto_if_exists(chan, dialcontext, ext, 1)) {
ast_log(LOG_WARNING,
Modified: team/murf/fast-ast/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/apps/app_macro.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/apps/app_macro.c (original)
+++ team/murf/fast-ast/apps/app_macro.c Fri Feb 2 12:03:37 2007
@@ -190,8 +190,8 @@
ast_copy_string(oldexten, chan->exten, sizeof(oldexten));
ast_copy_string(oldcontext, chan->context, sizeof(oldcontext));
if (ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->macrocontext, chan->context, sizeof(chan->macrocontext));
- ast_copy_string(chan->macroexten, chan->exten, sizeof(chan->macroexten));
+ chan->macrocontext = chan->context;
+ chan->macroexten = chan->exten;
chan->macropriority = chan->priority;
setmacrocontext=1;
}
@@ -211,10 +211,9 @@
pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", NULL);
/* Setup environment for new run */
- chan->exten[0] = 's';
- chan->exten[1] = '\0';
- ast_copy_string(chan->context, fullmacro, sizeof(chan->context));
- chan->priority = 1;
+ ast_channel_setexten(chan,"s");
+ ast_channel_setcontext(chan, fullmacro);
+ ast_channel_setpriority(chan,1);
while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) {
const char *s;
@@ -309,25 +308,25 @@
free(save_macro_priority);
if (!dead && setmacrocontext) {
- chan->macrocontext[0] = '\0';
- chan->macroexten[0] = '\0';
- chan->macropriority = 0;
+ ast_channel_setmacrocontext(chan,"");
+ ast_channel_setmacroexten(chan,"");
+ ast_channel_setmacropriority(chan,0);
}
if (!dead && !strcasecmp(chan->context, fullmacro)) {
/* If we're leaving the macro normally, restore original information */
chan->priority = oldpriority;
- ast_copy_string(chan->context, oldcontext, sizeof(chan->context));
+ ast_channel_setcontext(chan, oldcontext);
if (!(chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO)) {
/* Copy the extension, so long as we're not in softhangup, where we could be given an asyncgoto */
const char *offsets;
- ast_copy_string(chan->exten, oldexten, sizeof(chan->exten));
+ ast_channel_setexten(chan, oldexten);
if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) {
/* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue
normally if there is any problem */
if (sscanf(offsets, "%d", &offset) == 1) {
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + offset + 1, chan->cid.cid_num)) {
- chan->priority += offset;
+ ast_channel_setpriority(chan, chan->priority+offset);
}
}
}
Modified: team/murf/fast-ast/apps/app_parkandannounce.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/apps/app_parkandannounce.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/apps/app_parkandannounce.c (original)
+++ team/murf/fast-ast/apps/app_parkandannounce.c Fri Feb 2 12:03:37 2007
@@ -153,11 +153,11 @@
/* At this point we have a priority and maybe an extension and a context */
chan->priority = atoi(priority);
if (exten)
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_setexten(chan, exten);
if (context)
- ast_copy_string(chan->context, context, sizeof(chan->context));
+ ast_channel_setcontext(chan, context);
} else { /* increment the priority by default*/
- chan->priority++;
+ ast_channel_setpriority(chan, chan->priority+1);
}
if(option_verbose > 2) {
Modified: team/murf/fast-ast/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/apps/app_voicemail.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/apps/app_voicemail.c (original)
+++ team/murf/fast-ast/apps/app_voicemail.c Fri Feb 2 12:03:37 2007
@@ -2936,12 +2936,12 @@
/* Check for a '*' here in case the caller wants to escape from voicemail to something
other than the operator -- an automated attendant or mailbox login for example */
if (res == '*') {
- chan->exten[0] = 'a';
- chan->exten[1] = '\0';
+ ast_channel_setexten(chan, "a");
+
if (!ast_strlen_zero(vmu->exit)) {
- ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
+ ast_channel_setcontext(chan, vmu->exit);
} else if (ausemacro && !ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
+ ast_channel_setcontext(chan, chan->macrocontext);
}
chan->priority = 0;
free_user(vmu);
@@ -2953,12 +2953,12 @@
if (res == '0') {
transfer:
if (ouseexten || ousemacro) {
- chan->exten[0] = 'o';
- chan->exten[1] = '\0';
+ ast_channel_setexten(chan,"o");
+
if (!ast_strlen_zero(vmu->exit)) {
- ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
+ ast_channel_setcontext(chan, vmu->exit);
} else if (ousemacro && !ast_strlen_zero(chan->macrocontext)) {
- ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
+ ast_channel_setcontext(chan, chan->macrocontext);
}
ast_play_and_wait(chan, "transfer");
chan->priority = 0;
@@ -3946,8 +3946,8 @@
if (use_directory) {
/* use app_directory */
- char old_context[sizeof(chan->context)];
- char old_exten[sizeof(chan->exten)];
+ const char *old_context;
+ const char *old_exten;
int old_priority;
struct ast_app* app;
@@ -3956,8 +3956,8 @@
if (app) {
char vmcontext[256];
/* make backup copies */
- memcpy(old_context, chan->context, sizeof(chan->context));
- memcpy(old_exten, chan->exten, sizeof(chan->exten));
+ old_context = chan->context;
+ old_exten = chan->exten;
old_priority = chan->priority;
/* call the the Directory, changes the channel */
@@ -3967,8 +3967,8 @@
ast_copy_string(username, chan->exten, sizeof(username));
/* restore the old context, exten, and priority */
- memcpy(chan->context, old_context, sizeof(chan->context));
- memcpy(chan->exten, old_exten, sizeof(chan->exten));
+ chan->context = old_context;
+ chan->exten = old_exten;
chan->priority = old_priority;
} else {
@@ -7669,9 +7669,9 @@
return 0;
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, chan->context);
- ast_copy_string(chan->exten, destination, sizeof(chan->exten));
- ast_copy_string(chan->context, outgoing_context, sizeof(chan->context));
- chan->priority = 0;
+ ast_channel_setexten(chan, destination);
+ ast_channel_setcontext(chan, outgoing_context);
+ ast_channel_setpriority(chan,0);
return 9;
}
return 0;
Modified: team/murf/fast-ast/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_agent.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_agent.c (original)
+++ team/murf/fast-ast/channels/chan_agent.c Fri Feb 2 12:03:37 2007
@@ -922,8 +922,8 @@
tmp->readformat = p->chan->readformat;
tmp->rawreadformat = p->chan->readformat;
ast_string_field_set(tmp, language, p->chan->language);
- ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
+ tmp->context = p->chan->context;
+ tmp->exten = p->chan->exten;
/* XXX Is this really all we copy form the originating channel?? */
} else {
tmp->nativeformats = AST_FORMAT_SLINEAR;
@@ -1192,7 +1192,7 @@
/* Safe -- agent lock already held */
ast_setstate(parent, AST_STATE_UP);
ast_setstate(chan, AST_STATE_UP);
- ast_copy_string(parent->context, chan->context, sizeof(parent->context));
+ parent->context = chan->context;
/* Go ahead and mark the channel as a zombie so that masquerade will
destroy it for us, and we need not call ast_hangup */
ast_mutex_lock(&parent->lock);
Modified: team/murf/fast-ast/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_iax2.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_iax2.c (original)
+++ team/murf/fast-ast/channels/chan_iax2.c Fri Feb 2 12:03:37 2007
@@ -2833,7 +2833,7 @@
pds.context = cai.peercontext;
/* Keep track of the context for outgoing calls too */
- ast_copy_string(c->context, cai.context, sizeof(c->context));
+ c->context = cai.context;
if (pds.port)
sin.sin_port = htons(atoi(pds.port));
@@ -3295,8 +3295,8 @@
ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ tmp->context = i->context;
+ tmp->exten = i->exten;
if (i->adsi)
tmp->adsicpe = i->peeradsicpe;
else
@@ -6110,8 +6110,8 @@
chan1m->writeformat = chan1->writeformat;
ast_channel_masquerade(chan1m, chan1);
/* Setup the extensions and such */
- ast_copy_string(chan1m->context, chan1->context, sizeof(chan1m->context));
- ast_copy_string(chan1m->exten, chan1->exten, sizeof(chan1m->exten));
+ chan1m->context = chan1->context;
+ chan1m->exten = chan1->exten;
chan1m->priority = chan1->priority;
/* We make a clone of the peer channel too, so we can play
@@ -6121,8 +6121,8 @@
chan2m->writeformat = chan2->writeformat;
ast_channel_masquerade(chan2m, chan2);
/* Setup the extensions and such */
- ast_copy_string(chan2m->context, chan2->context, sizeof(chan2m->context));
- ast_copy_string(chan2m->exten, chan2->exten, sizeof(chan2m->exten));
+ chan2m->context = chan2->context;
+ chan2m->exten = chan2->exten;
chan2m->priority = chan2->priority;
if (ast_do_masquerade(chan2m)) {
ast_log(LOG_WARNING, "Masquerade failed :(\n");
Modified: team/murf/fast-ast/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_local.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_local.c (original)
+++ team/murf/fast-ast/channels/chan_local.c Fri Feb 2 12:03:37 2007
@@ -583,9 +583,9 @@
p->u_owner = ast_module_user_add(p->owner);
p->u_chan = ast_module_user_add(p->chan);
- ast_copy_string(tmp->context, p->context, sizeof(tmp->context));
- ast_copy_string(tmp2->context, p->context, sizeof(tmp2->context));
- ast_copy_string(tmp2->exten, p->exten, sizeof(tmp->exten));
+ tmp->context = p->context;
+ tmp2->context = p->context;
+ tmp2->exten = p->exten;
tmp->priority = 1;
tmp2->priority = 1;
Modified: team/murf/fast-ast/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_mgcp.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_mgcp.c (original)
+++ team/murf/fast-ast/channels/chan_mgcp.c Fri Feb 2 12:03:37 2007
@@ -1469,8 +1469,8 @@
tmp->callgroup = i->callgroup;
tmp->pickupgroup = i->pickupgroup;
ast_string_field_set(tmp, call_forward, i->call_forward);
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ ast_channel_setcontext(tmp,i->context);
+ ast_channel_setexten(tmp,i->exten);
/* Don't use ast_set_callerid() here because it will
* generate a needless NewCallerID event */
@@ -2666,7 +2666,7 @@
} else {
/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
ast_indicate(chan, -1);
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_setexten(chan,exten);
ast_set_callerid(chan,
p->hidecallerid ? "" : p->cid_num,
p->hidecallerid ? "" : p->cid_name,
@@ -2851,7 +2851,7 @@
break;
}
if (ast_exists_extension(chan, chan->context, exten, 1, chan->callerid)) {
- ast_copy_string(chan->exten, exten, sizeof(chan->exten)1);
+ ast_channel_setexten(chan, exten);
if (!p->rtp) {
start_rtp(p);
}
Modified: team/murf/fast-ast/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_oss.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_oss.c (original)
+++ team/murf/fast-ast/channels/chan_oss.c Fri Feb 2 12:03:37 2007
@@ -1003,9 +1003,9 @@
c->tech_pvt = o;
if (!ast_strlen_zero(ctx))
- ast_copy_string(c->context, ctx, sizeof(c->context));
+ ast_channel_setcontext(c,ctx);
if (!ast_strlen_zero(ext))
- ast_copy_string(c->exten, ext, sizeof(c->exten));
+ ast_channel_setexten(c,ext);
if (!ast_strlen_zero(o->language))
ast_string_field_set(c, language, o->language);
/* Don't use ast_set_callerid() here because it will
@@ -1282,7 +1282,9 @@
{
struct chan_oss_pvt *o = find_desc(oss_active);
struct ast_channel *b = NULL;
- char *tmp, *ext, *ctx;
+ const char *ctx;
+ const char *ext;
+ char *tmp;
if (argc != 3)
return RESULT_SHOWUSAGE;
Modified: team/murf/fast-ast/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_phone.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_phone.c (original)
+++ team/murf/fast-ast/channels/chan_phone.c Fri Feb 2 12:03:37 2007
@@ -865,11 +865,11 @@
if (state == AST_STATE_RING)
tmp->rings = 1;
tmp->tech_pvt = i;
- ast_copy_string(tmp->context, context, sizeof(tmp->context));
+ ast_channel_setcontext(tmp,context);
if (!ast_strlen_zero(i->ext))
- ast_copy_string(tmp->exten, i->ext, sizeof(tmp->exten));
+ ast_channel_setexten(tmp, i->ext);
else
- strcpy(tmp->exten, "s");
+ ast_channel_setexten(tmp, "s");
if (!ast_strlen_zero(i->language))
ast_string_field_set(tmp, language, i->language);
Modified: team/murf/fast-ast/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_sip.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_sip.c (original)
+++ team/murf/fast-ast/channels/chan_sip.c Fri Feb 2 12:03:37 2007
@@ -3910,9 +3910,9 @@
if (!ast_strlen_zero(i->language))
ast_string_field_set(tmp, language, i->language);
i->owner = tmp;
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
-
+ ast_channel_setcontext(tmp, i->context);
+ ast_channel_setexten(tmp, i->exten);
+
/* Don't use ast_set_callerid() here because it will
* generate an unnecessary NewCallerID event */
tmp->cid.cid_num = ast_strdup(i->cid_num);
@@ -12621,8 +12621,8 @@
ast_channel_masquerade(transferee, chan1);
/* Setup the extensions and such */
- ast_copy_string(transferee->context, chan1->context, sizeof(transferee->context));
- ast_copy_string(transferee->exten, chan1->exten, sizeof(transferee->exten));
+ transferee->context = chan1->context;
+ transferee->exten = chan1->exten;
transferee->priority = chan1->priority;
/* We make a clone of the peer channel too, so we can play
@@ -12636,8 +12636,8 @@
ast_channel_masquerade(transferer, chan2);
/* Setup the extensions and such */
- ast_copy_string(transferer->context, chan2->context, sizeof(transferer->context));
- ast_copy_string(transferer->exten, chan2->exten, sizeof(transferer->exten));
+ transferer->context = chan2->context;
+ transferer->exten, chan2->exten;
transferer->priority = chan2->priority;
ast_channel_lock(transferer);
Modified: team/murf/fast-ast/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_skinny.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_skinny.c (original)
+++ team/murf/fast-ast/channels/chan_skinny.c Fri Feb 2 12:03:37 2007
@@ -2294,7 +2294,7 @@
len = 0;
getforward = 0;
} else {
- ast_copy_string(c->exten, exten, sizeof(c->exten));
+ ast_channel_setexten(c,exten);
ast_copy_string(l->lastnumberdialed, exten, sizeof(l->lastnumberdialed));
skinny_newcall(c);
return NULL;
@@ -2754,8 +2754,8 @@
tmp->callgroup = l->callgroup;
tmp->pickupgroup = l->pickupgroup;
ast_string_field_set(tmp, call_forward, l->call_forward);
- ast_copy_string(tmp->context, l->context, sizeof(tmp->context));
- ast_copy_string(tmp->exten, l->exten, sizeof(tmp->exten));
+ ast_channel_setcontext(tmp,l->context);
+ ast_channel_setexten(tmp,l->exten);
/* Don't use ast_set_callerid() here because it will
* generate a needless NewCallerID event */
Modified: team/murf/fast-ast/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/channels/chan_zap.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/channels/chan_zap.c (original)
+++ team/murf/fast-ast/channels/chan_zap.c Fri Feb 2 12:03:37 2007
@@ -5614,13 +5614,13 @@
if (i->amaflags)
tmp->amaflags = i->amaflags;
i->subs[index].owner = tmp;
- ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
+ ast_channel_setcontext(tmp,i->context);
ast_string_field_set(tmp, call_forward, i->call_forward);
/* If we've been told "no ADSI" then enforce it */
if (!i->adsi)
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
if (!ast_strlen_zero(i->exten))
- ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
+ ast_channel_setexten(tmp,i->exten);
if (!ast_strlen_zero(i->rdnis))
tmp->cid.cid_rdnis = ast_strdup(i->rdnis);
if (!ast_strlen_zero(i->dnid))
@@ -5782,7 +5782,7 @@
tone_zone_play_tone(p->subs[index].zfd, -1);
if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) {
/* Start the real PBX */
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_setexten(chan, exten);
if (p->dsp) ast_dsp_digitreset(p->dsp);
zt_enable_ec(p);
ast_setstate(chan, AST_STATE_RING);
@@ -6045,7 +6045,7 @@
}
if (ast_exists_extension(chan, chan->context, exten, 1, chan->cid.cid_num)) {
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_setexten(chan,exten);
if (p->dsp) ast_dsp_digitreset(p->dsp);
res = ast_pbx_run(chan);
if (res) {
@@ -6120,7 +6120,7 @@
getforward = 0;
} else {
res = tone_zone_play_tone(p->subs[index].zfd, -1);
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ ast_channel_setexten(chan, exten);
if (!ast_strlen_zero(p->cid_num)) {
if (!p->hidecallerid)
ast_set_callerid(chan, p->cid_num, NULL, p->cid_num);
@@ -6386,7 +6386,7 @@
smdi_msg = ast_smdi_md_message_wait(p->smdi_iface, SMDI_MD_WAIT_TIMEOUT);
if (smdi_msg != NULL) {
- ast_copy_string(chan->exten, smdi_msg->fwd_st, sizeof(chan->exten));
+ ast_channel_setexten(chan, smdi_msg->fwd_st);
if (smdi_msg->type == 'B')
pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "b");
@@ -6562,7 +6562,7 @@
/* Check to see if context is what it should be, if not set to be. */
if (strcmp(p->context,p->defcontext) != 0) {
ast_copy_string(p->context, p->defcontext, sizeof(p->context));
- ast_copy_string(chan->context,p->defcontext,sizeof(chan->context));
+ ast_channel_setcontext(chan, p->defcontext);
}
for (;;) {
@@ -6623,7 +6623,7 @@
if (distMatches == 3) {
/* The ring matches, set the context to whatever is for distinctive ring.. */
ast_copy_string(p->context, p->drings.ringContext[counter].contextData, sizeof(p->context));
- ast_copy_string(chan->context, p->drings.ringContext[counter].contextData, sizeof(chan->context));
+ ast_channel_setcontext(chan, p->drings.ringContext[counter].contextData);
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n",p->context);
break;
@@ -6665,7 +6665,7 @@
/* Check to see if context is what it should be, if not set to be. */
if (strcmp(p->context,p->defcontext) != 0) {
ast_copy_string(p->context, p->defcontext, sizeof(p->context));
- ast_copy_string(chan->context,p->defcontext,sizeof(chan->context));
+ ast_channel_setcontext(chan, p->defcontext);
}
/* Take out of linear mode for Caller*ID processing */
@@ -6799,7 +6799,7 @@
if (distMatches == 3) {
/* The ring matches, set the context to whatever is for distinctive ring.. */
ast_copy_string(p->context, p->drings.ringContext[counter].contextData, sizeof(p->context));
- ast_copy_string(chan->context, p->drings.ringContext[counter].contextData, sizeof(chan->context));
+ ast_channel_setcontext(chan, p->drings.ringContext[counter].contextData);
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n",p->context);
break;
@@ -8933,9 +8933,9 @@
switch (f->subclass) {
case AST_CONTROL_ANSWER:
/* Launch the PBX */
- ast_copy_string(chan->exten, pvt->pri->idleext, sizeof(chan->exten));
- ast_copy_string(chan->context, pvt->pri->idlecontext, sizeof(chan->context));
- chan->priority = 1;
+ ast_channel_setcontext(chan, pvt->pri->idlecontext);
+ ast_channel_setexten(chan, pvt->pri->idleext);
+ ast_channel_setpriority(chan,1);
if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_3 "Idle channel '%s' answered, sending to %s@%s\n", chan->name, chan->exten, chan->context);
ast_pbx_run(chan);
Modified: team/murf/fast-ast/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/include/asterisk/channel.h?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/include/asterisk/channel.h (original)
+++ team/murf/fast-ast/include/asterisk/channel.h Fri Feb 2 12:03:37 2007
@@ -1224,7 +1224,28 @@
This function will return 1 if internal timing is enabled and the timing
device is available.
*/
+
int ast_internal_timing_enabled(struct ast_channel *chan);
+
+
+/*! \brief Set the channel's exten field */
+void ast_channel_setexten(struct ast_channel *chan, const char *exten);
+
+/*! \brief Set the channel's context field */
+void ast_channel_setcontext(struct ast_channel *chan, const char *context);
+
+/*! \brief Set the channel's priority field */
+void ast_channel_setpriority(struct ast_channel *chan, int prio);
+
+/*! \brief Set the channel's macro-context field */
+void ast_channel_setmacrocontext(struct ast_channel *chan, const char *context);
+
+/*! \brief Set the channel's macro-exten field */
+void ast_channel_setmacroexten(struct ast_channel *chan, const char *exten);
+
+/*! \brief Set the channel's macro-priority field */
+void ast_channel_setmacropriority(struct ast_channel *chan, int prio);
+
/* Misc. functions below */
Modified: team/murf/fast-ast/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/main/channel.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/main/channel.c (original)
+++ team/murf/fast-ast/main/channel.c Fri Feb 2 12:03:37 2007
@@ -69,6 +69,11 @@
#include "asterisk/sha1.h"
#include "asterisk/threadstorage.h"
#include "asterisk/slinfactory.h"
+#include "asterisk/hashtab.h"
+#include "asterisk/stringtab.h"
+
+extern struct ast_strtab *pbx_stringtab;
+
struct channel_spy_trans {
int last_format;
@@ -413,6 +418,45 @@
}
}
+/*! \brief Set the channel's extension field */
+void ast_channel_setexten(struct ast_channel *chan, const char *exten)
+{
+ chan->exten = st_insert(pbx_stringtab, exten);
+}
+
+/*! \brief Set the channel's context field */
+void ast_channel_setcontext(struct ast_channel *chan, const char *context)
+{
+ chan->context = st_insert(pbx_stringtab, context);
+
+}
+
+/*! \brief Set the channel's priority field */
+void ast_channel_setpriority(struct ast_channel *chan, int prio)
+{
+ chan->priority = prio;
+}
+
+/*! \brief Set the channel's macro-context field */
+void ast_channel_setmacrocontext(struct ast_channel *chan, const char *context)
+{
+ chan->macrocontext = st_insert(pbx_stringtab, context);
+
+}
+
+/*! \brief Set the channel's macro-exten field */
+void ast_channel_setmacroexten(struct ast_channel *chan, const char *exten)
+{
+ chan->macroexten = st_insert(pbx_stringtab, exten);
+
+}
+
+/*! \brief Set the channel's macro-priority field */
+void ast_channel_setmacropriority(struct ast_channel *chan, int prio)
+{
+ chan->macropriority = prio;
+}
+
/*! \brief Register a new telephony channel in Asterisk */
int ast_channel_register(const struct ast_channel_tech *tech)
{
@@ -743,9 +787,9 @@
AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores);
- strcpy(tmp->context, "default");
- strcpy(tmp->exten, "s");
- tmp->priority = 1;
+ ast_channel_setcontext(tmp, "default");
+ ast_channel_setexten(tmp, "s");
+ ast_channel_setpriority(tmp,1);
ast_string_field_set(tmp, language, defaultlanguage);
tmp->amaflags = ast_default_amaflags;
@@ -2835,11 +2879,11 @@
/* Final fixups */
if (oh) {
if (!ast_strlen_zero(oh->context))
- ast_copy_string(chan->context, oh->context, sizeof(chan->context));
+ ast_channel_setcontext(chan, oh->context);
if (!ast_strlen_zero(oh->exten))
- ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
- if (oh->priority)
- chan->priority = oh->priority;
+ ast_channel_setexten(chan, oh->exten);
+ if (oh->priority)
+ ast_channel_setpriority(chan, oh->priority);
}
if (chan->_state == AST_STATE_UP)
*outstate = AST_CONTROL_ANSWER;
Modified: team/murf/fast-ast/main/hashtab.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/main/hashtab.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/main/hashtab.c (original)
+++ team/murf/fast-ast/main/hashtab.c Fri Feb 2 12:03:37 2007
@@ -44,8 +44,7 @@
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"
#include "asterisk/linkedlists.h"
-
-#include "hashtab.h"
+#include "asterisk/hashtab.h"
/* some standard, default routines for general use */
@@ -157,6 +156,17 @@
total += ((unsigned int)(*str));
}
+ return (total % modulus);
+}
+
+static int ast_hashtab_hash_string_sax(const void *obj, int modulus) /* from Josh */
+{
+ unsigned char *str = (unsigned char*)obj;
+ unsigned int total, c = 0;
+
+ while (c = *str++)
+ total ^= ( total << 5 ) + ( total >> 2 ) + ( total << 10) + c;
+
return (total % modulus);
}
Modified: team/murf/fast-ast/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/main/pbx.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/main/pbx.c (original)
+++ team/murf/fast-ast/main/pbx.c Fri Feb 2 12:03:37 2007
@@ -1,5 +1,4 @@
/*
- *
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 1999 - 2006, Digium, Inc.
@@ -61,8 +60,8 @@
#include "asterisk/app.h"
#include "asterisk/devicestate.h"
#include "asterisk/stringfields.h"
-#include "hashtab.h"
-#include "stringtab.h"
+#include "asterisk/hashtab.h"
+#include "asterisk/stringtab.h"
/*!
* \note I M P O R T A N T :
@@ -81,7 +80,8 @@
* Also, using a hash table for context/priority name lookup can help prevent
* the find_extension routines from absorbing exponential cpu cycles. I've tested
* find_extension with red-black trees, which have O(log2(n)) speed.Right now,
- * I'm using hash tables, which do searches (ideally) in O(1) time.
+ * I'm using hash tables, which do searches (ideally) in O(1) time. Experiments
+ * showed that response time is even flatter than with rbtrees!
*
* A simple hack to prevent repetitive calls to find_extension when it isn't
* necessary has been added.
@@ -136,7 +136,7 @@
priority.
*/
struct ast_exten {
- char *exten; /*!< Extension name */
+ const char *exten; /*!< Extension name */
int matchcid; /*!< Match caller id ? */
const char *cidmatch; /*!< Caller id to match for this extension */
int priority; /*!< Priority */
@@ -577,7 +577,7 @@
static struct ast_context *contexts = NULL;
static struct ast_hashtab *contexts_tree = NULL;
-static struct ast_strtab *pbx_stringtab = NULL;
+struct ast_strtab *pbx_stringtab = NULL;
AST_MUTEX_DEFINE_STATIC(conlock); /*!< Lock for the ast_context list */
@@ -905,7 +905,7 @@
t1 = ast_hashtab_start_traversal(con->root_tree);
while( (e1 = ast_hashtab_next(t1)) ) {
int pattern = 0;
- char *s1 = e1->exten;
+ const char *s1 = e1->exten;
m1 = con->pattern_tree; /* each pattern starts over at the root of the pattern tree */
already = 1;
@@ -2176,9 +2176,9 @@
return -1;
}
if (c->context != context)
- ast_copy_string(c->context, context, sizeof(c->context));
+ c->context = st_insert(pbx_stringtab, context);
if (c->exten != exten)
- ast_copy_string(c->exten, exten, sizeof(c->exten));
+ c->exten = st_insert(pbx_stringtab,exten);
c->priority = priority;
pbx_substitute_variables(passdata, sizeof(passdata), c, e);
if (option_debug) {
@@ -2668,7 +2668,7 @@
/* helper function to set extension and priority */
static void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
{
- ast_copy_string(c->exten, exten, sizeof(c->exten));
+ c->exten = st_insert(pbx_stringtab, exten);
c->priority = pri;
}
@@ -2749,7 +2749,7 @@
/* JK02: And finally back to default if everything else failed */
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d still failed so falling back to context 'default'\n", c->name, c->context, c->exten, c->priority);
- ast_copy_string(c->context, "default", sizeof(c->context));
+ ast_channel_setcontext(c, "default");
}
}
if (c->cdr && ast_tvzero(c->cdr->start))
@@ -2758,8 +2758,8 @@
char dst_exten[256]; /* buffer to accumulate digits */
int pos = 0; /* XXX should check bounds */
int digit = 0;
- char last_context[AST_MAX_CONTEXT];
- char last_extension[AST_MAX_EXTENSION];
+ const char *last_context;
+ const char *last_extension;
int last_priority = 0;
struct ast_exten *target=0;
@@ -2769,8 +2769,8 @@
*/
while (pbx_extension_helper(c, NULL, c->context, c->exten, c->priority, NULL, c->cid.cid_num, E_MATCH, &target)) {
found = 1;
- strcpy(last_context, c->context);
- strcpy(last_extension, c->exten);
+ last_context = c->context;
+ last_extension = c->exten;
last_priority = c->priority;
/* we call pbx_extension_helper(...E_SPAWN...) here instead of ast_spawn_extension, so we can use
* the extension previously looked up instead of forcing a fresh search for extension
@@ -2825,7 +2825,7 @@
* to the next extension, it's already at the peer pointer on the extension we just ran! If all
* the planets are in alignment, set the target to point to the next extension, and we won't be searching!
*/
- if (c->priority == last_priority+1 && strcasecmp(c->context,last_context) == 0 && strcasecmp(c->exten,last_extension) == 0 && target && target->peer && target->peer->priority == c->priority)
+ if (c->priority == last_priority+1 && c->context == last_context && c->exten == last_extension&& target && target->peer && target->peer->priority == c->priority)
target = target->peer;
else
target = 0;
@@ -3213,12 +3213,13 @@
{
struct ast_exten *exten, *prev_exten = NULL;
struct ast_exten *peer;
+ extension = st_insert(pbx_stringtab, extension);
ast_mutex_lock(&con->lock);
/* scan the extension list to find matching extension-registrar */
for (exten = con->root; exten; prev_exten = exten, exten = exten->next) {
- if (!strcmp(exten->exten, extension) &&
+ if (exten->exten == extension &&
(!registrar || !strcmp(exten->registrar, registrar)))
break;
}
@@ -5048,9 +5049,9 @@
return -1;
if (!ast_strlen_zero(context))
- ast_copy_string(chan->context, context, sizeof(chan->context));
+ chan->context = st_insert(pbx_stringtab,context);
if (!ast_strlen_zero(exten))
- ast_copy_string(chan->exten, exten, sizeof(chan->exten));
+ chan->exten = st_insert(pbx_stringtab, exten);
if (priority > -1) {
chan->priority = priority;
/* see flag description in channel.h for explanation */
@@ -5294,6 +5295,8 @@
char *p;
char expand_buf[VAR_BUF_SIZE] = { 0, };
+ extension = st_insert(pbx_stringtab, extension);
+
/* if we are adding a hint, and there are global variables, and the hint
contains variable references, then expand them
*/
@@ -5305,9 +5308,9 @@
ast_mutex_unlock(&globalslock);
length = sizeof(struct ast_exten);
- length += strlen(extension) + 1;
length += strlen(application) + 1;
#ifdef NOMORE
+ length += strlen(extension) + 1;
if (label)
length += strlen(label) + 1;
#endif
@@ -5326,9 +5329,8 @@
tmp->label = st_insert(pbx_stringtab, label);
}
/* use p as dst in assignments, as the fields are const char * */
+ tmp->exten = st_insert(pbx_stringtab, extension);
p = tmp->stuff;
- tmp->exten = p;
- p += ext_strncpy(p, extension, strlen(extension) + 1) + 1;
tmp->priority = priority;
tmp->cidmatch = p; /* but use p for assignments below */
if (callerid) {
@@ -5492,11 +5494,11 @@
ast_log(LOG_WARNING, "No such application '%s'\n", as->app);
} else {
if (!ast_strlen_zero(as->context))
- ast_copy_string(chan->context, as->context, sizeof(chan->context));
+ ast_channel_setcontext(chan, as->context);
if (!ast_strlen_zero(as->exten))
- ast_copy_string(chan->exten, as->exten, sizeof(chan->exten));
+ ast_channel_setexten(chan, as->exten);
if (as->priority > 0)
- chan->priority = as->priority;
+ ast_channel_setpriority(chan, as->priority);
/* Run the PBX */
if (ast_pbx_run(chan)) {
ast_log(LOG_ERROR, "Failed to start PBX on %s\n", chan->name);
@@ -5636,7 +5638,7 @@
chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "OutgoingSpoolFailed");
if (chan) {
if (!ast_strlen_zero(context))
- ast_copy_string(chan->context, context, sizeof(chan->context));
+ ast_channel_setcontext(chan, context);
set_ext_pri(chan, "failed", 1);
ast_set_variables(chan, vars);
if (account)
@@ -6247,7 +6249,9 @@
args.lang = (char *)chan->language; /* XXX this is const */
if (!args.context)
- args.context = chan->context;
+ args.context = (char*)chan->context;
+ else
+ args.context = (char*)st_insert(pbx_stringtab,args.context);
if (args.options) {
if (!strcasecmp(args.options, "skip"))
@@ -6291,8 +6295,10 @@
}
}
if (args.context != chan->context && res) {
- snprintf(chan->exten, sizeof(chan->exten), "%c", res);
- ast_copy_string(chan->context, args.context, sizeof(chan->context));
+ char buf7[80];
+ snprintf(buf7, sizeof(buf7), "%c", res);
+ chan->exten = st_insert(pbx_stringtab,buf7);
+ chan->context = args.context;
chan->priority = 0;
res = 0;
}
Modified: team/murf/fast-ast/main/stringtab.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast/main/stringtab.c?view=diff&rev=53124&r1=53123&r2=53124
==============================================================================
--- team/murf/fast-ast/main/stringtab.c (original)
+++ team/murf/fast-ast/main/stringtab.c Fri Feb 2 12:03:37 2007
@@ -44,9 +44,8 @@
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"
#include "asterisk/linkedlists.h"
-
-#include "hashtab.h"
-#include "stringtab.h"
+#include "asterisk/hashtab.h"
+#include "asterisk/stringtab.h"
static char NULLSTR[1] = "";
Modified: team/murf/fast-ast/main/test-hashtab.c
[... 82 lines stripped ...]
More information about the svn-commits
mailing list