From 3dbc15f0ecbfd225b5b05bb1c66524b82e21380f Mon Sep 17 00:00:00 2001 From: kpfleming Date: Tue, 4 Dec 2007 17:41:52 +0000 Subject: fix a bunch of silly bugs and do some code cleanup git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@3290 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- ztscan.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'ztscan.c') diff --git a/ztscan.c b/ztscan.c index 48316b1..dbad8f4 100644 --- a/ztscan.c +++ b/ztscan.c @@ -43,7 +43,6 @@ int main(int argc, char *argv[]) { int ctl; - int span = 0; int x, y; int hasgeneral = 0; struct zt_params params; @@ -61,9 +60,15 @@ int main(int argc, char *argv[]) for (x = 1; x < totalspans; x++) { memset(&s, 0, sizeof(s)); s.spanno = x; - if (ioctl(ctl, ZT_SPANSTAT, s)) + if (ioctl(ctl, ZT_SPANSTAT, &s)) continue; + if (!hasgeneral) { + fprintf(stdout, "[general]\ntotalspans=%d\n", s.totalspans); + hasgeneral++; + totalspans = s.totalspans; + } + alarms[0] = '\0'; if (s.alarms) { if (s.alarms & ZT_ALARM_BLUE) @@ -91,12 +96,6 @@ int main(int argc, char *argv[]) strcpy(alarms, "UNCONFIGURED"); } - if (!hasgeneral) { - fprintf(stdout, "[general]\ntotalspans=%d\n", s.totalspans); - hasgeneral++; - totalspans = s.totalspans; - } - fprintf(stdout, "[%d]\n", x); fprintf(stdout, "active=yes\n"); fprintf(stdout, "alarms=%s\n", alarms); @@ -111,8 +110,11 @@ int main(int argc, char *argv[]) y = basechan; memset(¶ms, 0, sizeof(params)); params.channo = y; - if (ioctl(ctl, ZT_GET_PARAMS, ¶ms)) - goto skip; + if (ioctl(ctl, ZT_GET_PARAMS, ¶ms)) { + basechan += s.totalchans; + continue; + } + if (params.sigcap & __ZT_SIG_DACS) { /* this is a digital span */ fprintf(stdout, "type=digital-%s\n", s.spantype); @@ -169,9 +171,7 @@ int main(int argc, char *argv[]) } } - skip: basechan += s.totalchans; - span++; } if (!hasgeneral) -- cgit v1.2.3