From 4914a97d304d772d9d125c86fd6c173d8d4b63a5 Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Sun, 19 Nov 2006 14:45:32 +0000 Subject: [PATCH] - Adapted to new ast_channel_alloc from asterisk trunk. --- chan_capi.c | 11 +++++++++++ create_config.sh | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/chan_capi.c b/chan_capi.c index 6dbddf7..6001b00 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -2091,13 +2091,19 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state) int fds[2]; int flags; +#ifdef CC_AST_HAS_EXT_CHAN_ALLOC + tmp = ast_channel_alloc(0, state, i->cid, NULL, + "CAPI/%s/%s-%x", i->name, i->dnid, capi_counter++); +#else tmp = ast_channel_alloc(0); +#endif if (tmp == NULL) { cc_log(LOG_ERROR,"Unable to allocate channel!\n"); return(NULL); } +#ifndef CC_AST_HAS_EXT_CHAN_ALLOC #ifdef CC_AST_HAS_STRINGFIELD_IN_CHANNEL ast_string_field_build(tmp, name, "CAPI/%s/%s-%x", i->name, i->dnid, capi_counter++); @@ -2105,6 +2111,7 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state) snprintf(tmp->name, sizeof(tmp->name) - 1, "CAPI/%s/%s-%x", i->name, i->dnid, capi_counter++); #endif +#endif #ifndef CC_AST_HAS_VERSION_1_4 tmp->type = channeltype; #endif @@ -2178,12 +2185,14 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state) (i->rtp) ? " (RTP)" : ""); cc_copy_string(tmp->context, i->context, sizeof(tmp->context)); +#ifndef CC_AST_HAS_EXT_CHAN_ALLOC if (!ast_strlen_zero(i->cid)) { if (tmp->cid.cid_num) { free(tmp->cid.cid_num); } tmp->cid.cid_num = strdup(i->cid); } +#endif if (!ast_strlen_zero(i->dnid)) { if (tmp->cid.cid_dnid) { free(tmp->cid.cid_dnid); @@ -2213,7 +2222,9 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state) #endif ast_update_use_count(); +#ifndef CC_AST_HAS_EXT_CHAN_ALLOC ast_setstate(tmp, state); +#endif return tmp; } diff --git a/create_config.sh b/create_config.sh index 9ccf2ef..0a0f91a 100755 --- a/create_config.sh +++ b/create_config.sh @@ -44,7 +44,13 @@ if grep -q "ASTERISK_VERSION_NUM 0104" $INCLUDEDIR/version.h; then echo " * found Asterisk version 1.4" VER=1_4 else - echo "#undef CC_AST_HAS_VERSION_1_4" >>$CONFIGFILE + if [ -f "$INCLUDEDIR/../asterisk.h" ]; then + echo "#define CC_AST_HAS_VERSION_1_4" >>$CONFIGFILE + echo " * assuming Asterisk version 1.4" + VER=1_4 + else + echo "#undef CC_AST_HAS_VERSION_1_4" >>$CONFIGFILE + fi fi if grep -q "AST_STRING_FIELD(name)" $INCLUDEDIR/channel.h; then @@ -63,6 +69,14 @@ else echo " * no data on 'indicate'" fi +if grep -q "ast_channel_alloc.*name_fmt" $INCLUDEDIR/channel.h; then + echo "#define CC_AST_HAS_EXT_CHAN_ALLOC" >>$CONFIGFILE + echo " * found extended ast_channel_alloc" +else + echo "#undef CC_AST_HAS_EXT_CHAN_ALLOC" >>$CONFIGFILE + echo " * no extended ast_channel_alloc" +fi + if [ "$VER" = "1_2" ]; then if grep -q "AST_JB" $INCLUDEDIR/channel.h; then if [ ! -f "$INCLUDEDIR/../../lib/asterisk/modules/chan_sip.so" ]; then