[asterisk-commits] rmudgett: branch 1.4 r145293 - in /branches/1.4: channels/ channels/misdn/ co...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 30 18:55:24 CDT 2008


Author: rmudgett
Date: Tue Sep 30 18:55:24 2008
New Revision: 145293

URL: http://svn.digium.com/view/asterisk?view=rev&rev=145293
Log:
channels/chan_misdn.c
channels/misdn/isdn_lib.c
*  Miscellaneous other fixes from trunk to make merging easier later.

........
r145200 | rmudgett | 2008-09-30 16:00:54 -0500 (Tue, 30 Sep 2008) | 7 lines

*  Miscellaneous formatting changes to make v1.4 and trunk
more merge compatible in the mISDN area.

channels/chan_misdn.c
*  Eliminated redundant code in cb_events() EVENT_SETUP

........
r144257 | crichter | 2008-09-24 03:42:55 -0500 (Wed, 24 Sep 2008) | 9 lines

improved helptext of misdn_set_opt.
........
r142181 | rmudgett | 2008-09-09 12:30:52 -0500 (Tue, 09 Sep 2008) | 1 line

Cleaned up comment

........
r138738 | rmudgett | 2008-08-18 16:07:28 -0500 (Mon, 18 Aug 2008) | 30 lines

channels/chan_misdn.c
*  Made bearer2str() use allowed_bearers_array[]
*  Made use the causes.h defines instead of hardcoded numbers.
*  Made use Asterisk presentation indicator values if either of the
mISDN presentation or screen options are negative.
*  Updated the misdn_set_opt application option descriptions.
*  Renamed the awkward Caller ID presentation misdn_set_opt
application option value not_screened to restricted.
Deprecated the not_screened option value.

channels/misdn/isdn_lib.c
*  Made use the causes.h defines instead of hardcoded numbers.
*  Fixed some spelling errors and typos.
*  Added all defined facility code strings to fac2str().

channels/misdn/isdn_lib.h
*  Added doxygen comments to struct misdn_bchannel.

channels/misdn/isdn_lib_intern.h
*  Added doxygen comments to struct misdn_stack.

channels/misdn_config.c
configs/misdn.conf.sample
*  Updated the mISDN presentation and screen parameter descriptions.

doc/misdn.txt (doc/tex/misdn.tex)
*  Updated the misdn_set_opt application option descriptions.
*  Fixed some spelling errors and typos.

Modified:
    branches/1.4/channels/chan_misdn.c
    branches/1.4/channels/misdn/isdn_lib.c
    branches/1.4/channels/misdn/isdn_lib.h
    branches/1.4/channels/misdn/isdn_lib_intern.h
    branches/1.4/channels/misdn_config.c
    branches/1.4/configs/misdn.conf.sample
    branches/1.4/doc/misdn.txt
    branches/1.4/main/callerid.c

Modified: branches/1.4/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_misdn.c?view=diff&rev=145293&r1=145292&r2=145293
==============================================================================
--- branches/1.4/channels/chan_misdn.c (original)
+++ branches/1.4/channels/chan_misdn.c Tue Sep 30 18:55:24 2008
@@ -21,7 +21,10 @@
  * \file
  *
  * \brief the chan_misdn channel driver for Asterisk
+ *
  * \author Christian Richter <crich at beronet.com>
+ *
+ * \extref MISDN http://www.misdn.org/
  *
  * \ingroup channel_drivers
  */
@@ -72,13 +75,14 @@
 #include "asterisk/term.h"
 #include "asterisk/sched.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/causes.h"
 
 #include "chan_misdn_config.h"
 #include "isdn_lib.h"
 
-char global_tracefile[BUFFERSIZE+1];
-
-static int g_config_initialized=0;
+char global_tracefile[BUFFERSIZE + 1];
+
+static int g_config_initialized = 0;
 
 struct misdn_jb{
 	int size;
@@ -94,17 +98,17 @@
 
 
 
-/* allocates the jb-structure and initialize the elements*/
+/*! \brief allocates the jb-structure and initialize the elements */
 struct misdn_jb *misdn_jb_init(int size, int upper_threshold);
 
-/* frees the data and destroys the given jitterbuffer struct */
+/*! \brief frees the data and destroys the given jitterbuffer struct */
 void misdn_jb_destroy(struct misdn_jb *jb);
 
-/* fills the jitterbuffer with len data returns < 0 if there was an
+/*! \brief fills the jitterbuffer with len data returns < 0 if there was an
 error (buffer overrun). */
 int misdn_jb_fill(struct misdn_jb *jb, const char *data, int len);
 
-/* gets len bytes out of the jitterbuffer if available, else only the
+/*! \brief gets len bytes out of the jitterbuffer if available, else only the
 available data is returned and the return value indicates the number
 of data. */
 int misdn_jb_empty(struct misdn_jb *jb, char *data, int len);
@@ -132,9 +136,8 @@
 	MISDN_RELEASED, /*!<  when connected */
 	MISDN_BRIDGED, /*!<  when bridged */
 	MISDN_CLEANING, /*!< when hangup from * but we were connected before */
-	MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP  cam from misdn */
-	MISDN_HUNGUP_FROM_AST, /*!< when DISCONNECT/RELEASE/REL_COMP came out of */
-	/* misdn_hangup */
+	MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP  came from misdn */
+	MISDN_HUNGUP_FROM_AST, /*!< when DISCONNECT/RELEASE/REL_COMP came out of misdn_hangup */
 	MISDN_HOLDED, /*!< if this chan is holded */
 	MISDN_HOLD_DISCONNECT, /*!< if this chan is holded */
   
@@ -150,17 +153,16 @@
 
 struct chan_list {
   
-	char allowed_bearers[BUFFERSIZE+1];
+	char allowed_bearers[BUFFERSIZE + 1];
 	
 	enum misdn_chan_state state;
 	int need_queue_hangup;
 	int need_hangup;
 	int need_busy;
 	
+	int originator;
 	int noautorespond_on_setup;
 	
-	int originator;
-
 	int norxtone;
 	int notxtone; 
 
@@ -174,7 +176,7 @@
 	char ast_rd_buf[4096];
 	struct ast_frame frame;
 
-	int faxdetect; /* 0:no 1:yes 2:yes+nojump */
+	int faxdetect; /*!<  0:no 1:yes 2:yes+nojump */
 	int faxdetect_timeout;
 	struct timeval faxdetect_tv;
 	int faxhandled;
@@ -246,11 +248,13 @@
 
 static inline void free_robin_list_r (struct robin_list *r)
 {
-        if (r) {
-                if (r->next) free_robin_list_r(r->next);
-                if (r->group) free(r->group);
-                free(r);
-        }
+	if (r) {
+		if (r->next)
+			free_robin_list_r(r->next);
+		if (r->group)
+			free(r->group);
+		free(r);
+	}
 }
 
 static void free_robin_list ( void )
@@ -267,7 +271,7 @@
 		if (!strcasecmp(iter->group, group))
 			return iter;
 	}
-	new = (struct robin_list *)calloc(1, sizeof(struct robin_list));
+	new = (struct robin_list *) calloc(1, sizeof(struct robin_list));
 	new->group = strndup(group, strlen(group));
 	new->port = 0;
 	new->channel = 0;
@@ -280,13 +284,14 @@
 }
 
 
-/* the main schedule context for stuff like l1 watcher, overlap dial, ... */
+/*! \brief the main schedule context for stuff like l1 watcher, overlap dial, ... */
 static struct sched_context *misdn_tasks = NULL;
 static pthread_t misdn_tasks_thread;
 
 static int *misdn_ports;
 
-static void chan_misdn_log(int level, int port, char *tmpl, ...);
+static void chan_misdn_log(int level, int port, char *tmpl, ...)
+	__attribute__ ((format (printf, 3, 4)));
 
 static struct ast_channel *misdn_new(struct chan_list *cl, int state,  char *exten, char *callerid, int format, int port, int c);
 static void send_digit_to_chan(struct chan_list *cl, char digit );
@@ -297,7 +302,7 @@
 #define MISDN_ASTERISK_TECH_PVT(ast) ast->tech_pvt
 #define MISDN_ASTERISK_PVT(ast) 1
 
-#include <asterisk/strings.h>
+#include "asterisk/strings.h"
 
 /* #define MISDN_DEBUG 1 */
 
@@ -305,7 +310,7 @@
 
 static int tracing = 0 ;
 
-/* Only alaw and mulaw is allowed for now */
+/*! \brief Only alaw and mulaw is allowed for now */
 static int prefformat =  AST_FORMAT_ALAW ; /*  AST_FORMAT_SLINEAR ;  AST_FORMAT_ULAW | */
 
 static int *misdn_debug;
@@ -390,51 +395,35 @@
 
 
 struct allowed_bearers {
-	int cap;
-	int val;
-	char *name;
-	int deprecated;
+	char *name;			/*!< Bearer capability name string used in /etc/misdn.conf allowed_bearers */
+	char *display;		/*!< Bearer capability displayable name */
+	int cap;			/*!< SETUP message bearer capability field code value */
+	int deprecated;		/*!< TRUE if this entry is deprecated. (Misspelled or bad name to use) */
 };
 
-static struct allowed_bearers allowed_bearers_array[]= {
-	{INFO_CAPABILITY_SPEECH,1,"speech"},
-	{INFO_CAPABILITY_AUDIO_3_1K,2,"3_1khz"},
-	{INFO_CAPABILITY_DIGITAL_UNRESTRICTED,4,"digital_unrestricted"},
-	{INFO_CAPABILITY_DIGITAL_RESTRICTED,8,"digital_restricted"},
-	{INFO_CAPABILITY_DIGITAL_RESTRICTED,8,"digital_restriced", 1}, /* Allow misspelling for backwards compatibility */
-	{INFO_CAPABILITY_VIDEO,16,"video"}
+/* *INDENT-OFF* */
+static const struct allowed_bearers allowed_bearers_array[]= {
+	/* Name,                      Displayable Name       Bearer Capability,                    Deprecated */
+	{ "speech",                  "Speech",               INFO_CAPABILITY_SPEECH,               0 },
+	{ "3_1khz",                  "3.1KHz Audio",         INFO_CAPABILITY_AUDIO_3_1K,           0 },
+	{ "digital_unrestricted",    "Unrestricted Digital", INFO_CAPABILITY_DIGITAL_UNRESTRICTED, 0 },
+	{ "digital_restricted",      "Restricted Digital",   INFO_CAPABILITY_DIGITAL_RESTRICTED,   0 },
+	{ "digital_restriced",       "Restricted Digital",   INFO_CAPABILITY_DIGITAL_RESTRICTED,   1 }, /* Allow misspelling for backwards compatibility */
+	{ "video",                   "Video",                INFO_CAPABILITY_VIDEO,                0 }
 };
-
-static char *bearer2str(int cap) {
-	static char *bearers[]={
-		"Speech",
-		"Audio 3.1k",
-		"Unres Digital",
-		"Res Digital",
-		"Video",
-		"Unknown Bearer"
-	};
-	
-	switch (cap) {
-	case INFO_CAPABILITY_SPEECH:
-		return bearers[0];
-		break;
-	case INFO_CAPABILITY_AUDIO_3_1K:
-		return bearers[1];
-		break;
-	case INFO_CAPABILITY_DIGITAL_UNRESTRICTED:
-		return bearers[2];
-		break;
-	case INFO_CAPABILITY_DIGITAL_RESTRICTED:
-		return bearers[3];
-		break;
-	case INFO_CAPABILITY_VIDEO:
-		return bearers[4];
-		break;
-	default:
-		return bearers[5];
-		break;
-	}
+/* *INDENT-ON* */
+
+static const char *bearer2str(int cap)
+{
+	unsigned index;
+
+	for (index = 0; index < ARRAY_LEN(allowed_bearers_array); ++index) {
+		if (allowed_bearers_array[index].cap == cap) {
+			return allowed_bearers_array[index].display;
+		}
+	}	/* end for */
+
+	return "Unknown Bearer";
 }
 
 
@@ -443,7 +432,7 @@
 	switch (fac->Function) {
 	case Fac_CD:
 		chan_misdn_log(1,bc->port," --> calldeflect to: %s, screened: %s\n", fac->u.CDeflection.DeflectedToNumber,
-					   fac->u.CDeflection.PresentationAllowed ? "yes" : "no");
+			fac->u.CDeflection.PresentationAllowed ? "yes" : "no");
 		break;
 	case Fac_AOCDCurrency:
 		if (fac->u.AOCDcur.chargeNotAvailable)
@@ -451,13 +440,13 @@
 		else if (fac->u.AOCDcur.freeOfCharge)
 			chan_misdn_log(1,bc->port," --> AOCD currency: free of charge\n");
 		else if (fac->u.AOCDchu.billingId >= 0)
-			chan_misdn_log(1,bc->port," --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%d billingId:%d\n",
-						   fac->u.AOCDcur.currency, fac->u.AOCDcur.currencyAmount, fac->u.AOCDcur.multiplier,
-						   (fac->u.AOCDcur.typeOfChargingInfo == 0) ? "subTotal" : "total", fac->u.AOCDcur.billingId);
+			chan_misdn_log(1,bc->port," --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%s billingId:%d\n",
+				fac->u.AOCDcur.currency, fac->u.AOCDcur.currencyAmount, fac->u.AOCDcur.multiplier,
+				(fac->u.AOCDcur.typeOfChargingInfo == 0) ? "subTotal" : "total", fac->u.AOCDcur.billingId);
 		else
-			chan_misdn_log(1,bc->port," --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%d\n",
-						   fac->u.AOCDcur.currency, fac->u.AOCDcur.currencyAmount, fac->u.AOCDcur.multiplier,
-						   (fac->u.AOCDcur.typeOfChargingInfo == 0) ? "subTotal" : "total");
+			chan_misdn_log(1,bc->port," --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%s\n",
+				fac->u.AOCDcur.currency, fac->u.AOCDcur.currencyAmount, fac->u.AOCDcur.multiplier,
+				(fac->u.AOCDcur.typeOfChargingInfo == 0) ? "subTotal" : "total");
 		break;
 	case Fac_AOCDChargingUnit:
 		if (fac->u.AOCDchu.chargeNotAvailable)
@@ -466,13 +455,14 @@
 			chan_misdn_log(1,bc->port," --> AOCD charging unit: free of charge\n");
 		else if (fac->u.AOCDchu.billingId >= 0)
 			chan_misdn_log(1,bc->port," --> AOCD charging unit: recordedUnits:%d typeOfChargingInfo:%s billingId:%d\n",
-						   fac->u.AOCDchu.recordedUnits, (fac->u.AOCDchu.typeOfChargingInfo == 0) ? "subTotal" : "total", fac->u.AOCDchu.billingId);
+				fac->u.AOCDchu.recordedUnits, (fac->u.AOCDchu.typeOfChargingInfo == 0) ? "subTotal" : "total", fac->u.AOCDchu.billingId);
 		else
 			chan_misdn_log(1,bc->port," --> AOCD charging unit: recordedUnits:%d typeOfChargingInfo:%s\n",
-						   fac->u.AOCDchu.recordedUnits, (fac->u.AOCDchu.typeOfChargingInfo == 0) ? "subTotal" : "total");
+				fac->u.AOCDchu.recordedUnits, (fac->u.AOCDchu.typeOfChargingInfo == 0) ? "subTotal" : "total");
 		break;
 	default:
-		chan_misdn_log(1,bc->port," --> unknown\n");
+		chan_misdn_log(1,bc->port," --> unknown facility\n");
+		break;
 	}
 }
 
@@ -687,7 +677,7 @@
 		} else {
 misdn_overlap_dial_task_disconnect:
 			hanguptone_indicate(ch);
-			ch->bc->out_cause=1;
+			ch->bc->out_cause = AST_CAUSE_UNALLOCATED;
 			ch->state=MISDN_CLEANING;
 			misdn_lib_send_event(ch->bc, EVENT_DISCONNECT);
 		}
@@ -729,10 +719,9 @@
 	else {
 		/* not handled */
 		ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
-    
-    
-	}
-}
+	}
+}
+
 /*** CLI HANDLING ***/
 static int misdn_set_debug(int fd, int argc, char *argv[])
 {
@@ -744,52 +733,55 @@
 	level = atoi(argv[3]);
 
 	switch (argc) {
-		case 4:	
-		case 5: {
-					int i;
-					int only = 0;
-					if (argc == 5) {
-						if (strncasecmp(argv[4], "only", strlen(argv[4])))
-							return RESULT_SHOWUSAGE;
-						else
-							only = 1;
-					}
-					for (i=0; i<=max_ports; i++) {
-						misdn_debug[i] = level;
-						misdn_debug_only[i] = only;
-					}
-					ast_cli(fd, "changing debug level for all ports to %d%s\n",misdn_debug[0], only?" (only)":"");
+	case 4:
+	case 5:
+		{
+			int i;
+			int only = 0;
+			if (argc == 5) {
+				if (strncasecmp(argv[4], "only", strlen(argv[4])))
+					return RESULT_SHOWUSAGE;
+				else
+					only = 1;
+			}
+	
+			for (i = 0; i <= max_ports; i++) {
+				misdn_debug[i] = level;
+				misdn_debug_only[i] = only;
+			}
+			ast_cli(fd, "changing debug level for all ports to %d%s\n",misdn_debug[0], only?" (only)":"");
+		}
+		break;
+	case 6:
+	case 7:
+		{
+			int port;
+			if (strncasecmp(argv[4], "port", strlen(argv[4])))
+				return RESULT_SHOWUSAGE;
+			port = atoi(argv[5]);
+			if (port <= 0 || port > max_ports) {
+				switch (max_ports) {
+				case 0:
+					ast_cli(fd, "port number not valid! no ports available so you won't get lucky with any number here...\n");
+					break;
+				case 1:
+					ast_cli(fd, "port number not valid! only port 1 is available.\n");
+					break;
+				default:
+					ast_cli(fd, "port number not valid! only ports 1 to %d are available.\n", max_ports);
 				}
-				break;
-		case 6: 
-		case 7: {
-					int port;
-					if (strncasecmp(argv[4], "port", strlen(argv[4])))
-						return RESULT_SHOWUSAGE;
-					port = atoi(argv[5]);
-					if (port <= 0 || port > max_ports) {
-						switch (max_ports) {
-							case 0:
-								ast_cli(fd, "port number not valid! no ports available so you won't get lucky with any number here...\n");
-								break;
-							case 1:
-								ast_cli(fd, "port number not valid! only port 1 is available.\n");
-								break;
-							default:
-								ast_cli(fd, "port number not valid! only ports 1 to %d are available.\n", max_ports);
-							}
-							return 0;
-					}
-					if (argc == 7) {
-						if (strncasecmp(argv[6], "only", strlen(argv[6])))
-							return RESULT_SHOWUSAGE;
-						else
-							misdn_debug_only[port] = 1;
-					} else
-						misdn_debug_only[port] = 0;
-					misdn_debug[port] = level;
-					ast_cli(fd, "changing debug level to %d%s for port %d\n", misdn_debug[port], misdn_debug_only[port]?" (only)":"", port);
-				}
+				return 0;
+			}
+			if (argc == 7) {
+				if (strncasecmp(argv[6], "only", strlen(argv[6])))
+					return RESULT_SHOWUSAGE;
+				else
+					misdn_debug_only[port] = 1;
+			} else
+				misdn_debug_only[port] = 0;
+			misdn_debug[port] = level;
+			ast_cli(fd, "changing debug level to %d%s for port %d\n", misdn_debug[port], misdn_debug_only[port]?" (only)":"", port);
+		}
 	}
 	return 0;
 }
@@ -920,7 +912,7 @@
 	if (argc >= 4) {
 		if (!strcmp(argv[3], "description")) {
 			if (argc == 5) {
-				enum misdn_cfg_elements elem = misdn_cfg_get_elem (argv[4]);
+				enum misdn_cfg_elements elem = misdn_cfg_get_elem(argv[4]);
 				if (elem == MISDN_CFG_FIRST)
 					ast_cli(fd, "Unknown element: %s\n", argv[4]);
 				else
@@ -953,9 +945,9 @@
 	}
 	
 	if (argc == 3 || onlyport == 0) {
-		ast_cli(fd,"Misdn General-Config: \n"); 
+		ast_cli(fd, "Misdn General-Config:\n");
 		for (elem = MISDN_GEN_FIRST + 1, linebreak = 1; elem < MISDN_GEN_LAST; elem++, linebreak++) {
-			misdn_cfg_get_config_string( 0, elem, buffer, BUFFERSIZE);
+			misdn_cfg_get_config_string(0, elem, buffer, BUFFERSIZE);
 			ast_cli(fd, "%-36s%s", buffer, !(linebreak % 2) ? "\n" : "");
 		}
 		ast_cli(fd, "\n");
@@ -966,7 +958,7 @@
 		for (; port > 0; port = misdn_cfg_get_next_port(port)) {
 			ast_cli(fd, "\n[PORT %d]\n", port);
 			for (elem = MISDN_CFG_FIRST + 1, linebreak = 1; elem < MISDN_CFG_LAST; elem++, linebreak++) {
-				misdn_cfg_get_config_string( port, elem, buffer, BUFFERSIZE);
+				misdn_cfg_get_config_string(port, elem, buffer, BUFFERSIZE);
 				ast_cli(fd, "%-36s%s", buffer, !(linebreak % 2) ? "\n" : "");
 			}	
 			ast_cli(fd, "\n");
@@ -985,13 +977,14 @@
 			ast_cli(fd, "Port %d is not active!\n", onlyport);
 		}
 	}
+
 	return 0;
 }
 
 struct state_struct {
 	enum misdn_chan_state state;
-	char txt[255] ;
-} ;
+	char txt[255];
+};
 
 static struct state_struct state_array[] = {
 	{MISDN_NOTHING,"NOTHING"}, /* at beginning */
@@ -1017,18 +1010,19 @@
 	{MISDN_HUNGUP_FROM_AST,"HUNGUP_FROM_AST"} /* when DISCONNECT/RELEASE/REL_COMP came out of misdn_hangup */
 };
 
-static char *misdn_get_ch_state(struct chan_list *p) 
+static const char *misdn_get_ch_state(struct chan_list *p) 
 {
 	int i;
 	static char state[8];
 	
 	if( !p) return NULL;
   
-	for (i=0; i< sizeof(state_array)/sizeof(struct state_struct); i++) {
-		if ( state_array[i].state == p->state) return state_array[i].txt; 
-	}
-
- 	sprintf(state,"%d",p->state) ;
+	for (i = 0; i < sizeof(state_array) / sizeof(struct state_struct); i++) {
+		if (state_array[i].state == p->state)
+			return state_array[i].txt; 
+	}
+
+ 	snprintf(state, sizeof(state), "%d", p->state) ;
 
 	return state;
 }
@@ -1047,8 +1041,8 @@
 	free_robin_list();
 	misdn_cfg_reload();
 	misdn_cfg_update_ptp();
-	misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
-	misdn_cfg_get( 0, MISDN_GEN_DEBUG, &cfg_debug, sizeof(int));
+	misdn_cfg_get(0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
+	misdn_cfg_get(0, MISDN_GEN_DEBUG, &cfg_debug, sizeof(int));
 
 	for (i = 0;  i <= max_ports; i++) {
 		misdn_debug[i] = cfg_debug;
@@ -1058,24 +1052,24 @@
 
 static int misdn_reload (int fd, int argc, char *argv[])
 {
-	ast_cli(fd, "Reloading mISDN Config\n");
+	ast_cli(fd, "Reloading mISDN configuration\n");
 	reload_config();
 	return 0;
 }
 
-static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel* bc)
-{
-	struct ast_channel *ast=help->ast;
+static void print_bc_info (int fd, struct chan_list *help, struct misdn_bchannel *bc)
+{
+	struct ast_channel *ast = help->ast;
 	ast_cli(fd,
 		"* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s rad:%s ctx:%s state:%s\n",
 
 		bc->pid, bc->port, bc->channel,
-		bc->nt?"NT":"TE",
-		help->originator == ORG_AST?"*":"I",
-		ast?ast->exten:NULL,
-		ast?ast->cid.cid_num:NULL,
+		bc->nt ? "NT" : "TE",
+		help->originator == ORG_AST ? "*" : "I",
+		ast ? ast->exten : NULL,
+		ast ? ast->cid.cid_num : NULL,
 		bc->rad,
-		ast?ast->context:NULL,
+		ast ? ast->context : NULL,
 		misdn_get_ch_state(help)
 		);
 	if (misdn_debug[bc->port] > 0)
@@ -1100,7 +1094,7 @@
 			help->l3id,
 			help->addr,
 			bc->addr,
-			bc?bc->l3_id:-1,
+			bc ? bc->l3_id : -1,
 			bc->display,
 			
 			bc->active,
@@ -1112,21 +1106,23 @@
  			bc->ec_enable,
 #endif
 
-			help->norxtone,help->notxtone,
+			help->norxtone, help->notxtone,
 			bc->holded
 			);
+
+}
+
+static int misdn_show_cls (int fd, int argc, char *argv[])
+{
+	struct chan_list *help;
+
+	help = cl_te;
   
-}
-
-static int misdn_show_cls (int fd, int argc, char *argv[])
-{
-	struct chan_list *help=cl_te;
-  
-	ast_cli(fd,"Chan List: %p\n",cl_te); 
-
-	for (;help; help=help->next) {
-		struct misdn_bchannel *bc=help->bc;   
-		struct ast_channel *ast=help->ast;
+	ast_cli(fd, "Channel List: %p\n", cl_te);
+
+	for (; help; help = help->next) {
+		struct misdn_bchannel *bc = help->bc;   
+		struct ast_channel *ast = help->ast;
 		if (!ast) {
 			if (!bc) {
 				ast_cli(fd, "chan_list obj. with l3id:%x has no bc and no ast Leg\n", help->l3id);
@@ -1135,7 +1131,9 @@
 			ast_cli(fd, "bc with pid:%d has no Ast Leg\n", bc->pid);
 			continue;
 		}
-		if (misdn_debug[0] > 2) ast_cli(fd, "Bc:%p Ast:%p\n", bc, ast);
+
+		if (misdn_debug[0] > 2)
+			ast_cli(fd, "Bc:%p Ast:%p\n", bc, ast);
 		if (bc) {
 			print_bc_info(fd, help, bc);
 		} else {
@@ -1144,34 +1142,36 @@
 				ast_cli(fd, " --> l3_id: %x\n"
 						" --> dad:%s oad:%s\n"
 						" --> hold_port: %d\n"
-						" --> hold_channel: %d\n"
-				
-						,help->l3id
-						,ast->exten
-						,ast->cid.cid_num
-						,help->hold_info.port
-						,help->hold_info.channel
+						" --> hold_channel: %d\n",
+						help->l3id,
+						ast->exten,
+						ast->cid.cid_num,
+						help->hold_info.port,
+						help->hold_info.channel
 						);
 			} else {
-				ast_cli(fd,"* Channel in unknown STATE !!! Exten:%s, Callerid:%s\n", ast->exten, ast->cid.cid_num);
-			}
-		}
-	}
-  
+				ast_cli(fd, "* Channel in unknown STATE !!! Exten:%s, Callerid:%s\n", ast->exten, ast->cid.cid_num);
+			}
+		}
+	}
+
  	misdn_dump_chanlist();
+
 	return 0;
 }
 
 static int misdn_show_cl (int fd, int argc, char *argv[])
 {
-	struct chan_list *help=cl_te;
+	struct chan_list *help;
 
 	if (argc != 4)
 		return RESULT_SHOWUSAGE;
-  
-	for (;help; help=help->next) {
-		struct misdn_bchannel *bc=help->bc;   
-		struct ast_channel *ast=help->ast;
+
+	help = cl_te;
+
+	for (; help; help = help->next) {
+		struct misdn_bchannel *bc = help->bc;   
+		struct ast_channel *ast = help->ast;
     
 		if (bc && ast) {
 			if (!strcasecmp(ast->name,argv[3])) {
@@ -1180,21 +1180,20 @@
 			}
 		} 
 	}
-  
-  
+
 	return 0;
 }
 
 ast_mutex_t lock;
-int MAXTICS=8;
+int MAXTICS = 8;
 
 static int misdn_set_tics (int fd, int argc, char *argv[])
 {
 	if (argc != 4)
 		return RESULT_SHOWUSAGE;
-  
-	MAXTICS=atoi(argv[3]);
-  
+
+	MAXTICS = atoi(argv[3]);
+
 	return 0;
 }
 
@@ -1203,103 +1202,97 @@
 	int port;
 
 	ast_cli(fd, "BEGIN STACK_LIST:\n");
-
-	for (port=misdn_cfg_get_next_port(0); port > 0;
-	     port=misdn_cfg_get_next_port(port)) {
+	for (port = misdn_cfg_get_next_port(0); port > 0;
+	     port = misdn_cfg_get_next_port(port)) {
 		char buf[128];
-		get_show_stack_details(port,buf);
-		ast_cli(fd,"  %s  Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port]?"(only)":"");
-	}
-		
+		get_show_stack_details(port, buf);
+		ast_cli(fd, "  %s  Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port] ? "(only)" : "");
+	}
+
 	return 0;
 }
 
-
 static int misdn_show_ports_stats (int fd, int argc, char *argv[])
 {
 	int port;
 
 	ast_cli(fd, "Port\tin_calls\tout_calls\n");
-	
-	for (port=misdn_cfg_get_next_port(0); port > 0;
-	     port=misdn_cfg_get_next_port(port)) {
-		ast_cli(fd,"%d\t%d\t\t%d\n",port,misdn_in_calls[port],misdn_out_calls[port]);
-	}
-	ast_cli(fd,"\n");
-	
+	for (port = misdn_cfg_get_next_port(0); port > 0;
+	     port = misdn_cfg_get_next_port(port)) {
+		ast_cli(fd, "%d\t%d\t\t%d\n", port, misdn_in_calls[port], misdn_out_calls[port]);
+	}
+	ast_cli(fd, "\n");
+
 	return 0;
-
-}
-
+}
 
 static int misdn_show_port (int fd, int argc, char *argv[])
 {
 	int port;
 	char buf[128];
-	
+
 	if (argc != 4)
 		return RESULT_SHOWUSAGE;
-  
+
 	port = atoi(argv[3]);
   
 	ast_cli(fd, "BEGIN STACK_LIST:\n");
-
-	get_show_stack_details(port,buf);
-	ast_cli(fd,"  %s  Debug:%d%s\n",buf, misdn_debug[port], misdn_debug_only[port]?"(only)":"");
-
-	
+	get_show_stack_details(port, buf);
+	ast_cli(fd, "  %s  Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port] ? "(only)" : "");
+
 	return 0;
 }
 
 static int misdn_send_cd (int fd, int argc, char *argv[])
 {
 	char *channame; 
-	char *nr; 
-  
+	char *nr;
+	struct chan_list *tmp;
+
 	if (argc != 5)
 		return RESULT_SHOWUSAGE;
-  
-	channame = argv[3];
-	nr = argv[4];
-
-	ast_cli(fd, "Sending Calldeflection (%s) to %s\n",nr, channame);
+ 
 	
 	{
-		struct chan_list *tmp=get_chan_by_ast_name(channame);
-		
+		channame = argv[3];
+		nr = argv[4];
+
+		ast_cli(fd, "Sending Calldeflection (%s) to %s\n", nr, channame);
+		tmp = get_chan_by_ast_name(channame);
 		if (!tmp) {
 			ast_cli(fd, "Sending CD with nr %s to %s failed: Channel does not exist.\n",nr, channame);
 			return 0; 
-		} else {
-			if (strlen(nr) >= 15) {
-				ast_cli(fd, "Sending CD with nr %s to %s failed: Number too long (up to 15 digits are allowed).\n",nr, channame);
-				return 0; 
-			}
-			tmp->bc->fac_out.Function = Fac_CD;
-			strncpy((char *)tmp->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(tmp->bc->fac_out.u.CDeflection.DeflectedToNumber));
-			misdn_lib_send_event(tmp->bc, EVENT_FACILITY);
-		}
-	}
-  
-	return 0; 
+		}
+
+		if (strlen(nr) >= 15) {
+			ast_cli(fd, "Sending CD with nr %s to %s failed: Number too long (up to 15 digits are allowed).\n",nr, channame);
+			return 0; 
+		}
+		tmp->bc->fac_out.Function = Fac_CD;
+		ast_copy_string((char *)tmp->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(tmp->bc->fac_out.u.CDeflection.DeflectedToNumber));
+		misdn_lib_send_event(tmp->bc, EVENT_FACILITY);
+	}
+
+	return 0;
 }
 
 static int misdn_send_restart(int fd, int argc, char *argv[])
 {
 	int port;
 	int channel;
-	
-	if ( (argc < 4) ||  (argc >  5) )
+
+	if (argc < 4 || argc > 5)
 		return RESULT_SHOWUSAGE;
-  
+
 	port = atoi(argv[3]);
 
-	if (argc==5) {
+	if (argc == 5) {
 		channel = atoi(argv[4]);
- 		misdn_lib_send_restart(port, channel);
-	} else
- 		misdn_lib_send_restart(port, -1 );
-	
+		misdn_lib_send_restart(port, channel);
+	} else {
+ 		misdn_lib_send_restart(port, -1);
+	}
+
 	return 0;
 }
 
@@ -1307,105 +1300,96 @@
 {
 	char *channame; 
 	char *msg; 
-  
+	struct chan_list *tmp;
+	int i, msglen;
+
 	if (argc != 5)
 		return RESULT_SHOWUSAGE;
-  
+
 	channame = argv[3];
 	msg = argv[4];
-
-	ast_cli(fd, "Sending %s to %s\n",msg, channame);
-  
-	{
-		struct chan_list *tmp=get_chan_by_ast_name(channame);
-    
-		if (!tmp) {
-			ast_cli(fd, "Sending %s to %s failed Channel does not exist\n",msg, channame);
-			return 0; 
-		} else {
+	msglen = strlen(msg);
+
+	ast_cli(fd, "Sending %s to %s\n", msg, channame);
+
+	tmp = get_chan_by_ast_name(channame);
+	if (!tmp) {
+		ast_cli(fd, "Sending %s to %s failed Channel does not exist\n", msg, channame);
+		return 0; 
+	}
 #if 1
-			int i;
-			int msglen = strlen(msg);
-			for (i=0; i<msglen; i++) {
-				ast_cli(fd, "Sending: %c\n",msg[i]);
-				send_digit_to_chan(tmp, msg[i]);
-				/* res = ast_safe_sleep(tmp->ast, 250); */
-				usleep(250000);
-				/* res = ast_waitfor(tmp->ast,100); */
-			}
+	for (i = 0; i < msglen; i++) {
+		ast_cli(fd, "Sending: %c\n", msg[i]);
+		send_digit_to_chan(tmp, msg[i]);
+		/* res = ast_safe_sleep(tmp->ast, 250); */
+		usleep(250000);
+		/* res = ast_waitfor(tmp->ast,100); */
+	}
 #else
-			int res;
-			res = ast_dtmf_stream(tmp->ast,NULL,msg,250);
+	ast_dtmf_stream(tmp->ast, NULL, msg, 250);
 #endif
-		}
-	}
-  
-	return 0; 
+
+	return 0;
 }
 
 static int misdn_toggle_echocancel (int fd, int argc, char *argv[])
 {
-	char *channame; 
+	char *channame;
+	struct chan_list *tmp;
 
 	if (argc != 4)
 		return RESULT_SHOWUSAGE;
-	
+
 	channame = argv[3];
   
 	ast_cli(fd, "Toggling EchoCancel on %s\n", channame);
   
-	{
-		struct chan_list *tmp=get_chan_by_ast_name(channame);
-    
-		if (!tmp) {
-			ast_cli(fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame);
-			return 0; 
-		} else {
-			
-			tmp->toggle_ec=tmp->toggle_ec?0:1;
-
-			if (tmp->toggle_ec) {
+	tmp = get_chan_by_ast_name(channame);
+	if (!tmp) {
+		ast_cli(fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame);
+		return 0;
+	}
+
+	tmp->toggle_ec = tmp->toggle_ec ? 0 : 1;
+
+	if (tmp->toggle_ec) {
 #ifdef MISDN_1_2
-				update_pipeline_config(tmp->bc);
+		update_pipeline_config(tmp->bc);
 #else
-				update_ec_config(tmp->bc);
+		update_ec_config(tmp->bc);
 #endif
-				manager_ec_enable(tmp->bc);
-			} else {
-				manager_ec_disable(tmp->bc);
-			}
-		}
-	}
-  
-	return 0; 
+		manager_ec_enable(tmp->bc);
+	} else {
+		manager_ec_disable(tmp->bc);
+	}
+
+	return 0;
 }
 
 static int misdn_send_display (int fd, int argc, char *argv[])
 {
-	char *channame; 
-	char *msg; 
-  
+	char *channame;
+	char *msg;
+	struct chan_list *tmp;
+
 	if (argc != 5)
 		return RESULT_SHOWUSAGE;
-  
+
 	channame = argv[3];
 	msg = argv[4];
 
-	ast_cli(fd, "Sending %s to %s\n",msg, channame);
-	{
-		struct chan_list *tmp;
-		tmp=get_chan_by_ast_name(channame);
+	ast_cli(fd, "Sending %s to %s\n", msg, channame);
+	tmp = get_chan_by_ast_name(channame);
     
-		if (tmp && tmp->bc) {
-			ast_copy_string(tmp->bc->display, msg, sizeof(tmp->bc->display));
-			misdn_lib_send_event(tmp->bc, EVENT_INFORMATION);
-		} else {
-			ast_cli(fd,"No such channel %s\n",channame);
-			return RESULT_FAILURE;
-		}
-	}
-
-	return RESULT_SUCCESS ;
+	if (tmp && tmp->bc) {
+		ast_copy_string(tmp->bc->display, msg, sizeof(tmp->bc->display));
+		misdn_lib_send_event(tmp->bc, EVENT_INFORMATION);
+	} else {
+		ast_cli(fd, "No such channel %s\n", channame);
+		return RESULT_FAILURE;
+	}
+
+	return RESULT_SUCCESS;
 }
 
 static char *complete_ch_helper(const char *line, const char *word, int pos, int state, int rpos)
@@ -1443,14 +1427,16 @@
 		return NULL;
 
 	switch (pos) {
-	case 4: if (*word == 'p')
-				return strdup("port");
-			else if (*word == 'o')
-				return strdup("only");
-			break;
-	case 6: if (*word == 'o')
-				return strdup("only");
-			break;
+	case 4:
+		if (*word == 'p')
+			return strdup("port");
+		else if (*word == 'o')
+			return strdup("only");
+		break;
+	case 6:
+		if (*word == 'o')
+			return strdup("only");
+		break;
 	}
 	return NULL;
 }
@@ -1464,37 +1450,38 @@
 	int port = 0;
 
 	switch (pos) {
-	case 3: if ((!strncmp(word, "description", wordlen)) && (++which > state))
-				return strdup("description");
-			if ((!strncmp(word, "descriptions", wordlen)) && (++which > state))
-				return strdup("descriptions");
-			if ((!strncmp(word, "0", wordlen)) && (++which > state))
-				return strdup("0");
-			while ((port = misdn_cfg_get_next_port(port)) != -1) {
-				snprintf(buffer, sizeof(buffer), "%d", port);
-				if ((!strncmp(word, buffer, wordlen)) && (++which > state)) {
-					return strdup(buffer);
+	case 3:
+		if ((!strncmp(word, "description", wordlen)) && (++which > state))
+			return strdup("description");
+		if ((!strncmp(word, "descriptions", wordlen)) && (++which > state))
+			return strdup("descriptions");
+		if ((!strncmp(word, "0", wordlen)) && (++which > state))
+			return strdup("0");
+		while ((port = misdn_cfg_get_next_port(port)) != -1) {
+			snprintf(buffer, sizeof(buffer), "%d", port);
+			if ((!strncmp(word, buffer, wordlen)) && (++which > state)) {
+				return strdup(buffer);
+			}
+		}
+		break;
+	case 4:
+		if (strstr(line, "description ")) {
+			for (elem = MISDN_CFG_FIRST + 1; elem < MISDN_GEN_LAST; ++elem) {
+				if ((elem == MISDN_CFG_LAST) || (elem == MISDN_GEN_FIRST))
+					continue;
+				misdn_cfg_get_name(elem, buffer, BUFFERSIZE);
+				if (!wordlen || !strncmp(word, buffer, wordlen)) {
+					if (++which > state)
+						return strdup(buffer);
 				}
 			}
-			break;
-	case 4:
-			if (strstr(line, "description ")) {
-				for (elem = MISDN_CFG_FIRST + 1; elem < MISDN_GEN_LAST; ++elem) {
-					if ((elem == MISDN_CFG_LAST) || (elem == MISDN_GEN_FIRST))
-						continue;
-					misdn_cfg_get_name(elem, buffer, BUFFERSIZE);
-					if (!wordlen || !strncmp(word, buffer, wordlen)) {
-						if (++which > state)
-							return strdup(buffer);
-					}
-				}
-			} else if (strstr(line, "descriptions ")) {
-				if ((!wordlen || !strncmp(word, "general", wordlen)) && (++which > state))
-					return strdup("general");
-				if ((!wordlen || !strncmp(word, "ports", wordlen)) && (++which > state))
-					return strdup("ports");
-			}
-			break;
+		} else if (strstr(line, "descriptions ")) {
+			if ((!wordlen || !strncmp(word, "general", wordlen)) && (++which > state))
+				return strdup("general");
+			if ((!wordlen || !strncmp(word, "ports", wordlen)) && (++which > state))
+				return strdup("ports");
+		}
+		break;
 	}
 	return NULL;
 }
@@ -1550,139 +1537,122 @@
 		"Usage: misdn set crypt debug <level>\n" }
 };
 
-static int update_config (struct chan_list *ch, int orig) 
-{
-	struct ast_channel *ast=ch->ast;
-	struct misdn_bchannel *bc=ch->bc;
-	int port;
+static int update_config(struct chan_list *ch, int orig) 
+{
+	struct ast_channel *ast;
+	struct misdn_bchannel *bc;
+	int port, hdlc = 0;
 	int pres, screen;
-	int hdlc=0;
 
 	if (!ch) {
 		ast_log(LOG_WARNING, "Cannot configure without chanlist\n");
 		return -1;
 	}
-	
-	ast=ch->ast;
-	bc=ch->bc;
-	if (! ast || ! bc ) {
+
+	ast = ch->ast;
+	bc = ch->bc;
+	if (! ast || ! bc) {
 		ast_log(LOG_WARNING, "Cannot configure without ast || bc\n");
 		return -1;
 	}
-	
-	port=bc->port;
-	
-	chan_misdn_log(7,port,"update_config: Getting Config\n");
-
-	misdn_cfg_get( port, MISDN_CFG_HDLC, &hdlc, sizeof(int));
+
+	port = bc->port;
+
+	chan_misdn_log(7, port, "update_config: Getting Config\n");
+
+	misdn_cfg_get(port, MISDN_CFG_HDLC, &hdlc, sizeof(int));
 	
 	if (hdlc) {
 		switch (bc->capability) {
 		case INFO_CAPABILITY_DIGITAL_UNRESTRICTED:
 		case INFO_CAPABILITY_DIGITAL_RESTRICTED:
-			chan_misdn_log(1,bc->port," --> CONF HDLC\n");
-			bc->hdlc=1;
-			break;
-		}
+			chan_misdn_log(1, bc->port, " --> CONF HDLC\n");
+			bc->hdlc = 1;
+			break;
+		}
+	}
+
+
+	misdn_cfg_get(port, MISDN_CFG_PRES, &pres, sizeof(pres));
+	misdn_cfg_get(port, MISDN_CFG_SCREEN, &screen, sizeof(screen));
+	chan_misdn_log(2, port, " --> pres: %d screen: %d\n", pres, screen);
 		
-	}
-	
-	misdn_cfg_get( port, MISDN_CFG_PRES, &pres, sizeof(int));
-	misdn_cfg_get( port, MISDN_CFG_SCREEN, &screen, sizeof(int));
-	chan_misdn_log(2,port," --> pres: %d screen: %d\n",pres, screen);
-		
-	if ( (pres + screen) < 0 ) {
-
-		chan_misdn_log(2,port," --> pres: %x\n", ast->cid.cid_pres);
+	if (pres < 0 || screen < 0) {
+		chan_misdn_log(2, port, " --> pres: %x\n", ast->cid.cid_pres);
 			
-		switch (ast->cid.cid_pres & 0x60){
-				
+		switch (ast->cid.cid_pres & 0x60) {
 		case AST_PRES_RESTRICTED:
-			bc->pres=1;
-			chan_misdn_log(2, port, " --> PRES: Restricted (0x1)\n");
-			break;
-				
-				
+			bc->pres = 1;
+			chan_misdn_log(2, port, " --> PRES: Restricted (1)\n");
+			break;
 		case AST_PRES_UNAVAILABLE:
-			bc->pres=2;
-			chan_misdn_log(2, port, " --> PRES: Unavailable (0x2)\n");
-			break;
-				
+			bc->pres = 2;
+			chan_misdn_log(2, port, " --> PRES: Unavailable (2)\n");
+			break;
 		default:
-			bc->pres=0;
-			chan_misdn_log(2, port, " --> PRES: Allowed (0x0)\n");
-		}
-			
-		switch (ast->cid.cid_pres & 0x3){
-				
+			bc->pres = 0;
+			chan_misdn_log(2, port, " --> PRES: Allowed (0)\n");
+			break;
+		}
+
+		switch (ast->cid.cid_pres & 0x3) {
+		default:
 		case AST_PRES_USER_NUMBER_UNSCREENED:
-			bc->screen=0;
-			chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
-			break;
-
+			bc->screen = 0;
+			chan_misdn_log(2, port, " --> SCREEN: Unscreened (0)\n");
+			break;
 		case AST_PRES_USER_NUMBER_PASSED_SCREEN:
-			bc->screen=1;
-			chan_misdn_log(2, port, " --> SCREEN: Passed Screen (0x1)\n");
+			bc->screen = 1;
+			chan_misdn_log(2, port, " --> SCREEN: Passed Screen (1)\n");
 			break;
 		case AST_PRES_USER_NUMBER_FAILED_SCREEN:
-			bc->screen=2;
-			chan_misdn_log(2, port, " --> SCREEN: Failed Screen (0x2)\n");
-			break;
-				
+			bc->screen = 2;
+			chan_misdn_log(2, port, " --> SCREEN: Failed Screen (2)\n");
+			break;
 		case AST_PRES_NETWORK_NUMBER:
-			bc->screen=3;
-			chan_misdn_log(2, port, " --> SCREEN: Network Nr. (0x3)\n");
-			break;
-				
-		default:
-			bc->screen=0;
-			chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
-		}
-
-			
+			bc->screen = 3;
+			chan_misdn_log(2, port, " --> SCREEN: Network Nr. (3)\n");
+			break;
+		}
 	} else {
-		bc->screen=screen;
-		bc->pres=pres;
+		bc->screen = screen;
+		bc->pres = pres;
 	}
 
 	return 0;
-	
-}
-
-
+}
 
 
 static void config_jitterbuffer(struct chan_list *ch)
 {
-	struct misdn_bchannel *bc=ch->bc;
-	int len=ch->jb_len, threshold=ch->jb_upper_threshold;
-	
-	chan_misdn_log(5,bc->port, "config_jb: Called\n");
-	
-	if ( ! len ) {
-		chan_misdn_log(1,bc->port, "config_jb: Deactivating Jitterbuffer\n");
+	struct misdn_bchannel *bc = ch->bc;
+	int len = ch->jb_len, threshold = ch->jb_upper_threshold;
+	
+	chan_misdn_log(5, bc->port, "config_jb: Called\n");
+	
+	if (! len) {
+		chan_misdn_log(1, bc->port, "config_jb: Deactivating Jitterbuffer\n");
 		bc->nojitter=1;
 	} else {
-		
-		if (len <=100 || len > 8000) {
-			chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
-			len=1000;
-		}
-		
+		if (len <= 100 || len > 8000) {
+			chan_misdn_log(0, bc->port, "config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
+			len = 1000;
+		}
+
 		if ( threshold > len ) {
-			chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
-		}
-		
+			chan_misdn_log(0, bc->port, "config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
+		}
+
 		if ( ch->jb) {
-			cb_log(0,bc->port,"config_jb: We've got a Jitterbuffer Already on this port.\n");
+			cb_log(0, bc->port, "config_jb: We've got a Jitterbuffer Already on this port.\n");
 			misdn_jb_destroy(ch->jb);
-			ch->jb=NULL;
-		}
-		
+			ch->jb = NULL;
+		}
+
 		ch->jb=misdn_jb_init(len, threshold);
 
 		if (!ch->jb ) 
-			bc->nojitter=1;
+			bc->nojitter = 1;
 	}
 }
 
@@ -1691,16 +1661,16 @@
 {
 	switch (numplan) {
 	case NUMPLAN_INTERNATIONAL:
-		chan_misdn_log(2, port, " --> %s: International\n",type);
+		chan_misdn_log(2, port, " --> %s: International\n", type);
 		break;
 	case NUMPLAN_NATIONAL:
-		chan_misdn_log(2, port, " --> %s: National\n",type);
+		chan_misdn_log(2, port, " --> %s: National\n", type);
 		break;
 	case NUMPLAN_SUBSCRIBER:
-		chan_misdn_log(2, port, " --> %s: Subscriber\n",type);
+		chan_misdn_log(2, port, " --> %s: Subscriber\n", type);
 		break;
 	case NUMPLAN_UNKNOWN:
-		chan_misdn_log(2, port, " --> %s: Unknown\n",type);
+		chan_misdn_log(2, port, " --> %s: Unknown\n", type);
 		break;
 		/* Maybe we should cut off the prefix if present ? */
 	default:
@@ -1710,8 +1680,6 @@
 }
 
 
-
-
 #ifdef MISDN_1_2
 static int update_pipeline_config(struct misdn_bchannel *bc)
 {
@@ -1724,9 +1692,9 @@
 
 	misdn_cfg_get(bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
 	if (ec == 1)
-		snprintf(bc->pipeline, sizeof(bc->pipeline) - 1, "mg2ec");
+		ast_copy_string(bc->pipeline, "mg2ec", sizeof(bc->pipeline));
 	else if (ec > 1)
-		snprintf(bc->pipeline, sizeof(bc->pipeline) - 1, "mg2ec(deftaps=%d)", ec);
+		snprintf(bc->pipeline, sizeof(bc->pipeline), "mg2ec(deftaps=%d)", ec);
 
 	return 0;
 }
@@ -1734,15 +1702,15 @@
 static int update_ec_config(struct misdn_bchannel *bc)
 {
 	int ec;
-	int port=bc->port;
-		
-	misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
-	
-	if (ec == 1 ) {
-		bc->ec_enable=1;
-	} else if ( ec > 1 ) {
-		bc->ec_enable=1;
-		bc->ec_deftaps=ec;
+	int port = bc->port;
+
+	misdn_cfg_get(port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
+
+	if (ec == 1) {
+		bc->ec_enable = 1;
+	} else if (ec > 1) {
+		bc->ec_enable = 1;
+		bc->ec_deftaps = ec;
 	}
 
 	return 0;
@@ -1750,87 +1718,86 @@
 #endif
 
 
-static int read_config(struct chan_list *ch, int orig) 

[... 7024 lines stripped ...]



More information about the asterisk-commits mailing list