Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/cdplay KNF



details:   https://anonhg.NetBSD.org/src/rev/4a686abde199
branches:  trunk
changeset: 473483:4a686abde199
user:      ad <ad%NetBSD.org@localhost>
date:      Sat Jun 05 14:03:32 1999 +0000

description:
KNF

diffstat:

 usr.bin/cdplay/cdplay.c |  140 +++++++++++++++++++++++++++--------------------
 1 files changed, 80 insertions(+), 60 deletions(-)

diffs (truncated from 320 to 300 lines):

diff -r a26e4acdb9d0 -r 4a686abde199 usr.bin/cdplay/cdplay.c
--- a/usr.bin/cdplay/cdplay.c   Sat Jun 05 13:49:53 1999 +0000
+++ b/usr.bin/cdplay/cdplay.c   Sat Jun 05 14:03:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdplay.c,v 1.1 1999/06/05 13:22:00 ad Exp $ */
+/*     $NetBSD: cdplay.c,v 1.2 1999/06/05 14:03:32 ad Exp $ */
 
 /*
  * Copyright (c) 1999 Andy Doran <ad%NetBSD.org@localhost>
@@ -56,7 +56,7 @@
  
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cdplay.c,v 1.1 1999/06/05 13:22:00 ad Exp $");
+__RCSID("$NetBSD: cdplay.c,v 1.2 1999/06/05 14:03:32 ad Exp $");
 #endif /* not lint */
 
 #include <ctype.h>
@@ -137,19 +137,20 @@
 int    get_vol __P((int *, int *));
 int    status __P((int *, int *, int *, int *));
 int    open_cd __P((void));
-int    play __P((char *arg));
-int    info __P((char *arg));
-int    pstatus __P((char *arg));
+int    play __P((char *));
+int    info __P((char *));
+int    pstatus __P((char *));
 char   *input __P((int *));
-void   prtrack __P((struct cd_toc_entry * e, int lastflag));
-void   lba2msf __P((unsigned long lba, u_char * m, u_char * s, u_char * f));
-u_int  msf2lba __P((u_char m, u_char s, u_char f));
-int    play_blocks __P((int blk, int len));
-int    run __P((int cmd, char *arg));
-char   *parse __P((char *buf, int *cmd));
+void   prtrack __P((struct cd_toc_entry *, int));
+void   lba2msf __P((u_long, u_char *, u_char *, u_char *));
+u_int  msf2lba __P((u_char, u_char, u_char));
+int    play_blocks __P((int, int));
+int    run __P((int, char *));
+char   *parse __P((char *, int *));
 void   help __P((void));
 void   usage __P((void));
 char   *strstatus __P((int));
+int    main __P((int, char **));
 
 void
 help()
@@ -185,7 +186,9 @@
 }
 
 int 
-main(int argc, char **argv)
+main(argc, argv)
+       int argc;
+       char **argv;
 {
        char *arg;
        int cmd;
@@ -261,7 +264,9 @@
 }
 
 int 
-run(int cmd, char *arg)
+run(cmd, arg)
+       int cmd;
+       char *arg;
 {
        int l, r, rc;
 
@@ -386,16 +391,17 @@
 }
 
 int 
-play(char *arg)
+play(arg)
+       char *arg;
 {
+       int rc, n, start, end, istart, iend;
        struct ioc_toc_header h;
-       int rc, n, start, end = 0, istart = 1, iend = 1;
-
-       rc = ioctl(fd, CDIOREADTOCHEADER, &h);
-
-       if (rc < 0)
+       
+       if ((rc = ioctl(fd, CDIOREADTOCHEADER, &h)) <  0)
                return (rc);
 
+       end = 0;
+       istart = iend = 1;
        n = h.ending_track - h.starting_track + 1;
        rc = read_toc_entrys((n + 1) * sizeof(struct cd_toc_entry));
 
@@ -511,22 +517,17 @@
 Play_Relative_Addresses:
                if (!tr1)
                        tr1 = 1;
-               else
-                       if (tr1 > n)
-                               tr1 = n;
+               else if (tr1 > n)
+                       tr1 = n;
 
                if (msf) {
                        tm = toc_buffer[tr1].addr.msf.minute;
                        ts = toc_buffer[tr1].addr.msf.second;
                        tf = toc_buffer[tr1].addr.msf.frame;
                } else
-                       lba2msf(ntohl(toc_buffer[tr1].addr.lba),
-                           &tm, &ts, &tf);
-               if ((m1 > tm)
-                   || ((m1 == tm)
-                       && ((s1 > ts)
-                           || ((s1 == ts)
-                               && (f1 > tf))))) {
+                       lba2msf(ntohl(toc_buffer[tr1].addr.lba), &tm, &ts, &tf);
+               if ((m1 > tm) || ((m1 == tm) && ((s1 > ts) || ((s1 == ts) && 
+                   (f1 > tf))))) {
                        printf("Track %d is not that long.\n", tr1);
                        return (0);
                }
@@ -605,17 +606,14 @@
                        ts = toc_buffer[n].addr.msf.second;
                        tf = toc_buffer[n].addr.msf.frame;
                } else
-                       lba2msf(ntohl(toc_buffer[n].addr.lba),
-                           &tm, &ts, &tf);
-               if ((tr2 < n)
-                   && ((m2 > tm)
-                       || ((m2 == tm)
-                           && ((s2 > ts)
-                               || ((s2 == ts)
-                                   && (f2 > tf)))))) {
+                       lba2msf(ntohl(toc_buffer[n].addr.lba), &tm, &ts, &tf);
+
+               if ((tr2 < n) && ((m2 > tm) || ((m2 == tm) && ((s2 > ts) || 
+                   ((s2 == ts) && (f2 > tf)))))) {
                        printf("The playing time of the disc is not that long.\n");
                        return (0);
                }
+
                return (play_msf(m1, s1, f1, m2, s2, f2));
 
 Try_Absolute_Timed_Addresses:
@@ -663,9 +661,11 @@
        return (0);
 }
 
-char   *
-strstatus(int sts)
+char *
+strstatus(sts)
+       int sts;
 {
+
        switch (sts) {
        case ASTS_INVALID:
                return ("invalid");
@@ -685,12 +685,13 @@
 }
 
 int 
-pstatus(char *arg)
+pstatus(arg)
+       char *arg;
 {
+       struct cd_sub_channel_info data;
+       struct ioc_read_subchannel ss;
+       int rc, trk, m, s, f;
        struct ioc_vol v;
-       struct ioc_read_subchannel ss;
-       struct cd_sub_channel_info data;
-       int rc, trk, m, s, f;
        int what = 0;
        char *p;
 
@@ -754,7 +755,8 @@
 }
 
 int 
-info(char *arg)
+info(arg)
+       char *arg;
 {
        struct ioc_toc_header h;
        int rc, i, n;
@@ -782,8 +784,13 @@
 }
 
 void 
-lba2msf(unsigned long lba, u_char * m, u_char * s, u_char * f)
+lba2msf(lba, m, s, f)
+       u_long lba;
+       u_char *m;
+       u_char *s;
+       u_char *f;
 {
+       
        lba += 150;             /* block start offset */
        lba &= 0xffffff;        /* negative lbas use only 24 bits */
        *m = lba / (60 * 75);
@@ -793,13 +800,19 @@
 }
 
 u_int 
-msf2lba(u_char m, u_char s, u_char f)
+msf2lba(m, s, f)
+       u_char m;
+       u_char s;
+       u_char f;
 {
+
        return (((m * 60) + s) * 75 + f) - 150;
 }
 
 void 
-prtrack(struct cd_toc_entry * e, int lastflag)
+prtrack(e, lastflag)
+       struct cd_toc_entry *e;
+       int lastflag;
 {
        int block, next, len;
        u_char m, s, f;
@@ -836,7 +849,8 @@
 }
 
 int 
-play_track(int tstart, int istart, int tend, int iend)
+play_track(tstart, istart, tend, iend)
+       int tstart, istart, tend, iend;
 {
        struct ioc_play_track t;
 
@@ -849,7 +863,8 @@
 }
 
 int 
-play_blocks(int blk, int len)
+play_blocks(blk, len)
+       int blk, len;
 {
        struct ioc_play_blocks t;
 
@@ -860,7 +875,8 @@
 }
 
 int 
-setvol(int left, int right)
+setvol(left, right)
+       int left, right;
 {
        struct ioc_vol v;
 
@@ -873,7 +889,8 @@
 }
 
 int 
-read_toc_entrys(int len)
+read_toc_entrys(len)
+       int len;
 {
        struct ioc_read_toc_entry t;
 
@@ -886,8 +903,8 @@
 }
 
 int 
-play_msf(int start_m, int start_s, int start_f,
-    int end_m, int end_s, int end_f)
+play_msf(start_m, start_s, start_f, end_m, end_s, end_f)
+       int start_m, start_s, start_f, end_m, end_s, end_f;
 {
        struct ioc_play_msf a;
 
@@ -902,7 +919,8 @@
 }
 
 int 
-status(int *trk, int *min, int *sec, int *frame)
+status(trk, min, sec, frame)
+       int *trk, *min, *sec, *frame;
 {
        struct ioc_read_subchannel s;
        struct cd_sub_channel_info data;
@@ -923,8 +941,7 @@
                *sec = s.data->what.position.reladdr.msf.second;
                *frame = s.data->what.position.reladdr.msf.frame;
        } else {
-               lba2msf(ntohl(s.data->what.position.reladdr.lba),
-                   &mm, &ss, &ff);
+               lba2msf(ntohl(s.data->what.position.reladdr.lba), &mm, &ss, &ff);
                *min = mm;
                *sec = ss;
                *frame = ff;
@@ -933,8 +950,9 @@
        return s.data->header.audio_status;
 }
 
-char   *



Home | Main Index | Thread Index | Old Index