struct zt_distRings drings;
- char context[AST_MAX_CONTEXT];
- char defcontext[AST_MAX_CONTEXT];
- char exten[AST_MAX_EXTENSION];
- char language[MAX_LANGUAGE];
- char musicclass[MAX_MUSICCLASS];
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(language);
+ AST_STRING_FIELD(musicclass);
+ AST_STRING_FIELD(accountcode);
+ AST_STRING_FIELD(mailbox);
+ AST_STRING_FIELD(call_forward);
+ AST_STRING_FIELD(cid_num);
+ AST_STRING_FIELD(cid_name);
+ AST_STRING_FIELD(lastcid_num);
+ AST_STRING_FIELD(lastcid_name);
+ AST_STRING_FIELD(dnid);
+ AST_STRING_FIELD(callwait_num);
+ AST_STRING_FIELD(callwait_name);
+ AST_STRING_FIELD(finaldial);
+ AST_STRING_FIELD(context);
+ AST_STRING_FIELD(defcontext);
+ AST_STRING_FIELD(exten);
#ifdef PRI_ANI
- char cid_ani[AST_MAX_EXTENSION];
+ AST_STRING_FIELD(cid_ani);
#endif
- char cid_num[AST_MAX_EXTENSION];
+ );
int cid_ton; /*!< Type Of Number (TON) */
- char cid_name[AST_MAX_EXTENSION];
- char lastcid_num[AST_MAX_EXTENSION];
- char lastcid_name[AST_MAX_EXTENSION];
char *origcid_num; /*!< malloced original callerid */
char *origcid_name; /*!< malloced original callerid */
- char callwait_num[AST_MAX_EXTENSION];
- char callwait_name[AST_MAX_EXTENSION];
char rdnis[AST_MAX_EXTENSION];
- char dnid[AST_MAX_EXTENSION];
unsigned int group;
int law;
int confno; /*!< Our conference */
int cref; /*!< Call reference number */
ZT_DIAL_OPERATION dop;
int whichwink; /*!< SIG_FEATDMF_TA Which wink are we on? */
- char finaldial[64];
- char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Account code */
int amaflags; /*!< AMA Flags */
struct tdd_state *tdd; /*!< TDD flag */
- char call_forward[AST_MAX_EXTENSION];
- char mailbox[AST_MAX_EXTENSION];
char dialdest[256];
int onhooktime;
int msgstate;
/* Call waiting call */
p->callwaitrings = 0;
if (ast->cid.cid_num)
- ast_copy_string(p->callwait_num, ast->cid.cid_num, sizeof(p->callwait_num));
+ ast_string_field_set(p, callwait_num, ast->cid.cid_num);
else
- p->callwait_num[0] = '\0';
+ ast_string_field_set(p, callwait_num, "");
if (ast->cid.cid_name)
- ast_copy_string(p->callwait_name, ast->cid.cid_name, sizeof(p->callwait_name));
+ ast_string_field_set(p, callwait_name, ast->cid.cid_name);
else
- p->callwait_name[0] = '\0';
+ ast_string_field_set(p, callwait_name, "");
/* Call waiting tone instead */
if (zt_callwait(ast)) {
ast_mutex_unlock(&p->lock);
n = ast->cid.cid_name;
l = ast->cid.cid_num;
if (l)
- ast_copy_string(p->lastcid_num, l, sizeof(p->lastcid_num));
+ ast_string_field_set(p, lastcid_num, l);
else
- p->lastcid_num[0] = '\0';
+ ast_string_field_set(p, lastcid_num, "");
if (n)
- ast_copy_string(p->lastcid_name, n, sizeof(p->lastcid_name));
+ ast_string_field_set(p, lastcid_name, n);
else
- p->lastcid_name[0] = '\0';
+ ast_string_field_set(p, lastcid_name, "");
ast_setstate(ast, AST_STATE_RINGING);
index = zt_get_index(ast, p, 0);
if (index > -1) {
return -1;
}
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s%s#", ozz, cic);
- snprintf(p->finaldial, sizeof(p->finaldial), "M*%s#", c);
+ ast_string_field_build(p, finaldial, "M*%s#", c);
p->whichwink = 0;
}
break;
ASTOBJ_UNREF(p->smdi_iface, ast_smdi_interface_destroy);
#endif
ast_mutex_destroy(&p->lock);
+ ast_string_field_free_all(p);
free(p);
*pvt = NULL;
}
zt_confmute(p, 0);
restore_gains(p);
if (p->origcid_num) {
- ast_copy_string(p->cid_num, p->origcid_num, sizeof(p->cid_num));
+ ast_string_field_set(p, cid_num, p->origcid_num);
free(p->origcid_num);
p->origcid_num = NULL;
- }
+ }
if (p->origcid_name) {
- ast_copy_string(p->cid_name, p->origcid_name, sizeof(p->cid_name));
+ ast_string_field_set(p, cid_name, p->origcid_name);
free(p->origcid_name);
p->origcid_name = NULL;
}
if (p->dsp)
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax);
- if (p->exten)
- p->exten[0] = '\0';
+ if (!ast_strlen_zero(p->exten))
+ ast_string_field_set(p, exten, "");
ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
p->origcid_num = ast_strdup(p->cid_num);
if (!p->origcid_name)
p->origcid_name = ast_strdup(p->cid_name);
- ast_copy_string(p->cid_num, cid_num, sizeof(p->cid_num));
- ast_copy_string(p->cid_name, cid_name, sizeof(p->cid_name));
+ ast_string_field_set(p, cid_num, cid_num);
+ ast_string_field_set(p, cid_name, cid_name);
}
/* Swap things around between the three-way and real call */
swap_subs(p, SUB_THREEWAY, SUB_REAL);
ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
chan->hangupcause = AST_CAUSE_UNALLOCATED;
ast_hangup(chan);
- p->exten[0] = '\0';
+ ast_string_field_set(p, exten, "");
/* Since we send release complete here, we won't get one */
p->call = NULL;
}
if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
if (getforward) {
/* Record this as the forwarding extension */
- ast_copy_string(p->call_forward, exten, sizeof(p->call_forward));
+ ast_string_field_set(p, call_forward, exten);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Setting call forward to '%s' on channel %d\n", p->call_forward, p->channel);
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Cancelling call forwarding on channel %d\n", p->channel);
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);
- memset(p->call_forward, 0, sizeof(p->call_forward));
+ ast_string_field_set(p, call_forward, "");
getforward = 0;
memset(exten, 0, sizeof(exten));
len = 0;
counter = 0;
counter1 = 0;
/* 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));
+ if (!strcmp(p->context, p->defcontext)) {
+ ast_string_field_set(p, context, p->defcontext);
+ ast_copy_string(chan->context, p->defcontext, sizeof(chan->context));
}
for (;;) {
}
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_string_field_set(p, context, p->drings.ringContext[counter].contextData);
ast_copy_string(chan->context, p->drings.ringContext[counter].contextData, sizeof(chan->context));
if (option_verbose > 2)
- ast_verbose( VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n",p->context);
+ ast_verbose( VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n", p->context);
break;
}
}
counter = 0;
counter1 = 0;
/* 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));
+ if (!strcmp(p->context, p->defcontext)) {
+ ast_string_field_set(p, context, p->defcontext);
+ ast_copy_string(chan->context, p->defcontext, sizeof(chan->context));
}
/* Take out of linear mode for Caller*ID processing */
}
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_string_field_set(p, context, p->drings.ringContext[counter].contextData);
ast_copy_string(chan->context, p->drings.ringContext[counter].contextData, sizeof(chan->context));
if (option_verbose > 2)
- ast_verbose( VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n",p->context);
+ ast_verbose(VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n", p->context);
break;
}
}
destroy_zt_pvt(&tmp);
return NULL;
}
+ if (ast_string_field_init(tmp, 256)) {
+ destroy_zt_pvt(&tmp);
+ return NULL;
+ }
ast_mutex_init(&tmp->lock);
ifcount++;
for (x = 0; x < 3; x++)
}
#endif
- ast_copy_string(tmp->accountcode, accountcode, sizeof(tmp->accountcode));
+ ast_string_field_set(tmp, accountcode, accountcode);
tmp->amaflags = amaflags;
if (!here) {
tmp->confno = -1;
}
tmp->canpark = canpark;
tmp->transfer = transfer;
- ast_copy_string(tmp->defcontext,context,sizeof(tmp->defcontext));
- ast_copy_string(tmp->language, language, sizeof(tmp->language));
- ast_copy_string(tmp->musicclass, musicclass, sizeof(tmp->musicclass));
- ast_copy_string(tmp->context, context, sizeof(tmp->context));
- ast_copy_string(tmp->cid_num, cid_num, sizeof(tmp->cid_num));
+ ast_string_field_set(tmp, defcontext, context);
+ ast_string_field_set(tmp, language, language);
+ ast_string_field_set(tmp, musicclass, musicclass);
+ ast_string_field_set(tmp, context, context);
+ ast_string_field_set(tmp, cid_num, cid_num);
tmp->cid_ton = 0;
- ast_copy_string(tmp->cid_name, cid_name, sizeof(tmp->cid_name));
- ast_copy_string(tmp->mailbox, mailbox, sizeof(tmp->mailbox));
+ ast_string_field_set(tmp, cid_name, cid_name);
+ ast_string_field_set(tmp, mailbox, mailbox);
tmp->msgstate = -1;
tmp->group = cur_group;
tmp->callgroup=cur_callergroup;
apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan);
if (pri->pvts[chanpos]->use_callerid) {
ast_shrink_phone_number(plancallingnum);
- ast_copy_string(pri->pvts[chanpos]->cid_num, plancallingnum, sizeof(pri->pvts[chanpos]->cid_num));
+ ast_string_field_set(pri->pvts[chanpos], cid_num, plancallingnum);
#ifdef PRI_ANI
if (!ast_strlen_zero(e->ring.callingani)) {
apply_plan_to_number(plancallingani, sizeof(plancallingani), pri, e->ring.callingani, e->ring.callingplanani);
ast_shrink_phone_number(plancallingani);
- ast_copy_string(pri->pvts[chanpos]->cid_ani, plancallingani, sizeof(pri->pvts[chanpos]->cid_ani));
+ ast_string_field_set(pri->pvts[chanpos], cid_ani, plancallingani);
} else {
- pri->pvts[chanpos]->cid_ani[0] = '\0';
+ ast_string_field_set(pri->pvts[chanpos], cid_ani, "");
}
#endif
- ast_copy_string(pri->pvts[chanpos]->cid_name, e->ring.callingname, sizeof(pri->pvts[chanpos]->cid_name));
+ ast_string_field_set(pri->pvts[chanpos], cid_name, e->ring.callingname);
pri->pvts[chanpos]->cid_ton = e->ring.callingplan; /* this is the callingplan (TON/NPI), e->ring.callingplan>>4 would be the TON */
} else {
- pri->pvts[chanpos]->cid_num[0] = '\0';
- pri->pvts[chanpos]->cid_ani[0] = '\0';
- pri->pvts[chanpos]->cid_name[0] = '\0';
+ ast_string_field_set(pri->pvts[chanpos], cid_num, "");
+ ast_string_field_set(pri->pvts[chanpos], cid_ani, "");
+ ast_string_field_set(pri->pvts[chanpos], cid_name, "");
pri->pvts[chanpos]->cid_ton = 0;
}
apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
if (pri->pvts[chanpos]->immediate) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of immediate=yes\n");
- pri->pvts[chanpos]->exten[0] = 's';
- pri->pvts[chanpos]->exten[1] = '\0';
+ ast_string_field_set(pri->pvts[chanpos], exten, "s");
}
/* Get called number */
else if (!ast_strlen_zero(e->ring.callednum)) {
- ast_copy_string(pri->pvts[chanpos]->exten, e->ring.callednum, sizeof(pri->pvts[chanpos]->exten));
- ast_copy_string(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid));
+ ast_string_field_set(pri->pvts[chanpos], exten, e->ring.callednum);
+ ast_string_field_set(pri->pvts[chanpos], dnid, e->ring.callednum);
} else
- pri->pvts[chanpos]->exten[0] = '\0';
+ ast_string_field_set(pri->pvts[chanpos], exten, "");
/* Set DNID on all incoming calls -- even immediate */
if (!ast_strlen_zero(e->ring.callednum))
- ast_copy_string(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid));
+ ast_string_field_set(pri->pvts[chanpos], dnid, e->ring.callednum);
/* No number yet, but received "sending complete"? */
if (e->ring.complete && (ast_strlen_zero(e->ring.callednum))) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of Complete received\n");
- pri->pvts[chanpos]->exten[0] = 's';
- pri->pvts[chanpos]->exten[1] = '\0';
+ ast_string_field_set(pri->pvts[chanpos], exten, "s");
}
/* Make sure extension exists (or in overlap dial mode, can exist) */
if ((pri->overlapdial && ast_canmatch_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) ||
pri->pvts[chanpos]->prioffset, pri->span);
pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED);
pri->pvts[chanpos]->call = NULL;
- pri->pvts[chanpos]->exten[0] = '\0';
+ ast_string_field_set(pri->pvts[chanpos], exten, "");
}
if (crv)
ast_mutex_unlock(&crv->lock);
} else {
/* Re-use *69 field for PRI */
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- ast_copy_string(pri->pvts[chanpos]->lastcid_num, e->facname.callingnum, sizeof(pri->pvts[chanpos]->lastcid_num));
- ast_copy_string(pri->pvts[chanpos]->lastcid_name, e->facname.callingname, sizeof(pri->pvts[chanpos]->lastcid_name));
+ ast_string_field_set(pri->pvts[chanpos], lastcid_num, e->facname.callingnum);
+ ast_string_field_set(pri->pvts[chanpos], lastcid_name, e->facname.callingname);
pri->pvts[chanpos]->subs[SUB_REAL].needcallerid =1;
zt_enable_ec(pri->pvts[chanpos]);
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
if (cur_outsignalling < 0) cur_outsignalling = cur_signalling;
for (x = start; x <= finish; x++) {
#ifdef HAVE_LIBPRI
+ ast_verbose("channel: %d cur_sig: %d cur_outsig: %d cur_radio: %d\n", x, cur_signalling, cur_outsignalling, cur_radio);
tmp = mkintf(x, cur_signalling, cur_outsignalling, cur_radio, pri, reload);
#else
tmp = mkintf(x, cur_signalling, cur_outsignalling, cur_radio, NULL, reload);
}
} else {
if (reload == 1)
- ast_log(LOG_ERROR, "Unable to reconfigure channel '%s'\n", v->value);
+ ast_log(LOG_ERROR, "Unable to reconfigure channel '%d'\n", x);
else
- ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
+ ast_log(LOG_ERROR, "Unable to register channel '%d'\n", x);
ast_config_destroy(cfg);
ast_mutex_unlock(&iflock);
return -1;