Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/cdplay Some cleanup [Fixes to follow as soon as I ge...
details: https://anonhg.NetBSD.org/src/rev/849e0775c4d1
branches: trunk
changeset: 476517:849e0775c4d1
user: ad <ad%NetBSD.org@localhost>
date: Sat Sep 18 21:15:23 1999 +0000
description:
Some cleanup [Fixes to follow as soon as I get a CD-ROM drive at home]
diffstat:
usr.bin/cdplay/cdplay.c | 140 ++++++++++++++++++++++++-----------------------
1 files changed, 71 insertions(+), 69 deletions(-)
diffs (truncated from 438 to 300 lines):
diff -r cbd5ffe4be5f -r 849e0775c4d1 usr.bin/cdplay/cdplay.c
--- a/usr.bin/cdplay/cdplay.c Sat Sep 18 20:50:28 1999 +0000
+++ b/usr.bin/cdplay/cdplay.c Sat Sep 18 21:15:23 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cdplay.c,v 1.2 1999/06/05 14:03:32 ad Exp $ */
+/* $NetBSD: cdplay.c,v 1.3 1999/09/18 21:15:23 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.2 1999/06/05 14:03:32 ad Exp $");
+__RCSID("$NetBSD: cdplay.c,v 1.3 1999/09/18 21:15:23 ad Exp $");
#endif /* not lint */
#include <ctype.h>
@@ -136,7 +136,7 @@
int play_track __P((int, int, int, int));
int get_vol __P((int *, int *));
int status __P((int *, int *, int *, int *));
-int open_cd __P((void));
+int opencd __P((void));
int play __P((char *));
int info __P((char *));
int pstatus __P((char *));
@@ -181,6 +181,7 @@
void
usage()
{
+
fprintf(stderr, "usage: cdplay [-f device] [command ...]\n");
exit(1);
}
@@ -190,8 +191,8 @@
int argc;
char **argv;
{
- char *arg;
- int cmd;
+ char *arg, *p, buf[80];
+ int cmd, len;
cdname = getenv("MUSIC_CD");
if (!cdname)
@@ -226,11 +227,10 @@
sprintf(defdev, "cd0%c", 'a' + RAW_PART);
cdname = defdev;
}
+
+ opencd();
if (argc > 0) {
- char buf[80], *p;
- int len;
-
for (p = buf; argc-- > 0; ++argv) {
len = strlen(*argv);
@@ -275,39 +275,39 @@
exit(0);
case CMD_INFO:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
return info(arg);
case CMD_STATUS:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
return pstatus(arg);
case CMD_PAUSE:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
return ioctl(fd, CDIOCPAUSE);
case CMD_RESUME:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
return ioctl(fd, CDIOCRESUME);
case CMD_STOP:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
rc = ioctl(fd, CDIOCSTOP);
- (void) ioctl(fd, CDIOCALLOW);
+ ioctl(fd, CDIOCALLOW);
return (rc);
case CMD_RESET:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
rc = ioctl(fd, CDIOCRESET);
@@ -318,20 +318,20 @@
return (0);
case CMD_EJECT:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
- (void) ioctl(fd, CDIOCALLOW);
+ ioctl(fd, CDIOCALLOW);
rc = ioctl(fd, CDIOCEJECT);
if (rc < 0)
return (rc);
return (0);
case CMD_CLOSE:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
- (void) ioctl(fd, CDIOCALLOW);
+ ioctl(fd, CDIOCALLOW);
rc = ioctl(fd, CDIOCCLOSE);
if (rc < 0)
return (rc);
@@ -340,7 +340,7 @@
return (0);
case CMD_PLAY:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
while (isspace(*arg))
@@ -358,30 +358,30 @@
return (0);
case CMD_VOLUME:
- if (fd < 0 && !open_cd())
+ if (fd < 0 && !opencd())
return (0);
if (!strncasecmp(arg, "left", strlen(arg)))
- return ioctl(fd, CDIOCSETLEFT);
+ return (ioctl(fd, CDIOCSETLEFT));
if (!strncasecmp(arg, "right", strlen(arg)))
- return ioctl(fd, CDIOCSETRIGHT);
+ return (ioctl(fd, CDIOCSETRIGHT));
if (!strncasecmp(arg, "mono", strlen(arg)))
- return ioctl(fd, CDIOCSETMONO);
+ return (ioctl(fd, CDIOCSETMONO));
if (!strncasecmp(arg, "stereo", strlen(arg)))
- return ioctl(fd, CDIOCSETSTEREO);
+ return (ioctl(fd, CDIOCSETSTEREO));
if (!strncasecmp(arg, "mute", strlen(arg)))
- return ioctl(fd, CDIOCSETMUTE);
+ return (ioctl(fd, CDIOCSETMUTE));
if (2 != sscanf(arg, "%d %d", &l, &r)) {
warnx("invalid command arguments");
return (0);
}
- return setvol(l, r);
-
+ return (setvol(l, r));
+
case CMD_HELP:
default:
help();
@@ -394,7 +394,7 @@
play(arg)
char *arg;
{
- int rc, n, start, end, istart, iend;
+ int rc, n, start, end, istart, iend, blk, len;
struct ioc_toc_header h;
if ((rc = ioctl(fd, CDIOREADTOCHEADER, &h)) < 0)
@@ -415,12 +415,12 @@
toc_buffer[n].addr.msf.second,
toc_buffer[n].addr.msf.frame));
- return play_blocks(0, ntohl(toc_buffer[n].addr.lba));
+ return (play_blocks(0, ntohl(toc_buffer[n].addr.lba)));
}
if (strchr(arg, '#')) {
/* Play block #blk [ len ] */
- int blk, len = 0;
+ len = 0;
if (2 != sscanf(arg, "#%d%d", &blk, &len) &&
1 != sscanf(arg, "#%d", &blk))
@@ -434,7 +434,7 @@
else
len = ntohl(toc_buffer[n].addr.lba) - blk;
}
- return play_blocks(blk, len);
+ return (play_blocks(blk, len));
}
if (strchr(arg, ':')) {
@@ -451,52 +451,53 @@
unsigned char tm, ts, tf;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (8 == sscanf(arg, "%d %d:%d.%d %d %d:%d.%d",
- &tr1, &m1, &s1, &f1, &tr2, &m2, &s2, &f2))
+ if (8 == sscanf(arg, "%d %d:%d.%d %d %d:%d.%d", &tr1, &m1,
+ &s1, &f1, &tr2, &m2, &s2, &f2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (7 == sscanf(arg, "%d %d:%d %d %d:%d.%d",
- &tr1, &m1, &s1, &tr2, &m2, &s2, &f2))
+ if (7 == sscanf(arg, "%d %d:%d %d %d:%d.%d", &tr1, &m1, &s1,
+ &tr2, &m2, &s2, &f2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (7 == sscanf(arg, "%d %d:%d.%d %d %d:%d",
- &tr1, &m1, &s1, &f1, &tr2, &m2, &s2))
+ if (7 == sscanf(arg, "%d %d:%d.%d %d %d:%d", &tr1, &m1, &s1,
+ &f1, &tr2, &m2, &s2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (7 == sscanf(arg, "%d %d:%d.%d %d:%d.%d",
- &tr1, &m1, &s1, &f1, &m2, &s2, &f2))
+ if (7 == sscanf(arg, "%d %d:%d.%d %d:%d.%d", &tr1, &m1, &s1,
+ &f1, &m2, &s2, &f2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (6 == sscanf(arg, "%d %d:%d.%d %d:%d",
- &tr1, &m1, &s1, &f1, &m2, &s2))
+ if (6 == sscanf(arg, "%d %d:%d.%d %d:%d", &tr1, &m1, &s1, &f1,
+ &m2, &s2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (6 == sscanf(arg, "%d %d:%d %d:%d.%d",
- &tr1, &m1, &s1, &m2, &s2, &f2))
+ if (6 == sscanf(arg, "%d %d:%d %d:%d.%d", &tr1, &m1, &s1, &m2,
+ &s2, &f2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (6 == sscanf(arg, "%d %d:%d.%d %d %d",
- &tr1, &m1, &s1, &f1, &tr2, &m2))
+ if (6 == sscanf(arg, "%d %d:%d.%d %d %d", &tr1, &m1, &s1, &f1,
+ &tr2, &m2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (5 == sscanf(arg, "%d %d:%d %d:%d", &tr1, &m1, &s1, &m2, &s2))
+ if (5 == sscanf(arg, "%d %d:%d %d:%d", &tr1, &m1, &s1, &m2,
+ &s2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (5 == sscanf(arg, "%d %d:%d %d %d",
- &tr1, &m1, &s1, &tr2, &m2))
+ if (5 == sscanf(arg, "%d %d:%d %d %d", &tr1, &m1, &s1, &tr2,
+ &m2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
- if (5 == sscanf(arg, "%d %d:%d.%d %d",
- &tr1, &m1, &s1, &f1, &tr2))
+ if (5 == sscanf(arg, "%d %d:%d.%d %d", &tr1, &m1, &s1, &f1,
+ &tr2))
goto Play_Relative_Addresses;
tr2 = m2 = s2 = f2 = f1 = 0;
@@ -639,7 +640,7 @@
f2 = tf;
}
}
- return play_msf(m1, s1, f1, m2, s2, f2);
+ return (play_msf(m1, s1, f1, m2, s2, f2));
}
/*
* Play track trk1 [ .idx1 ] [ trk2 [ .idx2 ] ]
@@ -786,9 +787,7 @@
void
lba2msf(lba, m, s, f)
u_long lba;
- u_char *m;
Home |
Main Index |
Thread Index |
Old Index