Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/cdplay Show the last "track" as the start of the lea...



details:   https://anonhg.NetBSD.org/src/rev/f75ce4d84576
branches:  trunk
changeset: 543215:f75ce4d84576
user:      simonb <simonb%NetBSD.org@localhost>
date:      Wed Feb 19 12:55:58 2003 +0000

description:
Show the last "track" as the start of the lead-out area instead of a
bogus track number.  Remove a magic number and (slightly) simplify the
TOC entry display function a little.

diffstat:

 usr.bin/cdplay/cdplay.c |  34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diffs (108 lines):

diff -r 23ba359cd656 -r f75ce4d84576 usr.bin/cdplay/cdplay.c
--- a/usr.bin/cdplay/cdplay.c   Wed Feb 19 12:49:10 2003 +0000
+++ b/usr.bin/cdplay/cdplay.c   Wed Feb 19 12:55:58 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdplay.c,v 1.22 2003/01/30 21:23:57 is Exp $   */
+/*     $NetBSD: cdplay.c,v 1.23 2003/02/19 12:55:58 simonb Exp $       */
 
 /*
  * Copyright (c) 1999, 2000, 2001 Andrew Doran.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cdplay.c,v 1.22 2003/01/30 21:23:57 is Exp $");
+__RCSID("$NetBSD: cdplay.c,v 1.23 2003/02/19 12:55:58 simonb Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -113,7 +113,9 @@
        { CMD_VOLUME,   "volume",  1, "<l> <r>|left|right|mute|mono|stereo" },
 };
 
-struct cd_toc_entry toc_buffer[100];
+#define        CD_MAX_TRACK    99      /* largest 2 digit BCD number */
+
+struct cd_toc_entry toc_buffer[CD_MAX_TRACK + 1];
 
 const char *cdname;
 int     fd = -1;
@@ -140,7 +142,7 @@
 int    play_msf(int, int, int, int, int, int);
 int    play_track(int, int, int, int);
 int    print_status(const char *);
-void   print_track(struct cd_toc_entry *, int);
+void   print_track(struct cd_toc_entry *);
 const char     *prompt(void);
 int    read_toc_entrys(int);
 int    run(int, const char *);
@@ -822,15 +824,15 @@
        if (rc < 0)
                return (rc);
 
-       printf("track     start  duration   block  length   type\n");
-       printf("-------------------------------------------------\n");
+       printf("track     start  duration   block  length     type\n");
+       printf("--------------------------------------------------\n");
 
        for (i = 0; i < n; i++) {
                printf("%5d  ", toc_buffer[i].track);
-               print_track(toc_buffer + i, 0);
+               print_track(toc_buffer + i);
        }
-       printf("%5d  ", toc_buffer[n].track);
-       print_track(toc_buffer + n, 1);
+       printf("    -  ", toc_buffer[n].track); /* Lead-out area */
+       print_track(toc_buffer + n);
        return (0);
 }
 
@@ -854,7 +856,7 @@
 }
 
 void
-print_track(struct cd_toc_entry *e, int lastflag)
+print_track(struct cd_toc_entry *e)
 {
        int block, next, len;
        u_int m, s, f;
@@ -872,9 +874,9 @@
                /* Print track start */
                printf("%2d:%02d.%02d  ", m, s, f);
        }
-       if (lastflag) {
-               /* Last track -- print block */
-               printf("       -  %6d       -      -\n", block);
+       if (e->track > CD_MAX_TRACK) {
+               /* lead-out area -- print block */
+               printf("       -  %6d       - lead-out\n", block);
                return;
        }
        if (msf)
@@ -886,7 +888,7 @@
        lba2msf(len, &m, &s, &f);
 
        /* Print duration, block, length, type */
-       printf("%2d:%02d.%02d  %6d  %6d  %5s\n", m, s, f, block, len,
+       printf("%2d:%02d.%02d  %6d  %6d %8s\n", m, s, f, block, len,
            (e->control & 4) ? "data" : "audio");
 }
 
@@ -1102,7 +1104,7 @@
        struct cd_toc_entry *ctep;
 
        assert(i >= 0);
-       assert(i < 100);
+       assert(i <= CD_MAX_TRACK);
 
        ctep = &toc_buffer[i];
 
@@ -1121,7 +1123,7 @@
        struct cd_toc_entry *ctep;
 
        assert(i > 0);
-       assert(i < 100);
+       assert(i <= CD_MAX_TRACK);
 
        ctep = &toc_buffer[i-1];
 



Home | Main Index | Thread Index | Old Index