[asterisk-commits] seanbright: trunk r136890 - /trunk/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Aug 9 08:13:48 CDT 2008


Author: seanbright
Date: Sat Aug  9 08:13:48 2008
New Revision: 136890

URL: http://svn.digium.com/view/asterisk?view=rev&rev=136890
Log:
Biggest offender?  chan_dahdi.c!  More RSW merging.

Modified:
    trunk/channels/chan_dahdi.c

Modified: trunk/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=136890&r1=136889&r2=136890
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Sat Aug  9 08:13:48 2008
@@ -1216,16 +1216,16 @@
 static int dahdi_digit_begin(struct ast_channel *chan, char digit)
 {
 	struct dahdi_pvt *pvt;
-	int index;
+	int idx;
 	int dtmf = -1;
 	
 	pvt = chan->tech_pvt;
 
 	ast_mutex_lock(&pvt->lock);
 
-	index = dahdi_get_index(chan, pvt, 0);
-
-	if ((index != SUB_REAL) || !pvt->owner)
+	idx = dahdi_get_index(chan, pvt, 0);
+
+	if ((idx != SUB_REAL) || !pvt->owner)
 		goto out;
 
 #ifdef HAVE_PRI
@@ -1279,16 +1279,16 @@
 {
 	struct dahdi_pvt *pvt;
 	int res = 0;
-	int index;
+	int idx;
 	int x;
 	
 	pvt = chan->tech_pvt;
 
 	ast_mutex_lock(&pvt->lock);
 	
-	index = dahdi_get_index(chan, pvt, 0);
-
-	if ((index != SUB_REAL) || !pvt->owner || pvt->pulse)
+	idx = dahdi_get_index(chan, pvt, 0);
+
+	if ((idx != SUB_REAL) || !pvt->owner || pvt->pulse)
 		goto out;
 
 #ifdef HAVE_PRI
@@ -1347,14 +1347,14 @@
 	{ DAHDI_ALARM_NONE, "None" },
 };
 
-static char *alarm2str(int alarm)
+static char *alarm2str(int alm)
 {
 	int x;
 	for (x = 0; x < ARRAY_LEN(alarms); x++) {
-		if (alarms[x].alarm & alarm)
+		if (alarms[x].alarm & alm)
 			return alarms[x].name;
 	}
-	return alarm ? "Unknown Alarm" : "No Alarm";
+	return alm ? "Unknown Alarm" : "No Alarm";
 }
 
 static char *event2str(int event)
@@ -1444,7 +1444,7 @@
 
 #define sig2str dahdi_sig2str
 
-static int conf_add(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index, int slavechannel)
+static int conf_add(struct dahdi_pvt *p, struct dahdi_subchannel *c, int idx, int slavechannel)
 {
 	/* If the conference already exists, and we're already in it
 	   don't bother doing anything */
@@ -1458,7 +1458,7 @@
 		zi.confmode = DAHDI_CONF_DIGITALMON;
 		zi.confno = slavechannel;
 	} else {
-		if (!index) {
+		if (!idx) {
 			/* Real-side and pseudo-side both participate in conference */
 			zi.confmode = DAHDI_CONF_REALANDPSEUDO | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER |
 				DAHDI_CONF_PSEUDO_TALKER | DAHDI_CONF_PSEUDO_LISTENER;
@@ -1493,7 +1493,7 @@
 	return 0;
 }
 
-static int conf_del(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index)
+static int conf_del(struct dahdi_pvt *p, struct dahdi_subchannel *c, int idx)
 {
 	struct dahdi_confinfo zi;
 	if (/* Can't delete if there's no zfd */
@@ -2074,7 +2074,7 @@
 static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
 {
 	struct dahdi_pvt *p = ast->tech_pvt;
-	int x, res, index,mysig;
+	int x, res, idx,mysig;
 	char *c, *n, *l;
 #ifdef HAVE_PRI
 	char *s = NULL;
@@ -2200,9 +2200,9 @@
 		else
 			p->lastcid_name[0] = '\0';
 		ast_setstate(ast, AST_STATE_RINGING);
-		index = dahdi_get_index(ast, p, 0);
-		if (index > -1) {
-			p->subs[index].needringing = 1;
+		idx = dahdi_get_index(ast, p, 0);
+		if (idx > -1) {
+			p->subs[idx].needringing = 1;
 		}
 		break;
 	case SIG_FXSLS:
@@ -2961,7 +2961,7 @@
 static int dahdi_hangup(struct ast_channel *ast)
 {
 	int res;
-	int index,x, law;
+	int idx,x, law;
 	/*static int restore_gains(struct dahdi_pvt *p);*/
 	struct dahdi_pvt *p = ast->tech_pvt;
 	struct dahdi_pvt *tmp = NULL;
@@ -2976,7 +2976,7 @@
 	
 	ast_mutex_lock(&p->lock);
 	
-	index = dahdi_get_index(ast, p, 1);
+	idx = dahdi_get_index(ast, p, 1);
 
 	if ((p->sig == SIG_PRI) || (p->sig == SIG_SS7) || (p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP)) {
 		x = 1;
@@ -3003,22 +3003,22 @@
 		p->exten[0] = '\0';
 
 	ast_debug(1, "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->channel, idx, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
 	p->ignoredtmf = 0;
 	
-	if (index > -1) {
+	if (idx > -1) {
 		/* Real channel, do some fixup */
-		p->subs[index].owner = NULL;
-		p->subs[index].needanswer = 0;
-		p->subs[index].needflash = 0;
-		p->subs[index].needringing = 0;
-		p->subs[index].needbusy = 0;
-		p->subs[index].needcongestion = 0;
-		p->subs[index].linear = 0;
-		p->subs[index].needcallerid = 0;
+		p->subs[idx].owner = NULL;
+		p->subs[idx].needanswer = 0;
+		p->subs[idx].needflash = 0;
+		p->subs[idx].needringing = 0;
+		p->subs[idx].needbusy = 0;
+		p->subs[idx].needcongestion = 0;
+		p->subs[idx].linear = 0;
+		p->subs[idx].needcallerid = 0;
 		p->polarity = POLARITY_IDLE;
-		dahdi_setlinear(p->subs[index].zfd, 0);
-		if (index == SUB_REAL) {
+		dahdi_setlinear(p->subs[idx].zfd, 0);
+		if (idx == SUB_REAL) {
 			if ((p->subs[SUB_CALLWAIT].zfd > -1) && (p->subs[SUB_THREEWAY].zfd > -1)) {
 				ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
 				if (p->subs[SUB_CALLWAIT].inthreeway) {
@@ -3069,7 +3069,7 @@
 				}
 				p->subs[SUB_REAL].inthreeway = 0;
 			}
-		} else if (index == SUB_CALLWAIT) {
+		} else if (idx == SUB_CALLWAIT) {
 			/* Ditch the holding callwait call, and immediately make it availabe */
 			if (p->subs[SUB_CALLWAIT].inthreeway) {
 				/* This is actually part of a three way, placed on hold.  Place the third part
@@ -3085,7 +3085,7 @@
 				unalloc_sub(p, SUB_THREEWAY);
 			} else
 				unalloc_sub(p, SUB_CALLWAIT);
-		} else if (index == SUB_THREEWAY) {
+		} else if (idx == SUB_THREEWAY) {
 			if (p->subs[SUB_CALLWAIT].inthreeway) {
 				/* The other party of the three way call is currently in a call-wait state.
 				   Start music on hold for them, and take the main guy out of the third call */
@@ -3313,13 +3313,13 @@
 {
 	struct dahdi_pvt *p = ast->tech_pvt;
 	int res = 0;
-	int index;
+	int idx;
 	int oldstate = ast->_state;
 	ast_setstate(ast, AST_STATE_UP);
 	ast_mutex_lock(&p->lock);
-	index = dahdi_get_index(ast, p, 0);
-	if (index < 0)
-		index = SUB_REAL;
+	idx = dahdi_get_index(ast, p, 0);
+	if (idx < 0)
+		idx = SUB_REAL;
 	/* nothing to do if a radio channel */
 	if ((p->radio || (p->oprmode < 0))) {
 		ast_mutex_unlock(&p->lock);
@@ -3355,9 +3355,9 @@
 			p->polaritydelaytv = ast_tvnow();
 		}
 		res = dahdi_set_hook(p->subs[SUB_REAL].zfd, DAHDI_OFFHOOK);
-		tone_zone_play_tone(p->subs[index].zfd, -1);
+		tone_zone_play_tone(p->subs[idx].zfd, -1);
 		p->dialing = 0;
-		if ((index == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) {
+		if ((idx == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) {
 			if (oldstate == AST_STATE_RINGING) {
 				ast_debug(1, "Finally swapping real and threeway\n");
 				tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, -1);
@@ -3413,7 +3413,7 @@
 	char *cp;
 	signed char *scp;
 	int x;
-	int index;
+	int idx;
 	struct dahdi_pvt *p = chan->tech_pvt, *pp;
 	struct oprmode *oprmode;
 	
@@ -3427,22 +3427,22 @@
 	switch (option) {
 	case AST_OPTION_TXGAIN:
 		scp = (signed char *) data;
-		index = dahdi_get_index(chan, p, 0);
-		if (index < 0) {
+		idx = dahdi_get_index(chan, p, 0);
+		if (idx < 0) {
 			ast_log(LOG_WARNING, "No index in TXGAIN?\n");
 			return -1;
 		}
 		ast_debug(1, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
-		return set_actual_txgain(p->subs[index].zfd, 0, p->txgain + (float) *scp, p->law);
+		return set_actual_txgain(p->subs[idx].zfd, 0, p->txgain + (float) *scp, p->law);
 	case AST_OPTION_RXGAIN:
 		scp = (signed char *) data;
-		index = dahdi_get_index(chan, p, 0);
-		if (index < 0) {
+		idx = dahdi_get_index(chan, p, 0);
+		if (idx < 0) {
 			ast_log(LOG_WARNING, "No index in RXGAIN?\n");
 			return -1;
 		}
 		ast_debug(1, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
-		return set_actual_rxgain(p->subs[index].zfd, 0, p->rxgain + (float) *scp, p->law);
+		return set_actual_rxgain(p->subs[idx].zfd, 0, p->rxgain + (float) *scp, p->law);
 	case AST_OPTION_TONE_VERIFY:
 		if (!p->dsp)
 			break;
@@ -3486,12 +3486,12 @@
 			memset(buf, 0x7f, sizeof(mybuf)); /* set to silence */
 			ast_tdd_gen_ecdisa(buf + 16000, 16000);  /* put in tone */
 			len = 40000;
-			index = dahdi_get_index(chan, p, 0);
-			if (index < 0) {
+			idx = dahdi_get_index(chan, p, 0);
+			if (idx < 0) {
 				ast_log(LOG_WARNING, "No index in TDD?\n");
 				return -1;
 			}
-			fd = p->subs[index].zfd;
+			fd = p->subs[idx].zfd;
 			while (len) {
 				if (ast_check_hangup(chan))
 					return -1;
@@ -4171,7 +4171,7 @@
 	return DAHDI_ALARM_NONE;
 }
 
-static void dahdi_handle_dtmfup(struct ast_channel *ast, int index, struct ast_frame **dest)
+static void dahdi_handle_dtmfup(struct ast_channel *ast, int idx, struct ast_frame **dest)
 {
 	struct dahdi_pvt *p = ast->tech_pvt;
 	struct ast_frame *f = *dest;
@@ -4182,9 +4182,9 @@
 		ast_debug(1, "Confirm answer on %s!\n", ast->name);
 		/* Upon receiving a DTMF digit, consider this an answer confirmation instead
 		   of a DTMF digit */
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_ANSWER;
-		*dest = &p->subs[index].f;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
+		*dest = &p->subs[idx].f;
 		/* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
 		p->confirmanswer = 0;
 	} else if (p->callwaitcas) {
@@ -4195,9 +4195,9 @@
 			send_cwcidspill(p);
 		}
 		p->callwaitcas = 0;
-		p->subs[index].f.frametype = AST_FRAME_NULL;
-		p->subs[index].f.subclass = 0;
-		*dest = &p->subs[index].f;
+		p->subs[idx].f.frametype = AST_FRAME_NULL;
+		p->subs[idx].f.subclass = 0;
+		*dest = &p->subs[idx].f;
 	} else if (f->subclass == 'f') {
 		/* Fax tone -- Handle and return NULL */
 		if ((p->callprogress & CALLPROGRESS_FAX) && !p->faxhandled) {
@@ -4218,15 +4218,15 @@
 		} else
 			ast_debug(1, "Fax already handled\n");
 		dahdi_confmute(p, 0);
-		p->subs[index].f.frametype = AST_FRAME_NULL;
-		p->subs[index].f.subclass = 0;
-		*dest = &p->subs[index].f;
+		p->subs[idx].f.frametype = AST_FRAME_NULL;
+		p->subs[idx].f.subclass = 0;
+		*dest = &p->subs[idx].f;
 	}
 }
 			
-static void handle_alarms(struct dahdi_pvt *p, int alarms)
-{
-	const char *alarm_str = alarm2str(alarms);
+static void handle_alarms(struct dahdi_pvt *p, int alms)
+{
+	const char *alarm_str = alarm2str(alms);
 
 	ast_log(LOG_WARNING, "Detected alarm on channel %d: %s\n", p->channel, alarm_str);
 	manager_event(EVENT_FLAG_SYSTEM, "Alarm",
@@ -4238,36 +4238,36 @@
 static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
 {
 	int res, x;
-	int index, mysig;
+	int idx, mysig;
 	char *c;
 	struct dahdi_pvt *p = ast->tech_pvt;
 	pthread_t threadid;
 	struct ast_channel *chan;
 	struct ast_frame *f;
 
-	index = dahdi_get_index(ast, p, 0);
+	idx = dahdi_get_index(ast, p, 0);
 	mysig = p->sig;
 	if (p->outsigmod > -1)
 		mysig = p->outsigmod;
-	p->subs[index].f.frametype = AST_FRAME_NULL;
-	p->subs[index].f.subclass = 0;
-	p->subs[index].f.datalen = 0;
-	p->subs[index].f.samples = 0;
-	p->subs[index].f.mallocd = 0;
-	p->subs[index].f.offset = 0;
-	p->subs[index].f.src = "dahdi_handle_event";
-	p->subs[index].f.data.ptr = NULL;
-	f = &p->subs[index].f;
-
-	if (index < 0)
-		return &p->subs[index].f;
+	p->subs[idx].f.frametype = AST_FRAME_NULL;
+	p->subs[idx].f.subclass = 0;
+	p->subs[idx].f.datalen = 0;
+	p->subs[idx].f.samples = 0;
+	p->subs[idx].f.mallocd = 0;
+	p->subs[idx].f.offset = 0;
+	p->subs[idx].f.src = "dahdi_handle_event";
+	p->subs[idx].f.data.ptr = NULL;
+	f = &p->subs[idx].f;
+
+	if (idx < 0)
+		return &p->subs[idx].f;
 	if (p->fake_event) {
 		res = p->fake_event;
 		p->fake_event = 0;
 	} else
-		res = dahdi_get_event(p->subs[index].zfd);
-
-	ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
+		res = dahdi_get_event(p->subs[idx].zfd);
+
+	ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, idx);
 
 	if (res & (DAHDI_EVENT_PULSEDIGIT | DAHDI_EVENT_DTMFUP)) {
 		p->pulsedial =  (res & DAHDI_EVENT_PULSEDIGIT) ? 1 : 0;
@@ -4277,12 +4277,12 @@
 			/* absorb event */
 		} else {
 #endif
-			p->subs[index].f.frametype = AST_FRAME_DTMF_END;
-			p->subs[index].f.subclass = res & 0xff;
+			p->subs[idx].f.frametype = AST_FRAME_DTMF_END;
+			p->subs[idx].f.subclass = res & 0xff;
 #ifdef HAVE_PRI
 		}
 #endif
-		dahdi_handle_dtmfup(ast, index, &f);
+		dahdi_handle_dtmfup(ast, idx, &f);
 		return f;
 	}
 
@@ -4290,9 +4290,9 @@
 		ast_debug(1, "DTMF Down '%c'\n", res & 0xff);
 		/* Mute conference */
 		dahdi_confmute(p, 1);
-		p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
-		p->subs[index].f.subclass = res & 0xff;
-		return &p->subs[index].f;
+		p->subs[idx].f.frametype = AST_FRAME_DTMF_BEGIN;
+		p->subs[idx].f.subclass = res & 0xff;
+		return &p->subs[idx].f;
 	}
 
 	switch (res) {
@@ -4305,12 +4305,12 @@
 		case DAHDI_EVENT_PULSE_START:
 			/* Stop tone if there's a pulse start and the PBX isn't started */
 			if (!ast->pbx)
-				tone_zone_play_tone(p->subs[index].zfd, -1);
+				tone_zone_play_tone(p->subs[idx].zfd, -1);
 			break;	
 		case DAHDI_EVENT_DIALCOMPLETE:
 			if (p->inalarm) break;
 			if ((p->radio || (p->oprmode < 0))) break;
-			if (ioctl(p->subs[index].zfd,DAHDI_DIALING,&x) == -1) {
+			if (ioctl(p->subs[idx].zfd,DAHDI_DIALING,&x) == -1) {
 				ast_log(LOG_DEBUG, "DAHDI_DIALING ioctl failed on %s: %s\n",ast->name, strerror(errno));
 				return NULL;
 			}
@@ -4328,8 +4328,8 @@
 						/* if thru with dialing after offhook */
 						if (ast->_state == AST_STATE_DIALING_OFFHOOK) {
 							ast_setstate(ast, AST_STATE_UP);
-							p->subs[index].f.frametype = AST_FRAME_CONTROL;
-							p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+							p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+							p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
 							break;
 						} else { /* if to state wait for offhook to dial rest */
 							/* we now wait for off hook */
@@ -4343,8 +4343,8 @@
 							ast_setstate(ast, AST_STATE_RINGING);
 						} else if (!p->answeronpolarityswitch) {
 							ast_setstate(ast, AST_STATE_UP);
-							p->subs[index].f.frametype = AST_FRAME_CONTROL;
-							p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+							p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+							p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
 							/* If aops=0 and hops=1, this is necessary */
 							p->polarity = POLARITY_REV;
 						} else {
@@ -4396,8 +4396,8 @@
 #endif
 		case DAHDI_EVENT_ONHOOK:
 			if (p->radio) {
-				p->subs[index].f.frametype = AST_FRAME_CONTROL;
-				p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
+				p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+				p->subs[idx].f.subclass = AST_CONTROL_RADIO_UNKEY;
 				break;
 			}
 			if (p->oprmode < 0)
@@ -4420,7 +4420,7 @@
 				p->onhooktime = time(NULL);
 				p->msgstate = -1;
 				/* Check for some special conditions regarding call waiting */
-				if (index == SUB_REAL) {
+				if (idx == SUB_REAL) {
 					/* The normal line was hung up */
 					if (p->subs[SUB_CALLWAIT].owner) {
 						/* There's a call waiting call, so ring the phone, but make it unowned in the mean time */
@@ -4428,8 +4428,8 @@
 						ast_verb(3, "Channel %d still has (callwait) call, ringing phone\n", p->channel);
 						unalloc_sub(p, SUB_CALLWAIT);	
 #if 0
-						p->subs[index].needanswer = 0;
-						p->subs[index].needringing = 0;
+						p->subs[idx].needanswer = 0;
+						p->subs[idx].needringing = 0;
 #endif						
 						p->callwaitingrepeat = 0;
 						p->cidcwexpire = 0;
@@ -4509,7 +4509,7 @@
 						}
 					}
 				} else {
-					ast_log(LOG_WARNING, "Got a hangup and my index is %d?\n", index);
+					ast_log(LOG_WARNING, "Got a hangup and my index is %d?\n", idx);
 				}
 				/* Fall through */
 			default:
@@ -4532,8 +4532,8 @@
 			}
 			if (p->radio)
 			{
-				p->subs[index].f.frametype = AST_FRAME_CONTROL;
-				p->subs[index].f.subclass = AST_CONTROL_RADIO_KEY;
+				p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+				p->subs[idx].f.subclass = AST_CONTROL_RADIO_KEY;
 				break;
  			}
 			/* for E911, its supposed to wait for offhook then dial
@@ -4563,7 +4563,7 @@
 					return NULL;
 					}
 				p->dialing = 1;
-				return &p->subs[index].f;
+				return &p->subs[idx].f;
 			}
 			switch (p->sig) {
 			case SIG_FXOLS:
@@ -4573,10 +4573,10 @@
 				case AST_STATE_RINGING:
 					dahdi_enable_ec(p);
 					dahdi_train_ec(p);
-					p->subs[index].f.frametype = AST_FRAME_CONTROL;
-					p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+					p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+					p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
 					/* Make sure it stops ringing */
-					dahdi_set_hook(p->subs[index].zfd, DAHDI_OFFHOOK);
+					dahdi_set_hook(p->subs[idx].zfd, DAHDI_OFFHOOK);
 					ast_debug(1, "channel %d answered\n", p->channel);
 					if (p->cidspill) {
 						/* Cancel any running CallerID spill */
@@ -4587,8 +4587,8 @@
 					p->callwaitcas = 0;
 					if (p->confirmanswer) {
 						/* Ignore answer if "confirm answer" is enabled */
-						p->subs[index].f.frametype = AST_FRAME_NULL;
-						p->subs[index].f.subclass = 0;
+						p->subs[idx].f.frametype = AST_FRAME_NULL;
+						p->subs[idx].f.subclass = 0;
 					} else if (!ast_strlen_zero(p->dop.dialstr)) {
 						/* nick at dccinc.com 4/3/03 - fxo should be able to do deferred dialing */
 						res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop);
@@ -4598,29 +4598,29 @@
 							return NULL;
 						} else {
 							ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
-							p->subs[index].f.frametype = AST_FRAME_NULL;
-							p->subs[index].f.subclass = 0;
+							p->subs[idx].f.frametype = AST_FRAME_NULL;
+							p->subs[idx].f.subclass = 0;
 							p->dialing = 1;
 						}
 						p->dop.dialstr[0] = '\0';
 						ast_setstate(ast, AST_STATE_DIALING);
 					} else
 						ast_setstate(ast, AST_STATE_UP);
-					return &p->subs[index].f;
+					return &p->subs[idx].f;
 				case AST_STATE_DOWN:
 					ast_setstate(ast, AST_STATE_RING);
 					ast->rings = 1;
-					p->subs[index].f.frametype = AST_FRAME_CONTROL;
-					p->subs[index].f.subclass = AST_CONTROL_OFFHOOK;
+					p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+					p->subs[idx].f.subclass = AST_CONTROL_OFFHOOK;
 					ast_debug(1, "channel %d picked up\n", p->channel);
-					return &p->subs[index].f;
+					return &p->subs[idx].f;
 				case AST_STATE_UP:
 					/* Make sure it stops ringing */
-					dahdi_set_hook(p->subs[index].zfd, DAHDI_OFFHOOK);
+					dahdi_set_hook(p->subs[idx].zfd, DAHDI_OFFHOOK);
 					/* Okay -- probably call waiting*/
 					if (ast_bridged_channel(p->owner))
 						ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
-					p->subs[index].needunhold = 1;
+					p->subs[idx].needunhold = 1;
 					break;
 				case AST_STATE_RESERVED:
 					/* Start up dialtone */
@@ -4667,16 +4667,16 @@
 					ast_setstate(ast, AST_STATE_RING);
 				if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
 					ast_debug(1, "Ring detected\n");
-					p->subs[index].f.frametype = AST_FRAME_CONTROL;
-					p->subs[index].f.subclass = AST_CONTROL_RING;
+					p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+					p->subs[idx].f.subclass = AST_CONTROL_RING;
 				} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
 					ast_debug(1, "Line answered\n");
 					if (p->confirmanswer) {
-						p->subs[index].f.frametype = AST_FRAME_NULL;
-						p->subs[index].f.subclass = 0;
+						p->subs[idx].f.frametype = AST_FRAME_NULL;
+						p->subs[idx].f.subclass = 0;
 					} else {
-						p->subs[index].f.frametype = AST_FRAME_CONTROL;
-						p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+						p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+						p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
 						ast_setstate(ast, AST_STATE_UP);
 					}
 				} else if (ast->_state != AST_STATE_RING)
@@ -4707,8 +4707,8 @@
 				p->cidspill = NULL;
 				p->callwaitcas = 0;
 			}
-			p->subs[index].f.frametype = AST_FRAME_CONTROL;
-			p->subs[index].f.subclass = AST_CONTROL_RINGING;
+			p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+			p->subs[idx].f.subclass = AST_CONTROL_RINGING;
 			break;
 		case DAHDI_EVENT_RINGERON:
 			break;
@@ -4751,11 +4751,11 @@
 			case SIG_FXOGS:
 			case SIG_FXOKS:
 				ast_debug(1, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
-					index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
+					idx, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
 				p->callwaitcas = 0;
 
-				if (index != SUB_REAL) {
-					ast_log(LOG_WARNING, "Got flash hook with index %d on channel %d?!?\n", index, p->channel);
+				if (idx != SUB_REAL) {
+					ast_log(LOG_WARNING, "Got flash hook with index %d on channel %d?!?\n", idx, p->channel);
 					goto winkflashdone;
 				}
 				
@@ -5065,7 +5065,7 @@
 		default:
 			ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
 	}
-	return &p->subs[index].f;
+	return &p->subs[idx].f;
 }
 
 static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
@@ -5073,21 +5073,21 @@
 	struct dahdi_pvt *p = ast->tech_pvt;
 	int res;
 	int usedindex=-1;
-	int index;
+	int idx;
 	struct ast_frame *f;
 
 
-	index = dahdi_get_index(ast, p, 1);
+	idx = dahdi_get_index(ast, p, 1);
 	
-	p->subs[index].f.frametype = AST_FRAME_NULL;
-	p->subs[index].f.datalen = 0;
-	p->subs[index].f.samples = 0;
-	p->subs[index].f.mallocd = 0;
-	p->subs[index].f.offset = 0;
-	p->subs[index].f.subclass = 0;
-	p->subs[index].f.delivery = ast_tv(0,0);
-	p->subs[index].f.src = "dahdi_exception";
-	p->subs[index].f.data.ptr = NULL;
+	p->subs[idx].f.frametype = AST_FRAME_NULL;
+	p->subs[idx].f.datalen = 0;
+	p->subs[idx].f.samples = 0;
+	p->subs[idx].f.mallocd = 0;
+	p->subs[idx].f.offset = 0;
+	p->subs[idx].f.subclass = 0;
+	p->subs[idx].f.delivery = ast_tv(0,0);
+	p->subs[idx].f.src = "dahdi_exception";
+	p->subs[idx].f.data.ptr = NULL;
 	
 	
 	if ((!p->owner) && (!(p->radio || (p->oprmode < 0)))) {
@@ -5159,7 +5159,7 @@
 		default:
 			ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", event2str(res));
 		}
-		f = &p->subs[index].f;
+		f = &p->subs[idx].f;
 		return f;
 	}
 	if (!(p->radio || (p->oprmode < 0))) 
@@ -5167,7 +5167,7 @@
 	/* If it's not us, return NULL immediately */
 	if (ast != p->owner) {
 		ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
-		f = &p->subs[index].f;
+		f = &p->subs[idx].f;
 		return f;
 	}
 	f = dahdi_handle_event(ast);
@@ -5188,7 +5188,7 @@
 {
 	struct dahdi_pvt *p = ast->tech_pvt;
 	int res;
-	int index;
+	int idx;
 	void *readbuf;
 	struct ast_frame *f;
 
@@ -5196,10 +5196,10 @@
 		CHANNEL_DEADLOCK_AVOIDANCE(ast);
 	}
 
-	index = dahdi_get_index(ast, p, 0);
+	idx = dahdi_get_index(ast, p, 0);
 	
 	/* Hang up if we don't really exist */
-	if (index < 0)	{
+	if (idx < 0)	{
 		ast_log(LOG_WARNING, "We dont exist?\n");
 		ast_mutex_unlock(&p->lock);
 		return NULL;
@@ -5207,15 +5207,15 @@
 	
 	if ((p->radio || (p->oprmode < 0)) && p->inalarm) return NULL;
 
-	p->subs[index].f.frametype = AST_FRAME_NULL;
-	p->subs[index].f.datalen = 0;
-	p->subs[index].f.samples = 0;
-	p->subs[index].f.mallocd = 0;
-	p->subs[index].f.offset = 0;
-	p->subs[index].f.subclass = 0;
-	p->subs[index].f.delivery = ast_tv(0,0);
-	p->subs[index].f.src = "dahdi_read";
-	p->subs[index].f.data.ptr = NULL;
+	p->subs[idx].f.frametype = AST_FRAME_NULL;
+	p->subs[idx].f.datalen = 0;
+	p->subs[idx].f.samples = 0;
+	p->subs[idx].f.mallocd = 0;
+	p->subs[idx].f.offset = 0;
+	p->subs[idx].f.subclass = 0;
+	p->subs[idx].f.delivery = ast_tv(0,0);
+	p->subs[idx].f.src = "dahdi_read";
+	p->subs[idx].f.data.ptr = NULL;
 	
 	/* make sure it sends initial key state as first frame */
 	if ((p->radio || (p->oprmode < 0)) && (!p->firstradio))
@@ -5228,17 +5228,17 @@
 			return NULL;
 		}
 		p->firstradio = 1;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
 		if (ps.rxisoffhook)
 		{
-			p->subs[index].f.subclass = AST_CONTROL_RADIO_KEY;
+			p->subs[idx].f.subclass = AST_CONTROL_RADIO_KEY;
 		}
 		else
 		{
-			p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
+			p->subs[idx].f.subclass = AST_CONTROL_RADIO_UNKEY;
 		}
 		ast_mutex_unlock(&p->lock);
-		return &p->subs[index].f;
+		return &p->subs[idx].f;
 	}
 	if (p->ringt == 1) {
 		ast_mutex_unlock(&p->lock);
@@ -5247,103 +5247,103 @@
 	else if (p->ringt > 0) 
 		p->ringt--;
 
-	if (p->subs[index].needringing) {
+	if (p->subs[idx].needringing) {
 		/* Send ringing frame if requested */
-		p->subs[index].needringing = 0;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_RINGING;
+		p->subs[idx].needringing = 0;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_RINGING;
 		ast_setstate(ast, AST_STATE_RINGING);
 		ast_mutex_unlock(&p->lock);
-		return &p->subs[index].f;
-	}
-
-	if (p->subs[index].needbusy) {
+		return &p->subs[idx].f;
+	}
+
+	if (p->subs[idx].needbusy) {
 		/* Send busy frame if requested */
-		p->subs[index].needbusy = 0;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_BUSY;
+		p->subs[idx].needbusy = 0;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_BUSY;
 		ast_mutex_unlock(&p->lock);
-		return &p->subs[index].f;
-	}
-
-	if (p->subs[index].needcongestion) {
+		return &p->subs[idx].f;
+	}
+
+	if (p->subs[idx].needcongestion) {
 		/* Send congestion frame if requested */
-		p->subs[index].needcongestion = 0;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_CONGESTION;
+		p->subs[idx].needcongestion = 0;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_CONGESTION;
 		ast_mutex_unlock(&p->lock);
-		return &p->subs[index].f;
-	}
-
-	if (p->subs[index].needcallerid) {
+		return &p->subs[idx].f;
+	}
+
+	if (p->subs[idx].needcallerid) {
 		ast_set_callerid(ast, S_OR(p->lastcid_num, NULL),
 							S_OR(p->lastcid_name, NULL),
 							S_OR(p->lastcid_num, NULL)
 							);
-		p->subs[index].needcallerid = 0;
+		p->subs[idx].needcallerid = 0;
 	}
 	
-	if (p->subs[index].needanswer) {
+	if (p->subs[idx].needanswer) {
 		/* Send answer frame if requested */
-		p->subs[index].needanswer = 0;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+		p->subs[idx].needanswer = 0;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
 		ast_mutex_unlock(&p->lock);
-		return &p->subs[index].f;
+		return &p->subs[idx].f;
 	}	
 	
-	if (p->subs[index].needflash) {
+	if (p->subs[idx].needflash) {
 		/* Send answer frame if requested */
-		p->subs[index].needflash = 0;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_FLASH;
+		p->subs[idx].needflash = 0;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_FLASH;
 		ast_mutex_unlock(&p->lock);
-		return &p->subs[index].f;
+		return &p->subs[idx].f;
 	}	
 	
-	if (p->subs[index].needhold) {
+	if (p->subs[idx].needhold) {
 		/* Send answer frame if requested */
-		p->subs[index].needhold = 0;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_HOLD;
+		p->subs[idx].needhold = 0;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_HOLD;
 		ast_mutex_unlock(&p->lock);
 		ast_debug(1, "Sending hold on '%s'\n", ast->name);
-		return &p->subs[index].f;
+		return &p->subs[idx].f;
 	}	
 	
-	if (p->subs[index].needunhold) {
+	if (p->subs[idx].needunhold) {
 		/* Send answer frame if requested */
-		p->subs[index].needunhold = 0;
-		p->subs[index].f.frametype = AST_FRAME_CONTROL;
-		p->subs[index].f.subclass = AST_CONTROL_UNHOLD;
+		p->subs[idx].needunhold = 0;
+		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
+		p->subs[idx].f.subclass = AST_CONTROL_UNHOLD;
 		ast_mutex_unlock(&p->lock);
 		ast_debug(1, "Sending unhold on '%s'\n", ast->name);
-		return &p->subs[index].f;
+		return &p->subs[idx].f;
 	}	
 	
 	if (ast->rawreadformat == AST_FORMAT_SLINEAR) {
-		if (!p->subs[index].linear) {
-			p->subs[index].linear = 1;
-			res = dahdi_setlinear(p->subs[index].zfd, p->subs[index].linear);
+		if (!p->subs[idx].linear) {
+			p->subs[idx].linear = 1;
+			res = dahdi_setlinear(p->subs[idx].zfd, p->subs[idx].linear);
 			if (res) 
-				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to linear mode.\n", p->channel, index);
+				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to linear mode.\n", p->channel, idx);
 		}
 	} else if ((ast->rawreadformat == AST_FORMAT_ULAW) ||
 		   (ast->rawreadformat == AST_FORMAT_ALAW)) {
-		if (p->subs[index].linear) {
-			p->subs[index].linear = 0;
-			res = dahdi_setlinear(p->subs[index].zfd, p->subs[index].linear);
+		if (p->subs[idx].linear) {
+			p->subs[idx].linear = 0;
+			res = dahdi_setlinear(p->subs[idx].zfd, p->subs[idx].linear);
 			if (res) 
-				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to companded mode.\n", p->channel, index);
+				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to companded mode.\n", p->channel, idx);
 		}
 	} else {
 		ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast->rawreadformat));
 		ast_mutex_unlock(&p->lock);
 		return NULL;
 	}
-	readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET;
+	readbuf = ((unsigned char *)p->subs[idx].buffer) + AST_FRIENDLY_OFFSET;
 	CHECK_BLOCKING(ast);
-	res = read(p->subs[index].zfd, readbuf, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
+	res = read(p->subs[idx].zfd, readbuf, p->subs[idx].linear ? READ_SIZE * 2 : READ_SIZE);
 	ast_clear_flag(ast, AST_FLAG_BLOCKING);
 	/* Check for hangup */
 	if (res < 0) {
@@ -5352,7 +5352,7 @@
 			if (errno == EAGAIN) {
 				/* Return "NULL" frame if there is nobody there */
 				ast_mutex_unlock(&p->lock);
-				return &p->subs[index].f;
+				return &p->subs[idx].f;
 			} else if (errno == ELAST) {
 				f = __dahdi_exception(ast);
 			} else
@@ -5361,8 +5361,8 @@
 		ast_mutex_unlock(&p->lock);
 		return f;
 	}
-	if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
-		ast_debug(1, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
+	if (res != (p->subs[idx].linear ? READ_SIZE * 2 : READ_SIZE)) {
+		ast_debug(1, "Short read (%d/%d), must be an event...\n", res, p->subs[idx].linear ? READ_SIZE * 2 : READ_SIZE);
 		f = __dahdi_exception(ast);
 		ast_mutex_unlock(&p->lock);
 		return f;
@@ -5377,15 +5377,15 @@
 			return NULL;
 		}
 		if (c) { /* if a char to return */
-			p->subs[index].f.subclass = 0;
-			p->subs[index].f.frametype = AST_FRAME_TEXT;
-			p->subs[index].f.mallocd = 0;
-			p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
-			p->subs[index].f.data.ptr = p->subs[index].buffer + AST_FRIENDLY_OFFSET;
-			p->subs[index].f.datalen = 1;
-			*((char *) p->subs[index].f.data.ptr) = c;
+			p->subs[idx].f.subclass = 0;
+			p->subs[idx].f.frametype = AST_FRAME_TEXT;
+			p->subs[idx].f.mallocd = 0;
+			p->subs[idx].f.offset = AST_FRIENDLY_OFFSET;
+			p->subs[idx].f.data.ptr = p->subs[idx].buffer + AST_FRIENDLY_OFFSET;
+			p->subs[idx].f.datalen = 1;
+			*((char *) p->subs[idx].f.data.ptr) = c;
 			ast_mutex_unlock(&p->lock);
-			return &p->subs[index].f;
+			return &p->subs[idx].f;
 		}
 	}
 	/* Ensure the CW timer decrements only on a single subchannel */
@@ -5404,44 +5404,44 @@
 		ast_verb(3, "CPE does not support Call Waiting Caller*ID.\n");
 		restore_conference(p);
 	}
-	if (p->subs[index].linear) {
-		p->subs[index].f.datalen = READ_SIZE * 2;
+	if (p->subs[idx].linear) {
+		p->subs[idx].f.datalen = READ_SIZE * 2;
 	} else 
-		p->subs[index].f.datalen = READ_SIZE;
+		p->subs[idx].f.datalen = READ_SIZE;
 
 	/* Handle CallerID Transmission */
 	if ((p->owner == ast) && p->cidspill &&((ast->_state == AST_STATE_UP) || (ast->rings == p->cidrings))) {
 		send_callerid(p);
 	}
 
-	p->subs[index].f.frametype = AST_FRAME_VOICE;
-	p->subs[index].f.subclass = ast->rawreadformat;
-	p->subs[index].f.samples = READ_SIZE;
-	p->subs[index].f.mallocd = 0;
-	p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
-	p->subs[index].f.data.ptr = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]);
+	p->subs[idx].f.frametype = AST_FRAME_VOICE;
+	p->subs[idx].f.subclass = ast->rawreadformat;
+	p->subs[idx].f.samples = READ_SIZE;
+	p->subs[idx].f.mallocd = 0;
+	p->subs[idx].f.offset = AST_FRIENDLY_OFFSET;
+	p->subs[idx].f.data.ptr = p->subs[idx].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[idx].buffer[0]);
 #if 0
-	ast_debug(1, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
+	ast_debug(1, "Read %d of voice on %s\n", p->subs[idx].f.datalen, ast->name);
 #endif	
 	if (p->dialing || /* Transmitting something */
-	   (index && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */
-	   ((index == SUB_CALLWAIT) && !p->subs[SUB_CALLWAIT].inthreeway) /* Inactive and non-confed call-wait */
+	   (idx && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */
+	   ((idx == SUB_CALLWAIT) && !p->subs[SUB_CALLWAIT].inthreeway) /* Inactive and non-confed call-wait */
 	   ) {
 		/* Whoops, we're still dialing, or in a state where we shouldn't transmit....
 		   don't send anything */
-		p->subs[index].f.frametype = AST_FRAME_NULL;
-		p->subs[index].f.subclass = 0;
-		p->subs[index].f.samples = 0;
-		p->subs[index].f.mallocd = 0;
-		p->subs[index].f.offset = 0;
-		p->subs[index].f.data.ptr = NULL;
-		p->subs[index].f.datalen= 0;
-	}
-	if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect  || p->callprogress) && !index) {
+		p->subs[idx].f.frametype = AST_FRAME_NULL;
+		p->subs[idx].f.subclass = 0;
+		p->subs[idx].f.samples = 0;
+		p->subs[idx].f.mallocd = 0;
+		p->subs[idx].f.offset = 0;
+		p->subs[idx].f.data.ptr = NULL;
+		p->subs[idx].f.datalen= 0;
+	}
+	if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect  || p->callprogress) && !idx) {
 		/* Perform busy detection. etc on the dahdi line */
 		int mute;
 
-		f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
+		f = ast_dsp_process(ast, p->dsp, &p->subs[idx].f);
 
 		/* Check if DSP code thinks we should be muting this frame and mute the conference if so */
 		mute = ast_dsp_was_muted(p->dsp);
@@ -5472,10 +5472,10 @@
 			}
 		}
 	} else 
-		f = &p->subs[index].f; 
+		f = &p->subs[idx].f; 
 
 	if (f && (f->frametype == AST_FRAME_DTMF))
-		dahdi_handle_dtmfup(ast, index, &f);
+		dahdi_handle_dtmfup(ast, idx, &f);
 
 	/* If we have a fake_event, trigger exception to handle it */
 	if (p->fake_event)
@@ -5485,13 +5485,13 @@
 	return f;
 }
 
-static int my_dahdi_write(struct dahdi_pvt *p, unsigned char *buf, int len, int index, int linear)
+static int my_dahdi_write(struct dahdi_pvt *p, unsigned char *buf, int len, int idx, int linear)
 {
 	int sent=0;
 	int size;
 	int res;
 	int fd;
-	fd = p->subs[index].zfd;
+	fd = p->subs[idx].zfd;
 	while (len) {
 		size = len;
 		if (size > (linear ? READ_SIZE * 2 : READ_SIZE))
@@ -5511,9 +5511,9 @@
 {
 	struct dahdi_pvt *p = ast->tech_pvt;
 	int res;
-	int index;
-	index = dahdi_get_index(ast, p, 0);
-	if (index < 0) {
+	int idx;
+	idx = dahdi_get_index(ast, p, 0);
+	if (idx < 0) {
 		ast_log(LOG_WARNING, "%s doesn't really exist?\n", ast->name);
 		return -1;
 	}
@@ -5563,22 +5563,22 @@
 		return 0;
 
 	if (frame->subclass == AST_FORMAT_SLINEAR) {
-		if (!p->subs[index].linear) {
-			p->subs[index].linear = 1;
-			res = dahdi_setlinear(p->subs[index].zfd, p->subs[index].linear);
+		if (!p->subs[idx].linear) {
+			p->subs[idx].linear = 1;
+			res = dahdi_setlinear(p->subs[idx].zfd, p->subs[idx].linear);
 			if (res)
 				ast_log(LOG_WARNING, "Unable to set linear mode on channel %d\n", p->channel);
 		}
-		res = my_dahdi_write(p, (unsigned char *)frame->data.ptr, frame->datalen, index, 1);
+		res = my_dahdi_write(p, (unsigned char *)frame->data.ptr, frame->datalen, idx, 1);
 	} else {
 		/* x-law already */
-		if (p->subs[index].linear) {
-			p->subs[index].linear = 0;
-			res = dahdi_setlinear(p->subs[index].zfd, p->subs[index].linear);
+		if (p->subs[idx].linear) {
+			p->subs[idx].linear = 0;
+			res = dahdi_setlinear(p->subs[idx].zfd, p->subs[idx].linear);
 			if (res)
 				ast_log(LOG_WARNING, "Unable to set companded mode on channel %d\n", p->channel);
 		}
-		res = my_dahdi_write(p, (unsigned char *)frame->data.ptr, frame->datalen, index, 0);
+		res = my_dahdi_write(p, (unsigned char *)frame->data.ptr, frame->datalen, idx, 0);
 	}
 	if (res < 0) {
 		ast_log(LOG_WARNING, "write failed: %s\n", strerror(errno));
@@ -5591,12 +5591,12 @@
 {
 	struct dahdi_pvt *p = chan->tech_pvt;
 	int res=-1;
-	int index;
+	int idx;
 	int func = DAHDI_FLASH;
 	ast_mutex_lock(&p->lock);
-	index = dahdi_get_index(chan, p, 0);
+	idx = dahdi_get_index(chan, p, 0);
 	ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
-	if (index == SUB_REAL) {
+	if (idx == SUB_REAL) {
 		switch (condition) {
 		case AST_CONTROL_BUSY:
 #ifdef HAVE_PRI
@@ -5616,10 +5616,10 @@
 						ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span);
 				}
 				p->progress = 1;
-				res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_BUSY);
+				res = tone_zone_play_tone(p->subs[idx].zfd, DAHDI_TONE_BUSY);
 			} else
 #endif
-				res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_BUSY);
+				res = tone_zone_play_tone(p->subs[idx].zfd, DAHDI_TONE_BUSY);
 			break;
 		case AST_CONTROL_RINGING:
 #ifdef HAVE_PRI
@@ -5652,7 +5652,7 @@
 			}
 #endif
 				
-			res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_RINGTONE);
+			res = tone_zone_play_tone(p->subs[idx].zfd, DAHDI_TONE_RINGTONE);
 			
 			if (chan->_state != AST_STATE_UP) {
 				if ((chan->_state != AST_STATE_RING) ||
@@ -5748,10 +5748,10 @@
 						ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span);
 				}
 				p->progress = 1;
-				res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_CONGESTION);
+				res = tone_zone_play_tone(p->subs[idx].zfd, DAHDI_TONE_CONGESTION);
 			} else
 #endif
-				res = tone_zone_play_tone(p->subs[index].zfd, DAHDI_TONE_CONGESTION);
+				res = tone_zone_play_tone(p->subs[idx].zfd, DAHDI_TONE_CONGESTION);
 			break;
 		case AST_CONTROL_HOLD:
 #ifdef HAVE_PRI
@@ -5779,12 +5779,12 @@
 			break;
 		case AST_CONTROL_RADIO_KEY:
 			if (p->radio) 
-			    res =  dahdi_set_hook(p->subs[index].zfd, DAHDI_OFFHOOK);
+			    res =  dahdi_set_hook(p->subs[idx].zfd, DAHDI_OFFHOOK);
 			res = 0;
 			break;
 		case AST_CONTROL_RADIO_UNKEY:
 			if (p->radio)
-			    res =  dahdi_set_hook(p->subs[index].zfd, DAHDI_RINGOFF);
+			    res =  dahdi_set_hook(p->subs[idx].zfd, DAHDI_RINGOFF);
 			res = 0;
 			break;
 		case AST_CONTROL_FLASH:
@@ -5804,7 +5804,7 @@
 			res = 0;
 			break;
 		case -1:
-			res = tone_zone_play_tone(p->subs[index].zfd, -1);
+			res = tone_zone_play_tone(p->subs[idx].zfd, -1);
 			break;
 		}
 	} else
@@ -5813,7 +5813,7 @@
 	return res;
 }
 
-static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int index, int law, int transfercapability)
+static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, int transfercapability)
 {
 	struct ast_channel *tmp;
 	int deflaw;
@@ -5823,8 +5823,8 @@
 	struct ast_str *chan_name;
 	struct ast_variable *v;
 	struct dahdi_params ps;
-	if (i->subs[index].owner) {

[... 752 lines stripped ...]



More information about the asterisk-commits mailing list