[asterisk-commits] trunk r13850 - /trunk/channels/chan_skinny.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Mar 21 08:12:43 MST 2006


Author: russell
Date: Tue Mar 21 09:12:41 2006
New Revision: 13850

URL: http://svn.digium.com/view/asterisk?rev=13850&view=rev
Log:
spelling and formatting fixes (issue #6760)

Modified:
    trunk/channels/chan_skinny.c

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?rev=13850&r1=13849&r2=13850&view=diff
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Tue Mar 21 09:12:41 2006
@@ -70,9 +70,9 @@
 #include "asterisk/dsp.h"
 #include "asterisk/stringfields.h"
 
-/************************************************************************************/
-/*                         Skinny/Asterisk Protocol Settings                        */
-/************************************************************************************/
+/*************************************
+ * 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 config[] = "skinny.conf";
@@ -81,17 +81,17 @@
 static int capability = AST_FORMAT_ULAW;
 
 #define DEFAULT_SKINNY_PORT	2000
-#define DEFAULT_SKINNY_BACKLOG  2
+#define DEFAULT_SKINNY_BACKLOG	2
 #define SKINNY_MAX_PACKET	1000
 
-static int  keep_alive = 120;
+static int keep_alive = 120;
 static char date_format[6] = "D-M-Y";
 static char version_id[16] = "P002F202";
 
 /* these should be in an include file, but dunno what to include */
-typedef unsigned char  UINT8;
-typedef unsigned short UINT16;
-typedef unsigned int   UINT32;
+typedef unsigned char	UINT8;
+typedef unsigned short	UINT16;
+typedef unsigned int	UINT32;
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define letohl(x) (x)
@@ -101,13 +101,13 @@
 #else
 #if defined(SOLARIS) || defined(__Darwin__) || defined(__NetBSD__)
 #define __bswap_16(x) \
-     ((((x) & 0xff00) >> 8) | \
-      (((x) & 0x00ff) << 8))
+	((((x) & 0xff00) >> 8) | \
+	 (((x) & 0x00ff) << 8))
 #define __bswap_32(x) \
-     ((((x) & 0xff000000) >> 24) | \
-      (((x) & 0x00ff0000) >>  8) | \
-      (((x) & 0x0000ff00) <<  8) | \
-      (((x) & 0x000000ff) << 24))
+	((((x) & 0xff000000) >> 24) | \
+	 (((x) & 0x00ff0000) >>  8) | \
+	 (((x) & 0x0000ff00) <<  8) | \
+	 (((x) & 0x000000ff) << 24))
 #else
 #include <bits/byteswap.h>
 #endif
@@ -118,9 +118,9 @@
 #endif
 
 
-/************************************************************************************/
-/*                                Protocol Messages                                 */
-/************************************************************************************/
+/*********************
+ * Protocol Messages *
+ *********************/
 /* message types */
 #define	KEEP_ALIVE_MESSAGE 0x0000
 /* no additional struct */
@@ -248,7 +248,7 @@
 #define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B
 typedef struct stop_media_transmission_message {
 	int conferenceId;
-        int passThruPartyId;
+	int passThruPartyId;
 } stop_media_transmission_message;
 
 #define CALL_INFO_MESSAGE 0x008F
@@ -257,9 +257,9 @@
 	char callingParty[24];
 	char calledPartyName[40];
 	char calledParty[24];
-	int  instance;
-	int  reference;
-	int  type;
+	int instance;
+	int reference;
+	int type;
 	char originalCalledPartyName[40];
 	char originalCalledParty[24];
 } call_info_message;
@@ -273,10 +273,10 @@
 
 #define LINE_STAT_RES_MESSAGE 0x0092
 typedef struct line_stat_res_message {
-	int  linenumber;
+	int linenumber;
 	char lineDirNumber[24];
 	char lineDisplayName[42];
-	int  space;
+	int space;
 } line_stat_res_message;
 
 #define DEFINETIMEDATE_MESSAGE 0x0094
@@ -533,7 +533,7 @@
 	int softKeyOffset;
 	int softKeyCount;
 	int totalSoftKeyCount;
-    soft_key_template_definition softKeyTemplateDefinition[32];
+	soft_key_template_definition softKeyTemplateDefinition[32];
 } soft_key_template;
 
 #define	SOFT_KEY_SET_RES_MESSAGE 0x0109
@@ -574,7 +574,7 @@
 };
 
 typedef struct soft_key_set_definition {
-	UINT8  softKeyTemplateIndex[16];
+	UINT8 softKeyTemplateIndex[16];
 	UINT16 softKeyInfoIndex[16];
 } soft_key_set_definition;
 
@@ -620,12 +620,12 @@
 	int lineInstance;
 } activate_call_plane_message;
 
-#define DIALLED_NUMBER_MESSAGE 0x011D
-typedef struct dialled_number_message {
-	char dialledNumber[24];
+#define DIALED_NUMBER_MESSAGE 0x011D
+typedef struct dialed_number_message {
+	char dialedNumber[24];
 	int lineInstance;
 	int callReference;
-} dialled_number_message;
+} dialed_number_message;
 
 /* packet composition */
 typedef struct {
@@ -665,13 +665,13 @@
 		open_recieve_channel_ack_message openrecievechannelack;
 		close_recieve_channel_message closerecievechannel;
 		display_notify_message displaynotify;
-		dialled_number_message diallednumber;
+		dialed_number_message dialednumber;
 	} data;
 } skinny_req;
 
-/************************************************************************************/
-/*                            Asterisk specific globals                             */
-/************************************************************************************/
+/*****************************
+ * Asterisk specific globals *
+ *****************************/
 
 static int skinnydebug = 1;	/* XXX for now, enable debugging default */
 
@@ -681,7 +681,7 @@
 static int ourport;
 static struct in_addr __ourip;
 struct ast_hostent ahp; struct hostent *hp;
-static int skinnysock  = -1;
+static int skinnysock = -1;
 static pthread_t tcp_thread;
 static pthread_t accept_t;
 static char context[AST_MAX_CONTEXT] = "default";
@@ -708,7 +708,7 @@
 static int callnums = 1;
 
 #define SUB_REAL 0
-#define SUB_ALT  1
+#define SUB_ALT 1
 #define MAX_SUBS 2
 
 #define SKINNY_SPEAKERON 1
@@ -737,7 +737,7 @@
 #define SKINNY_NOTONE 		0x7F
 
 #define SKINNY_LAMP_OFF 1
-#define SKINNY_LAMP_ON  2
+#define SKINNY_LAMP_ON 2
 #define SKINNY_LAMP_WINK 3
 #define SKINNY_LAMP_FLASH 4
 #define SKINNY_LAMP_BLINK 5
@@ -751,21 +751,21 @@
 #define TYPE_LINE 2
 
 /* Skinny rtp stream modes. Do we really need this? */
-#define SKINNY_CX_SENDONLY 0
-#define SKINNY_CX_RECVONLY 1
-#define SKINNY_CX_SENDRECV 2
-#define SKINNY_CX_CONF     3
-#define SKINNY_CX_CONFERENCE 3
-#define SKINNY_CX_MUTE     4
-#define SKINNY_CX_INACTIVE 4
+#define SKINNY_CX_SENDONLY	0
+#define SKINNY_CX_RECVONLY	1
+#define SKINNY_CX_SENDRECV	2
+#define SKINNY_CX_CONF		3
+#define SKINNY_CX_CONFERENCE	3
+#define SKINNY_CX_MUTE		4
+#define SKINNY_CX_INACTIVE	4
 
 #if 0
 static char *skinny_cxmodes[] = {
-    "sendonly",
-    "recvonly",
-    "sendrecv",
-    "confrnce",
-    "inactive"
+	"sendonly",
+	"recvonly",
+	"sendrecv",
+	"confrnce",
+	"inactive"
 };
 #endif
 
@@ -792,7 +792,7 @@
 #endif
 
 /* This is the thread for the monitor which checks for input on the channels
-   which are not currently in use.  */
+   which are not currently in use. */
 static pthread_t monitor_thread = AST_PTHREADT_NULL;
 
 /* Wait up to 16 seconds for first digit */
@@ -825,7 +825,7 @@
 	ast_mutex_t lock;
 	char name[80];
 	char label[42];					/* Label that shows next to the line buttons */
-  	struct skinny_subchannel *sub;			/* pointer to our current connection, channel and stuff */
+	struct skinny_subchannel *sub;			/* pointer to our current connection, channel and stuff */
 	char accountcode[AST_MAX_ACCOUNT_CODE];
 	char exten[AST_MAX_EXTENSION];			/* Extention where to start */
 	char context[AST_MAX_CONTEXT];
@@ -1006,7 +1006,7 @@
 /* XXX Do this right */
 static int convert_cap(int capability)
 {
-	return 4; /* ulaw (this is not the same as asterisk's '4'  */
+	return 4; /* ulaw (this is not the same as asterisk's '4' */
 
 }
 
@@ -1063,11 +1063,11 @@
 		req->data.closerecievechannel.partyId = 0;
 		transmit_response(s, req);
 		memset(req, 0, memsize);
-                req->len = htolel(sizeof(stop_media_transmission_message)+4);
-                req->e = htolel(STOP_MEDIA_TRANSMISSION_MESSAGE);
-                req->data.stopmedia.conferenceId = 0;   
-                req->data.stopmedia.passThruPartyId = 0;
-                transmit_response(s, req);	
+		req->len = htolel(sizeof(stop_media_transmission_message)+4);
+		req->e = htolel(STOP_MEDIA_TRANSMISSION_MESSAGE);
+		req->data.stopmedia.conferenceId = 0;
+		req->data.stopmedia.passThruPartyId = 0;
+		transmit_response(s, req);	
 	}
 }	
 
@@ -1233,10 +1233,10 @@
 
 	req = req_alloc(sizeof(struct display_notify_message));
 
-        if (!req) {
-                ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
-                return;
-        }
+	if (!req) {
+		ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
+		return;
+	}
 
 	req->e = htolel(DISPLAY_NOTIFY_MESSAGE);
 	req->len = htolel(sizeof(display_notify_message) + 4);
@@ -1256,10 +1256,10 @@
 
 	req = req_alloc(sizeof(struct display_prompt_status_message));
 
-        if (!req) {
-                ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
-                return;
-        }
+	if (!req) {
+		ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
+		return;
+	}
 
 	req->e = htolel(DISPLAY_PROMPT_STATUS_MESSAGE);
 	req->len = htolel(sizeof(display_prompt_status_message) + 4);
@@ -1275,22 +1275,22 @@
 	transmit_response(s, req);
 }
 
-static void transmit_diallednumber(struct skinnysession *s, char *text, int instance, int callid)
+static void transmit_dialednumber(struct skinnysession *s, char *text, int instance, int callid)
 {
 	skinny_req *req;
 
-	req = req_alloc(sizeof(struct dialled_number_message));
-
-        if (!req) {
-                ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
-                return;
-        }
-
-	req->e = htolel(DIALLED_NUMBER_MESSAGE);
-	req->len = htolel(sizeof(dialled_number_message) + 4);
-	strncpy(req->data.diallednumber.dialledNumber, text, sizeof(req->data.diallednumber.dialledNumber)-1);
-	req->data.diallednumber.lineInstance = htolel(instance);
-        req->data.diallednumber.callReference = htolel(callid);
+	req = req_alloc(sizeof(struct dialed_number_message));
+
+	if (!req) {
+		ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
+		return;
+	}
+
+	req->e = htolel(DIALED_NUMBER_MESSAGE);
+	req->len = htolel(sizeof(dialed_number_message) + 4);
+	strncpy(req->data.dialednumber.dialedNumber, text, sizeof(req->data.dialednumber.dialedNumber)-1);
+	req->data.dialednumber.lineInstance = htolel(instance);
+	req->data.dialednumber.callReference = htolel(callid);
 
 	transmit_response(s, req);
 }
@@ -1357,7 +1357,7 @@
 static struct ast_rtp_protocol skinny_rtp = {
 	.type = "Skinny",
 	.get_rtp_info = skinny_get_rtp_peer,
-	.get_vrtp_info =  skinny_get_vrtp_peer,
+	.get_vrtp_info = skinny_get_vrtp_peer,
 	.set_rtp_peer = skinny_set_rtp_peer,
 };
 
@@ -1383,7 +1383,7 @@
 
 static int skinny_show_devices(int fd, int argc, char *argv[])
 {
-	struct skinny_device  *d;
+	struct skinny_device *d;
 	struct skinny_line *l;
 	int numlines = 0;
 	char iabuf[INET_ADDRSTRLEN];
@@ -1418,7 +1418,7 @@
 
 static int skinny_show_lines(int fd, int argc, char *argv[])
 {
-	struct skinny_device  *d;
+	struct skinny_device *d;
 	struct skinny_line *l;
 
 	if (argc != 3) {
@@ -1460,16 +1460,16 @@
 "Usage: skinny no debug\n"
 "       Disables dumping of Skinny packets for debugging purposes\n";
 
-static struct ast_cli_entry  cli_show_devices =
+static struct ast_cli_entry cli_show_devices =
 	{ { "skinny", "show", "devices", NULL }, skinny_show_devices, "Show defined Skinny devices", show_devices_usage };
 
-static struct ast_cli_entry  cli_show_lines =
+static struct ast_cli_entry cli_show_lines =
 	{ { "skinny", "show", "lines", NULL }, skinny_show_lines, "Show defined Skinny lines per device", show_lines_usage };
 
-static struct ast_cli_entry  cli_debug =
+static struct ast_cli_entry cli_debug =
 	{ { "skinny", "debug", NULL }, skinny_do_debug, "Enable Skinny debugging", debug_usage };
 
-static struct ast_cli_entry  cli_no_debug =
+static struct ast_cli_entry cli_no_debug =
 	{ { "skinny", "no", "debug", NULL }, skinny_no_debug, "Disable Skinny debugging", no_debug_usage };
 
 #if 0
@@ -1499,16 +1499,16 @@
 			} else if (!strcasecmp(v->name, "port")) {
 				d->addr.sin_port = htons(atoi(v->value));
 			} else if (!strcasecmp(v->name, "device")) {
-           			strncpy(d->id, v->value, sizeof(d->id)-1);
+				strncpy(d->id, v->value, sizeof(d->id)-1);
 			} else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
 				d->ha = ast_append_ha(v->name, v->value, d->ha);
 			} else if (!strcasecmp(v->name, "context")) {
 				strncpy(context, v->value, sizeof(context) - 1);
 			} else if (!strcasecmp(v->name, "version")) {
-                		strncpy(d->version_id, v->value, sizeof(d->version_id) -1); 
+				strncpy(d->version_id, v->value, sizeof(d->version_id) -1); 
 			} else if (!strcasecmp(v->name, "nat")) {
 				nat = ast_true(v->value);
-       		} else if (!strcasecmp(v->name, "model")) {
+			} else if (!strcasecmp(v->name, "model")) {
 				strncpy(d->model, v->value, sizeof(d->model) - 1);
 			} else if (!strcasecmp(v->name, "callerid")) {
 				if (!strcasecmp(v->value, "asreceived")) {
@@ -1519,44 +1519,44 @@
 				}
 			} else if (!strcasecmp(v->name, "language")) {
 				strncpy(language, v->value, sizeof(language)-1);
-       			} else if (!strcasecmp(v->name, "accountcode")) {
-           			strncpy(accountcode, v->value, sizeof(accountcode)-1);
-       			} else if (!strcasecmp(v->name, "amaflags")) {
-           			y = ast_cdr_amaflags2int(v->value);
-           			if (y < 0) {
-		   			ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value, v->lineno);
-          			} else {
-           				amaflags = y;
-            			}
+			} else if (!strcasecmp(v->name, "accountcode")) {
+				strncpy(accountcode, v->value, sizeof(accountcode)-1);
+			} else if (!strcasecmp(v->name, "amaflags")) {
+				y = ast_cdr_amaflags2int(v->value);
+				if (y < 0) {
+					ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value, v->lineno);
+				} else {
+					amaflags = y;
+				}
 			} else if (!strcasecmp(v->name, "musiconhold")) {
-            			strncpy(musicclass, v->value, sizeof(musicclass)-1);
-            		} else if (!strcasecmp(v->name, "callgroup")) {
-             			cur_callergroup = ast_get_group(v->value);
-            		} else if (!strcasecmp(v->name, "pickupgroup")) {
-            			cur_pickupgroup = ast_get_group(v->value);
-            		} else if (!strcasecmp(v->name, "immediate")) {
-            			immediate = ast_true(v->value);
-            		} else if (!strcasecmp(v->name, "cancallforward")) {
-            			cancallforward = ast_true(v->value);
-            		} else if (!strcasecmp(v->name, "mailbox")) {
-            			strncpy(mailbox, v->value, sizeof(mailbox) -1);
-	    		} else if (!strcasecmp(v->name, "callreturn")) {
+				strncpy(musicclass, v->value, sizeof(musicclass)-1);
+			} else if (!strcasecmp(v->name, "callgroup")) {
+				cur_callergroup = ast_get_group(v->value);
+			} else if (!strcasecmp(v->name, "pickupgroup")) {
+				cur_pickupgroup = ast_get_group(v->value);
+			} else if (!strcasecmp(v->name, "immediate")) {
+				immediate = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "cancallforward")) {
+				cancallforward = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "mailbox")) {
+				strncpy(mailbox, v->value, sizeof(mailbox) -1);
+			} else if (!strcasecmp(v->name, "callreturn")) {
 				callreturn = ast_true(v->value);
-            		} else if (!strcasecmp(v->name, "callwaiting")) {
-            			callwaiting = ast_true(v->value);
-            		} else if (!strcasecmp(v->name, "transfer")) {
-            			transfer = ast_true(v->value);
-            		} else if (!strcasecmp(v->name, "threewaycalling")) {
-                		threewaycalling = ast_true(v->value);
-            		} else if (!strcasecmp(v->name, "mwiblink")) {
-                		mwiblink = ast_true(v->value);
-	    		} else if (!strcasecmp(v->name, "linelabel")) {
-           			strncpy(linelabel, v->value, sizeof(linelabel)-1);
-       	    		} else if (!strcasecmp(v->name, "trunk") || !strcasecmp(v->name, "line")) {
+			} else if (!strcasecmp(v->name, "callwaiting")) {
+				callwaiting = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "transfer")) {
+				transfer = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "threewaycalling")) {
+				threewaycalling = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "mwiblink")) {
+				mwiblink = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "linelabel")) {
+				strncpy(linelabel, v->value, sizeof(linelabel)-1);
+			} else if (!strcasecmp(v->name, "trunk") || !strcasecmp(v->name, "line")) {
 				l = malloc(sizeof(struct skinny_line));;
 				if (l) {
 					memset(l, 0, sizeof(struct skinny_line));
-                                        ast_mutex_init(&l->lock);
+					ast_mutex_init(&l->lock);
 					strncpy(l->name, v->value, sizeof(l->name) - 1);
 					
 					/* XXX Should we check for uniqueness?? XXX */
@@ -1565,7 +1565,7 @@
 					strncpy(l->cid_name, cid_name, sizeof(l->cid_name) - 1);
 					strncpy(l->label, linelabel, sizeof(l->label) - 1);
 					strncpy(l->language, language, sizeof(l->language) - 1);
-        				strncpy(l->musicclass, musicclass, sizeof(l->musicclass)-1);
+					strncpy(l->musicclass, musicclass, sizeof(l->musicclass)-1);
 					strncpy(l->mailbox, mailbox, sizeof(l->mailbox)-1);
 					strncpy(l->mailbox, mailbox, sizeof(l->mailbox)-1);
 					if (!ast_strlen_zero(mailbox)) {
@@ -1583,42 +1583,42 @@
 					l->callgroup = cur_callergroup;
 					l->pickupgroup = cur_pickupgroup;
 					l->callreturn = callreturn;
-		        		l->cancallforward = cancallforward;
-		        		l->callwaiting = callwaiting;
-		        		l->transfer = transfer;	
-		        		l->threewaycalling = threewaycalling;
-		        		l->mwiblink = mwiblink;
-		        		l->onhooktime = time(NULL);
+					l->cancallforward = cancallforward;
+					l->callwaiting = callwaiting;
+					l->transfer = transfer;	
+					l->threewaycalling = threewaycalling;
+					l->mwiblink = mwiblink;
+					l->onhooktime = time(NULL);
 					l->instance = 1;
-		        		/* ASSUME we're onhook at this point*/
-              				l->hookstate = SKINNY_ONHOOK;
-
-		       			for (i = 0; i < MAX_SUBS; i++) {
-               			        	sub = malloc(sizeof(struct skinny_subchannel));
-                       				if (sub) {
-                           				ast_verbose(VERBOSE_PREFIX_3 "Allocating Skinny subchannel '%d' on %s@%s\n", i, l->name, d->name);
-                           				memset(sub, 0, sizeof(struct skinny_subchannel));
-                                                        ast_mutex_init(&sub->lock);
-                       					sub->parent = l;
-                       					/* Make a call*ID */
+					/* ASSUME we're onhook at this point*/
+					l->hookstate = SKINNY_ONHOOK;
+
+					for (i = 0; i < MAX_SUBS; i++) {
+						sub = malloc(sizeof(struct skinny_subchannel));
+						if (sub) {
+							ast_verbose(VERBOSE_PREFIX_3 "Allocating Skinny subchannel '%d' on %s@%s\n", i, l->name, d->name);
+							memset(sub, 0, sizeof(struct skinny_subchannel));
+							ast_mutex_init(&sub->lock);
+							sub->parent = l;
+							/* Make a call*ID */
 							sub->callid = callnums;
 							callnums++;
-                      					sub->cxmode = SKINNY_CX_INACTIVE;
-                       					sub->nat = nat;
-                       					sub->next = l->sub;
-                       					l->sub = sub;
-                       				} else {
-                       					/* XXX Should find a way to clean up our memory */
-                       					ast_log(LOG_WARNING, "Out of memory allocating subchannel");
-                      					return NULL;
-                       				}
-                    			}
-		    			l->next = d->lines;
+							sub->cxmode = SKINNY_CX_INACTIVE;
+							sub->nat = nat;
+							sub->next = l->sub;
+							l->sub = sub;
+						} else {
+							/* XXX Should find a way to clean up our memory */
+							ast_log(LOG_WARNING, "Out of memory allocating subchannel");
+							return NULL;
+						}
+					}
+					l->next = d->lines;
 					d->lines = l;			
-	    			} else {
-			        	/* XXX Should find a way to clean up our memory */
-                    			ast_log(LOG_WARNING, "Out of memory allocating line");
-                    			return NULL;
+				} else {
+					/* XXX Should find a way to clean up our memory */
+					ast_log(LOG_WARNING, "Out of memory allocating line");
+					return NULL;
 				}
 			} else {
 				ast_log(LOG_WARNING, "Don't know keyword '%s' at line %d\n", v->name, v->lineno);
@@ -1698,212 +1698,212 @@
 	int timeout = firstdigittimeout;
 	int res;
 	int getforward=0;
-    
+
 	if (option_verbose > 2) {
 		ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s@%s'\n", l->name, l->parent->name);
 	}
 	while(len < AST_MAX_EXTENSION-1) {
-        	res = ast_waitfordigit(chan, timeout);
-        	timeout = 0;
-        	if (res < 0) {
+		res = ast_waitfordigit(chan, timeout);
+		timeout = 0;
+		if (res < 0) {
 			if (skinnydebug) {
 				ast_verbose("Skinny(%s@%s): waitfordigit returned < 0\n", l->name, l->parent->name);
-        		}
+			}
 			ast_indicate(chan, -1);
 			ast_hangup(chan);
-            		return NULL;
-        	} else if (res)  {
-            		exten[len++]=res;
-            		exten[len] = '\0';
-        	}
-        	if (!ast_ignore_pattern(chan->context, exten)) {
+			return NULL;
+		} else if (res) {
+			exten[len++]=res;
+			exten[len] = '\0';
+		}
+		if (!ast_ignore_pattern(chan->context, exten)) {
 			transmit_tone(s, SKINNY_SILENCE);
-        	} 
-        	if (ast_exists_extension(chan, chan->context, exten, 1, l->cid_num)) {
-            		if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, l->cid_num)) {
-                		if (getforward) {
-                    			/* Record this as the forwarding extension */
-                    			strncpy(l->call_forward, exten, sizeof(l->call_forward) - 1); 
-                    			if (option_verbose > 2) {
-                        			ast_verbose(VERBOSE_PREFIX_3 "Setting call forward to '%s' on channel %s\n", 
-                                			l->call_forward, chan->name);
-                    			}
-                    			transmit_tone(s, SKINNY_DIALTONE); 
-		    			if (res) {
-	        	    			break;
-		    			}
+		} 
+		if (ast_exists_extension(chan, chan->context, exten, 1, l->cid_num)) {
+			if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, l->cid_num)) {
+				if (getforward) {
+					/* Record this as the forwarding extension */
+					strncpy(l->call_forward, exten, sizeof(l->call_forward) - 1); 
+					if (option_verbose > 2) {
+						ast_verbose(VERBOSE_PREFIX_3 "Setting call forward to '%s' on channel %s\n", 
+							l->call_forward, chan->name);
+					}
+					transmit_tone(s, SKINNY_DIALTONE); 
+					if (res) {
+						break;
+					}
 					ast_safe_sleep(chan, 500);
-	              			ast_indicate(chan, -1);
+					ast_indicate(chan, -1);
  					ast_safe_sleep(chan, 1000);
-                    			memset(exten, 0, sizeof(exten));
-		    			transmit_tone(s, SKINNY_DIALTONE); 
-                    			len = 0;
-                    			getforward = 0;
-                		} else  {
-                    			strncpy(chan->exten, exten, sizeof(chan->exten)-1);
-                    			if (!ast_strlen_zero(l->cid_num)) {
-                        			if (!l->hidecallerid) {
-                            				chan->cid.cid_num = strdup(l->cid_num);
-                        				chan->cid.cid_ani = strdup(l->cid_num);
-                    				}
-                    				ast_setstate(chan, AST_STATE_RING);
-                    				res = ast_pbx_run(chan);
-                    				if (res) {
-                        				ast_log(LOG_WARNING, "PBX exited non-zero\n");
+					memset(exten, 0, sizeof(exten));
+					transmit_tone(s, SKINNY_DIALTONE); 
+					len = 0;
+					getforward = 0;
+				} else {
+					strncpy(chan->exten, exten, sizeof(chan->exten)-1);
+					if (!ast_strlen_zero(l->cid_num)) {
+						if (!l->hidecallerid) {
+							chan->cid.cid_num = strdup(l->cid_num);
+							chan->cid.cid_ani = strdup(l->cid_num);
+						}
+						ast_setstate(chan, AST_STATE_RING);
+						res = ast_pbx_run(chan);
+						if (res) {
+							ast_log(LOG_WARNING, "PBX exited non-zero\n");
 							transmit_tone(s, SKINNY_REORDER); 
-                    				}
-                    				return NULL;
-                			}
+						}
+						return NULL;
+					}
 				}
-            		} else {
-                		/* It's a match, but they just typed a digit, and there is an ambiguous match,
-                   			so just set the timeout to matchdigittimeout and wait some more */
-               			timeout = matchdigittimeout;
-		        }
+			} else {
+				/* It's a match, but they just typed a digit, and there is an ambiguous match,
+				   so just set the timeout to matchdigittimeout and wait some more */
+				timeout = matchdigittimeout;
+			}
 		} else if (res == 0) {
-            		ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n");
-    			transmit_tone(s, SKINNY_REORDER); 
-          		ast_hangup(chan);
-           		return NULL;
-        	} else if (l->callwaiting && !strcmp(exten, "*70")) {
-            		if (option_verbose > 2) {
-               			ast_verbose(VERBOSE_PREFIX_3 "Disabling call waiting on %s\n", chan->name);
-            		}
-           		/* Disable call waiting if enabled */
-      			l->callwaiting = 0;
-       			transmit_tone(s, SKINNY_DIALTONE);
+			ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n");
+			transmit_tone(s, SKINNY_REORDER); 
+			ast_hangup(chan);
+			return NULL;
+		} else if (l->callwaiting && !strcmp(exten, "*70")) {
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Disabling call waiting on %s\n", chan->name);
+			}
+			/* Disable call waiting if enabled */
+			l->callwaiting = 0;
+			transmit_tone(s, SKINNY_DIALTONE);
 			len = 0;
-       			memset(exten, 0, sizeof(exten));\
-       			timeout = firstdigittimeout;
-	       } else if (!strcmp(exten,ast_pickup_ext())) {
-		      	/* Scan all channels and see if any there
-            	    	 * ringing channqels with that have call groups
-       		     	 * that equal this channels pickup group  
-       		     	 */
-            		if (ast_pickup_call(chan)) {
-                		ast_log(LOG_WARNING, "No call pickup possible...\n");
+			memset(exten, 0, sizeof(exten));
+			timeout = firstdigittimeout;
+		} else if (!strcmp(exten,ast_pickup_ext())) {
+			/* Scan all channels and see if any there
+			 * ringing channels with that have call groups
+			 * that equal this channels pickup group
+			 */
+			if (ast_pickup_call(chan)) {
+				ast_log(LOG_WARNING, "No call pickup possible...\n");
 				transmit_tone(s, SKINNY_REORDER);
-            		}
-		        ast_hangup(chan);
-            		return NULL;
-              	} else if (!l->hidecallerid && !strcmp(exten, "*67")) {
-      			if (option_verbose > 2) {
-           			 ast_verbose(VERBOSE_PREFIX_3 "Disabling Caller*ID on %s\n", chan->name);
-            		}
-		       	/* Disable Caller*ID if enabled */
-		        l->hidecallerid = 1;
-       			if (chan->cid.cid_num) {
-	               		free(chan->cid.cid_num);
-	    		}
-	            	chan->cid.cid_num = NULL;
-	   		if (chan->cid.cid_name) {
-               			free(chan->cid.cid_name);
-	    		}
-	      		chan->cid.cid_name = NULL;
-            		transmit_tone(s, SKINNY_DIALTONE);
-       			len = 0;
-           		memset(exten, 0, sizeof(exten));
-            		timeout = firstdigittimeout;
-        	} else if (l->callreturn && !strcmp(exten, "*69")) {
-          		res = 0;
-       			if (!ast_strlen_zero(l->lastcallerid)) {
-            			res = ast_say_digit_str(chan, l->lastcallerid, "", chan->language);
-       			}
-		       	if (!res) {
-              			transmit_tone(s, SKINNY_DIALTONE);
-			}
-		       	break;
-        	} else if (!strcmp(exten, "*78")) {
-            		/* Do not disturb */
-            		if (option_verbose > 2) {
-               			ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %s\n", chan->name);
-            		}
-           		transmit_tone(s, SKINNY_DIALTONE);
-            		l->dnd = 1;
-            		getforward = 0;
-            		memset(exten, 0, sizeof(exten));
-            		len = 0;
-        	} else if (!strcmp(exten, "*79")) {
-       			/* Do not disturb */
-           		if (option_verbose > 2) {
-                		ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %s\n", chan->name);
-            		}
+			}
+			ast_hangup(chan);
+			return NULL;
+		} else if (!l->hidecallerid && !strcmp(exten, "*67")) {
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Disabling Caller*ID on %s\n", chan->name);
+			}
+			/* Disable Caller*ID if enabled */
+			l->hidecallerid = 1;
+			if (chan->cid.cid_num) {
+				free(chan->cid.cid_num);
+			}
+			chan->cid.cid_num = NULL;
+			if (chan->cid.cid_name) {
+				free(chan->cid.cid_name);
+			}
+			chan->cid.cid_name = NULL;
 			transmit_tone(s, SKINNY_DIALTONE);
-		        l->dnd = 0;
-            		getforward = 0;
-            		memset(exten, 0, sizeof(exten));
-            		len = 0;
-        	} else if (l->cancallforward && !strcmp(exten, "*72")) {
-       			transmit_tone(s, SKINNY_DIALTONE);
-       			getforward = 1;
-       			memset(exten, 0, sizeof(exten));
-       			len = 0;
-       		} else if (l->cancallforward && !strcmp(exten, "*73")) {
-       			if (option_verbose > 2) {
-           			ast_verbose(VERBOSE_PREFIX_3 "Cancelling call forwarding on channel %s\n", chan->name);
-       			}
-      			transmit_tone(s, SKINNY_DIALTONE); 
-       			memset(l->call_forward, 0, sizeof(l->call_forward));
-       			getforward = 0;
-      			memset(exten, 0, sizeof(exten));
-       			len = 0;
-       		} else if (!strcmp(exten, ast_parking_ext()) && 
-               			sub->next->owner &&
-               			ast_bridged_channel(sub->next->owner)) {
-           		/* This is a three way call, the main call being a real channel, 
-               			and we're parking the first call. */
-            			ast_masq_park_call(ast_bridged_channel(sub->next->owner), chan, 0, NULL);
-           		if (option_verbose > 2) {
-               			ast_verbose(VERBOSE_PREFIX_3 "Parking call to '%s'\n", chan->name);
-       			}
-       	 		break;
-       		} else if (!ast_strlen_zero(l->lastcallerid) && !strcmp(exten, "*60")) {
-       			if (option_verbose > 2) {
-             			ast_verbose(VERBOSE_PREFIX_3 "Blacklisting number %s\n", l->lastcallerid);
-       			}
-            		res = ast_db_put("blacklist", l->lastcallerid, "1");
-            		if (!res) {
-               			transmit_tone(s, SKINNY_DIALTONE);		
-      	 			memset(exten, 0, sizeof(exten));
-               			len = 0;
-       			}
-       		} else if (l->hidecallerid && !strcmp(exten, "*82")) {
-      			if (option_verbose > 2) {
-             			ast_verbose(VERBOSE_PREFIX_3 "Enabling Caller*ID on %s\n", chan->name);
-       			}
-       			/* Enable Caller*ID if enabled */
-       			l->hidecallerid = 0;
-       			if (chan->cid.cid_num) {
-              			free(chan->cid.cid_num);	
-    			}
-            		if (!ast_strlen_zero(l->cid_num)) {
-                		chan->cid.cid_num = strdup(l->cid_num);
-	    		}
-      			if (chan->cid.cid_name) {
-               			free(chan->cid.cid_name);
-    			}
-            		if (!ast_strlen_zero(l->cid_name)) {
-               			chan->cid.cid_name = strdup(l->cid_name);	
-			}
-            		transmit_tone(s, SKINNY_DIALTONE);
-            		len = 0;
-            		memset(exten, 0, sizeof(exten));
-      			timeout = firstdigittimeout;
-       		} else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
-                   	     	((exten[0] != '*') || (!ast_strlen_zero(exten) > 2))) {
-            		ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
-            		transmit_tone(s, SKINNY_REORDER); 	
+			len = 0;
+			memset(exten, 0, sizeof(exten));
+			timeout = firstdigittimeout;
+		} else if (l->callreturn && !strcmp(exten, "*69")) {
+			res = 0;
+			if (!ast_strlen_zero(l->lastcallerid)) {
+				res = ast_say_digit_str(chan, l->lastcallerid, "", chan->language);
+			}
+			if (!res) {
+				transmit_tone(s, SKINNY_DIALTONE);
+			}
+			break;
+		} else if (!strcmp(exten, "*78")) {
+			/* Do not disturb */
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %s\n", chan->name);
+			}
+			transmit_tone(s, SKINNY_DIALTONE);
+			l->dnd = 1;
+			getforward = 0;
+			memset(exten, 0, sizeof(exten));
+			len = 0;
+		} else if (!strcmp(exten, "*79")) {
+			/* Do not disturb */
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %s\n", chan->name);
+			}
+			transmit_tone(s, SKINNY_DIALTONE);
+			l->dnd = 0;
+			getforward = 0;
+			memset(exten, 0, sizeof(exten));
+			len = 0;
+		} else if (l->cancallforward && !strcmp(exten, "*72")) {
+			transmit_tone(s, SKINNY_DIALTONE);
+			getforward = 1;
+			memset(exten, 0, sizeof(exten));
+			len = 0;
+		} else if (l->cancallforward && !strcmp(exten, "*73")) {
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Cancelling call forwarding on channel %s\n", chan->name);
+			}
+			transmit_tone(s, SKINNY_DIALTONE); 
+			memset(l->call_forward, 0, sizeof(l->call_forward));
+			getforward = 0;
+			memset(exten, 0, sizeof(exten));
+			len = 0;
+		} else if (!strcmp(exten, ast_parking_ext()) && 
+			sub->next->owner &&
+			ast_bridged_channel(sub->next->owner)) {
+			/* This is a three way call, the main call being a real channel, 
+				and we're parking the first call. */
+				ast_masq_park_call(ast_bridged_channel(sub->next->owner), chan, 0, NULL);
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Parking call to '%s'\n", chan->name);
+			}
+			break;
+		} else if (!ast_strlen_zero(l->lastcallerid) && !strcmp(exten, "*60")) {
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Blacklisting number %s\n", l->lastcallerid);
+			}
+			res = ast_db_put("blacklist", l->lastcallerid, "1");
+			if (!res) {
+				transmit_tone(s, SKINNY_DIALTONE);		
+				memset(exten, 0, sizeof(exten));
+				len = 0;
+			}
+		} else if (l->hidecallerid && !strcmp(exten, "*82")) {
+			if (option_verbose > 2) {
+				ast_verbose(VERBOSE_PREFIX_3 "Enabling Caller*ID on %s\n", chan->name);
+			}
+			/* Enable Caller*ID if enabled */
+			l->hidecallerid = 0;
+			if (chan->cid.cid_num) {
+				free(chan->cid.cid_num);	
+			}
+			if (!ast_strlen_zero(l->cid_num)) {
+				chan->cid.cid_num = strdup(l->cid_num);
+			}
+			if (chan->cid.cid_name) {
+				free(chan->cid.cid_name);
+			}
+			if (!ast_strlen_zero(l->cid_name)) {
+				chan->cid.cid_name = strdup(l->cid_name);	
+			}
+			transmit_tone(s, SKINNY_DIALTONE);
+			len = 0;
+			memset(exten, 0, sizeof(exten));
+			timeout = firstdigittimeout;
+		} else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
+			   ((exten[0] != '*') || (!ast_strlen_zero(exten) > 2))) {
+			ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+			transmit_tone(s, SKINNY_REORDER); 	
 			/* hang out for 3 seconds to let congestion play */
-   			ast_safe_sleep(chan, 3000); 
-   			break;
-       		}
-       		if (!timeout) {
-            		timeout = gendigittimeout;
-		}
-        	if (len && !ast_ignore_pattern(chan->context, exten)) {
+			ast_safe_sleep(chan, 3000); 
+			break;
+		}
+		if (!timeout) {
+			timeout = gendigittimeout;
+		}
+		if (len && !ast_ignore_pattern(chan->context, exten)) {
 			ast_indicate(chan, -1);
 		}
-    	}	
+	}	
 	ast_hangup(chan);
 	return NULL;
 }
@@ -1915,11 +1915,11 @@
 	int res = 0;
 	int tone = 0;
 	struct skinny_line *l;
-        struct skinny_subchannel *sub;
+	struct skinny_subchannel *sub;
 	struct skinnysession *session;
 	
 	sub = ast->tech_pvt;
-        l = sub->parent;
+	l = sub->parent;
 	session = l->parent->session;
 
 	if (!l->parent->registered) {
@@ -1932,26 +1932,26 @@
 		return -1;
 	}
 
-        if (skinnydebug) {
-        	ast_verbose(VERBOSE_PREFIX_3 "skinny_call(%s)\n", ast->name);
-    	}
+	if (skinnydebug) {
+		ast_verbose(VERBOSE_PREFIX_3 "skinny_call(%s)\n", ast->name);
+	}
 
 	if (l->dnd) {
 		ast_queue_control(ast, AST_CONTROL_BUSY);
 		return -1;
 	}
-   
+
 	switch (l->hookstate) {
-        case SKINNY_OFFHOOK:
-            	tone = SKINNY_CALLWAITTONE;
-            	break;
-        case SKINNY_ONHOOK:
+	case SKINNY_OFFHOOK:
+		tone = SKINNY_CALLWAITTONE;
+		break;
+	case SKINNY_ONHOOK:
 		tone = SKINNY_ALERT;
 		break;
-        default:
-            	ast_log(LOG_ERROR, "Don't know how to deal with hookstate %d\n", l->hookstate);
-            	break;
-   	}
+	default:
+		ast_log(LOG_ERROR, "Don't know how to deal with hookstate %d\n", l->hookstate);
+		break;
+	}
 
 	transmit_lamp_indication(session, STIMULUS_LINE, l->instance, SKINNY_LAMP_BLINK);
 	transmit_ringer_mode(session, SKINNY_RING_INSIDE);
@@ -1998,20 +1998,20 @@
 
 static int skinny_hangup(struct ast_channel *ast)
 {
-    struct skinny_subchannel *sub = ast->tech_pvt;
-    struct skinny_line *l = sub->parent;
-    struct skinnysession *s = l->parent->session;
-
-    if (skinnydebug) {
-        ast_verbose("skinny_hangup(%s) on %s@%s\n", ast->name, l->name, l->parent->name);
-    }
-    if (!ast->tech_pvt) {
-        ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
-        return 0;
-    }
-
-    if (l->parent->registered) {
-	if ((sub->parent->type = TYPE_LINE) && (sub->parent->hookstate == SKINNY_OFFHOOK)) {
+	struct skinny_subchannel *sub = ast->tech_pvt;
+	struct skinny_line *l = sub->parent;
+	struct skinnysession *s = l->parent->session;
+
+	if (skinnydebug) {
+		ast_verbose("skinny_hangup(%s) on %s@%s\n", ast->name, l->name, l->parent->name);
+	}
+	if (!ast->tech_pvt) {
+		ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+		return 0;
+	}
+
+	if (l->parent->registered) {
+		if ((sub->parent->type = TYPE_LINE) && (sub->parent->hookstate == SKINNY_OFFHOOK)) {
 			sub->parent->hookstate = SKINNY_ONHOOK;
 			transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid);
 			transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF);
@@ -2024,39 +2024,39 @@
 			transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF);
 			do_housekeeping(s);
 		} 
-    }
-    ast_mutex_lock(&sub->lock);
-    sub->owner = NULL;
-    ast->tech_pvt = NULL;
-    sub->alreadygone = 0;
-    sub->outgoing = 0;
-    if (sub->rtp) {
-        ast_rtp_destroy(sub->rtp);
-        sub->rtp = NULL;
-    }
-    ast_mutex_unlock(&sub->lock);
-    return 0;
+	}
+	ast_mutex_lock(&sub->lock);
+	sub->owner = NULL;
+	ast->tech_pvt = NULL;
+	sub->alreadygone = 0;
+	sub->outgoing = 0;
+	if (sub->rtp) {
+		ast_rtp_destroy(sub->rtp);
+		sub->rtp = NULL;
+	}
+	ast_mutex_unlock(&sub->lock);
+	return 0;
 }
 
 static int skinny_answer(struct ast_channel *ast)
 {
-    int res = 0;
-    struct skinny_subchannel *sub = ast->tech_pvt;
-    struct skinny_line *l = sub->parent;
-    struct skinnysession *s = l->parent->session;
-
-    sub->cxmode = SKINNY_CX_SENDRECV;
-    if (!sub->rtp) {
+	int res = 0;
+	struct skinny_subchannel *sub = ast->tech_pvt;
+	struct skinny_line *l = sub->parent;
+	struct skinnysession *s = l->parent->session;
+
+	sub->cxmode = SKINNY_CX_SENDRECV;
+	if (!sub->rtp) {
 		start_rtp(sub);
-    } 

[... 510 lines stripped ...]


More information about the asterisk-commits mailing list