Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/audio/ctl Delete the old code which made audioctl us...



details:   https://anonhg.NetBSD.org/src/rev/72a871e4d592
branches:  trunk
changeset: 521290:72a871e4d592
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Jan 27 18:21:52 2002 +0000

description:
Delete the old code which made audioctl use stderr for output
if the stdout was same as the audio device. It's no longer relevant,
and the check was broken anyway (code used st_dev rather than st_rdev
when comparing the character devices).
A by-product of this is that 'audioctl -a > /dev/null' now works.

Okay'ed by Lennart.

diffstat:

 usr.bin/audio/ctl/ctl.c |  56 ++++++++++++++++++------------------------------
 1 files changed, 21 insertions(+), 35 deletions(-)

diffs (154 lines):

diff -r b607a9e10966 -r 72a871e4d592 usr.bin/audio/ctl/ctl.c
--- a/usr.bin/audio/ctl/ctl.c   Sun Jan 27 18:10:34 2002 +0000
+++ b/usr.bin/audio/ctl/ctl.c   Sun Jan 27 18:21:52 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ctl.c,v 1.29 2002/01/27 10:09:56 jdolecek Exp $        */
+/*     $NetBSD: ctl.c,v 1.30 2002/01/27 18:21:52 jdolecek Exp $        */
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -60,8 +60,6 @@
 void usage (void);
 int main (int argc, char **argv);
 
-FILE *out = stdout;
-
 audio_device_t adev;
 
 audio_info_t info;
@@ -174,63 +172,63 @@
        int i;
 
        if (sep)
-               fprintf(out, "%s%s", p->name, sep);
+               printf("%s%s", p->name, sep);
        switch(p->format) {
        case STRING:
-               fprintf(out, "%s", (char*)p->valp);
+               printf("%s", (char*)p->valp);
                break;
        case INT:
-               fprintf(out, "%d", *(int*)p->valp);
+               printf("%d", *(int*)p->valp);
                break;
        case UINT:
-               fprintf(out, "%u", *(u_int*)p->valp);
+               printf("%u", *(u_int*)p->valp);
                break;
        case XINT:
-               fprintf(out, "0x%x", *(u_int*)p->valp);
+               printf("0x%x", *(u_int*)p->valp);
                break;
        case UCHAR:
-               fprintf(out, "%u", *(u_char*)p->valp);
+               printf("%u", *(u_char*)p->valp);
                break;
        case ULONG:
-               fprintf(out, "%lu", *(u_long*)p->valp);
+               printf("%lu", *(u_long*)p->valp);
                break;
        case P_R:
                v = *(u_int*)p->valp;
                cm = "";
                if (v & AUMODE_PLAY) {
                        if (v & AUMODE_PLAY_ALL)
-                               fprintf(out, "play");
+                               printf("play");
                        else
-                               fprintf(out, "playsync");
+                               printf("playsync");
                        cm = ",";
                }
                if (v & AUMODE_RECORD)
-                       fprintf(out, "%srecord", cm);
+                       printf("%srecord", cm);
                break;
        case ENC:
                v = *(u_int*)p->valp;
                encstr = audio_enc_from_val(v);
                if (encstr)
-                       fprintf(out, "%s", encstr);
+                       printf("%s", encstr);
                else
-                       fprintf(out, "%u", v);
+                       printf("%u", v);
                break;
        case PROPS:
                v = *(u_int*)p->valp;
                for (cm = "", i = 0; props[i].name; i++) {
                        if (v & props[i].prop) {
-                               fprintf(out, "%s%s", cm, props[i].name);
+                               printf("%s%s", cm, props[i].name);
                                cm = ",";
                        }
                }
                break;
        case FORMAT:
                prfield(p + 1, 0);
-               fprintf(out, ",");
+               printf(",");
                prfield(p + 3, 0);
-               fprintf(out, ",");
+               printf(",");
                prfield(p + 4, 0);
-               fprintf(out, ",");
+               printf(",");
                prfield(p + 5, 0);
                break;
        default:
@@ -343,7 +341,6 @@
 {
        int fd, i, ch;
        int aflag = 0, wflag = 0;
-       struct stat dstat, ostat;
        const char *file;
        const char *sep = "=";
 
@@ -389,17 +386,6 @@
        if (fd < 0)
                err(1, "%s", file);
 
-       /* Check if stdout is the same device as the audio device. */
-       if (fstat(fd, &dstat) < 0)
-               err(1, "fstat audioctl");
-       if (fstat(STDOUT_FILENO, &ostat) < 0)
-               err(1, "fstat stdout");
-       if (S_ISCHR(dstat.st_mode) && S_ISCHR(ostat.st_mode) &&
-           major(dstat.st_dev) == major(ostat.st_dev) &&
-           minor(dstat.st_dev) == minor(ostat.st_dev))
-               /* We can't write to stdout so use stderr */
-               out = stderr;
-
        if (!wflag)
                getinfo(fd);
 
@@ -407,7 +393,7 @@
                for (i = 0; fields[i].name; i++) {
                        if (!(fields[i].flags & ALIAS)) {
                                prfield(&fields[i], sep);
-                               fprintf(out, "\n");
+                               printf("\n");
                        }
                }
        } else if (argc > 0 && !aflag) {
@@ -417,9 +403,9 @@
                                getinfo(fd);
                                for (i = 0; fields[i].name; i++) {
                                        if (fields[i].flags & SET) {
-                                               fprintf(out, "%s: -> ", fields[i].name);
+                                               printf("%s: -> ", fields[i].name);
                                                prfield(&fields[i], 0);
-                                               fprintf(out, "\n");
+                                               printf("\n");
                                        }
                                }
                        }
@@ -434,7 +420,7 @@
                                                warnx("field %s does not exist", *argv);
                                } else {
                                        prfield(p, sep);
-                                       fprintf(out, "\n");
+                                       printf("\n");
                                }
                                argv++;
                        }



Home | Main Index | Thread Index | Old Index