[Asterisk-cvs] asterisk/res res_adsi.c,1.7,1.8 res_monitor.c,1.18,1.19 res_musiconhold.c,1.31,1.32

citats at lists.digium.com citats at lists.digium.com
Tue Jun 29 00:56:27 CDT 2004


Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/home/citats/cvs/asterisk/res

Modified Files:
	res_adsi.c res_monitor.c res_musiconhold.c 
Log Message:
More formatting cleanups.

Index: res_adsi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_adsi.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- res_adsi.c	6 Apr 2004 22:17:32 -0000	1.7
+++ res_adsi.c	29 Jun 2004 04:42:19 -0000	1.8
@@ -306,11 +306,11 @@
 	int bytes;
 	unsigned char buf[256];
 	char ack[2];
-        bytes = 0;
-        /* Setup the resident soft key stuff, a piece at a time */
-        /* Upload what scripts we can for voicemail ahead of time */
-        bytes += adsi_download_connect(buf + bytes, service, fdn, sec, version);
-        if (adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD))
+	bytes = 0;
+	/* Setup the resident soft key stuff, a piece at a time */
+	/* Upload what scripts we can for voicemail ahead of time */
+	bytes += adsi_download_connect(buf + bytes, service, fdn, sec, version);
+	if (adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD))
 		return -1;
 	if (ast_readstring(chan, ack, 1, 10000, 10000, ""))
 		return -1;
@@ -328,7 +328,7 @@
         /* Setup the resident soft key stuff, a piece at a time */
         /* Upload what scripts we can for voicemail ahead of time */
         bytes += adsi_download_disconnect(buf + bytes);
-        if (adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD))
+	if (adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD))
 		return -1;
 	return 0;
 }
@@ -798,7 +798,7 @@
 {
 	int bytes=0;
 
- 	if (page) {
+	if (page) {
 		if (line > 4) return -1;
 	} else {
 		if (line > 33) return -1;
@@ -857,7 +857,7 @@
 
 	/* Sanity check line number */
 
- 	if (page) {
+	if (page) {
 		if (line > 4) return -1;
 	} else {
 		if (line > 33) return -1;

Index: res_monitor.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_monitor.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- res_monitor.c	22 Jun 2004 14:47:21 -0000	1.18
+++ res_monitor.c	29 Jun 2004 04:42:19 -0000	1.19
@@ -172,50 +172,45 @@
 /* Stop monitoring a channel */
 int ast_monitor_stop( struct ast_channel *chan, int need_lock )
 {
-  char *execute;
-  int soxmix =0;
-	if(need_lock) {
-		if(ast_mutex_lock(&chan->lock)) {
+	char *execute;
+	int soxmix =0;
+
+	if (need_lock) {
+		if (ast_mutex_lock(&chan->lock)) {
 			ast_log(LOG_WARNING, "Unable to lock channel\n");
 			return -1;
 		}
 	}
 
-	if(chan->monitor) {
+	if (chan->monitor) {
 		char filename[ FILENAME_MAX ];
 
-		if(chan->monitor->read_stream) {
+		if (chan->monitor->read_stream) {
 			ast_closestream( chan->monitor->read_stream );
 		}
-		if(chan->monitor->write_stream) {
+		if (chan->monitor->write_stream) {
 			ast_closestream( chan->monitor->write_stream );
 		}
 
-		if(chan->monitor->filename_changed&&strlen(chan->monitor->filename_base)) {
-			if( ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0 ) {
-				snprintf(	filename, FILENAME_MAX, "%s-in",
-							chan->monitor->filename_base );
-				if(ast_fileexists( filename, NULL, NULL ) > 0) {
+		if (chan->monitor->filename_changed&&strlen(chan->monitor->filename_base)) {
+			if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0 ) {
+				snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base);
+				if (ast_fileexists( filename, NULL, NULL ) > 0) {
 					ast_filedelete( filename, NULL );
 				}
-				ast_filerename(	chan->monitor->read_filename, filename,
-								chan->monitor->format );
+				ast_filerename(chan->monitor->read_filename, filename, chan->monitor->format );
 			} else {
-				ast_log(	LOG_WARNING, "File %s not found\n",
-							chan->monitor->read_filename );
+				ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->read_filename );
 			}
 
-			if(ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
-				snprintf(	filename, FILENAME_MAX, "%s-out",
-							chan->monitor->filename_base );
-				if( ast_fileexists( filename, NULL, NULL ) > 0 ) {
-					ast_filedelete( filename, NULL );
+			if (ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
+				snprintf(filename, FILENAME_MAX, "%s-out", chan->monitor->filename_base );
+				if (ast_fileexists(filename, NULL, NULL) > 0 ) {
+					ast_filedelete(filename, NULL);
 				}
-				ast_filerename(	chan->monitor->write_filename, filename,
-								chan->monitor->format );
+				ast_filerename(chan->monitor->write_filename, filename, chan->monitor->format );
 			} else {
-				ast_log(	LOG_WARNING, "File %s not found\n",
-							chan->monitor->write_filename );
+				ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->write_filename );
 			}
 		}
 
@@ -227,53 +222,49 @@
 			int directory = strchr(name, '/') ? 1 : 0;
 			char *dir = directory ? "" : AST_MONITOR_DIR;
 
-		        /* Set the execute application */
-		        execute=pbx_builtin_getvar_helper(chan,"MONITOR_EXEC");
-		        if (!execute || ast_strlen_zero(execute)) { 
-			  execute = "nice -n 19 soxmix"; 
-			  soxmix = 1;
+			/* Set the execute application */
+			execute=pbx_builtin_getvar_helper(chan,"MONITOR_EXEC");
+			if (!execute || ast_strlen_zero(execute)) { 
+				execute = "nice -n 19 soxmix"; 
+				soxmix = 1;
 			}			
 			snprintf(tmp, sizeof(tmp), "%s %s/%s-in.%s %s/%s-out.%s %s/%s.%s &", execute, dir, name, format, dir, name, format, dir, name, format);
 			if (soxmix) {
-			  snprintf(tmp2,sizeof(tmp2), "( %s& rm -f %s/%s-* ) &",tmp, dir ,name); /* remove legs when done mixing */
-			  strncpy(tmp, tmp2, sizeof(tmp) - 1);
+				snprintf(tmp2,sizeof(tmp2), "( %s& rm -f %s/%s-* ) &",tmp, dir ,name); /* remove legs when done mixing */
+				strncpy(tmp, tmp2, sizeof(tmp) - 1);
 			}
 			ast_verbose("monitor executing %s\n",tmp);
 			if (ast_safe_system(tmp) == -1)
-			  ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
+				ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
 		}
 		
-		free( chan->monitor->format );
-		free( chan->monitor );
+		free(chan->monitor->format);
+		free(chan->monitor);
 		chan->monitor = NULL;
 	}
 
-	if( need_lock ) {
+	if (need_lock)
 		ast_mutex_unlock(&chan->lock);
-	}
 	return 0;
 }
 
 /* Change monitoring filename of a channel */
-int ast_monitor_change_fname(	struct ast_channel *chan,
-								const char *fname_base, int need_lock )
+int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, int need_lock)
 {
 	char tmp[256];
-	if( (!fname_base) || (!strlen(fname_base)) ) {
-		ast_log(	LOG_WARNING,
-					"Cannot change monitor filename of channel %s to null",
-					chan->name );
+	if ((!fname_base) || (!strlen(fname_base))) {
+		ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to null", chan->name );
 		return -1;
 	}
 	
-	if( need_lock ) {
+	if (need_lock) {
 		if (ast_mutex_lock(&chan->lock)) {
 			ast_log(LOG_WARNING, "Unable to lock channel\n");
 			return -1;
 		}
 	}
 
-	if( chan->monitor ) {
+	if (chan->monitor) {
 		int directory = strchr(fname_base, '/') ? 1 : 0;
 		/* try creating the directory just in case it doesn't exist */
 		if (directory) {
@@ -283,18 +274,14 @@
 			system(tmp);
 		}
 
-		snprintf(	chan->monitor->filename_base, FILENAME_MAX, "%s/%s",
-					directory ? "" : AST_MONITOR_DIR, fname_base );
+		snprintf(chan->monitor->filename_base, FILENAME_MAX, "%s/%s", directory ? "" : AST_MONITOR_DIR, fname_base );
 	} else {
-		ast_log(	LOG_WARNING,
-					"Cannot change monitor filename of channel %s to %s, monitoring not started",
-					chan->name, fname_base );
-				
+		ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to %s, monitoring not started", chan->name, fname_base );
 	}
 
-	if( need_lock ) {
+	if (need_lock)
 		ast_mutex_unlock(&chan->lock);
-	}
+
 	return 0;
 }
 
@@ -308,11 +295,11 @@
 	int res;
 	
 	/* Parse arguments. */
-	if( data && strlen((char*)data) ) {
-		arg = strdup( (char*)data );
+	if (data && strlen((char*)data)) {
+		arg = strdup((char*)data);
 		format = arg;
-		fname_base = strchr( arg, '|' );
-		if( fname_base ) {
+		fname_base = strchr(arg, '|');
+		if (fname_base) {
 			*fname_base = 0;
 			fname_base++;
 			if ((options = strchr(fname_base, '|'))) {
@@ -325,27 +312,25 @@
 		
 	}
 
-	res = ast_monitor_start( chan, format, fname_base, 1 );
-	if( res < 0 ) {
+	res = ast_monitor_start(chan, format, fname_base, 1);
+	if (res < 0)
 		res = ast_monitor_change_fname( chan, fname_base, 1 );
-	}
 	ast_monitor_setjoinfiles(chan, joinfiles);
 
-	if( arg ) {
+	if (arg)
 		free( arg );
-	}
 
 	return res;
 }
 
 static int stop_monitor_exec(struct ast_channel *chan, void *data)
 {
-	return ast_monitor_stop( chan, 1 );
+	return ast_monitor_stop(chan, 1);
 }
 
 static int change_monitor_exec(struct ast_channel *chan, void *data)
 {
-	return ast_monitor_change_fname( chan, (const char*)data, 1 );
+	return ast_monitor_change_fname(chan, (const char*)data, 1);
 }
 
 static int start_monitor_action(struct mansession *s, struct message *m)
@@ -357,12 +342,12 @@
 	char *mix = astman_get_header(m, "Mix");
 	char *d;
 	
-	if((!name)||(!strlen(name))) {
+	if ((!name)||(!strlen(name))) {
 		astman_send_error(s, m, "No channel specified");
 		return 0;
 	}
 	c = ast_channel_walk_locked(NULL);
-	while(c) {
+	while (c) {
 		if (!strcasecmp(c->name, name)) {
 			break;
 		}
@@ -373,8 +358,8 @@
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
-     
-	if( (!fname) || (!strlen(fname)) ) {
+
+	if ((!fname) || (!strlen(fname))) {
 		// No filename base specified, default to channel name as per CLI
 		fname = malloc (FILENAME_MAX);
 		memset( fname, 0, FILENAME_MAX);
@@ -383,16 +368,16 @@
 		if( (d=strchr( fname, '/')) ) *d='-';
 	}
 	
-	if( ast_monitor_start( c, format, fname, 1 ) ) {
-		if( ast_monitor_change_fname( c, fname, 1 ) ) {
+	if (ast_monitor_start( c, format, fname, 1)) {
+		if (ast_monitor_change_fname(c, fname, 1)) {
 			astman_send_error(s, m, "Could not start monitoring channel");
 			ast_mutex_unlock(&c->lock);
 			return 0;
 		}
 	}
 
-	if(ast_true(mix)) {
-	  ast_monitor_setjoinfiles( c, 1);
+	if (ast_true(mix)) {
+		ast_monitor_setjoinfiles( c, 1);
 	}
 
 	ast_mutex_unlock(&c->lock);
@@ -405,7 +390,7 @@
 	struct ast_channel *c = NULL;
 	char *name = astman_get_header(m, "Channel");
 	int res;
-	if((!name)||(!strlen(name))) {
+	if ((!name)||(!strlen(name))) {
 		astman_send_error(s, m, "No channel specified");
 		return 0;
 	}
@@ -421,9 +406,9 @@
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
-	res = ast_monitor_stop( c, 1 );
+	res = ast_monitor_stop(c, 1);
 	ast_mutex_unlock(&c->lock);
-	if( res ) {
+	if (res) {
 		astman_send_error(s, m, "Could not stop monitoring channel");
 		return 0;
 	}
@@ -436,7 +421,7 @@
 	struct ast_channel *c = NULL;
 	char *name = astman_get_header(m, "Channel");
 	char *fname = astman_get_header(m, "File");
-	if((!name) || (!strlen(name))) {
+	if ((!name) || (!strlen(name))) {
 		astman_send_error(s, m, "No channel specified");
 		return 0;
 	}
@@ -456,7 +441,7 @@
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
-	if( ast_monitor_change_fname( c, fname, 1 ) ) {
+	if (ast_monitor_change_fname(c, fname, 1)) {
 		astman_send_error(s, m, "Could not change monitored filename of channel");
 		ast_mutex_unlock(&c->lock);
 		return 0;

Index: res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- res_musiconhold.c	22 Jun 2004 18:49:00 -0000	1.31
+++ res_musiconhold.c	29 Jun 2004 04:42:19 -0000	1.32
@@ -233,7 +233,7 @@
 	error_usec = 0;
 	for(;/* ever */;) {
 		/* Spawn mp3 player if it's not there */
-		if (class->srcfd < 0)  {
+		if (class->srcfd < 0) {
 			if ((class->srcfd = spawn_mp3(class)) < 0) {
 				ast_log(LOG_WARNING, "unable to spawn mp3player\n");
 				/* Try again later */
@@ -300,7 +300,7 @@
 			/* Write data */
 			if ((res = write(moh->pipe[1], sbuf, res2)) != res2) 
 				if (option_debug)
-				    ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2);
+					ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2);
 			moh = moh->next;
 		}
 		ast_mutex_unlock(&moh_lock);




More information about the svn-commits mailing list