From b15d7d047504f82708aed64eee88af61eed97d60 Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Sat, 4 Feb 2006 12:50:41 +0000 Subject: [PATCH] - make it compilable with latest Asterisk HEAD --- chan_capi.c | 25 +++++++++++++++++++++++-- create_config.sh | 16 ++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/chan_capi.c b/chan_capi.c index 01f3fef..5902af5 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -1547,9 +1547,16 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state) } #endif +#ifdef CC_AST_HAS_STRINGFIELD_IN_CHANNEL + ast_string_field_build(tmp, name, "CAPI/%s/%s-%x", + i->name, i->dnid, capi_counter++); +#else snprintf(tmp->name, sizeof(tmp->name) - 1, "CAPI/%s/%s-%x", i->name, i->dnid, capi_counter++); +#endif +#ifdef CC_AST_HAS_TYPE_IN_CHANNEL tmp->type = channeltype; +#endif if (pipe(fds) != 0) { cc_log(LOG_ERROR, "%s: unable to create pipe.\n", i->name); @@ -1628,8 +1635,13 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state) #endif cc_copy_string(tmp->exten, i->dnid, sizeof(tmp->exten)); +#ifdef CC_AST_HAS_STRINGFIELD_IN_CHANNEL + ast_string_field_set(tmp, accountcode, i->accountcode); + ast_string_field_set(tmp, language, i->language); +#else cc_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode)); cc_copy_string(tmp->language, i->language, sizeof(tmp->language)); +#endif i->owner = tmp; cc_mutex_lock(&usecnt_lock); usecnt++; @@ -3618,14 +3630,19 @@ static void capi_handle_msg(_cmsg *CMSG) */ static int capi_retrieve(struct ast_channel *c, char *param) { - struct capi_pvt *i = NULL; + struct capi_pvt *i = CC_CHANNEL_PVT(c); _cmsg CMSG; char fac[4]; unsigned int plci = 0; +#ifdef CC_AST_HAVE_TECH_PVT + if (c->tech->type == channeltype) { +#else if (!(strcmp(c->type, "CAPI"))) { - i = CC_CHANNEL_PVT(c); +#endif plci = i->onholdPLCI; + } else { + i = NULL; } if (param) { @@ -4020,7 +4037,11 @@ static int capicommand_exec(struct ast_channel *chan, void *data) return -1; } +#ifdef CC_AST_HAVE_TECH_PVT + if ((capicmd->capionly) && (chan->tech->type != channeltype)) { +#else if ((capicmd->capionly) && (strcmp(chan->type, "CAPI"))) { +#endif LOCAL_USER_REMOVE(u); cc_log(LOG_WARNING, "capiCommand works on CAPI channels only, check your extensions.conf!\n"); return -1; diff --git a/create_config.sh b/create_config.sh index 8c03686..f9db346 100755 --- a/create_config.sh +++ b/create_config.sh @@ -130,6 +130,22 @@ else echo " * no 'devicestate.h'" fi +if grep -q " Type of channel " $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_TYPE_IN_CHANNEL" >>$CONFIGFILE + echo " * found 'type' in ast_channel" +else + echo "#undef CC_AST_HAS_TYPE_IN_CHANNEL" >>$CONFIGFILE + echo " * no 'type' in ast_channel" +fi + +if grep -q "AST_STRING_FIELD(name)" $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_STRINGFIELD_IN_CHANNEL" >>$CONFIGFILE + echo " * found stringfield in ast_channel" +else + echo "#undef CC_AST_HAS_STRINGFIELD_IN_CHANNEL" >>$CONFIGFILE + echo " * no stringfield in ast_channel" +fi + echo "" >>$CONFIGFILE echo "#endif /* CHAN_CAPI_CONFIG_H */" >>$CONFIGFILE echo "" >>$CONFIGFILE