[asterisk-commits] jpeeler: branch jpeeler/bug13494 r171451 - /team/jpeeler/bug13494/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 26 15:26:38 CST 2009


Author: jpeeler
Date: Mon Jan 26 15:26:38 2009
New Revision: 171451

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=171451
Log:
Rename some stuff and things to help code readability. 

Modified:
    team/jpeeler/bug13494/res/res_features.c

Modified: team/jpeeler/bug13494/res/res_features.c
URL: http://svn.digium.com/svn-view/asterisk/team/jpeeler/bug13494/res/res_features.c?view=diff&rev=171451&r1=171450&r2=171451
==============================================================================
--- team/jpeeler/bug13494/res/res_features.c (original)
+++ team/jpeeler/bug13494/res/res_features.c Mon Jan 26 15:26:38 2009
@@ -310,30 +310,31 @@
 		return AST_DEVICE_INUSE;
 }
 
-static int park_slot_reserve(struct ast_channel *chan)
+static int park_space_reserve(struct ast_channel *chan)
 {
 	struct parkeduser *cur;
-	int i, x = -1, parking_range;
+	int i, parking_space = -1, parking_range;
 	const char *parkingexten;
-	char validparkingexten[AST_MAX_EXTENSION];
 
 	/* Lock parking lot */
 	ast_mutex_lock(&parking_lock);
 	/* Check for channel variable PARKINGEXTEN */
 	parkingexten = pbx_builtin_getvar_helper(chan, "PARKINGEXTEN");
 	if (!ast_strlen_zero(parkingexten)) {
+		char validparkingexten[AST_MAX_EXTENSION];
+
 		/*!\note The API forces us to specify a numeric parking slot, even
 		 * though the architecture would tend to support non-numeric extensions
 		 * (as are possible with SIP, for example).  Hence, we enforce that
 		 * limitation here.  If extout was not numeric, we could permit
 		 * arbitrary non-numeric extensions.
 		 */
-		if (sscanf(parkingexten, "%d", &x) != 1 || x < 0) {
+		if (sscanf(parkingexten, "%d", &parking_space) != 1 || parking_space < 0) {
 			ast_log(LOG_WARNING, "PARKINGEXTEN does not indicate a valid parking slot: '%s'.\n", parkingexten);
 			ast_mutex_unlock(&parking_lock);
 			return -1;
 		}
-		snprintf(validparkingexten, sizeof(validparkingexten), "%d", x);
+		snprintf(validparkingexten, sizeof(validparkingexten), "%d", parking_space);
 
 		if (ast_exists_extension(NULL, parking_con, validparkingexten, 1, NULL)) {
 			ast_mutex_unlock(&parking_lock);
@@ -344,10 +345,10 @@
 		/* Select parking space within range */
 		parking_range = parking_stop - parking_start+1;
 		for (i = 0; i < parking_range; i++) {
-			x = (i + parking_offset) % parking_range + parking_start;
+			parking_space = (i + parking_offset) % parking_range + parking_start;
 			cur = parkinglot;
 			while(cur) {
-				if (cur->parkingnum == x) 
+				if (cur->parkingnum == parking_space) 
 					break;
 				cur = cur->next;
 			}
@@ -362,31 +363,28 @@
 		}
 		/* Set pointer for next parking */
 		if (parkfindnext) 
-			parking_offset = x - parking_start + 1;
+			parking_offset = parking_space - parking_start + 1;
 	}
 	ast_mutex_unlock(&parking_lock);
 
-	return x;
-}
-
-static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, int timeout, int *extout, const char *orig_chan_name, int reserved)
+	return parking_space;
+}
+
+static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, int timeout, int *extout, const char *orig_chan_name, int reserved_space)
 {
 	struct parkeduser *pu;
-	int x, parkingnum_copy;
+	int parkingnum_copy;
 	struct ast_context *con;
 	
 	/* Allocate memory for parking data */
 	if (!(pu = ast_calloc(1, sizeof(*pu)))) 
 		return -1;
 
-	if (reserved < 0)
-		x = park_slot_reserve(chan);
-	else
-		x = reserved;
-	//if ((x = park_slot_reserve(chan)) < 0)
-	//	return FEATURE_RETURN_PASSDIGITS;
-
-	snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", x);
+	/* Get a valid space if not already done */
+	if (reserved_space < 0)
+		reserved_space = park_space_reserve(chan);
+
+	snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", reserved_space);
 	
 	chan->appl = "Parked Call";
 	chan->data = NULL; 
@@ -401,10 +399,10 @@
 	}
 	
 	pu->start = ast_tvnow();
-	pu->parkingnum = x;
+	pu->parkingnum = reserved_space;
 	pu->parkingtime = (timeout > 0) ? timeout : parkingtime;
 	if (extout)
-		*extout = x;
+		*extout = reserved_space;
 
 	if (peer) { 
 		/* This is so ugly that it hurts, but implementing get_base_channel() on local channels
@@ -511,10 +509,10 @@
 {
 	struct ast_channel *chan;
 	struct ast_frame *f;
-	int x;
+	int reserved_space;
 	int park_status;
 
-	if ((x = park_slot_reserve(rchan)) < 0) {
+	if ((reserved_space = park_space_reserve(rchan)) < 0) {
 		ast_stream_and_wait(peer, "beeperr", peer->language, "");
 		return FEATURE_RETURN_PARKFAILED;
 	}
@@ -546,7 +544,7 @@
 		orig_chan_name = ast_strdupa(chan->name);
 	}
 
-	park_status = park_call_full(chan, peer, timeout, extout, orig_chan_name, x);
+	park_status = park_call_full(chan, peer, timeout, extout, orig_chan_name, reserved_space);
 	if (park_status == 1) {
 		/* would be nice to play: "invalid parking extension" */
 		ast_hangup(chan);




More information about the asterisk-commits mailing list