#include "asterisk/rtp.h"
#include "asterisk/manager.h"
#include "asterisk/privacy.h"
+#include "asterisk/stringfields.h"
static char *tdesc = "Dialing Application";
else
newcid = in->exten;
o->chan->cid.cid_num = strdup(newcid);
- ast_copy_string(o->chan->accountcode, winner->accountcode, sizeof(o->chan->accountcode));
+ ast_string_field_set(o->chan, accountcode, winner->accountcode);
o->chan->cdrflags = winner->cdrflags;
if (!o->chan->cid.cid_num)
ast_log(LOG_WARNING, "Out of memory\n");
if (!o->chan->cid.cid_name)
ast_log(LOG_WARNING, "Out of memory\n");
}
- ast_copy_string(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode));
+ ast_string_field_set(o->chan, accountcode, in->accountcode);
o->chan->cdrflags = in->cdrflags;
}
tmp->chan->cid.cid_ani = strdup(chan->cid.cid_ani);
/* Copy language from incoming to outgoing */
- ast_copy_string(tmp->chan->language, chan->language, sizeof(tmp->chan->language));
- ast_copy_string(tmp->chan->accountcode, chan->accountcode, sizeof(tmp->chan->accountcode));
+ ast_string_field_set(tmp->chan, language, chan->language);
+ ast_string_field_set(tmp->chan, accountcode, chan->accountcode);
tmp->chan->cdrflags = chan->cdrflags;
if (ast_strlen_zero(tmp->chan->musicclass))
- ast_copy_string(tmp->chan->musicclass, chan->musicclass, sizeof(tmp->chan->musicclass));
+ ast_string_field_set(tmp->chan, musicclass, chan->musicclass);
if (chan->cid.cid_rdnis)
tmp->chan->cid.cid_rdnis = strdup(chan->cid.cid_rdnis);
/* Pass callingpres setting */
#include "asterisk/translate.h"
#include "asterisk/ulaw.h"
#include "asterisk/callerid.h"
+#include "asterisk/stringfields.h"
static char *tdesc = "DISA (Direct Inward System Access) Application";
}
if (!ast_strlen_zero(acctcode))
- ast_copy_string(chan->accountcode, acctcode, sizeof(chan->accountcode));
+ ast_string_field_set(chan, accountcode, acctcode);
if (special_noanswer) flags.flags = 0;
ast_cdr_reset(chan->cdr, &flags);
"Data= %s\n"
"Blocking_in= %s\n",
c->name,
- c->type,
+ c->tech->type,
c->uniqueid,
(c->cid.cid_num ? c->cid.cid_num : "(N/A)"),
(c->cid.cid_name ? c->cid.cid_name : "(N/A)"),
struct localuser *u;
struct zt_params ztp;
LOCAL_USER_ADD(u);
- if (!strcasecmp(chan->type, "Zap")) {
+ if (!strcasecmp(chan->tech->type, "Zap")) {
memset(&ztp, 0, sizeof(ztp));
res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
if (!res) {
}
ast_indicate(chan, -1);
- retryzap = strcasecmp(chan->type, "Zap");
+ retryzap = strcasecmp(chan->tech->type, "Zap");
user->zapchannel = !retryzap;
zapretry:
using_pseudo = 0;
}
ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
- retryzap = strcasecmp(c->type, "Zap");
+ retryzap = strcasecmp(c->tech->type, "Zap");
user->zapchannel = !retryzap;
goto zapretry;
}
#include "asterisk/causes.h"
#include "asterisk/astdb.h"
#include "asterisk/devicestate.h"
+#include "asterisk/stringfields.h"
#define QUEUE_STRATEGY_RINGALL 0
#define QUEUE_STRATEGY_ROUNDROBIN 1
if (!o->chan->cid.cid_name)
ast_log(LOG_WARNING, "Out of memory\n");
}
- ast_copy_string(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode));
+ ast_string_field_set(o->chan, accountcode, in->accountcode);
o->chan->cdrflags = in->cdrflags;
if (in->cid.cid_ani) {
we will always return with -1 so that it is hung up properly after the
conversation. */
qe->handled++;
- if (!strcmp(qe->chan->type,"Zap"))
+ if (!strcmp(qe->chan->tech->type, "Zap"))
ast_channel_setoption(qe->chan, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
- if (!strcmp(peer->type,"Zap"))
+ if (!strcmp(peer->tech->type, "Zap"))
ast_channel_setoption(peer, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
/* Update parameters for the queue */
recalc_holdtime(qe);
/* XXX watch out, i think it is wrong to access c-> after unlocking! */
if (all) {
/* CAPI is set up like CAPI[foo/bar]/clcnt */
- if (!strcmp(c->type,"CAPI"))
+ if (!strcmp(c->tech->type, "CAPI"))
cut = strrchr(name,'/');
/* Basically everything else is Foo/Bar-Z */
else
tech = dest;
dest = slash + 1;
/* Allow execution only if the Tech/destination agrees with the type of the channel */
- if (strncasecmp(chan->type, tech, len)) {
+ if (strncasecmp(chan->tech->type, tech, len)) {
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
LOCAL_USER_REMOVE(u);
return 0;
#include "asterisk/localtime.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
+#include "asterisk/stringfields.h"
#ifdef USE_ODBC_STORAGE
#include "asterisk/res_odbc.h"
#endif
}
-static int say_and_wait(struct ast_channel *chan, int num, char *language)
+static int say_and_wait(struct ast_channel *chan, int num, const char *language)
{
int d;
d = ast_say_number(chan, num, AST_DIGIT_ANY, language, (char *) NULL);
/* Set language from config to override channel language */
if (!ast_strlen_zero(vmu->language))
- ast_copy_string(chan->language, vmu->language, sizeof(chan->language));
+ ast_string_field_set(chan, language, vmu->language);
create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, "");
/* Retrieve old and new message counts */
res = open_mailbox(&vms, vmu, 1);
goto outrun;
}
ast_indicate(chan, -1);
- retryzap = strcasecmp(chan->type, "Zap");
+ retryzap = strcasecmp(chan->tech->type, "Zap");
zapretry:
origfd = chan->fds[0];
if (retryzap) {
/* Answer the channel if it's not up */
if (chan->_state != AST_STATE_UP)
ast_answer(chan);
- if (strcasecmp(chan->type, "Zap")) {
+ if (strcasecmp(chan->tech->type, "Zap")) {
/* If it's not a zap channel, we're done. Wait a couple of
seconds and then hangup... */
if (option_verbose > 1)
goto outrun;
}
ast_indicate(chan, -1);
- retryzap = strcasecmp(chan->type, "Zap");
+ retryzap = strcasecmp(chan->tech->type, "Zap");
zapretry:
origfd = chan->fds[0];
if (retryzap) {
continue;
}
}
- if ( tempchan && tempchan->type && (!strcmp(tempchan->type, "Zap")) && (tempchan != chan) ) {
+ if (tempchan && (!strcmp(tempchan->tech->type, "Zap")) && (tempchan != chan) ) {
ast_verbose(VERBOSE_PREFIX_3 "Zap channel %s is in-use, monitoring...\n", tempchan->name);
ast_copy_string(confstr, tempchan->name, sizeof(confstr));
ast_mutex_unlock(&tempchan->lock);
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/module.h"
+#include "asterisk/stringfields.h"
/*! Default AMA flag for billing records (CDR's) */
int ast_default_amaflags = AST_CDR_DOCUMENTATION;
return res;
}
-void ast_cdr_setdestchan(struct ast_cdr *cdr, char *chann)
+void ast_cdr_setdestchan(struct ast_cdr *cdr, const char *chann)
{
char *chan;
{
struct ast_cdr *cdr = chan->cdr;
- ast_copy_string(chan->accountcode, account, sizeof(chan->accountcode));
+ ast_string_field_set(chan, accountcode, account);
while (cdr) {
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
ast_copy_string(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode));
return NULL;
}
+ ast_string_field_init(tmp, 128);
+
/* Don't bother initializing the last two FD here, because they
will *always* be set just a few lines down (AST_TIMING_FD,
AST_ALERT_FD). */
tmp->fds[AST_ALERT_FD] = tmp->alertpipe[0];
/* And timing pipe */
tmp->fds[AST_TIMING_FD] = tmp->timingfd;
- strcpy(tmp->name, "**Unknown**");
+ ast_string_field_set(tmp, name, "**Unknown**");
/* Initial state */
tmp->_state = AST_STATE_DOWN;
tmp->streamid = -1;
ast_mutex_init(&tmp->lock);
AST_LIST_HEAD_INIT_NOLOCK(headp);
strcpy(tmp->context, "default");
- ast_copy_string(tmp->language, defaultlanguage, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, defaultlanguage);
strcpy(tmp->exten, "s");
tmp->priority = 1;
tmp->amaflags = ast_default_amaflags;
- ast_copy_string(tmp->accountcode, ast_default_accountcode, sizeof(tmp->accountcode));
+ ast_string_field_set(tmp, accountcode, ast_default_accountcode);
tmp->tech = &null_tech;
void ast_change_name(struct ast_channel *chan, char *newname)
{
- char tmp[256];
- ast_copy_string(tmp, chan->name, sizeof(tmp));
- ast_copy_string(chan->name, newname, sizeof(chan->name));
- manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", tmp, chan->name, chan->uniqueid);
+ manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid);
+ ast_string_field_set(chan, name, newname);
}
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
/* Copy the name from the clone channel */
- ast_copy_string(original->name, newn, sizeof(original->name));
+ ast_string_field_set(original, name, newn);
/* Mangle the name of the clone channel */
- ast_copy_string(clone->name, masqn, sizeof(clone->name));
+ ast_string_field_set(clone, name, masqn);
/* Notify any managers of the change, first the masq then the other */
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig);
/* Mangle the name of the clone channel */
- ast_copy_string(clone->name, zombn, sizeof(clone->name));
+ ast_string_field_set(clone, name, zombn);
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid);
/* Update the type. */
- original->type = clone->type;
t_pvt = original->monitor;
original->monitor = clone->monitor;
clone->monitor = t_pvt;
/* Keep the same language. */
- ast_copy_string(original->language, clone->language, sizeof(original->language));
+ ast_string_field_set(original, language, clone->language);
/* Copy the FD's other than the generator fd */
for (x = 0; x < AST_MAX_FDS; x++) {
if (x != AST_GENERATOR_FD)
ast_set_read_format(original, rformat);
/* Copy the music class */
- ast_copy_string(original->musicclass, clone->musicclass, sizeof(original->musicclass));
+ ast_string_field_set(original, musicclass, clone->musicclass);
ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
res = original->tech->fixup(clone, original);
if (res) {
ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n",
- original->type, original->name);
+ original->tech->type, original->name);
ast_mutex_unlock(&clone->lock);
return -1;
}
} else
ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n",
- original->type, original->name);
+ original->tech->type, original->name);
/* Now, at this point, the "clone" channel is totally F'd up. We mark it as
a zombie so nothing tries to touch it. If it's already been marked as a
return group;
}
-static int (*ast_moh_start_ptr)(struct ast_channel *, char *) = NULL;
+static int (*ast_moh_start_ptr)(struct ast_channel *, const char *) = NULL;
static void (*ast_moh_stop_ptr)(struct ast_channel *) = NULL;
static void (*ast_moh_cleanup_ptr)(struct ast_channel *) = NULL;
-
-void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, char *),
- void (*stop_ptr)(struct ast_channel *),
- void (*cleanup_ptr)(struct ast_channel *)
- )
+void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *),
+ void (*stop_ptr)(struct ast_channel *),
+ void (*cleanup_ptr)(struct ast_channel *))
{
ast_moh_start_ptr = start_ptr;
ast_moh_stop_ptr = stop_ptr;
}
/*! \brief Turn on music on hold on a given channel */
-int ast_moh_start(struct ast_channel *chan, char *mclass)
+int ast_moh_start(struct ast_channel *chan, const char *mclass)
{
if (ast_moh_start_ptr)
return ast_moh_start_ptr(chan, mclass);
#include "asterisk/astdb.h"
#include "asterisk/devicestate.h"
#include "asterisk/monitor.h"
+#include "asterisk/stringfields.h"
static const char desc[] = "Agent Proxy Channel";
-static const char channeltype[] = "Agent";
static const char tdesc[] = "Call Agent Proxy Channel";
static const char config[] = "agents.conf";
static void set_agentbycallerid(const char *callerid, const char *agent);
static const struct ast_channel_tech agent_tech = {
- .type = channeltype,
+ .type = "Agent",
.description = tdesc,
.capabilities = -1,
.requester = agent_request,
CLEANUP(ast,p);
if (p->chan && !p->chan->_bridge) {
- if (strcasecmp(p->chan->type, "Local")) {
+ if (strcasecmp(p->chan->tech->type, "Local")) {
p->chan->_bridge = ast;
if (p->chan)
ast_log(LOG_DEBUG, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
tmp->rawwriteformat = p->chan->writeformat;
tmp->readformat = p->chan->readformat;
tmp->rawreadformat = p->chan->readformat;
- ast_copy_string(tmp->language, p->chan->language, sizeof(tmp->language));
+ 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));
} else {
tmp->rawreadformat = AST_FORMAT_SLINEAR;
}
if (p->pending)
- snprintf(tmp->name, sizeof(tmp->name), "Agent/P%s-%d", p->agent, rand() & 0xffff);
+ ast_string_field_build(tmp, name, "Agent/P%s-%d", p->agent, rand() & 0xffff);
else
- snprintf(tmp->name, sizeof(tmp->name), "Agent/%s", p->agent);
- tmp->type = channeltype;
+ ast_string_field_build(tmp, name, "Agent/%s", p->agent);
/* Safe, agentlock already held */
ast_setstate(tmp, state);
tmp->tech_pvt = p;
{
/* Make sure we can register our agent channel type */
if (ast_channel_register(&agent_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Agent'\n");
return -1;
}
/* Dialplan applications */
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/endian.h"
+#include "asterisk/stringfields.h"
#include "busy.h"
#include "ringtone.h"
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
AST_MUTEX_DEFINE_STATIC(alsalock);
-static const char type[] = "Console";
static const char desc[] = "ALSA Console Channel Driver";
static const char tdesc[] = "ALSA Console Channel Driver";
static const char config[] = "alsa.conf";
static int alsa_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static const struct ast_channel_tech alsa_tech = {
- .type = type,
+ .type = "Console",
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR,
.requester = alsa_request,
f.datalen = 0;
f.data = NULL;
f.offset = 0;
- f.src = type;
+ f.src = "Console";
f.mallocd = 0;
f.delivery.tv_sec = 0;
f.delivery.tv_usec = 0;
f.datalen = FRAME_SIZE * 2;
f.data = buf;
f.offset = AST_FRIENDLY_OFFSET;
- f.src = type;
+ f.src = "Console";
f.mallocd = 0;
#ifdef ALSA_MONITOR
alsa_monitor_read((char *)buf, FRAME_SIZE * 2);
tmp = ast_channel_alloc(1);
if (tmp) {
tmp->tech = &alsa_tech;
- snprintf(tmp->name, sizeof(tmp->name), "ALSA/%s", indevname);
- tmp->type = type;
+ ast_string_field_build(tmp, name, "ALSA/%s", indevname);
tmp->fds[0] = readdev;
tmp->nativeformats = AST_FORMAT_SLINEAR;
tmp->readformat = AST_FORMAT_SLINEAR;
if (!ast_strlen_zero(p->exten))
ast_copy_string(tmp->exten, p->exten, sizeof(tmp->exten));
if (!ast_strlen_zero(language))
- ast_copy_string(tmp->language, language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, language);
p->owner = tmp;
ast_setstate(tmp, state);
ast_mutex_lock(&usecnt_lock);
return res;
}
-static char *autoanswer_complete(char *line, char *word, int pos, int state)
+static char *autoanswer_complete(const char *line, const char *word, int pos, int state)
{
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
return NULL;
}
-static char autoanswer_usage[] =
+static const char autoanswer_usage[] =
"Usage: autoanswer [on|off]\n"
" Enables or disables autoanswer feature. If used without\n"
" argument, displays the current on/off status of autoanswer.\n"
res = ast_channel_register(&alsa_tech);
if (res < 0) {
- ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
return -1;
}
for (x=0;x<sizeof(myclis)/sizeof(struct ast_cli_entry); x++)
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/manager.h"
+#include "asterisk/stringfields.h"
static const char desc[] = "Feature Proxy Channel";
-static const char type[] = "Feature";
static const char tdesc[] = "Feature Proxy Channel Driver";
static int usecnt =0;
static int features_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static const struct ast_channel_tech features_tech = {
- .type = type,
+ .type = "Feature",
.description = tdesc,
.capabilities = -1,
.requester = features_request,
p->subchan->cid.cid_ani = NULL;
p->subchan->cid.cid_pres = p->owner->cid.cid_pres;
- strncpy(p->subchan->language, p->owner->language, sizeof(p->subchan->language) - 1);
- strncpy(p->subchan->accountcode, p->owner->accountcode, sizeof(p->subchan->accountcode) - 1);
+ ast_string_field_set(p->subchan, language, p->owner->language);
+ ast_string_field_set(p->subchan, accountcode, p->owner->accountcode);
p->subchan->cdrflags = p->owner->cdrflags;
res = ast_call(p->subchan, dest2, timeout);
update_features(p, x);
}
tmp->tech = &features_tech;
for (x=1;x<4;x++) {
- snprintf(tmp->name, sizeof(tmp->name), "Feature/%s/%s-%d", p->tech, p->dest, x);
+ ast_string_field_build(tmp, name, "Feature/%s/%s-%d", p->tech, p->dest, x);
for (y=0;y<3;y++) {
if (y == index)
continue;
if (y >= 3)
break;
}
- tmp->type = type;
ast_setstate(tmp, state);
tmp->writeformat = p->subchan->writeformat;
tmp->rawwriteformat = p->subchan->rawwriteformat;
{
/* Make sure we can register our sip channel type */
if (ast_channel_register(&features_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Feature'\n");
return -1;
}
ast_cli_register(&cli_show_features);
#include "asterisk/dnsmgr.h"
#include "asterisk/devicestate.h"
#include "asterisk/netsock.h"
+#include "asterisk/stringfields.h"
#include "iax2.h"
#include "iax2-parser.h"
static const char desc[] = "Inter Asterisk eXchange (Ver 2)";
static const char tdesc[] = "Inter Asterisk eXchange Driver (Ver 2)";
-static const char channeltype[] = "IAX2";
static char context[80] = "default";
static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan);
static const struct ast_channel_tech iax2_tech = {
- .type = channeltype,
+ .type = "IAX2",
.description = tdesc,
.capabilities = IAX_CAPABILITY_FULLBANDWIDTH,
.properties = AST_CHAN_TP_WANTSJITTER,
cs[1] = c1;
for (/* ever */;;) {
/* Check in case we got masqueraded into */
- if ((c0->type != channeltype) || (c1->type != channeltype)) {
+ if ((c0->tech != &iax2_tech) || (c1->tech != &iax2_tech)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Can't masquerade, we're different...\n");
/* Remove from native mode */
- if (c0->type == channeltype) {
+ if (c0->tech == &iax2_tech) {
ast_mutex_lock(&iaxsl[callno0]);
iaxs[callno0]->bridgecallno = 0;
ast_mutex_unlock(&iaxsl[callno0]);
}
- if (c1->type == channeltype) {
+ if (c1->tech == &iax2_tech) {
ast_mutex_lock(&iaxsl[callno1]);
iaxs[callno1]->bridgecallno = 0;
ast_mutex_unlock(&iaxsl[callno1]);
i = iaxs[callno];
if (i && tmp) {
tmp->tech = &iax2_tech;
- snprintf(tmp->name, sizeof(tmp->name), "IAX2/%s-%d", i->host, i->callno);
- tmp->type = channeltype;
+ ast_string_field_build(tmp, name, "IAX2/%s-%d", i->host, i->callno);
/* We can support any format by default, until we get restricted */
tmp->nativeformats = capability;
tmp->readformat = ast_best_codec(capability);
if (!ast_strlen_zero(i->ani))
tmp->cid.cid_ani = ast_strdup(i->ani);
if (!ast_strlen_zero(i->language))
- ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->dnid))
tmp->cid.cid_dnid = ast_strdup(i->dnid);
if (!ast_strlen_zero(i->rdnis))
tmp->cid.cid_ton = i->calling_ton;
tmp->cid.cid_tns = i->calling_tns;
if (!ast_strlen_zero(i->accountcode))
- ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode));
+ 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));
while((ext = strsep(&stringp, "&"))) {
if (onoff) {
if (!ast_exists_extension(NULL, regcontext, ext, 1, NULL))
- ast_add_extension(regcontext, 1, ext, 1, NULL, NULL, "Noop", ast_strdup(peer->name), free, channeltype);
+ ast_add_extension(regcontext, 1, ext, 1, NULL, NULL,
+ "Noop", ast_strdup(peer->name), free, "IAX2");
} else
ast_context_remove_extension(regcontext, ext, 1, NULL);
}
chan1m = ast_channel_alloc(0);
chan2m = ast_channel_alloc(0);
if (chan2m && chan1m) {
- snprintf(chan1m->name, sizeof(chan1m->name), "Parking/%s", chan1->name);
+ ast_string_field_build(chan1m, name, "Parking/%s", chan1->name);
/* Make formats okay */
chan1m->readformat = chan1->readformat;
chan1m->writeformat = chan1->writeformat;
/* We make a clone of the peer channel too, so we can play
back the announcement */
- snprintf(chan2m->name, sizeof (chan2m->name), "IAXPeer/%s",chan2->name);
+ ast_string_field_build(chan2m, name, "IAXPeer/%s",chan2->name);
/* Make formats okay */
chan2m->readformat = chan2->readformat;
chan2m->writeformat = chan2->writeformat;
if (opts)
*opts='\0';
- if (chan->type != channeltype) {
+ if (chan->tech != &iax2_tech) {
ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
return -1;
}
ast_copy_string(regcontext, v->value, sizeof(regcontext));
/* Create context if it doesn't exist already */
if (!ast_context_find(regcontext))
- ast_context_create(NULL, regcontext, channeltype);
+ ast_context_create(NULL, regcontext, "IAX2");
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
set_config(config, 0);
if (ast_channel_register(&iax2_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
+ ast_log(LOG_ERROR, "Unable to register channel class %s\n", "IAX2");
__unload_module();
return -1;
}
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/manager.h"
+#include "asterisk/stringfields.h"
static const char desc[] = "Local Proxy Channel";
-static const char type[] = "Local";
static const char tdesc[] = "Local Proxy Channel Driver";
static int usecnt =0;
/* PBX interface structure for channel registration */
static const struct ast_channel_tech local_tech = {
- .type = type,
+ .type = "Local",
.description = tdesc,
.capabilities = -1,
.requester = local_request,
p->chan->cid.cid_rdnis = ast_strdup(p->owner->cid.cid_rdnis);
p->chan->cid.cid_ani = ast_strdup(p->owner->cid.cid_ani);
- strncpy(p->chan->language, p->owner->language, sizeof(p->chan->language) - 1);
- strncpy(p->chan->accountcode, p->owner->accountcode, sizeof(p->chan->accountcode) - 1);
+ ast_string_field_set(p->chan, language, p->owner->language);
+ ast_string_field_set(p->chan, accountcode, p->owner->accountcode);
p->chan->cdrflags = p->owner->cdrflags;
/* copy the channel variables from the incoming channel to the outgoing channel */
tmp2->tech = tmp->tech = &local_tech;
tmp->nativeformats = p->reqformat;
tmp2->nativeformats = p->reqformat;
- snprintf(tmp->name, sizeof(tmp->name), "Local/%s@%s-%04x,1", p->exten, p->context, randnum);
- snprintf(tmp2->name, sizeof(tmp2->name), "Local/%s@%s-%04x,2", p->exten, p->context, randnum);
- tmp->type = type;
- tmp2->type = type;
+ ast_string_field_build(tmp, name, "Local/%s@%s-%04x,1", p->exten, p->context, randnum);
+ ast_string_field_build(tmp2, name, "Local/%s@%s-%04x,2", p->exten, p->context, randnum);
ast_setstate(tmp, state);
ast_setstate(tmp2, AST_STATE_RING);
tmp->writeformat = p->reqformat;
{
/* Make sure we can register our channel type */
if (ast_channel_register(&local_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
return -1;
}
ast_cli_register(&cli_show_locals);
#include "asterisk/causes.h"
#include "asterisk/dsp.h"
#include "asterisk/devicestate.h"
+#include "asterisk/stringfields.h"
#ifndef IPTOS_MINCOST
#define IPTOS_MINCOST 0x02
#endif
static const char desc[] = "Media Gateway Control Protocol (MGCP)";
-static const char type[] = "MGCP";
static const char tdesc[] = "Media Gateway Control Protocol (MGCP)";
static const char config[] = "mgcp.conf";
static int mgcp_devicestate(void *data);
static const struct ast_channel_tech mgcp_tech = {
- .type = type,
+ .type = "MGCP",
.description = tdesc,
.capabilities = AST_FORMAT_ULAW,
.properties = AST_CHAN_TP_WANTSJITTER,
if (!tmp->nativeformats)
tmp->nativeformats = capability;
fmt = ast_best_codec(tmp->nativeformats);
- snprintf(tmp->name, sizeof(tmp->name), "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
+ ast_string_field_build(tmp, name, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
if (sub->rtp)
tmp->fds[0] = ast_rtp_fd(sub->rtp);
- tmp->type = type;
if (i->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID)) {
i->dsp = ast_dsp_new();
ast_dsp_set_features(i->dsp,DSP_FEATURE_DTMF_DETECT);
tmp->rawreadformat = fmt;
tmp->tech_pvt = sub;
if (!ast_strlen_zero(i->language))
- strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->accountcode))
- strncpy(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode)-1);
+ ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
sub->owner = tmp;
ast_update_use_count();
tmp->callgroup = i->callgroup;
tmp->pickupgroup = i->pickupgroup;
- strncpy(tmp->call_forward, i->call_forward, sizeof(tmp->call_forward) - 1);
+ ast_string_field_set(tmp, call_forward, i->call_forward);
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
if (!ast_strlen_zero(i->cid_num))
}
static struct ast_rtp_protocol mgcp_rtp = {
- .type = type,
+ .type = "MGCP",
.get_rtp_info = mgcp_get_rtp_peer,
.set_rtp_peer = mgcp_set_rtp_peer,
};
if (!(res = reload_config())) {
/* Make sure we can register our mgcp channel type */
if (ast_channel_register(&mgcp_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'MGCP'\n");
return -1;
}
ast_rtp_proto_register(&mgcp_rtp);
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/endian.h"
+#include "asterisk/stringfields.h"
/* ringtones we use */
#include "busy.h"
struct chan_oss_pvt {
struct chan_oss_pvt *next;
- char *type; /* XXX maybe take the one from oss_tech */
char *name;
/*
* cursound indicates which in struct sound we play. -1 means nothing,
};
static struct chan_oss_pvt oss_default = {
- .type = "Console",
.cursound = -1,
.sounddev = -1,
.duplex = M_UNSET, /* XXX check this */
static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static const struct ast_channel_tech oss_tech = {
- .type = "Console",
+ .type = "Console",
.description = "OSS Console Channel Driver",
.capabilities = AST_FORMAT_SLINEAR,
- .requester = oss_request,
- .send_digit = oss_digit,
- .send_text = oss_text,
- .hangup = oss_hangup,
- .answer = oss_answer,
- .read = oss_read,
- .call = oss_call,
- .write = oss_write,
- .indicate = oss_indicate,
- .fixup = oss_fixup,
+ .requester = oss_request,
+ .send_digit = oss_digit,
+ .send_text = oss_text,
+ .hangup = oss_hangup,
+ .answer = oss_answer,
+ .read = oss_read,
+ .call = oss_call,
+ .write = oss_write,
+ .indicate = oss_indicate,
+ .fixup = oss_fixup,
};
/*
/* prepare a NULL frame in case we don't have enough data to return */
bzero(f, sizeof(struct ast_frame));
f->frametype = AST_FRAME_NULL;
- f->src = o->type;
+ f->src = oss_tech.type;
res = read(o->sounddev, o->oss_read_buf + o->readpos,
sizeof(o->oss_read_buf) - o->readpos);
if (c == NULL)
return NULL;
c->tech = &oss_tech;
- snprintf(c->name, sizeof(c->name), "OSS/%s", o->device + 5);
- c->type = o->type;
+ ast_string_field_build(c, name, "OSS/%s", o->device + 5);
c->fds[0] = o->sounddev; /* -1 if device closed, override later */
c->nativeformats = AST_FORMAT_SLINEAR;
c->readformat = AST_FORMAT_SLINEAR;
if (!ast_strlen_zero(ext))
ast_copy_string(c->exten, ext, sizeof(c->exten));
if (!ast_strlen_zero(o->language))
- ast_copy_string(c->language, o->language, sizeof(c->language));
+ ast_string_field_set(c, language, o->language);
if (!ast_strlen_zero(o->cid_num))
c->cid.cid_num = ast_strdup(o->cid_num);
if (!ast_strlen_zero(o->cid_name))
}
i = ast_channel_register(&oss_tech);
if (i < 0) {
- ast_log(LOG_ERROR, "Unable to register channel class '%s'\n",
- oss_default.type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
/* XXX should cleanup allocated memory etc. */
return -1;
}
#include "asterisk/utils.h"
#include "asterisk/callerid.h"
#include "asterisk/causes.h"
+#include "asterisk/stringfields.h"
+
#include "DialTone.h"
#ifdef QTI_PHONEJACK_TJ_PCI /* check for the newer quicknet driver v.3.1.0 which has this symbol */
#define DEFAULT_GAIN 0x100
static const char desc[] = "Linux Telephony API Support";
-static const char type[] = "Phone";
static const char tdesc[] = "Standard Linux Telephony API Driver";
static const char config[] = "phone.conf";
static int phone_indicate(struct ast_channel *chan, int condition);
static const struct ast_channel_tech phone_tech = {
- .type = type,
+ .type = "Phone",
.description = tdesc,
.capabilities = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW,
.requester = phone_request,
};
static struct ast_channel_tech phone_tech_fxs = {
- .type = type,
+ .type = "Phone",
.description = tdesc,
.requester = phone_request,
.send_digit = phone_digit,
p->fr.datalen = 0;
p->fr.samples = 0;
p->fr.data = NULL;
- p->fr.src = type;
+ p->fr.src = "Phone";
p->fr.offset = 0;
p->fr.mallocd=0;
p->fr.delivery = ast_tv(0,0);
p->fr.datalen = 0;
p->fr.samples = 0;
p->fr.data = NULL;
- p->fr.src = type;
+ p->fr.src = "Phone";
p->fr.offset = 0;
p->fr.mallocd=0;
p->fr.delivery = ast_tv(0,0);
tmp = ast_channel_alloc(1);
if (tmp) {
tmp->tech = cur_tech;
- snprintf(tmp->name, sizeof(tmp->name), "Phone/%s", i->dev + 5);
- tmp->type = type;
+ ast_string_field_build(tmp, name, "Phone/%s", i->dev + 5);
tmp->fds[0] = i->fd;
/* XXX Switching formats silently causes kernel panics XXX */
if (i->mode == MODE_FXS &&
else
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
if (!ast_strlen_zero(i->language))
- strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->cid_num))
tmp->cid.cid_num = strdup(i->cid_num);
if (!ast_strlen_zero(i->cid_name))
/* Make sure we can register our Adtranphone channel type */
if (ast_channel_register(cur_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Phone'\n");
ast_config_destroy(cfg);
__unload_module();
return -1;
static const char desc[] = "Session Initiation Protocol (SIP)";
-static const char channeltype[] = "SIP";
static const char config[] = "sip.conf";
static const char notify_config[] = "sip_notify.conf";
static int usecnt = 0;
/*! \brief Definition of this channel for PBX channel registration */
static const struct ast_channel_tech sip_tech = {
- .type = channeltype,
+ .type = "SIP",
.description = "Session Initiation Protocol (SIP)",
.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
.properties = AST_CHAN_TP_WANTSJITTER,
/*! \brief Interface structure with callbacks used to connect to RTP module */
static struct ast_rtp_protocol sip_rtp = {
- type: channeltype,
+ type: "SIP",
get_rtp_info: sip_get_rtp_peer,
get_vrtp_info: sip_get_vrtp_peer,
set_rtp_peer: sip_set_rtp_peer,
stringp = multi;
while((ext = strsep(&stringp, "&"))) {
if (onoff)
- ast_add_extension(regcontext, 1, ext, 1, NULL, NULL, "Noop", ast_strdup(peer->name), free, channeltype);
+ ast_add_extension(regcontext, 1, ext, 1, NULL, NULL, "Noop",
+ ast_strdup(peer->name), free, "SIP");
else
ast_context_remove_extension(regcontext, ext, 1, NULL);
}
fmt = ast_best_codec(tmp->nativeformats);
if (title)
- snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%04x", title, thread_safe_rand() & 0xffff);
+ ast_string_field_build(tmp, name, "SIP/%s-%04x", title, thread_safe_rand() & 0xffff);
else if (strchr(i->fromdomain,':'))
- snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", strchr(i->fromdomain,':')+1, (int)(long)(i));
+ ast_string_field_build(tmp, name, "SIP/%s-%08x", strchr(i->fromdomain,':')+1, (int)(long)(i));
else
- snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", i->fromdomain, (int)(long)(i));
+ ast_string_field_build(tmp, name, "SIP/%s-%08x", i->fromdomain, (int)(long)(i));
- tmp->type = channeltype;
if (ast_test_flag(i, SIP_DTMF) == SIP_DTMF_INBAND) {
i->vad = ast_dsp_new();
ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
tmp->pickupgroup = i->pickupgroup;
tmp->cid.cid_pres = i->callingpres;
if (!ast_strlen_zero(i->accountcode))
- ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode));
+ ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
if (!ast_strlen_zero(i->language))
- ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->musicclass))
- ast_copy_string(tmp->musicclass, i->musicclass, sizeof(tmp->musicclass));
+ ast_string_field_set(tmp, musicclass, i->musicclass);
i->owner = tmp;
ast_mutex_lock(&usecnt_lock);
usecnt++;
if (!(p = ast_calloc(1, sizeof(*p))))
return NULL;
- if (ast_string_field_init(p)) {
+ if (ast_string_field_init(p, 512)) {
free(p);
return NULL;
}
return -1;
}
- if (ast_string_field_init(reg)) {
+ if (ast_string_field_init(reg, 256)) {
ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry strings\n");
free(reg);
return -1;
}
ast_mutex_lock(&chan->lock);
- if (chan->type != channeltype) {
+ if (chan->tech != &sip_tech) {
ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
ast_mutex_unlock(&chan->lock);
return NULL;
}
ast_mutex_lock(&chan->lock);
- if (chan->type != channeltype) {
+ if (chan->tech != &sip_tech) {
ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
ast_mutex_unlock(&chan->lock);
return NULL;
*e = '\0';
ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
if (p->owner)
- snprintf(p->owner->call_forward, sizeof(p->owner->call_forward), "SIP/%s", s);
+ ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
} else {
e = strchr(tmp, '@');
if (e)
s += 4;
ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s);
if (p->owner)
- ast_copy_string(p->owner->call_forward, s, sizeof(p->owner->call_forward));
+ ast_string_field_set(p->owner, call_forward, s);
}
}
forward and hope we end up at the right place... */
ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
if (p->owner)
- snprintf(p->owner->call_forward, sizeof(p->owner->call_forward), "Local/%s@%s", p->username, p->context);
+ ast_string_field_build(p->owner, call_forward,
+ "Local/%s@%s", p->username, p->context);
/* Fall through */
case 488: /* Not acceptable here - codec error */
case 480: /* Temporarily Unavailable */
ast_hangup(chan2m);
return -1;
}
- snprintf(chan1m->name, sizeof(chan1m->name), "Parking/%s", chan1->name);
+ ast_string_field_build(chan1m, name, "Parking/%s", chan1->name);
/* Make formats okay */
chan1m->readformat = chan1->readformat;
chan1m->writeformat = chan1->writeformat;
/* We make a clone of the peer channel too, so we can play
back the announcement */
- snprintf(chan2m->name, sizeof (chan2m->name), "SIPPeer/%s",chan2->name);
+ ast_string_field_build(chan2m, name, "SIPPeer/%s",chan2->name);
/* Make formats okay */
chan2m->readformat = chan2->readformat;
chan2m->writeformat = chan2->writeformat;
ast_copy_string(regcontext, v->value, sizeof(regcontext));
/* Create context if it doesn't exist already */
if (!ast_context_find(regcontext))
- ast_context_create(NULL, regcontext, channeltype);
+ ast_context_create(NULL, regcontext, "SIP");
} else if (!strcasecmp(v->name, "callerid")) {
ast_copy_string(default_callerid, v->value, sizeof(default_callerid));
} else if (!strcasecmp(v->name, "fromdomain")) {
return 0;
}
ast_mutex_lock(&chan->lock);
- if (chan->type != channeltype) {
+ if (chan->tech != &sip_tech) {
ast_log(LOG_WARNING, "Call this application only on SIP incoming calls\n");
ast_mutex_unlock(&chan->lock);
return 0;
/* Make sure we can register our sip channel type */
if (ast_channel_register(&sip_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel type %s\n", channeltype);
+ ast_log(LOG_ERROR, "Unable to register channel type 'SIP'\n");
return -1;
}
#include "asterisk/musiconhold.h"
#include "asterisk/utils.h"
#include "asterisk/dsp.h"
+#include "asterisk/stringfields.h"
/************************************************************************************/
/* Skinny/Asterisk Protocol Settings */
/************************************************************************************/
static const char desc[] = "Skinny Client Control Protocol (Skinny)";
static const char tdesc[] = "Skinny Client Control Protocol (Skinny)";
-static const char type[] = "Skinny";
static const char config[] = "skinny.conf";
/* Just about everybody seems to support ulaw, so make it a nice default */
static int skinny_senddigit(struct ast_channel *ast, char digit);
static const struct ast_channel_tech skinny_tech = {
- .type = type,
+ .type = "Skinny",
.description = tdesc,
.capabilities = AST_FORMAT_ULAW,
.properties = AST_CHAN_TP_WANTSJITTER,
}
static struct ast_rtp_protocol skinny_rtp = {
- .type = type,
+ .type = "Skinny",
.get_rtp_info = skinny_get_rtp_peer,
.get_vrtp_info = skinny_get_vrtp_peer,
.set_rtp_peer = skinny_set_rtp_peer,
tmp->nativeformats = capability;
fmt = ast_best_codec(tmp->nativeformats);
ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt);
- snprintf(tmp->name, sizeof(tmp->name), "Skinny/%s@%s-%d", l->name, l->parent->name, sub->callid);
+ ast_string_field_build(tmp, name, "Skinny/%s@%s-%d", l->name, l->parent->name, sub->callid);
if (sub->rtp) {
tmp->fds[0] = ast_rtp_fd(sub->rtp);
}
- tmp->type = type;
ast_setstate(tmp, state);
if (state == AST_STATE_RING) {
tmp->rings = 1;
tmp->readformat = fmt;
tmp->rawreadformat = fmt;
tmp->tech_pvt = sub;
- if (!ast_strlen_zero(l->language)) {
- strncpy(tmp->language, l->language, sizeof(tmp->language)-1);
- }
- if (!ast_strlen_zero(l->accountcode)) {
- strncpy(tmp->accountcode, l->accountcode, sizeof(tmp->accountcode)-1);
- }
- if (l->amaflags) {
+ if (!ast_strlen_zero(l->language))
+ ast_string_field_set(tmp, language, l->language);
+ if (!ast_strlen_zero(l->accountcode))
+ ast_string_field_set(tmp, accountcode, l->accountcode);
+ if (l->amaflags)
tmp->amaflags = l->amaflags;
- }
sub->owner = tmp;
ast_mutex_lock(&usecnt_lock);
usecnt++;
ast_update_use_count();
tmp->callgroup = l->callgroup;
tmp->pickupgroup = l->pickupgroup;
- strncpy(tmp->call_forward, l->call_forward, sizeof(tmp->call_forward) - 1);
+ ast_string_field_set(tmp, call_forward, l->call_forward);
strncpy(tmp->context, l->context, sizeof(tmp->context)-1);
strncpy(tmp->exten,l->exten, sizeof(tmp->exten)-1);
if (!ast_strlen_zero(l->cid_num)) {
if (!res) {
/* Make sure we can register our skinny channel type */
if (ast_channel_register(&skinny_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Skinny'\n");
return -1;
}
}
#include "asterisk/term.h"
#include "asterisk/utils.h"
#include "asterisk/transcap.h"
+#include "asterisk/stringfields.h"
#ifndef ZT_SIG_EM_E1
-#error "Your zaptel is too old. please cvs update"
+#error "Your zaptel is too old. please update"
#endif
#ifndef ZT_TONEDETECT
#endif
;
-static const char type[] = "Zap";
static const char config[] = "zapata.conf";
#define SIG_EM ZT_SIG_EM
static char privateprefix[20] = "";
static char unknownprefix[20] = "";
static long resetinterval = 3600; /*!< How often (in seconds) to reset unused channels. Default 1 hour. */
-static struct ast_channel inuse = { "GR-303InUse" };
+static struct ast_channel inuse;
#ifdef PRI_GETSET_TIMERS
static int pritimers[PRI_MAX_TIMERS];
#endif
static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen);
static const struct ast_channel_tech zap_tech = {
- .type = type,
+ .type = "Zap",
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
.requester = zt_request,
do {
#ifdef ZAPATA_PRI
if (i->bearer || (i->pri && (i->sig == SIG_FXSKS)))
- snprintf(tmp->name, sizeof(tmp->name), "Zap/%d:%d-%d", i->pri->trunkgroup, i->channel, y);
+ ast_string_field_build(tmp, name, "Zap/%d:%d-%d", i->pri->trunkgroup, i->channel, y);
else
#endif
if (i->channel == CHAN_PSEUDO)
- snprintf(tmp->name, sizeof(tmp->name), "Zap/pseudo-%d", rand());
+ ast_string_field_build(tmp, name, "Zap/pseudo-%d", rand());
else
- snprintf(tmp->name, sizeof(tmp->name), "Zap/%d-%d", i->channel, y);
+ ast_string_field_build(tmp, name, "Zap/%d-%d", i->channel, y);
for (x=0;x<3;x++) {
if ((index != x) && i->subs[x].owner && !strcasecmp(tmp->name, i->subs[x].owner->name))
break;
}
y++;
} while (x < 3);
- tmp->type = type;
tmp->fds[0] = i->subs[index].zfd;
tmp->nativeformats = AST_FORMAT_SLINEAR | deflaw;
/* Start out assuming ulaw since it's smaller :) */
tmp->pickupgroup = i->pickupgroup;
}
if (!ast_strlen_zero(i->language))
- ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->musicclass))
- ast_copy_string(tmp->musicclass, i->musicclass, sizeof(tmp->musicclass));
+ ast_string_field_set(tmp, musicclass, i->musicclass);
if (!i->owner)
i->owner = tmp;
if (!ast_strlen_zero(i->accountcode))
- ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode));
+ ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
i->subs[index].owner = tmp;
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
- /* Copy call forward info */
- ast_copy_string(tmp->call_forward, i->call_forward, sizeof(tmp->call_forward));
+ 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 (nbridge && ast_bridged_channel(nbridge))
pbridge = ast_bridged_channel(nbridge)->tech_pvt;
if (nbridge && pbridge &&
- (!strcmp(nbridge->type,"Zap")) &&
- (!strcmp(ast_bridged_channel(nbridge)->type, "Zap")) &&
+ (nbridge->tech == &zap_tech) &&
+ (ast_bridged_channel(nbridge)->tech == &zap_tech) &&
ISTRUNK(pbridge)) {
int func = ZT_FLASH;
/* Clear out the dial buffer */
/* Fix it all up now */
pri->pvts[principle]->owner = pri->pvts[x]->owner;
if (pri->pvts[principle]->owner) {
- snprintf(pri->pvts[principle]->owner->name, sizeof(pri->pvts[principle]->owner->name),
- "Zap/%d:%d-%d", pri->trunkgroup, pri->pvts[principle]->channel, 1);
+ ast_string_field_build(pri->pvts[principle]->owner, name,
+ "Zap/%d:%d-%d", pri->trunkgroup,
+ pri->pvts[principle]->channel, 1);
pri->pvts[principle]->owner->tech_pvt = pri->pvts[principle];
pri->pvts[principle]->owner->fds[0] = pri->pvts[principle]->subs[SUB_REAL].zfd;
pri->pvts[principle]->subs[SUB_REAL].owner = pri->pvts[x]->subs[SUB_REAL].owner;
return -1;
}
if (ast_channel_register(&zap_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Zap'\n");
__unload_module();
return -1;
}
ast_manager_register( "ZapDNDon", 0, action_zapdndon, "Toggle Zap channel Do Not Disturb status ON" );
ast_manager_register( "ZapDNDoff", 0, action_zapdndoff, "Toggle Zap channel Do Not Disturb status OFF" );
ast_manager_register("ZapShowChannels", 0, action_zapshowchannels, "Show status zapata channels");
+ ast_string_field_init(&inuse, 16);
+ ast_string_field_set(&inuse, name, "GR-303InUse");
return res;
}
dump_ies(fh->iedata, datalen);
}
-int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen)
+int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
{
char tmp[256];
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
return 0;
}
-int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin)
+int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin)
{
return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
}
return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
}
-int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, char *str)
+int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
{
return iax_ie_append_raw(ied, ie, str, strlen(str));
}
};
/* Choose a different function for output */
-extern void iax_set_output(void (*output)(const char *data));
+void iax_set_output(void (*output)(const char *data));
/* Choose a different function for errors */
-extern void iax_set_error(void (*output)(const char *data));
-extern void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
+void iax_set_error(void (*output)(const char *data));
+void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
-extern const char *iax_ie2str(int ie);
+const char *iax_ie2str(int ie);
-extern int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen);
-extern int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin);
-extern int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
-extern int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
-extern int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, char *str);
-extern int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
-extern int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
-extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
+int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
+int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
+int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
+int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
+int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
+int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
+int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
+int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
-extern int iax_get_frames(void);
-extern int iax_get_iframes(void);
-extern int iax_get_oframes(void);
+int iax_get_frames(void);
+int iax_get_iframes(void);
+int iax_get_oframes(void);
-extern void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
-extern struct iax_frame *iax_frame_new(int direction, int datalen);
-extern void iax_frame_free(struct iax_frame *fr);
+void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
+struct iax_frame *iax_frame_new(int direction, int datalen);
+void iax_frame_free(struct iax_frame *fr);
#endif
" Application: %s\n"
" Data: %s\n"
" Blocking in: %s\n",
- c->name, c->type, c->uniqueid,
+ c->name, c->tech->type, c->uniqueid,
(c->cid.cid_num ? c->cid.cid_num : "(N/A)"),
(c->cid.cid_name ? c->cid.cid_name : "(N/A)"),
(c->cid.cid_dnid ? c->cid.cid_dnid : "(N/A)" ), ast_state2str(c->_state), c->_state, c->rings,
" Displays codec mapping\n";
/*! Dump a frame for debugging purposes */
-void ast_frame_dump(char *name, struct ast_frame *f, char *prefix)
+void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
{
- char *n = "unknown";
+ const char noname[] = "unknown";
char ftype[40] = "Unknown Frametype";
char cft[80];
char subclass[40] = "Unknown Subclass";
char cn[60];
char cp[40];
char cmn[40];
- if (name)
- n = name;
+
+ if (!name)
+ name = noname;
+
+
if (!f) {
ast_verbose("%s [ %s (NULL) ] [%s]\n",
term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
term_color(cft, "HANGUP", COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
- term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
+ term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
return;
}
/* XXX We should probably print one each of voice and video when the format changes XXX */
}
if (!ast_strlen_zero(moreinfo))
ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n",
- term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
- term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
- f->frametype,
- term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass,
- term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
- term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
+ term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
+ term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
+ f->frametype,
+ term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
+ f->subclass,
+ term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
+ term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
else
ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) ] [%s]\n",
- term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
- term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
- f->frametype,
- term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass,
- term_color(cn, n, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
-
+ term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
+ term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
+ f->frametype,
+ term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
+ f->subclass,
+ term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
}
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
+#include "asterisk/stringfields.h"
static char *builtin_function_language_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
static void builtin_function_language_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
{
if (value)
- ast_copy_string(chan->language, value, sizeof(chan->language));
+ ast_string_field_set(chan, language, value);
}
#ifndef BUILTIN_FUNC
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
+#include "asterisk/stringfields.h"
static char *function_moh_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
static void function_moh_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
{
- ast_copy_string(chan->musicclass, value, sizeof(chan->musicclass));
+ ast_string_field_set(chan, musicclass, value);
}
#ifndef BUILTIN_FUNC
return 0;
}
-static void make_filename(char *buf, int len, char *filename, char *preflang, char *ext)
+static void make_filename(char *buf, int len, char *filename, const char *preflang, char *ext)
{
if (filename[0] == '/') {
if (preflang && strlen(preflang))
}
}
-struct ast_frame *ast_read_image(char *filename, char *preflang, int format)
+struct ast_frame *ast_read_image(char *filename, const char *preflang, int format)
{
struct ast_imager *i;
char buf[256];
struct ast_cdr *next;
};
-extern void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur);
-extern int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur);
-extern int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, char delim, char sep, int recur);
-extern void ast_cdr_free_vars(struct ast_cdr *cdr, int recur);
-extern int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr);
+void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur);
+int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur);
+int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, char delim, char sep, int recur);
+void ast_cdr_free_vars(struct ast_cdr *cdr, int recur);
+int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr);
typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
/*! \brief Allocate a CDR record
* Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
*/
-extern struct ast_cdr *ast_cdr_alloc(void);
+struct ast_cdr *ast_cdr_alloc(void);
/*! \brief Duplicate a record
* Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
*/
-extern struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr);
+struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr);
/*! \brief Free a CDR record
* \param cdr ast_cdr structure to free
* Returns nothing important
*/
-extern void ast_cdr_free(struct ast_cdr *cdr);
+void ast_cdr_free(struct ast_cdr *cdr);
/*! \brief Initialize based on a channel
* \param cdr Call Detail Record to use for channel
* Initializes a CDR and associates it with a particular channel
* Return is negligible. (returns 0 by default)
*/
-extern int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
+int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
/*! Initialize based on a channel */
/*!
* Initializes a CDR and associates it with a particular channel
* Return is negligible. (returns 0 by default)
*/
-extern int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
+int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
/*! Register a CDR handling engine */
/*!
* Used to register a Call Detail Record handler.
* Returns -1 on error, 0 on success.
*/
-extern int ast_cdr_register(char *name, char *desc, ast_cdrbe be);
+int ast_cdr_register(char *name, char *desc, ast_cdrbe be);
/*! Unregister a CDR handling engine */
/*!
* \param name name of CDR handler to unregister
* Unregisters a CDR by it's name
*/
-extern void ast_cdr_unregister(char *name);
+void ast_cdr_unregister(char *name);
/*! Start a call */
/*!
* Starts all CDR stuff necessary for monitoring a call
* Returns nothing important
*/
-extern void ast_cdr_start(struct ast_cdr *cdr);
+void ast_cdr_start(struct ast_cdr *cdr);
/*! Answer a call */
/*!
* \param cdr the cdr you wish to associate with the call
* Starts all CDR stuff necessary for doing CDR when answering a call
*/
-extern void ast_cdr_answer(struct ast_cdr *cdr);
+void ast_cdr_answer(struct ast_cdr *cdr);
/*! Busy a call */
/*!
* \param cdr the cdr you wish to associate with the call
* Returns nothing important
*/
-extern void ast_cdr_busy(struct ast_cdr *cdr);
+void ast_cdr_busy(struct ast_cdr *cdr);
/*! Fail a call */
/*!
* \param cdr the cdr you wish to associate with the call
* Returns nothing important
*/
-extern void ast_cdr_failed(struct ast_cdr *cdr);
+void ast_cdr_failed(struct ast_cdr *cdr);
/*! Save the result of the call based on the AST_CAUSE_* */
/*!
* Returns nothing important
* \param cause the AST_CAUSE_*
*/
-extern int ast_cdr_disposition(struct ast_cdr *cdr, int cause);
+int ast_cdr_disposition(struct ast_cdr *cdr, int cause);
/*! End a call */
/*!
* Registers the end of call time in the cdr structure.
* Returns nothing important
*/
-extern void ast_cdr_end(struct ast_cdr *cdr);
+void ast_cdr_end(struct ast_cdr *cdr);
/*! Detaches the detail record for posting (and freeing) either now or at a
* later time in bulk with other records during batch mode operation */
* Prevents the channel thread from blocking on the CDR handling
* Returns nothing
*/
-extern void ast_cdr_detach(struct ast_cdr *cdr);
+void ast_cdr_detach(struct ast_cdr *cdr);
/*! Spawns (possibly) a new thread to submit a batch of CDRs to the backend engines */
/*!
* Blocks the asterisk shutdown procedures until the CDR data is submitted.
* Returns nothing
*/
-extern void ast_cdr_submit_batch(int shutdown);
+void ast_cdr_submit_batch(int shutdown);
/*! Set the destination channel, if there was one */
/*!
* Sets the destination channel the CDR is applied to
* Returns nothing
*/
-extern void ast_cdr_setdestchan(struct ast_cdr *cdr, char *chan);
+void ast_cdr_setdestchan(struct ast_cdr *cdr, const char *chan);
/*! Set the last executed application */
/*!
* Changes the value of the last executed app
* Returns nothing
*/
-extern void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data);
+void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data);
/*! Convert a string to a detail record AMA flag */
/*!
* Converts the string form of the flag to the binary form.
* Returns the binary form of the flag
*/
-extern int ast_cdr_amaflags2int(const char *flag);
+int ast_cdr_amaflags2int(const char *flag);
/*! Disposition to a string */
/*!
* Converts the binary form of a disposition to string form.
* Returns a pointer to the string form
*/
-extern char *ast_cdr_disp2str(int disposition);
+char *ast_cdr_disp2str(int disposition);
/*! Reset the detail record, optionally posting it first */
/*!
* \param flags |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it
* |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's
*/
-extern void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags);
+void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags);
/*! Flags to a string */
/*!
* Converts binary flags to string flags
* Returns string with flag name
*/
-extern char *ast_cdr_flags2str(int flags);
+char *ast_cdr_flags2str(int flags);
-extern int ast_cdr_setaccount(struct ast_channel *chan, const char *account);
-extern int ast_cdr_setamaflags(struct ast_channel *chan, const char *amaflags);
+int ast_cdr_setaccount(struct ast_channel *chan, const char *account);
+int ast_cdr_setamaflags(struct ast_channel *chan, const char *amaflags);
-extern int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield);
-extern int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield);
+int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield);
+int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield);
/* Update CDR on a channel */
-extern int ast_cdr_update(struct ast_channel *chan);
+int ast_cdr_update(struct ast_channel *chan);
extern int ast_default_amaflags;
extern char ast_default_accountcode[AST_MAX_ACCOUNT_CODE];
-extern struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
+struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
/*! Reload the configuration file cdr.conf and start/stop CDR scheduling thread */
-extern void ast_cdr_engine_reload(void);
+void ast_cdr_engine_reload(void);
/*! Load the configuration file cdr.conf and possibly start the CDR scheduling thread */
-extern int ast_cdr_engine_init(void);
+int ast_cdr_engine_init(void);
/*! Submit any remaining CDRs and prepare for shutdown */
-extern void ast_cdr_engine_term(void);
+void ast_cdr_engine_term(void);
#endif /* _ASTERISK_CDR_H */
#include "asterisk/cdr.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/stringfields.h"
#define MAX_LANGUAGE 20
* this structure is changed. XXX
*/
struct ast_channel {
- /*! ASCII unique channel name */
- char name[AST_CHANNEL_NAME];
-
/*! Technology (point to channel driver) */
const struct ast_channel_tech *tech;
/*! Private data used by the technology driver */
void *tech_pvt;
- /*! Language requested for voice prompts */
- char language[MAX_LANGUAGE];
- /*! Type of channel */
- const char *type;
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(name); /*! ASCII unique channel name */
+ AST_STRING_FIELD(language); /*! Language requested for voice prompts */
+ AST_STRING_FIELD(musicclass); /*! Default music class */
+ AST_STRING_FIELD(accountcode); /*! Account code for billing */
+ AST_STRING_FIELD(call_forward); /*! Where to forward to if asked to dial on this interface */
+ );
+
/*! File descriptor for channel -- Drivers will poll on these file descriptors, so at least one must be non -1. */
int fds[AST_MAX_FDS];
- /*! Default music class */
- char musicclass[MAX_MUSICCLASS];
/*! Music State*/
void *music_state;
/*! Current generator data if there is any */
struct ast_pbx *pbx;
/*! Set BEFORE PBX is started to determine AMA flags */
int amaflags;
- /*! Account code for billing */
- char accountcode[AST_MAX_ACCOUNT_CODE];
/*! Call Detail Record */
struct ast_cdr *cdr;
/*! Whether or not ADSI is detected on CPE */
int adsicpe;
- /*! Where to forward to if asked to dial on this interface */
- char call_forward[AST_MAX_EXTENSION];
/*! Tone zone as set in indications.conf */
struct tone_zone *zone;
#define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 1)
#endif
-extern void ast_frame_dump(char *name, struct ast_frame *f, char *prefix);
+extern void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix);
/*! \brief Initialize a codec preference to "no preference" */
extern void ast_codec_pref_init(struct ast_codec_pref *pref);
* Make an image from a filename ??? No estoy positivo
* Returns an ast_frame on success, NULL on failure
*/
-extern struct ast_frame *ast_read_image(char *filename, char *preflang, int format);
+extern struct ast_frame *ast_read_image(char *filename, const char *preflang, int format);
/*! Register image format */
/*!
#endif
/*! Turn on music on hold on a given channel */
-extern int ast_moh_start(struct ast_channel *chan, char *mclass);
+int ast_moh_start(struct ast_channel *chan, const char *mclass);
/*! Turn off music on hold on a given channel */
-extern void ast_moh_stop(struct ast_channel *chan);
+void ast_moh_stop(struct ast_channel *chan);
-extern void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, char *),
- void (*stop_ptr)(struct ast_channel *),
- void (*cleanup_ptr)(struct ast_channel *));
+void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *),
+ void (*stop_ptr)(struct ast_channel *),
+ void (*cleanup_ptr)(struct ast_channel *));
-extern void ast_uninstall_music_functions(void);
+void ast_uninstall_music_functions(void);
+
void ast_moh_cleanup(struct ast_channel *chan);
#if defined(__cplusplus) || defined(c_plusplus)
int index, const char *format, ...);
/*!
- The default amount of storage to be allocated for a field pool.
-*/
-#define AST_STRING_FIELD_DEFAULT_POOL 512
-
-/*!
\brief Declare a string field
\param name The field name
*/
\return the number of fields in the structure's definition
*/
#define ast_string_field_count(x) \
- (offsetof(typeof(*x), __end_field) - offsetof(typeof(*x), __begin_field)) / sizeof(ast_string_field)
+ (offsetof(typeof(*(x)), __end_field) - offsetof(typeof(*(x)), __begin_field)) / sizeof(ast_string_field)
/*!
\brief Get the index of a field in a structure
/*!
\brief Initialize a field pool and fields
\param x Pointer to a structure containing fields
+ \param size Amount of storage to allocate
\return 0 on failure, non-zero on success
*/
-#define ast_string_field_init(x) \
- __ast_string_field_init(&x->__field_mgr, AST_STRING_FIELD_DEFAULT_POOL, &x->__begin_field[0], ast_string_field_count(x))
+#define ast_string_field_init(x, size) \
+ __ast_string_field_init(&(x)->__field_mgr, size, &(x)->__begin_field[0], ast_string_field_count(x))
/*!
\brief Set a field to a simple string value
\return nothing
*/
#define ast_string_field_index_set(x, index, data) do { \
- if ((x->__begin_field[index] = __ast_string_field_alloc_space(&x->__field_mgr, strlen(data) + 1, &x->__begin_field[0], ast_string_field_count(x)))) \
- strcpy((char *) x->__begin_field[index], data); \
+ if (((x)->__begin_field[index] = __ast_string_field_alloc_space(&(x)->__field_mgr, strlen(data) + 1, &(x)->__begin_field[0], ast_string_field_count(x)))) \
+ strcpy((char *) (x)->__begin_field[index], data); \
} while (0)
/*!
\return nothing
*/
#define ast_string_field_index_build(x, index, fmt, args...) \
- __ast_string_field_index_build(&x->__field_mgr, &x->__begin_field[0], ast_string_field_count(x), index, fmt, args)
+ __ast_string_field_index_build(&(x)->__field_mgr, &(x)->__begin_field[0], ast_string_field_count(x), index, fmt, args)
/*!
\brief Set a field to a complex (built) value
pointer is just changed to point to an empty string.
*/
#define ast_string_field_index_free(x, index) do { \
- x->__begin_field[index] = __ast_string_field_empty; \
+ (x)->__begin_field[index] = __ast_string_field_empty; \
} while(0)
/*!
struct ast_string_field_pool *this, *prev; \
for (index = 0; index < ast_string_field_count(x); index ++) \
ast_string_field_index_free(x, index); \
- for (this = x->__field_mgr.pool; this; this = prev) { \
+ for (this = (x)->__field_mgr.pool; this; this = prev) { \
prev = this->prev; \
free(this); \
} \
#include "asterisk/app.h"
#include "asterisk/devicestate.h"
#include "asterisk/compat.h"
+#include "asterisk/stringfields.h"
/*!
* \note I M P O R T A N T :
struct ast_channel *tmpchan;
tmpchan = ast_channel_alloc(0);
if (tmpchan) {
- snprintf(tmpchan->name, sizeof(tmpchan->name), "AsyncGoto/%s", chan->name);
+ ast_string_field_build(tmpchan, name, "AsyncGoto/%s", chan->name);
ast_setstate(tmpchan, chan->_state);
/* Make formats okay */
tmpchan->readformat = chan->readformat;
if (ast_exists_extension(chan, context, "failed", 1, NULL)) {
chan = ast_channel_alloc(0);
if (chan) {
- ast_copy_string(chan->name, "OutgoingSpoolFailed", sizeof(chan->name));
+ ast_string_field_set(chan, name, "OutgoingSpoolFailed");
if (!ast_strlen_zero(context))
ast_copy_string(chan->context, context, sizeof(chan->context));
ast_copy_string(chan->exten, "failed", sizeof(chan->exten));
AST_STANDARD_APP_ARGS(args, parse);
if (!args.lang)
- args.lang = chan->language;
+ args.lang = (char *) chan->language;
if (!args.context)
args.context = chan->context;
fdprintf(fd, "agi_request: %s\n", request);
fdprintf(fd, "agi_channel: %s\n", chan->name);
fdprintf(fd, "agi_language: %s\n", chan->language);
- fdprintf(fd, "agi_type: %s\n", chan->type);
+ fdprintf(fd, "agi_type: %s\n", chan->tech->type);
fdprintf(fd, "agi_uniqueid: %s\n", chan->uniqueid);
/* ANI/DNIS */
for (x = goto_on_transfer; x && *x; x++)
if (*x == '^')
*x = '|';
- strcpy(xferchan->name, chan->name);
+ ast_string_field_set(xferchan, name, chan->name);
/* Make formats okay */
xferchan->readformat = chan->readformat;
xferchan->writeformat = chan->writeformat;
struct ast_bridge_thread_obj *tobj = data;
tobj->chan->appl = "Transferred Call";
- tobj->chan->data = tobj->peer->name;
+ tobj->chan->data = (char *) tobj->peer->name;
tobj->peer->appl = "Transferred Call";
- tobj->peer->data = tobj->chan->name;
+ tobj->peer->data = (char *) tobj->chan->name;
if (tobj->chan->cdr) {
ast_cdr_reset(tobj->chan->cdr, NULL);
ast_cdr_setdestchan(tobj->chan->cdr, tobj->peer->name);
/* Make a new, fake channel that we'll use to masquerade in the real one */
if ((chan = ast_channel_alloc(0))) {
/* Let us keep track of the channel name */
- snprintf(chan->name, sizeof (chan->name), "Parked/%s",rchan->name);
+ ast_string_field_build(chan, name, "Parked/%s",rchan->name);
/* Make formats okay */
chan->readformat = rchan->readformat;
}
if ((xferchan = ast_channel_alloc(0))) {
- snprintf(xferchan->name, sizeof (xferchan->name), "Transfered/%s",transferee->name);
+ ast_string_field_build(xferchan, name, "Transfered/%s", transferee->name);
/* Make formats okay */
xferchan->readformat = transferee->readformat;
xferchan->writeformat = transferee->writeformat;
if (ast_answer(chan))
return -1;
peer->appl = "Bridged Call";
- peer->data = chan->name;
+ peer->data = (char *) chan->name;
/* copy the userfield from the B-leg to A-leg if applicable */
if (chan->cdr && peer->cdr && !ast_strlen_zero(peer->cdr->userfield)) {
#include "asterisk/config.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
+#include "asterisk/stringfields.h"
#define MAX_MOHFILES 512
#define MAX_MOHFILE_LEN 128
ast_log(LOG_WARNING, "SetMusicOnHold requires an argument (class)\n");
return -1;
}
- strncpy(chan->musicclass, data, sizeof(chan->musicclass) - 1);
+ ast_string_field_set(chan, musicclass, data);
return 0;
}
return 0;
}
-static struct mohclass *get_mohbyname(char *name)
+static struct mohclass *get_mohbyname(const char *name)
{
struct mohclass *moh;
moh = mohclasses;
}
}
-static int local_ast_moh_start(struct ast_channel *chan, char *class)
+static int local_ast_moh_start(struct ast_channel *chan, const char *class)
{
struct mohclass *mohclass;
AST_LIST_LOCK(&protos);
AST_LIST_TRAVERSE(&protos, cur, list) {
- if (cur->type == chan->type)
+ if (cur->type == chan->tech->type)
break;
}
AST_LIST_UNLOCK(&protos);
cur = protos;
while (cur) {
- if (cur->type == chan->type)
+ if (cur->type == chan->tech->type)
return cur;
cur = cur->next;
}