[Asterisk-cvs] asterisk/res res_monitor.c, 1.25, 1.26 res_features.c, 1.23, 1.24

markster at lists.digium.com markster at lists.digium.com
Tue Dec 28 18:54:54 CST 2004


Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv15037/res

Modified Files:
	res_monitor.c res_features.c 
Log Message:
Formatting fixes, safe_system instead of system, cleanups (bug #3171)


Index: res_monitor.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_monitor.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- res_monitor.c	18 Dec 2004 22:04:07 -0000	1.25
+++ res_monitor.c	28 Dec 2004 23:49:46 -0000	1.26
@@ -33,22 +33,24 @@
 "Used to start monitoring a channel. The channel's input and output\n"
 "voice packets are logged to files until the channel hangs up or\n"
 "monitoring is stopped by the StopMonitor application.\n"
-"      file_format -- optional, if not set, defaults to \"wav\"\n"
-"      fname_base -- if set, changes the filename used to the one specified.\n"
-"      options:\n"
-"              'm' - when the recording ends mix the two leg files into one and\n"
-"                    delete the two leg files.  If MONITOR_EXEC is set, the\n"
-"                    application refernced in it will be executed instead of\n"
-"                    soxmix and the raw leg files will NOT be deleted automatically.\n"
-"                    soxmix or MONITOR_EXEC is handed 3 arguments, the two leg files\n"
-"                    and a target mixed file name which is the same as the leg file names\n"
-"                    only without the in/out designator.\n"
-"                    If MONITOR_EXEC_ARGS is set, the contents will be passed on as\n"
-"                    additional arguements to MONITOR_EXEC\n"
-"                    Both MONITOR_EXEC and the Mix flag can be set from the\n"
-"                    administrator interface\n\n"
+"  file_format		optional, if not set, defaults to \"wav\"\n"
+"  fname_base		if set, changes the filename used to the one specified.\n"
+"  options:\n"
+"    m   - when the recording ends mix the two leg files into one and\n"
+"          delete the two leg files.  If the variable MONITOR_EXEC is set, the\n"
+"          application referenced in it will be executed instead of\n"
+"          soxmix and the raw leg files will NOT be deleted automatically.\n"
+"          soxmix or MONITOR_EXEC is handed 3 arguments, the two leg files\n"
+"          and a target mixed file name which is the same as the leg file names\n"
+"          only without the in/out designator.\n"
+"          If MONITOR_EXEC_ARGS is set, the contents will be passed on as\n"
+"          additional arguements to MONITOR_EXEC\n"
+"          Both MONITOR_EXEC and the Mix flag can be set from the\n"
+"          administrator interface\n"
 "\n"
-"              'b' - Don't begin recording unless a call is bridged to another channel\n"
+"    b   - Don't begin recording unless a call is bridged to another channel\n"
+"\nReturns -1 if monitor files can't be opened or if the channel is already\n"
+"monitored, otherwise 0.\n"
 ;
 
 static char *stopmonitor_synopsis = "Stop monitoring a channel";
@@ -58,10 +60,9 @@
 
 static char *changemonitor_synopsis = "Change monitoring filename of a channel";
 
-static char *changemonitor_descrip = "ChangeMonitor\n"
+static char *changemonitor_descrip = "ChangeMonitor(filename_base)\n"
 	"Changes monitoring filename of a channel. Has no effect if the channel is not monitored\n"
-	"The option string may contain the following:\n"
-	"	filename_base -- if set, changes the filename used to the one specified.\n";
+	"The argument is the new filename base to use for monitoring this channel.\n";
 
 /* Start monitoring a channel */
 int ast_monitor_start(	struct ast_channel *chan, const char *format_spec,
@@ -105,7 +106,7 @@
 				char *name = strdup(fname_base);
 				snprintf(tmp, sizeof(tmp), "mkdir -p \"%s\"",dirname(name));
 				free(name);
-				system(tmp);
+				ast_safe_system(tmp);
 			}
 			snprintf(monitor->read_filename, FILENAME_MAX, "%s/%s-in",
 						directory ? "" : AST_MONITOR_DIR, fname_base);
@@ -286,7 +287,7 @@
 			char *name = strdup(fname_base);
 			snprintf(tmp, sizeof(tmp), "mkdir -p %s",dirname(name));
 			free(name);
-			system(tmp);
+			ast_safe_system(tmp);
 		}
 
 		snprintf(chan->monitor->filename_base, FILENAME_MAX, "%s/%s", directory ? "" : AST_MONITOR_DIR, fname_base);
@@ -528,6 +529,10 @@
 {
 	ast_unregister_application("Monitor");
 	ast_unregister_application("StopMonitor");
+	ast_unregister_application("ChangeMonitor");
+	ast_manager_unregister("Monitor");
+	ast_manager_unregister("StopMonitor");
+	ast_manager_unregister("ChangeMonitor");
 	return 0;
 }
 

Index: res_features.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_features.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- res_features.c	9 Dec 2004 22:39:14 -0000	1.23
+++ res_features.c	28 Dec 2004 23:49:46 -0000	1.24
@@ -77,19 +77,18 @@
 static char *synopsis = "Answer a parked call";
 
 static char *descrip = "ParkedCall(exten):"
-"Used to connect to a parked call.  This Application is always\n"
+"Used to connect to a parked call.  This application is always\n"
 "registered internally and does not need to be explicitly added\n"
 "into the dialplan, although you should include the 'parkedcalls'\n"
 "context.\n";
 
-
 static char *parkcall = "Park";
 
 static char *synopsis2 = "Park yourself";
 
 static char *descrip2 = "Park(exten):"
 "Used to park yourself (typically in combination with a supervised\n"
-"transfer to know the parking space.  This Application is always\n"
+"transfer to know the parking space). This application is always\n"
 "registered internally and does not need to be explicitly added\n"
 "into the dialplan, although you should include the 'parkedcalls'\n"
 "context.\n";
@@ -511,12 +510,12 @@
 					ast_moh_stop(transferee);
 					res=ast_autoservice_stop(transferee);
 					if (!transferee->pbx) {
-						/* Doh!  Use our handy async_goto funcitons */
+						/* Doh!  Use our handy async_goto functions */
 						if (option_verbose > 2) 
 							ast_verbose(VERBOSE_PREFIX_3 "Transferring %s to '%s' (context %s) priority 1\n"
 								,transferee->name, newext, transferer_real_context);
 						if (ast_async_goto(transferee, transferer_real_context, newext, 1))
-							ast_log(LOG_WARNING, "Async goto fialed :(\n");
+							ast_log(LOG_WARNING, "Async goto failed :-(\n");
 						res = -1;
 					} else {
 						/* Set the channel's new extension, since it exists, using transferer context */
@@ -545,12 +544,12 @@
 						ast_verbose(VERBOSE_PREFIX_2 "Hungup during autoservice stop on '%s'\n", transferee->name);
 				}
 			} else {
-            if (f && (f->frametype == AST_FRAME_DTMF)) {
-                  if (who == peer)
-                        ast_write(chan, f);
-                  else
-                        ast_write(peer, f);
-            }            
+            			if (f && (f->frametype == AST_FRAME_DTMF)) {
+                  			if (who == peer)
+                        			ast_write(chan, f);
+                  			else
+                        			ast_write(peer, f);
+            			}            
 #if 1
 				ast_log(LOG_DEBUG, "Read from %s (%d,%d)\n", who->name, f->frametype, f->subclass);
 #endif
@@ -602,14 +601,14 @@
 				/* Stop music on hold */
 				ast_moh_stop(pu->chan);
 				/* Get chan, exten from derived kludge */
-				if (pu->peername[0])
-				{
-					peername = strdupa(pu->peername);
-					cp = strrchr(peername,'-');
-					if (cp) *cp = 0;
+				if (pu->peername[0]) {
+					peername = ast_strdupa(pu->peername);
+					cp = strrchr(peername, '-');
+					if (cp) 
+						*cp = 0;
 					con = ast_context_find(parking_con_dial);
 					if (!con) {
-						con = ast_context_create(NULL,parking_con_dial, registrar);
+						con = ast_context_create(NULL, parking_con_dial, registrar);
 						if (!con) {
 							ast_log(LOG_ERROR, "Parking dial context '%s' does not exist and unable to create\n", parking_con_dial);
 						}
@@ -617,8 +616,8 @@
 					if (con) {
 						ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(peername), free, registrar);
 					}
-					strncpy(pu->chan->exten, peername, sizeof(pu->chan->exten)-1);
-					strncpy(pu->chan->context, parking_con_dial, sizeof(pu->chan->context)-1);
+					strncpy(pu->chan->exten, peername, sizeof(pu->chan->exten) - 1);
+					strncpy(pu->chan->context, parking_con_dial, sizeof(pu->chan->context) - 1);
 					pu->chan->priority = 1;
 
 				} else {
@@ -651,7 +650,7 @@
 					ast_log(LOG_WARNING, "Whoa, no parking context?\n");
 				free(pt);
 			} else {
-				for (x=0;x<AST_MAX_FDS;x++) {
+				for (x=0; x<AST_MAX_FDS; x++) {
 					if ((pu->chan->fds[x] > -1) && (FD_ISSET(pu->chan->fds[x], &rfds) || FD_ISSET(pu->chan->fds[x], &efds))) {
 						if (FD_ISSET(pu->chan->fds[x], &efds))
 							ast_set_flag(pu->chan, AST_FLAG_EXCEPTION);
@@ -689,7 +688,7 @@
 					}
 				}
 				if (x >= AST_MAX_FDS) {
-std:					for (x=0;x<AST_MAX_FDS;x++) {
+std:					for (x=0; x<AST_MAX_FDS; x++) {
 						/* Keep this one for next one */
 						if (pu->chan->fds[x] > -1) {
 							FD_SET(pu->chan->fds[x], &nrfds);
@@ -830,13 +829,13 @@
 		return res;
 	} else {
 		/* XXX Play a message XXX */
-	  dres = ast_streamfile(chan, "pbx-invalidpark", chan->language);
-	  if (!dres)
-	    dres = ast_waitstream(chan, "");
-	  else {
-	    ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", "pbx-invalidpark", chan->name);
-	    dres = 0;
-	  }
+		dres = ast_streamfile(chan, "pbx-invalidpark", chan->language);
+		if (!dres)
+	    		dres = ast_waitstream(chan, "");
+		 else {
+			ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", "pbx-invalidpark", chan->name);
+			dres = 0;
+		}
 		if (option_verbose > 2) 
 			ast_verbose(VERBOSE_PREFIX_3 "Channel %s tried to talk to non-existant parked call %d\n", chan->name, park);
 		res = -1;
@@ -854,7 +853,7 @@
 
 	ast_mutex_lock(&parking_lock);
 
-	cur=parkinglot;
+	cur = parkinglot;
 	while(cur) {
 		ast_cli(fd, "%4d %25s (%-15s %-12s %-4d) %6lds\n"
 			,cur->parkingnum, cur->chan->name, cur->context, cur->exten
@@ -1010,7 +1009,8 @@
 		cur = ast_channel_walk_locked(cur);
 	}
 	if (cur) {
-		ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
 		res = ast_answer(chan);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
@@ -1022,7 +1022,8 @@
 			ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name);		/* Done */
 		ast_mutex_unlock(&cur->lock);
 	} else	{
-		ast_log(LOG_DEBUG, "No call pickup possible...\n");
+		if (option_debug)
+			ast_log(LOG_DEBUG, "No call pickup possible...\n");
 	}
 	return res;
 }




More information about the svn-commits mailing list