summaryrefslogtreecommitdiff
path: root/dahdi_monitor.c
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-06-26 17:40:28 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-06-26 17:40:28 +0000
commitd371f84fa494d836193410835b5fdc645d50818d (patch)
tree224120a9531808dc4aa7b09c337606e5c0f43cfe /dahdi_monitor.c
parentbebfabc7e559e4af9eacb21e362bfa0212527383 (diff)
Merge the getopt changes of ztmonitor from zaptel 1.4 .
git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@4466 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'dahdi_monitor.c')
-rw-r--r--dahdi_monitor.c106
1 files changed, 53 insertions, 53 deletions
diff --git a/dahdi_monitor.c b/dahdi_monitor.c
index 74e9b7e..be516b5 100644
--- a/dahdi_monitor.c
+++ b/dahdi_monitor.c
@@ -279,8 +279,10 @@ int main(int argc, char *argv[])
int stereo_output = 0;
int limit = 0;
int readcount = 0;
- int x, i, chan;
+ int x = MON_BRX, chan;
struct dahdi_confinfo zc;
+ char opt, *output_file;
+ extern char *optarg;
if ((argc < 2) || (atoi(argv[1]) < 1)) {
fprintf(stderr, "Usage: dahdi_monitor <channel num> [-v[v]] [-m] [-o] [-p] [-l limit] [-f FILE | -s FILE | -r FILE1 -t FILE2] [-F FILE | -S FILE | -R FILE1 -T FILE2]\n");
@@ -315,81 +317,79 @@ int main(int argc, char *argv[])
chan = atoi(argv[1]);
- for (i = 2; i < argc; ++i) {
- if (!strcmp(argv[i], "-v")) {
+ while ((opt = getopt(argc, argv, ":vl:f:r:t:F:R:T:mop"))) {
+ switch (opt) {
+ case 'v':
if (visual)
verbose = 1;
- visual = 1;
- multichannel = 1;
- } else if (!strcmp(argv[i], "-vv")) {
visual = 1;
- verbose = 1;
multichannel = 1;
- } else if ((!strcmp(argv[i], "-f") || !strcmp(argv[i], "-r") || !strcmp(argv[i], "-t")
- || !strcmp(argv[i], "-F") || !strcmp(argv[i], "-R") || !strcmp(argv[i], "-T")
- || !strcmp(argv[i], "-s") || !strcmp(argv[i], "-S"))
- && (i+1) < argc) {
- char *output_file;
-
- /* Set which file descriptor to use */
- if (!strcmp(argv[i], "-f")) {
- savefile = 1;
+ break;
+
+ case 'm':
+ multichannel = 1;
+ break;
+
+ case 'o':
+ ossoutput = 1;
+ break;
+
+ case 'p':
+ preecho = 1;
+ break;
+ case 'l':
+ if (sscanf(optarg, "%d", &limit) != 1 || limit < 0)
+ limit = 0;
+ printf("limit: %d\n", limit);
+ break;
+ default:
+ if (!strchr("frstFRST", opt))
+ break;
+
+ savefile = 1;
+
+ if (opt == 'f') {
x = MON_BRX;
- } else if (!strcmp(argv[i], "-r")) {
- savefile = 1;
+ } else if (opt == 'r') {
multichannel = 1;
x = MON_BRX;
- } else if (!strcmp(argv[i], "-t")) {
- savefile = 1;
- multichannel = 1;
- x = MON_TX;
- } else if (!strcmp(argv[i], "-s")) {
- savefile = 1;
- stereo_output = 1;
+ } else if (opt == 's') {
multichannel = 1;
x = MON_STEREO;
- } else if (!strcmp(argv[i], "-F")) {
- savefile = 1;
- preecho = 1;
- x = MON_PRE_BRX;
- } else if (!strcmp(argv[i], "-R")) {
- savefile = 1;
+ } else if (opt == 't') {
multichannel = 1;
+ x = MON_TX;
+ } else if (opt == 'F') {
preecho = 1;
x = MON_PRE_BRX;
- } else if (!strcmp(argv[i], "-T")) {
- savefile = 1;
+ } else if (opt == 'R') {
multichannel = 1;
preecho = 1;
- x = MON_PRE_TX;
- } else if (!strcmp(argv[i], "-S")) {
- savefile = 1;
+ x = MON_PRE_BRX;
+ } else if (opt == 'S') {
preecho = 1;
stereo_output = 1;
multichannel = 1;
x = MON_PRE_STEREO;
- } else
- x = MON_BRX;
+ } else if (opt == 'T') {
+ multichannel = 1;
+ preecho = 1;
+ x = MON_PRE_TX;
+ }
+
+ output_file = optarg;
- ++i; /* we care about the file name */
- output_file = argv[i];
fprintf(stderr, "Output to %s\n", output_file);
- if ((ofh[x] = fopen(output_file, "w"))<0) {
+
+ if ((ofh[x] = fopen(output_file, "w")) < 0) {
fprintf(stderr, "Could not open %s for writing: %s\n",
- output_file, strerror(errno));
- exit(1);
+ output_file, strerror(errno));
+ exit(EXIT_FAILURE);
}
+
fprintf(stderr, "Run e.g., 'sox -r 8000 -s -w -c 1 %s %s.wav' to convert.\n",
output_file, output_file);
- } else if (!strcmp(argv[i], "-m")) {
- multichannel = 1;
- } else if (!strcmp(argv[i], "-o")) {
- ossoutput = 1;
- } else if (!strcmp(argv[i], "-p")) {
- preecho = 1;
- } else if (!strcmp(argv[i], "-l") && isdigit(argv[i+1][0])) {
- limit = atoi(argv[i+1]);
- i++;
+ break;
}
}
@@ -482,7 +482,7 @@ int main(int argc, char *argv[])
if (visual) {
printf("\nVisual Audio Levels.\n");
printf("--------------------\n");
- printf(" Use /etc/dahdi/system.conf file to adjust the gains if needed.\n\n");
+ printf(" Use chan_dahdi.conf file to adjust the gains if needed.\n\n");
printf("( # = Audio Level * = Max Audio Hit )\n");
draw_barheader();
}