[zaptel-commits] tzafrir: branch 1.4 r4009 - /branches/1.4/ztscan.c

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Tue Mar 18 17:53:02 CDT 2008


Author: tzafrir
Date: Tue Mar 18 17:53:01 2008
New Revision: 4009

URL: http://svn.digium.com/view/zaptel?view=rev&rev=4009
Log:
ztscan can now accept optional list of span numbers and print output for
those spans only. Default remains (when there are no parameters) to
print output for all spans.

Modified:
    branches/1.4/ztscan.c

Modified: branches/1.4/ztscan.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/ztscan.c?view=diff&rev=4009&r1=4008&r2=4009
==============================================================================
--- branches/1.4/ztscan.c (original)
+++ branches/1.4/ztscan.c Tue Mar 18 17:53:01 2008
@@ -164,16 +164,31 @@
 int main(int argc, char *argv[])
 {
 	int ctl;
-	int x;
+	int x, spanno;
 
 	if ((ctl = open("/dev/zap/ctl", O_RDWR)) < 0) {
 		fprintf(stderr, "Unable to open /dev/zap/ctl: %s\n", strerror(errno));
 		exit(1);
 	}
 	
-	for (x = 1; x < ZT_MAX_SPANS; x++) {
-		print_span(x, ctl);
+	/* If no parameters: loop over all spans */
+	if (argc == 1) {
+		for (spanno = 1; spanno < ZT_MAX_SPANS; spanno++)
+			print_span(spanno, ctl);
+		return 0;
 	}
 
-	exit(0);
+	/* Parameters provided: use them as span numbers */
+	for (x=1; argv[x]; x++) {
+		/* We can use atoi because span numbers must be > 0 */
+		int spanno = atoi(argv[x]);
+		if (spanno <= 0) {
+			fprintf(stderr, "%s: Error: Invalid span number %d (%s). Aborting\n",
+					argv[0], spanno, argv[x]);
+			exit(2);
+		}
+		print_span(spanno, ctl);
+	}
+
+	return 0;
 }




More information about the zaptel-commits mailing list