summaryrefslogtreecommitdiff
path: root/ztscan.c
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-03-18 22:53:01 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-03-18 22:53:01 +0000
commita23b66e49f5aca25aaf248c3ebe5fbc699955a50 (patch)
tree1e97aab365fedd9ea72bb80fc73a049a64b3aba7 /ztscan.c
parent3b4524f26a44db3c21bcc8ab3017fadb7f78cc27 (diff)
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. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4009 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztscan.c')
-rw-r--r--ztscan.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/ztscan.c b/ztscan.c
index 917767a..d821092 100644
--- a/ztscan.c
+++ b/ztscan.c
@@ -164,16 +164,31 @@ void print_span(int spanno, int ctl)
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;
}