summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cdcontrol
diff options
context:
space:
mode:
authorjmz <jmz@FreeBSD.org>1998-01-26 00:57:54 +0000
committerjmz <jmz@FreeBSD.org>1998-01-26 00:57:54 +0000
commit96686a66db48dc9cde71df58f710cba31f89aa73 (patch)
treefbe794f02cb91b4cad942c8f257afef8f524ef2f /usr.sbin/cdcontrol
parentc076a7316c193b5e2fca8dd4e9437d827a65aae4 (diff)
downloadFreeBSD-src-96686a66db48dc9cde71df58f710cba31f89aa73.zip
FreeBSD-src-96686a66db48dc9cde71df58f710cba31f89aa73.tar.gz
The status command prints the audio position, the media catalog and the
volume value for the disc. It is now possible to specify additional arguments (audio, volume, media) to print only a subset of the full status. This is particularly useful with drives which stop playing when asked to return the catalog number.
Diffstat (limited to 'usr.sbin/cdcontrol')
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.112
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.c78
2 files changed, 61 insertions, 29 deletions
diff --git a/usr.sbin/cdcontrol/cdcontrol.1 b/usr.sbin/cdcontrol/cdcontrol.1
index d2dcd8c..ba7ee16 100644
--- a/usr.sbin/cdcontrol/cdcontrol.1
+++ b/usr.sbin/cdcontrol/cdcontrol.1
@@ -1,4 +1,4 @@
-.\" $Id: cdcontrol.1,v 1.13 1997/12/08 07:43:13 charnier Exp $
+.\" $Id: cdcontrol.1,v 1.14 1998/01/07 07:43:04 charnier Exp $
.\"
.Dd July 3, 1995
.Dt CDCONTROL 1
@@ -126,10 +126,18 @@ Play the right subtrack on both left and right channels.
.It Cm info
Print the table of contents.
-.It Cm status
+.It Cm status
+.Op Ar audio | media | volume
+
Print the information about the disc:
+
+.Nm audio
the current playing status and position,
+
+.Nm media
the current media catalog status,
+
+.Nm volume
the current values of the volume for left and right channels.
.It Cm help
diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c
index 092410d..fc375ee 100644
--- a/usr.sbin/cdcontrol/cdcontrol.c
+++ b/usr.sbin/cdcontrol/cdcontrol.c
@@ -20,7 +20,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id$";
+ "$Id: cdcontrol.c,v 1.16 1997/09/04 11:52:28 charnier Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -65,6 +65,9 @@ static const char rcsid[] =
#define CMD_RESET 12
#define CMD_SET 13
#define CMD_STATUS 14
+#define STATUS_AUDIO 0x1
+#define STATUS_MEDIA 0x2
+#define STATUS_VOLUME 0x4
struct cmdtab {
int command;
@@ -87,7 +90,7 @@ struct cmdtab {
{ CMD_RESET, "reset", 4, "" },
{ CMD_RESUME, "resume", 1, "" },
{ CMD_SET, "set", 2, "msf | lba" },
-{ CMD_STATUS, "status", 1, "" },
+{ CMD_STATUS, "status", 1, "[audio | media | volume]" },
{ CMD_STOP, "stop", 3, "" },
{ CMD_VOLUME, "volume", 1, "<l> <r> | left | right | mute | mono | stereo" },
{ 0, }
@@ -677,43 +680,64 @@ int pstatus (char *arg)
struct ioc_read_subchannel ss;
struct cd_sub_channel_info data;
int rc, trk, m, s, f;
+ int what = 0;
+ char *p;
- rc = status (&trk, &m, &s, &f);
- if (rc >= 0)
+ while ((p = strtok(arg, " \t"))) {
+ arg = 0;
+ if (!strncasecmp(p, "audio", strlen(p)))
+ what |= STATUS_AUDIO;
+ else if (!strncasecmp(p, "media", strlen(p)))
+ what |= STATUS_MEDIA;
+ else if (!strncasecmp(p, "volume", strlen(p)))
+ what |= STATUS_VOLUME;
+ else {
+ warnx("invalid command arguments");
+ return 0;
+ }
+ }
+ if (!what)
+ what = STATUS_AUDIO|STATUS_MEDIA|STATUS_VOLUME;
+ if (what & STATUS_AUDIO) {
+ rc = status (&trk, &m, &s, &f);
+ if (rc >= 0)
if (verbose)
- printf ("Audio status = %d<%s>, current track = %d, current position = %d:%02d.%02d\n",
- rc, strstatus (rc), trk, m, s, f);
+ printf ("Audio status = %d<%s>, current track = %d, current position = %d:%02d.%02d\n",
+ rc, strstatus (rc), trk, m, s, f);
else
- printf ("%d %d %d:%02d.%02d\n", rc, trk, m, s, f);
- else
+ printf ("%d %d %d:%02d.%02d\n", rc, trk, m, s, f);
+ else
printf ("No current status info available\n");
-
- bzero (&ss, sizeof (ss));
- ss.data = &data;
- ss.data_len = sizeof (data);
- ss.address_format = msf ? CD_MSF_FORMAT : CD_LBA_FORMAT;
- ss.data_format = CD_MEDIA_CATALOG;
- rc = ioctl (fd, CDIOCREADSUBCHANNEL, (char *) &ss);
- if (rc >= 0) {
+ }
+ if (what & STATUS_MEDIA) {
+ bzero (&ss, sizeof (ss));
+ ss.data = &data;
+ ss.data_len = sizeof (data);
+ ss.address_format = msf ? CD_MSF_FORMAT : CD_LBA_FORMAT;
+ ss.data_format = CD_MEDIA_CATALOG;
+ rc = ioctl (fd, CDIOCREADSUBCHANNEL, (char *) &ss);
+ if (rc >= 0) {
printf("Media catalog is %sactive",
- ss.data->what.media_catalog.mc_valid ? "": "in");
+ ss.data->what.media_catalog.mc_valid ? "": "in");
if (ss.data->what.media_catalog.mc_valid &&
ss.data->what.media_catalog.mc_number[0])
- printf(", number \"%.15s\"",
- ss.data->what.media_catalog.mc_number);
+ printf(", number \"%.15s\"",
+ ss.data->what.media_catalog.mc_number);
putchar('\n');
- } else
+ } else
printf("No media catalog info available\n");
-
- rc = ioctl (fd, CDIOCGETVOL, &v);
- if (rc >= 0)
+ }
+ if (what & STATUS_VOLUME) {
+ rc = ioctl (fd, CDIOCGETVOL, &v);
+ if (rc >= 0)
if (verbose)
- printf ("Left volume = %d, right volume = %d\n",
- v.vol[0], v.vol[1]);
+ printf ("Left volume = %d, right volume = %d\n",
+ v.vol[0], v.vol[1]);
else
- printf ("%d %d\n", v.vol[0], v.vol[1]);
- else
+ printf ("%d %d\n", v.vol[0], v.vol[1]);
+ else
printf ("No volume level info available\n");
+ }
return(0);
}
OpenPOWER on IntegriCloud