From 6c7e3be3aa065aeb817c679f08439e3d3e1fc5cd Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Sun, 24 Aug 2008 10:52:19 +0000 Subject: dahdi_cfg.c: Reduce nesting in main() . git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@4821 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- dahdi_cfg.c | 271 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 136 insertions(+), 135 deletions(-) diff --git a/dahdi_cfg.c b/dahdi_cfg.c index 1bc1499..051888d 100644 --- a/dahdi_cfg.c +++ b/dahdi_cfg.c @@ -1490,147 +1490,148 @@ int main(int argc, char *argv[]) finish: if (!errcnt) { - if (verbose) { - printconfig(fd); + fprintf(stderr, "\n%d error(s) detected\n\n", errcnt); + exit(1); + } + if (verbose) { + printconfig(fd); + } + if (!fo_real) + exit(0); + + + if (debug & DEBUG_APPLY) { + printf("About to open Master device\n"); + fflush(stdout); + } + for (x=0;x> 16; + + if (cc[x].sigtype != current_state.sigtype) { + needupdate++; + if (verbose > 1) + printf("Changing signalling on channel %d from %s to %s\n", + cc[x].chan, sigtype_to_str(current_state.sigtype), + sigtype_to_str(cc[x].sigtype)); } - for (x=0;x 1) + printf("Changing law on channel %d from %s to %s\n", + cc[x].chan, laws[current_state.curlaw], + laws[cc[x].deflaw]); } - if (stopmode) { - for (x=0;x> 16; - - if (cc[x].sigtype != current_state.sigtype) { - needupdate++; - if (verbose > 1) - printf("Changing signalling on channel %d from %s to %s\n", - cc[x].chan, sigtype_to_str(current_state.sigtype), - sigtype_to_str(cc[x].sigtype)); - } - - if ((cc[x].deflaw != DAHDI_LAW_DEFAULT) && (cc[x].deflaw != current_state.curlaw)) { - needupdate++; - if (verbose > 1) - printf("Changing law on channel %d from %s to %s\n", - cc[x].chan, laws[current_state.curlaw], - laws[cc[x].deflaw]); - } - - if (cc[x].master != master) { - needupdate++; - if (verbose > 1) - printf("Changing master of channel %d from %d to %d\n", - cc[x].chan, master, - cc[x].master); - } - - if (cc[x].idlebits != current_state.idlebits) { - needupdate++; - if (verbose > 1) - printf("Changing idle bits of channel %d from %d to %d\n", - cc[x].chan, current_state.idlebits, - cc[x].idlebits); - } - } - - if (needupdate && ioctl(fd, DAHDI_CHANCONFIG, &cc[x])) { - fprintf(stderr, "DAHDI_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno); - if (errno == EINVAL) { - fprintf(stderr, "Did you forget that FXS interfaces are configured with FXO signalling\n" - "and that FXO interfaces use FXS signalling?\n"); - } - close(fd); - exit(1); - } + + if (cc[x].master != master) { + needupdate++; + if (verbose > 1) + printf("Changing master of channel %d from %d to %d\n", + cc[x].chan, master, + cc[x].master); + } + + if (cc[x].idlebits != current_state.idlebits) { + needupdate++; + if (verbose > 1) + printf("Changing idle bits of channel %d from %d to %d\n", + cc[x].chan, current_state.idlebits, + cc[x].idlebits); + } + } + + if (needupdate && ioctl(fd, DAHDI_CHANCONFIG, &cc[x])) { + fprintf(stderr, "DAHDI_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno); + if (errno == EINVAL) { + fprintf(stderr, "Did you forget that FXS interfaces are configured with FXO signalling\n" + "and that FXO interfaces use FXS signalling?\n"); + } + close(fd); + exit(1); + } - if (ae[x].chan) { - printf("Setting echocan for channel %d to %s\n", ae[x].chan, ae[x].echocan); - if (ioctl(fd, DAHDI_ATTACH_ECHOCAN, &ae[x])) { - fprintf(stderr, "DAHDI_ATTACH_ECHOCAN failed on channel %d: %s (%d)\n", x, strerror(errno), errno); - close(fd); - exit(1); - } - } - } - for (x=0;x -1) { - if (ioctl(fd, DAHDI_DEFAULTZONE, &deftonezone)) { - fprintf(stderr, "DAHDI_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno); - close(fd); - exit(1); - } - } - for (x=0;x -1) { + if (ioctl(fd, DAHDI_DEFAULTZONE, &deftonezone)) { + fprintf(stderr, "DAHDI_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno); + close(fd); + exit(1); + } + } + for (x=0;x