1995-08-18 11:41:32 +00:00
|
|
|
/*
|
1996-02-03 14:13:36 +00:00
|
|
|
* Compact Disc Control Utility by Serge V. Vakulenko <vak@cronyx.ru>.
|
1995-08-18 11:41:32 +00:00
|
|
|
* Based on the non-X based CD player by Jean-Marc Zucconi and
|
1996-02-01 19:09:50 +00:00
|
|
|
* Andrey A. Chernov.
|
1996-02-03 14:13:36 +00:00
|
|
|
*
|
1996-02-09 00:22:17 +00:00
|
|
|
* Fixed and further modified on 5-Sep-1995 by Jukka Ukkonen <jau@funet.fi>.
|
|
|
|
*
|
|
|
|
* 11-Sep-1995: Jukka A. Ukkonen <jau@funet.fi>
|
|
|
|
* A couple of further fixes to my own earlier "fixes".
|
|
|
|
*
|
|
|
|
* 18-Sep-1995: Jukka A. Ukkonen <jau@funet.fi>
|
|
|
|
* Added an ability to specify addresses relative to the
|
|
|
|
* beginning of a track. This is in fact a variation of
|
|
|
|
* doing the simple play_msf() call.
|
|
|
|
*
|
|
|
|
* 11-Oct-1995: Serge V.Vakulenko <vak@cronyx.ru>
|
|
|
|
* New eject algorithm.
|
|
|
|
* Some code style reformatting.
|
1995-08-18 11:41:32 +00:00
|
|
|
*/
|
1996-02-09 00:22:17 +00:00
|
|
|
|
2003-05-03 21:06:42 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1997-09-04 11:52:28 +00:00
|
|
|
|
2001-05-25 09:24:50 +00:00
|
|
|
#include <sys/cdio.h>
|
2002-05-08 07:32:40 +00:00
|
|
|
#include <sys/cdrio.h>
|
2001-05-25 09:24:50 +00:00
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/param.h>
|
2002-02-18 20:35:27 +00:00
|
|
|
#include <arpa/inet.h>
|
1996-02-09 00:22:17 +00:00
|
|
|
#include <ctype.h>
|
1997-09-04 11:52:28 +00:00
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
2001-05-25 09:24:50 +00:00
|
|
|
#include <histedit.h>
|
2002-05-08 07:32:40 +00:00
|
|
|
#include <limits.h>
|
2000-12-09 09:35:55 +00:00
|
|
|
#include <paths.h>
|
1995-08-18 11:41:32 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2001-05-25 09:24:50 +00:00
|
|
|
#include <vis.h>
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
#define VERSION "2.0"
|
1995-08-18 11:41:32 +00:00
|
|
|
|
2001-12-09 19:34:11 +00:00
|
|
|
#define ASTS_INVALID 0x00 /* Audio status byte not valid */
|
|
|
|
#define ASTS_PLAYING 0x11 /* Audio play operation in progress */
|
|
|
|
#define ASTS_PAUSED 0x12 /* Audio play operation paused */
|
|
|
|
#define ASTS_COMPLETED 0x13 /* Audio play operation successfully completed */
|
|
|
|
#define ASTS_ERROR 0x14 /* Audio play operation stopped due to error */
|
|
|
|
#define ASTS_VOID 0x15 /* No current audio status to return */
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
#ifndef DEFAULT_CD_DRIVE
|
2002-12-03 15:41:30 +00:00
|
|
|
# define DEFAULT_CD_DRIVE "/dev/cd0"
|
1996-02-09 00:22:17 +00:00
|
|
|
#endif
|
|
|
|
|
2001-12-09 19:34:11 +00:00
|
|
|
#define CMD_DEBUG 1
|
|
|
|
#define CMD_EJECT 2
|
|
|
|
#define CMD_HELP 3
|
|
|
|
#define CMD_INFO 4
|
|
|
|
#define CMD_PAUSE 5
|
|
|
|
#define CMD_PLAY 6
|
|
|
|
#define CMD_QUIT 7
|
|
|
|
#define CMD_RESUME 8
|
|
|
|
#define CMD_STOP 9
|
|
|
|
#define CMD_VOLUME 10
|
|
|
|
#define CMD_CLOSE 11
|
|
|
|
#define CMD_RESET 12
|
|
|
|
#define CMD_SET 13
|
|
|
|
#define CMD_STATUS 14
|
|
|
|
#define CMD_CDID 15
|
|
|
|
#define CMD_NEXT 16
|
|
|
|
#define CMD_PREVIOUS 17
|
2002-05-08 07:32:40 +00:00
|
|
|
#define CMD_SPEED 18
|
2001-12-09 19:34:11 +00:00
|
|
|
#define STATUS_AUDIO 0x1
|
|
|
|
#define STATUS_MEDIA 0x2
|
|
|
|
#define STATUS_VOLUME 0x4
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
struct cmdtab {
|
|
|
|
int command;
|
2001-12-09 18:40:56 +00:00
|
|
|
const char *name;
|
|
|
|
unsigned min;
|
|
|
|
const char *args;
|
1995-08-18 11:41:32 +00:00
|
|
|
} cmdtab[] = {
|
2001-12-09 19:34:11 +00:00
|
|
|
{ CMD_CLOSE, "close", 1, "" },
|
|
|
|
{ CMD_DEBUG, "debug", 1, "on | off" },
|
|
|
|
{ CMD_EJECT, "eject", 1, "" },
|
|
|
|
{ CMD_HELP, "?", 1, 0 },
|
|
|
|
{ CMD_HELP, "help", 1, "" },
|
|
|
|
{ CMD_INFO, "info", 1, "" },
|
|
|
|
{ CMD_NEXT, "next", 1, "" },
|
|
|
|
{ CMD_PAUSE, "pause", 2, "" },
|
|
|
|
{ CMD_PLAY, "play", 1, "min1:sec1[.fram1] [min2:sec2[.fram2]]" },
|
|
|
|
{ CMD_PLAY, "play", 1, "track1[.index1] [track2[.index2]]" },
|
|
|
|
{ CMD_PLAY, "play", 1, "tr1 m1:s1[.f1] [[tr2] [m2:s2[.f2]]]" },
|
|
|
|
{ CMD_PLAY, "play", 1, "[#block [len]]" },
|
|
|
|
{ CMD_PREVIOUS, "previous", 2, "" },
|
|
|
|
{ CMD_QUIT, "quit", 1, "" },
|
|
|
|
{ CMD_RESET, "reset", 4, "" },
|
|
|
|
{ CMD_RESUME, "resume", 1, "" },
|
|
|
|
{ CMD_SET, "set", 2, "msf | lba" },
|
|
|
|
{ CMD_STATUS, "status", 1, "[audio | media | volume]" },
|
|
|
|
{ CMD_STOP, "stop", 3, "" },
|
|
|
|
{ CMD_VOLUME, "volume", 1,
|
|
|
|
"<l> <r> | left | right | mute | mono | stereo" },
|
|
|
|
{ CMD_CDID, "cdid", 2, "" },
|
2002-05-08 07:32:40 +00:00
|
|
|
{ CMD_SPEED, "speed", 2, "speed" },
|
2001-12-09 19:34:11 +00:00
|
|
|
{ 0, NULL, 0, NULL }
|
1995-08-18 11:41:32 +00:00
|
|
|
};
|
|
|
|
|
2001-12-09 19:34:11 +00:00
|
|
|
struct cd_toc_entry toc_buffer[100];
|
|
|
|
|
|
|
|
const char *cdname;
|
|
|
|
int fd = -1;
|
|
|
|
int verbose = 1;
|
|
|
|
int msf = 1;
|
|
|
|
|
2002-07-11 18:31:16 +00:00
|
|
|
int setvol(int, int);
|
|
|
|
int read_toc_entrys(int);
|
|
|
|
int play_msf(int, int, int, int, int, int);
|
|
|
|
int play_track(int, int, int, int);
|
|
|
|
int get_vol(int *, int *);
|
|
|
|
int status(int *, int *, int *, int *);
|
|
|
|
int open_cd(void);
|
|
|
|
int next_prev(char *arg, int);
|
|
|
|
int play(char *arg);
|
|
|
|
int info(char *arg);
|
|
|
|
int cdid(void);
|
|
|
|
int pstatus(char *arg);
|
|
|
|
char *input(int *);
|
|
|
|
void prtrack(struct cd_toc_entry *e, int lastflag);
|
|
|
|
void lba2msf(unsigned long lba, u_char *m, u_char *s, u_char *f);
|
|
|
|
unsigned int msf2lba(u_char m, u_char s, u_char f);
|
|
|
|
int play_blocks(int blk, int len);
|
|
|
|
int run(int cmd, char *arg);
|
|
|
|
char *parse(char *buf, int *cmd);
|
|
|
|
void help(void);
|
|
|
|
void usage(void);
|
|
|
|
char *use_cdrom_instead(const char *);
|
|
|
|
__const char *strstatus(int);
|
|
|
|
static u_int dbprog_discid(void);
|
|
|
|
__const char *cdcontrol_prompt(void);
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
void help ()
|
|
|
|
{
|
|
|
|
struct cmdtab *c;
|
2001-12-09 18:40:56 +00:00
|
|
|
const char *s;
|
|
|
|
char n;
|
1996-02-09 00:22:17 +00:00
|
|
|
int i;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
for (c=cmdtab; c->name; ++c) {
|
|
|
|
if (! c->args)
|
|
|
|
continue;
|
1996-02-09 00:22:17 +00:00
|
|
|
printf("\t");
|
|
|
|
for (i = c->min, s = c->name; *s; s++, i--) {
|
|
|
|
if (i > 0)
|
|
|
|
n = toupper(*s);
|
|
|
|
else
|
|
|
|
n = *s;
|
|
|
|
putchar(n);
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
if (*c->args)
|
|
|
|
printf (" %s", c->args);
|
|
|
|
printf ("\n");
|
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
printf ("\n\tThe word \"play\" is not required for the play commands.\n");
|
|
|
|
printf ("\tThe plain target address is taken as a synonym for play.\n");
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void usage ()
|
|
|
|
{
|
1999-01-31 15:30:21 +00:00
|
|
|
fprintf (stderr, "usage: cdcontrol [-sv] [-f device] [command ...]\n");
|
1995-08-18 11:41:32 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2001-12-09 18:40:56 +00:00
|
|
|
char *use_cdrom_instead(const char *old_envvar)
|
2001-01-16 20:31:53 +00:00
|
|
|
{
|
|
|
|
char *device;
|
|
|
|
|
|
|
|
device = getenv(old_envvar);
|
|
|
|
if (device)
|
|
|
|
warnx("%s environment variable deprecated, "
|
|
|
|
"please use CDROM in the future.", old_envvar);
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int cmd;
|
|
|
|
char *arg;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
switch (getopt (argc, argv, "svhf:")) {
|
|
|
|
case EOF:
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
verbose = 0;
|
|
|
|
continue;
|
|
|
|
case 'v':
|
|
|
|
verbose = 2;
|
|
|
|
continue;
|
|
|
|
case 'f':
|
|
|
|
cdname = optarg;
|
|
|
|
continue;
|
|
|
|
case 'h':
|
|
|
|
default:
|
|
|
|
usage ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
if (argc > 0 && ! strcasecmp (*argv, "help"))
|
1995-08-18 11:41:32 +00:00
|
|
|
usage ();
|
|
|
|
|
2000-12-18 14:35:54 +00:00
|
|
|
if (! cdname) {
|
|
|
|
cdname = getenv("CDROM");
|
|
|
|
}
|
|
|
|
|
2001-04-08 21:35:17 +00:00
|
|
|
if (! cdname)
|
|
|
|
cdname = use_cdrom_instead("MUSIC_CD");
|
|
|
|
if (! cdname)
|
|
|
|
cdname = use_cdrom_instead("CD_DRIVE");
|
|
|
|
if (! cdname)
|
|
|
|
cdname = use_cdrom_instead("DISC");
|
|
|
|
if (! cdname)
|
|
|
|
cdname = use_cdrom_instead("CDPLAY");
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (! cdname) {
|
1996-02-09 00:22:17 +00:00
|
|
|
cdname = DEFAULT_CD_DRIVE;
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("no CD device name specified, defaulting to %s", cdname);
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
char buf[80], *p;
|
|
|
|
int len;
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
for (p=buf; argc-->0; ++argv) {
|
1995-08-18 11:41:32 +00:00
|
|
|
len = strlen (*argv);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (p + len >= buf + sizeof (buf) - 1)
|
|
|
|
usage ();
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (p > buf)
|
|
|
|
*p++ = ' ';
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
strcpy (p, *argv);
|
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
*p = 0;
|
|
|
|
arg = parse (buf, &cmd);
|
1996-02-09 00:22:17 +00:00
|
|
|
return (run (cmd, arg));
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose == 1)
|
|
|
|
verbose = isatty (0);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (verbose) {
|
1996-02-09 00:22:17 +00:00
|
|
|
printf ("Compact Disc Control utility, version %s\n", VERSION);
|
1995-08-18 11:41:32 +00:00
|
|
|
printf ("Type `?' for command list\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
arg = input (&cmd);
|
|
|
|
if (run (cmd, arg) < 0) {
|
|
|
|
if (verbose)
|
1997-09-04 11:52:28 +00:00
|
|
|
warn(NULL);
|
1995-08-18 11:41:32 +00:00
|
|
|
close (fd);
|
|
|
|
fd = -1;
|
|
|
|
}
|
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int run (int cmd, char *arg)
|
|
|
|
{
|
2002-05-08 07:32:40 +00:00
|
|
|
long speed;
|
1995-08-18 11:41:32 +00:00
|
|
|
int l, r, rc;
|
|
|
|
|
|
|
|
switch (cmd) {
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
case CMD_QUIT:
|
|
|
|
exit (0);
|
|
|
|
|
|
|
|
case CMD_INFO:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return info (arg);
|
|
|
|
|
2000-07-13 22:56:43 +00:00
|
|
|
case CMD_CDID:
|
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return cdid ();
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
case CMD_STATUS:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
return pstatus (arg);
|
|
|
|
|
2001-05-25 09:24:50 +00:00
|
|
|
case CMD_NEXT:
|
|
|
|
case CMD_PREVIOUS:
|
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
while (isspace (*arg))
|
|
|
|
arg++;
|
|
|
|
|
|
|
|
return next_prev (arg, cmd);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
case CMD_PAUSE:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCPAUSE);
|
|
|
|
|
|
|
|
case CMD_RESUME:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCRESUME);
|
|
|
|
|
|
|
|
case CMD_STOP:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
rc = ioctl (fd, CDIOCSTOP);
|
|
|
|
|
|
|
|
(void) ioctl (fd, CDIOCALLOW);
|
|
|
|
|
|
|
|
return (rc);
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
case CMD_RESET:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
rc = ioctl (fd, CDIOCRESET);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
return (0);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
case CMD_DEBUG:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
if (! strcasecmp (arg, "on"))
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCSETDEBUG);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
if (! strcasecmp (arg, "off"))
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCCLRDEBUG);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("invalid command arguments");
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
case CMD_EJECT:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
(void) ioctl (fd, CDIOCALLOW);
|
|
|
|
rc = ioctl (fd, CDIOCEJECT);
|
|
|
|
if (rc < 0)
|
|
|
|
return (rc);
|
1996-02-02 22:03:37 +00:00
|
|
|
return (0);
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
case CMD_CLOSE:
|
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
(void) ioctl (fd, CDIOCALLOW);
|
1996-02-02 22:03:37 +00:00
|
|
|
rc = ioctl (fd, CDIOCCLOSE);
|
|
|
|
if (rc < 0)
|
|
|
|
return (rc);
|
|
|
|
close(fd);
|
1995-08-18 11:41:32 +00:00
|
|
|
fd = -1;
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case CMD_PLAY:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
while (isspace (*arg))
|
|
|
|
arg++;
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return play (arg);
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
case CMD_SET:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (! strcasecmp (arg, "msf"))
|
1996-02-03 14:13:36 +00:00
|
|
|
msf = 1;
|
1996-02-09 00:22:17 +00:00
|
|
|
else if (! strcasecmp (arg, "lba"))
|
1996-02-03 14:13:36 +00:00
|
|
|
msf = 0;
|
|
|
|
else
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("invalid command arguments");
|
1996-02-03 14:13:36 +00:00
|
|
|
return (0);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
case CMD_VOLUME:
|
1996-02-09 00:22:17 +00:00
|
|
|
if (fd < 0 && !open_cd ())
|
|
|
|
return (0);
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
if (! strncasecmp (arg, "left", strlen(arg)))
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCSETLEFT);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
if (! strncasecmp (arg, "right", strlen(arg)))
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCSETRIGHT);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
if (! strncasecmp (arg, "mono", strlen(arg)))
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCSETMONO);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
if (! strncasecmp (arg, "stereo", strlen(arg)))
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCSETSTERIO);
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
if (! strncasecmp (arg, "mute", strlen(arg)))
|
|
|
|
return ioctl (fd, CDIOCSETMUTE);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (2 != sscanf (arg, "%d %d", &l, &r)) {
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("invalid command arguments");
|
1995-08-18 11:41:32 +00:00
|
|
|
return (0);
|
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return setvol (l, r);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
2002-05-08 07:32:40 +00:00
|
|
|
case CMD_SPEED:
|
|
|
|
if (fd < 0 && ! open_cd ())
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
errno = 0;
|
2002-10-18 22:03:39 +00:00
|
|
|
if (strcasecmp("max", arg) == 0)
|
|
|
|
speed = CDR_MAX_SPEED;
|
|
|
|
else
|
|
|
|
speed = strtol(arg, NULL, 10) * 177;
|
|
|
|
if (speed <= 0 || speed > INT_MAX) {
|
2002-05-08 07:32:40 +00:00
|
|
|
warnx("invalid command arguments %s", arg);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return ioctl(fd, CDRIOCREADSPEED, &speed);
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
default:
|
|
|
|
case CMD_HELP:
|
|
|
|
help ();
|
|
|
|
return (0);
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int play (char *arg)
|
|
|
|
{
|
|
|
|
struct ioc_toc_header h;
|
2001-12-09 18:40:56 +00:00
|
|
|
unsigned int n;
|
|
|
|
int rc, start, end = 0, istart = 1, iend = 1;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
rc = ioctl (fd, CDIOREADTOCHEADER, &h);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (rc < 0)
|
|
|
|
return (rc);
|
|
|
|
|
|
|
|
n = h.ending_track - h.starting_track + 1;
|
|
|
|
rc = read_toc_entrys ((n + 1) * sizeof (struct cd_toc_entry));
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (rc < 0)
|
|
|
|
return (rc);
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
if (! arg || ! *arg) {
|
1996-02-09 00:22:17 +00:00
|
|
|
/* Play the whole disc */
|
1996-02-09 01:16:23 +00:00
|
|
|
if (msf)
|
|
|
|
return play_blocks (0, msf2lba (toc_buffer[n].addr.msf.minute,
|
|
|
|
toc_buffer[n].addr.msf.second,
|
|
|
|
toc_buffer[n].addr.msf.frame));
|
|
|
|
else
|
|
|
|
return play_blocks (0, ntohl(toc_buffer[n].addr.lba));
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
if (strchr (arg, '#')) {
|
1996-02-09 00:22:17 +00:00
|
|
|
/* Play block #blk [ len ] */
|
1995-08-18 11:41:32 +00:00
|
|
|
int blk, len = 0;
|
|
|
|
|
|
|
|
if (2 != sscanf (arg, "#%d%d", &blk, &len) &&
|
1996-02-09 00:22:17 +00:00
|
|
|
1 != sscanf (arg, "#%d", &blk))
|
|
|
|
goto Clean_up;
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
if (len == 0) {
|
|
|
|
if (msf)
|
|
|
|
len = msf2lba (toc_buffer[n].addr.msf.minute,
|
|
|
|
toc_buffer[n].addr.msf.second,
|
|
|
|
toc_buffer[n].addr.msf.frame) - blk;
|
|
|
|
else
|
|
|
|
len = ntohl(toc_buffer[n].addr.lba) - blk;
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
return play_blocks (blk, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strchr (arg, ':')) {
|
|
|
|
/*
|
|
|
|
* Play MSF m1:s1 [ .f1 ] [ m2:s2 [ .f2 ] ]
|
1996-02-09 00:22:17 +00:00
|
|
|
*
|
|
|
|
* Will now also undestand timed addresses relative
|
|
|
|
* to the beginning of a track in the form...
|
|
|
|
*
|
|
|
|
* tr1 m1:s1[.f1] [[tr2] [m2:s2[.f2]]]
|
1995-08-18 11:41:32 +00:00
|
|
|
*/
|
1996-02-09 00:22:17 +00:00
|
|
|
unsigned tr1, tr2;
|
|
|
|
unsigned m1, m2, s1, s2, f1, f2;
|
1996-02-09 01:16:23 +00:00
|
|
|
unsigned char tm, ts, tf;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
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))
|
|
|
|
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))
|
|
|
|
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))
|
|
|
|
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))
|
|
|
|
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))
|
|
|
|
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))
|
|
|
|
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))
|
|
|
|
goto Play_Relative_Addresses;
|
|
|
|
|
|
|
|
tr2 = m2 = s2 = f2 = f1 = 0;
|
|
|
|
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))
|
|
|
|
goto Play_Relative_Addresses;
|
|
|
|
|
|
|
|
tr2 = m2 = s2 = f2 = f1 = 0;
|
|
|
|
if (5 == sscanf (arg, "%d %d:%d.%d %d",
|
|
|
|
&tr1, &m1, &s1, &f1, &tr2))
|
|
|
|
goto Play_Relative_Addresses;
|
|
|
|
|
|
|
|
tr2 = m2 = s2 = f2 = f1 = 0;
|
|
|
|
if (4 == sscanf (arg, "%d %d:%d %d", &tr1, &m1, &s1, &tr2))
|
|
|
|
goto Play_Relative_Addresses;
|
|
|
|
|
|
|
|
tr2 = m2 = s2 = f2 = f1 = 0;
|
|
|
|
if (4 == sscanf (arg, "%d %d:%d.%d", &tr1, &m1, &s1, &f1))
|
|
|
|
goto Play_Relative_Addresses;
|
|
|
|
|
|
|
|
tr2 = m2 = s2 = f2 = f1 = 0;
|
|
|
|
if (3 == sscanf (arg, "%d %d:%d", &tr1, &m1, &s1))
|
|
|
|
goto Play_Relative_Addresses;
|
|
|
|
|
|
|
|
tr2 = m2 = s2 = f2 = f1 = 0;
|
|
|
|
goto Try_Absolute_Timed_Addresses;
|
|
|
|
|
|
|
|
Play_Relative_Addresses:
|
|
|
|
if (! tr1)
|
|
|
|
tr1 = 1;
|
|
|
|
else if (tr1 > n)
|
|
|
|
tr1 = n;
|
|
|
|
|
2003-03-24 20:54:30 +00:00
|
|
|
tr1--;
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
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))))) {
|
1996-02-09 00:22:17 +00:00
|
|
|
printf ("Track %d is not that long.\n", tr1);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
f1 += tf;
|
1996-02-09 00:22:17 +00:00
|
|
|
if (f1 >= 75) {
|
|
|
|
s1 += f1 / 75;
|
|
|
|
f1 %= 75;
|
|
|
|
}
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
s1 += ts;
|
1996-02-09 00:22:17 +00:00
|
|
|
if (s1 >= 60) {
|
|
|
|
m1 += s1 / 60;
|
|
|
|
s1 %= 60;
|
|
|
|
}
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
m1 += tm;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
if (! tr2) {
|
|
|
|
if (m2 || s2 || f2) {
|
|
|
|
tr2 = tr1;
|
|
|
|
f2 += f1;
|
|
|
|
if (f2 >= 75) {
|
|
|
|
s2 += f2 / 75;
|
|
|
|
f2 %= 75;
|
|
|
|
}
|
|
|
|
|
|
|
|
s2 += s1;
|
|
|
|
if (s2 > 60) {
|
|
|
|
m2 += s2 / 60;
|
|
|
|
s2 %= 60;
|
|
|
|
}
|
|
|
|
|
|
|
|
m2 += m1;
|
|
|
|
} else {
|
|
|
|
tr2 = n;
|
1996-02-09 01:16:23 +00:00
|
|
|
if (msf) {
|
|
|
|
m2 = toc_buffer[n].addr.msf.minute;
|
|
|
|
s2 = toc_buffer[n].addr.msf.second;
|
|
|
|
f2 = toc_buffer[n].addr.msf.frame;
|
|
|
|
} else {
|
|
|
|
lba2msf(ntohl(toc_buffer[n].addr.lba),
|
|
|
|
&tm, &ts, &tf);
|
|
|
|
m2 = tm;
|
|
|
|
s2 = ts;
|
|
|
|
f2 = tf;
|
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
}
|
|
|
|
} else if (tr2 > n) {
|
|
|
|
tr2 = n;
|
|
|
|
m2 = s2 = f2 = 0;
|
|
|
|
} else {
|
|
|
|
if (m2 || s2 || f2)
|
|
|
|
tr2--;
|
1996-02-09 01:16:23 +00:00
|
|
|
if (msf) {
|
|
|
|
tm = toc_buffer[tr2].addr.msf.minute;
|
|
|
|
ts = toc_buffer[tr2].addr.msf.second;
|
|
|
|
tf = toc_buffer[tr2].addr.msf.frame;
|
|
|
|
} else
|
|
|
|
lba2msf(ntohl(toc_buffer[tr2].addr.lba),
|
|
|
|
&tm, &ts, &tf);
|
|
|
|
f2 += tf;
|
1996-02-09 00:22:17 +00:00
|
|
|
if (f2 >= 75) {
|
|
|
|
s2 += f2 / 75;
|
|
|
|
f2 %= 75;
|
|
|
|
}
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
s2 += ts;
|
1996-02-09 00:22:17 +00:00
|
|
|
if (s2 > 60) {
|
|
|
|
m2 += s2 / 60;
|
|
|
|
s2 %= 60;
|
|
|
|
}
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
m2 += tm;
|
1996-02-09 00:22:17 +00:00
|
|
|
}
|
|
|
|
|
1996-02-09 01:16:23 +00:00
|
|
|
if (msf) {
|
|
|
|
tm = toc_buffer[n].addr.msf.minute;
|
|
|
|
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);
|
1996-02-09 00:22:17 +00:00
|
|
|
if ((tr2 < n)
|
1996-02-09 01:16:23 +00:00
|
|
|
&& ((m2 > tm)
|
|
|
|
|| ((m2 == tm)
|
|
|
|
&& ((s2 > ts)
|
|
|
|
|| ((s2 == ts)
|
|
|
|
&& (f2 > tf)))))) {
|
1996-02-09 00:22:17 +00:00
|
|
|
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:
|
|
|
|
if (6 != sscanf (arg, "%d:%d.%d%d:%d.%d",
|
|
|
|
&m1, &s1, &f1, &m2, &s2, &f2) &&
|
1995-08-18 11:41:32 +00:00
|
|
|
5 != sscanf (arg, "%d:%d.%d%d:%d", &m1, &s1, &f1, &m2, &s2) &&
|
|
|
|
5 != sscanf (arg, "%d:%d%d:%d.%d", &m1, &s1, &m2, &s2, &f2) &&
|
|
|
|
3 != sscanf (arg, "%d:%d.%d", &m1, &s1, &f1) &&
|
|
|
|
4 != sscanf (arg, "%d:%d%d:%d", &m1, &s1, &m2, &s2) &&
|
|
|
|
2 != sscanf (arg, "%d:%d", &m1, &s1))
|
1996-02-09 00:22:17 +00:00
|
|
|
goto Clean_up;
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (m2 == 0) {
|
1996-02-09 01:16:23 +00:00
|
|
|
if (msf) {
|
|
|
|
m2 = toc_buffer[n].addr.msf.minute;
|
|
|
|
s2 = toc_buffer[n].addr.msf.second;
|
|
|
|
f2 = toc_buffer[n].addr.msf.frame;
|
|
|
|
} else {
|
|
|
|
lba2msf(ntohl(toc_buffer[n].addr.lba),
|
|
|
|
&tm, &ts, &tf);
|
|
|
|
m2 = tm;
|
|
|
|
s2 = ts;
|
|
|
|
f2 = tf;
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
return play_msf (m1, s1, f1, m2, s2, f2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Play track trk1 [ .idx1 ] [ trk2 [ .idx2 ] ]
|
|
|
|
*/
|
|
|
|
if (4 != sscanf (arg, "%d.%d%d.%d", &start, &istart, &end, &iend) &&
|
|
|
|
3 != sscanf (arg, "%d.%d%d", &start, &istart, &end) &&
|
|
|
|
3 != sscanf (arg, "%d%d.%d", &start, &end, &iend) &&
|
|
|
|
2 != sscanf (arg, "%d.%d", &start, &istart) &&
|
|
|
|
2 != sscanf (arg, "%d%d", &start, &end) &&
|
|
|
|
1 != sscanf (arg, "%d", &start))
|
1996-02-09 00:22:17 +00:00
|
|
|
goto Clean_up;
|
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (end == 0)
|
|
|
|
end = n;
|
1996-02-09 00:22:17 +00:00
|
|
|
return (play_track (start, istart, end, iend));
|
|
|
|
|
|
|
|
Clean_up:
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("invalid command arguments");
|
1996-02-09 00:22:17 +00:00
|
|
|
return (0);
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 09:24:50 +00:00
|
|
|
int next_prev (char *arg, int cmd)
|
|
|
|
{
|
|
|
|
struct ioc_toc_header h;
|
|
|
|
int dir, junk, n, off, rc, trk;
|
|
|
|
|
|
|
|
dir = (cmd == CMD_NEXT) ? 1 : -1;
|
|
|
|
rc = ioctl (fd, CDIOREADTOCHEADER, &h);
|
|
|
|
if (rc < 0)
|
|
|
|
return (rc);
|
|
|
|
|
|
|
|
n = h.ending_track - h.starting_track + 1;
|
|
|
|
rc = status (&trk, &junk, &junk, &junk);
|
|
|
|
if (rc < 0)
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
if (arg && *arg) {
|
|
|
|
if (sscanf (arg, "%u", &off) != 1) {
|
|
|
|
warnx("invalid command argument");
|
|
|
|
return (0);
|
|
|
|
} else
|
|
|
|
trk += off * dir;
|
|
|
|
} else
|
|
|
|
trk += dir;
|
|
|
|
|
|
|
|
if (trk > h.ending_track)
|
|
|
|
trk = 1;
|
|
|
|
|
|
|
|
return (play_track (trk, 1, n, 1));
|
|
|
|
}
|
|
|
|
|
2001-12-09 18:40:56 +00:00
|
|
|
const char *strstatus (int sts)
|
1995-08-18 11:41:32 +00:00
|
|
|
{
|
|
|
|
switch (sts) {
|
2001-12-09 19:34:11 +00:00
|
|
|
case ASTS_INVALID: return ("invalid");
|
|
|
|
case ASTS_PLAYING: return ("playing");
|
|
|
|
case ASTS_PAUSED: return ("paused");
|
|
|
|
case ASTS_COMPLETED: return ("completed");
|
|
|
|
case ASTS_ERROR: return ("error");
|
|
|
|
case ASTS_VOID: return ("void");
|
|
|
|
default: return ("??");
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
int pstatus (char *arg)
|
1995-08-18 11:41:32 +00:00
|
|
|
{
|
|
|
|
struct ioc_vol v;
|
1996-02-03 15:07:32 +00:00
|
|
|
struct ioc_read_subchannel ss;
|
|
|
|
struct cd_sub_channel_info data;
|
1996-02-03 14:13:36 +00:00
|
|
|
int rc, trk, m, s, f;
|
1998-01-26 00:57:54 +00:00
|
|
|
int what = 0;
|
2001-05-25 09:24:50 +00:00
|
|
|
char *p, vmcn[(4 * 15) + 1];
|
1998-01-26 00:57:54 +00:00
|
|
|
|
|
|
|
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)
|
1995-08-18 11:41:32 +00:00
|
|
|
if (verbose)
|
1998-01-26 00:57:54 +00:00
|
|
|
printf ("Audio status = %d<%s>, current track = %d, current position = %d:%02d.%02d\n",
|
|
|
|
rc, strstatus (rc), trk, m, s, f);
|
1995-08-18 11:41:32 +00:00
|
|
|
else
|
1998-01-26 00:57:54 +00:00
|
|
|
printf ("%d %d %d:%02d.%02d\n", rc, trk, m, s, f);
|
|
|
|
else
|
1996-02-03 15:07:32 +00:00
|
|
|
printf ("No current status info available\n");
|
1998-01-26 00:57:54 +00:00
|
|
|
}
|
|
|
|
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) {
|
1996-02-03 15:21:30 +00:00
|
|
|
printf("Media catalog is %sactive",
|
2001-12-09 19:34:11 +00:00
|
|
|
ss.data->what.media_catalog.mc_valid ? "": "in");
|
1996-06-25 21:01:27 +00:00
|
|
|
if (ss.data->what.media_catalog.mc_valid &&
|
|
|
|
ss.data->what.media_catalog.mc_number[0])
|
2001-05-25 09:24:50 +00:00
|
|
|
{
|
|
|
|
strvisx (vmcn, ss.data->what.media_catalog.mc_number,
|
|
|
|
(sizeof (vmcn) - 1) / 4, VIS_OCTAL | VIS_NL);
|
|
|
|
printf(", number \"%.*s\"", (int)sizeof (vmcn), vmcn);
|
|
|
|
}
|
1996-02-03 15:21:30 +00:00
|
|
|
putchar('\n');
|
1998-01-26 00:57:54 +00:00
|
|
|
} else
|
1996-02-03 15:07:32 +00:00
|
|
|
printf("No media catalog info available\n");
|
1998-01-26 00:57:54 +00:00
|
|
|
}
|
|
|
|
if (what & STATUS_VOLUME) {
|
|
|
|
rc = ioctl (fd, CDIOCGETVOL, &v);
|
|
|
|
if (rc >= 0)
|
1995-08-18 11:41:32 +00:00
|
|
|
if (verbose)
|
1998-01-26 00:57:54 +00:00
|
|
|
printf ("Left volume = %d, right volume = %d\n",
|
|
|
|
v.vol[0], v.vol[1]);
|
1995-08-18 11:41:32 +00:00
|
|
|
else
|
1998-01-26 00:57:54 +00:00
|
|
|
printf ("%d %d\n", v.vol[0], v.vol[1]);
|
|
|
|
else
|
1996-02-03 15:07:32 +00:00
|
|
|
printf ("No volume level info available\n");
|
1998-01-26 00:57:54 +00:00
|
|
|
}
|
1996-02-03 14:13:36 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2000-07-13 22:56:43 +00:00
|
|
|
/*
|
|
|
|
* dbprog_sum
|
|
|
|
* Convert an integer to its text string representation, and
|
|
|
|
* compute its checksum. Used by dbprog_discid to derive the
|
|
|
|
* disc ID.
|
|
|
|
*
|
|
|
|
* Args:
|
|
|
|
* n - The integer value.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The integer checksum.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
dbprog_sum(int n)
|
|
|
|
{
|
|
|
|
char buf[12],
|
|
|
|
*p;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* For backward compatibility this algorithm must not change */
|
|
|
|
sprintf(buf, "%u", n);
|
|
|
|
for (p = buf; *p != '\0'; p++)
|
|
|
|
ret += (*p - '0');
|
|
|
|
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dbprog_discid
|
|
|
|
* Compute a magic disc ID based on the number of tracks,
|
|
|
|
* the length of each track, and a checksum of the string
|
|
|
|
* that represents the offset of each track.
|
|
|
|
*
|
|
|
|
* Args:
|
|
|
|
* s - Pointer to the curstat_t structure.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The integer disc ID.
|
|
|
|
*/
|
|
|
|
static u_int
|
|
|
|
dbprog_discid()
|
|
|
|
{
|
|
|
|
struct ioc_toc_header h;
|
|
|
|
int rc;
|
|
|
|
int i, ntr,
|
|
|
|
t = 0,
|
|
|
|
n = 0;
|
|
|
|
|
|
|
|
rc = ioctl (fd, CDIOREADTOCHEADER, &h);
|
|
|
|
if (rc < 0)
|
|
|
|
return 0;
|
|
|
|
ntr = h.ending_track - h.starting_track + 1;
|
|
|
|
i = msf;
|
|
|
|
msf = 1;
|
|
|
|
rc = read_toc_entrys ((ntr + 1) * sizeof (struct cd_toc_entry));
|
|
|
|
msf = i;
|
|
|
|
if (rc < 0)
|
|
|
|
return 0;
|
|
|
|
/* For backward compatibility this algorithm must not change */
|
|
|
|
for (i = 0; i < ntr; i++) {
|
|
|
|
#define TC_MM(a) toc_buffer[a].addr.msf.minute
|
|
|
|
#define TC_SS(a) toc_buffer[a].addr.msf.second
|
|
|
|
n += dbprog_sum((TC_MM(i) * 60) + TC_SS(i));
|
|
|
|
|
|
|
|
t += ((TC_MM(i+1) * 60) + TC_SS(i+1)) -
|
2001-12-09 19:34:11 +00:00
|
|
|
((TC_MM(i) * 60) + TC_SS(i));
|
2000-07-13 22:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return((n % 0xff) << 24 | t << 8 | ntr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cdid ()
|
|
|
|
{
|
|
|
|
u_int id;
|
|
|
|
|
|
|
|
id = dbprog_discid();
|
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
if (verbose)
|
|
|
|
printf ("CDID=");
|
|
|
|
printf ("%08x\n",id);
|
|
|
|
}
|
|
|
|
return id ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
2001-12-09 18:40:56 +00:00
|
|
|
int info (char *arg __unused)
|
1996-02-03 14:13:36 +00:00
|
|
|
{
|
|
|
|
struct ioc_toc_header h;
|
|
|
|
int rc, i, n;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
rc = ioctl (fd, CDIOREADTOCHEADER, &h);
|
1996-02-03 15:07:32 +00:00
|
|
|
if (rc >= 0) {
|
1995-08-18 11:41:32 +00:00
|
|
|
if (verbose)
|
|
|
|
printf ("Starting track = %d, ending track = %d, TOC size = %d bytes\n",
|
|
|
|
h.starting_track, h.ending_track, h.len);
|
|
|
|
else
|
|
|
|
printf ("%d %d %d\n", h.starting_track,
|
|
|
|
h.ending_track, h.len);
|
1996-02-03 15:07:32 +00:00
|
|
|
} else {
|
1997-09-04 11:52:28 +00:00
|
|
|
warn("getting toc header");
|
1995-08-18 11:41:32 +00:00
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
n = h.ending_track - h.starting_track + 1;
|
|
|
|
rc = read_toc_entrys ((n + 1) * sizeof (struct cd_toc_entry));
|
|
|
|
if (rc < 0)
|
|
|
|
return (rc);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (verbose) {
|
|
|
|
printf ("track start duration block length type\n");
|
|
|
|
printf ("-------------------------------------------------\n");
|
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
printf ("%5d ", toc_buffer[i].track);
|
|
|
|
prtrack (toc_buffer + i, 0);
|
|
|
|
}
|
1996-02-02 22:14:39 +00:00
|
|
|
printf ("%5d ", toc_buffer[n].track);
|
1995-08-18 11:41:32 +00:00
|
|
|
prtrack (toc_buffer + n, 1);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
void lba2msf (unsigned long lba, u_char *m, u_char *s, u_char *f)
|
1995-08-18 11:41:32 +00:00
|
|
|
{
|
2001-12-09 19:34:11 +00:00
|
|
|
lba += 150; /* block start offset */
|
|
|
|
lba &= 0xffffff; /* negative lbas use only 24 bits */
|
1995-08-18 11:41:32 +00:00
|
|
|
*m = lba / (60 * 75);
|
|
|
|
lba %= (60 * 75);
|
|
|
|
*s = lba / 75;
|
|
|
|
*f = lba % 75;
|
|
|
|
}
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
unsigned int msf2lba (u_char m, u_char s, u_char f)
|
1995-08-18 11:41:32 +00:00
|
|
|
{
|
|
|
|
return (((m * 60) + s) * 75 + f) - 150;
|
|
|
|
}
|
|
|
|
|
|
|
|
void prtrack (struct cd_toc_entry *e, int lastflag)
|
|
|
|
{
|
|
|
|
int block, next, len;
|
|
|
|
u_char m, s, f;
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
if (msf) {
|
|
|
|
/* Print track start */
|
|
|
|
printf ("%2d:%02d.%02d ", e->addr.msf.minute,
|
|
|
|
e->addr.msf.second, e->addr.msf.frame);
|
|
|
|
|
|
|
|
block = msf2lba (e->addr.msf.minute, e->addr.msf.second,
|
|
|
|
e->addr.msf.frame);
|
|
|
|
} else {
|
|
|
|
block = ntohl(e->addr.lba);
|
|
|
|
lba2msf(block, &m, &s, &f);
|
|
|
|
/* Print track start */
|
|
|
|
printf ("%2d:%02d.%02d ", m, s, f);
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
if (lastflag) {
|
|
|
|
/* Last track -- print block */
|
|
|
|
printf (" - %6d - -\n", block);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
if (msf)
|
|
|
|
next = msf2lba (e[1].addr.msf.minute, e[1].addr.msf.second,
|
|
|
|
e[1].addr.msf.frame);
|
|
|
|
else
|
|
|
|
next = ntohl(e[1].addr.lba);
|
1995-08-18 11:41:32 +00:00
|
|
|
len = next - block;
|
2002-09-23 15:00:23 +00:00
|
|
|
/* Take into account a start offset time. */
|
|
|
|
lba2msf (len - 150, &m, &s, &f);
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
/* Print duration, block, length, type */
|
|
|
|
printf ("%2d:%02d.%02d %6d %6d %5s\n", m, s, f, block, len,
|
1996-02-09 00:22:17 +00:00
|
|
|
(e->control & 4) ? "data" : "audio");
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int play_track (int tstart, int istart, int tend, int iend)
|
|
|
|
{
|
|
|
|
struct ioc_play_track t;
|
|
|
|
|
|
|
|
t.start_track = tstart;
|
|
|
|
t.start_index = istart;
|
|
|
|
t.end_track = tend;
|
|
|
|
t.end_index = iend;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCPLAYTRACKS, &t);
|
|
|
|
}
|
|
|
|
|
|
|
|
int play_blocks (int blk, int len)
|
|
|
|
{
|
1996-02-09 00:22:17 +00:00
|
|
|
struct ioc_play_blocks t;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
t.blk = blk;
|
|
|
|
t.len = len;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCPLAYBLOCKS, &t);
|
|
|
|
}
|
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
int setvol (int left, int right)
|
1995-08-18 11:41:32 +00:00
|
|
|
{
|
1996-02-09 00:22:17 +00:00
|
|
|
struct ioc_vol v;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
v.vol[0] = left;
|
|
|
|
v.vol[1] = right;
|
1995-08-18 11:41:32 +00:00
|
|
|
v.vol[2] = 0;
|
|
|
|
v.vol[3] = 0;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCSETVOL, &v);
|
|
|
|
}
|
|
|
|
|
|
|
|
int read_toc_entrys (int len)
|
|
|
|
{
|
|
|
|
struct ioc_read_toc_entry t;
|
|
|
|
|
1996-02-03 14:13:36 +00:00
|
|
|
t.address_format = msf ? CD_MSF_FORMAT : CD_LBA_FORMAT;
|
1996-01-30 12:00:43 +00:00
|
|
|
t.starting_track = 0;
|
1995-08-18 11:41:32 +00:00
|
|
|
t.data_len = len;
|
|
|
|
t.data = toc_buffer;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
return (ioctl (fd, CDIOREADTOCENTRYS, (char *) &t));
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int play_msf (int start_m, int start_s, int start_f,
|
1996-02-09 00:22:17 +00:00
|
|
|
int end_m, int end_s, int end_f)
|
1995-08-18 11:41:32 +00:00
|
|
|
{
|
2001-12-09 19:34:11 +00:00
|
|
|
struct ioc_play_msf a;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
a.start_m = start_m;
|
|
|
|
a.start_s = start_s;
|
|
|
|
a.start_f = start_f;
|
|
|
|
a.end_m = end_m;
|
|
|
|
a.end_s = end_s;
|
|
|
|
a.end_f = end_f;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return ioctl (fd, CDIOCPLAYMSF, (char *) &a);
|
|
|
|
}
|
|
|
|
|
|
|
|
int status (int *trk, int *min, int *sec, int *frame)
|
|
|
|
{
|
|
|
|
struct ioc_read_subchannel s;
|
|
|
|
struct cd_sub_channel_info data;
|
1996-02-03 14:13:36 +00:00
|
|
|
u_char mm, ss, ff;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
bzero (&s, sizeof (s));
|
|
|
|
s.data = &data;
|
|
|
|
s.data_len = sizeof (data);
|
1996-02-03 14:13:36 +00:00
|
|
|
s.address_format = msf ? CD_MSF_FORMAT : CD_LBA_FORMAT;
|
1995-08-18 11:41:32 +00:00
|
|
|
s.data_format = CD_CURRENT_POSITION;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (ioctl (fd, CDIOCREADSUBCHANNEL, (char *) &s) < 0)
|
|
|
|
return -1;
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
*trk = s.data->what.position.track_number;
|
1996-02-03 14:13:36 +00:00
|
|
|
if (msf) {
|
|
|
|
*min = s.data->what.position.reladdr.msf.minute;
|
|
|
|
*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);
|
|
|
|
*min = mm;
|
|
|
|
*sec = ss;
|
|
|
|
*frame = ff;
|
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
return s.data->header.audio_status;
|
|
|
|
}
|
|
|
|
|
1999-08-19 03:29:15 +00:00
|
|
|
const char *
|
|
|
|
cdcontrol_prompt()
|
1995-08-18 11:41:32 +00:00
|
|
|
{
|
1999-08-19 03:29:15 +00:00
|
|
|
return ("cdcontrol> ");
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
input (int *cmd)
|
|
|
|
{
|
|
|
|
#define MAXLINE 80
|
|
|
|
static EditLine *el = NULL;
|
|
|
|
static History *hist = NULL;
|
2001-10-01 08:43:58 +00:00
|
|
|
HistEvent he;
|
1999-08-19 03:29:15 +00:00
|
|
|
static char buf[MAXLINE];
|
|
|
|
int num = 0;
|
1999-08-20 01:24:35 +00:00
|
|
|
int len;
|
1999-08-19 03:29:15 +00:00
|
|
|
const char *bp = NULL;
|
1995-08-18 11:41:32 +00:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
do {
|
1999-08-19 03:29:15 +00:00
|
|
|
if (verbose) {
|
|
|
|
if (!el) {
|
2001-10-01 08:43:58 +00:00
|
|
|
el = el_init("cdcontrol", stdin, stdout,
|
|
|
|
stderr);
|
1999-08-19 03:29:15 +00:00
|
|
|
hist = history_init();
|
2001-10-01 08:43:58 +00:00
|
|
|
history(hist, &he, H_EVENT, 100);
|
1999-08-19 03:29:15 +00:00
|
|
|
el_set(el, EL_HIST, history, hist);
|
|
|
|
el_set(el, EL_EDITOR, "emacs");
|
|
|
|
el_set(el, EL_PROMPT, cdcontrol_prompt);
|
|
|
|
el_set(el, EL_SIGNAL, 1);
|
1999-08-19 04:10:33 +00:00
|
|
|
el_source(el, NULL);
|
1999-08-19 03:29:15 +00:00
|
|
|
}
|
2000-07-13 12:55:50 +00:00
|
|
|
if ((bp = el_gets(el, &num)) == NULL || num == 0) {
|
|
|
|
*cmd = CMD_QUIT;
|
|
|
|
fprintf (stderr, "\r\n");
|
1999-08-19 03:29:15 +00:00
|
|
|
return (0);
|
2000-07-13 12:55:50 +00:00
|
|
|
}
|
1999-08-19 03:29:15 +00:00
|
|
|
|
1999-08-20 01:24:35 +00:00
|
|
|
len = (num > MAXLINE) ? MAXLINE : num;
|
|
|
|
memcpy(buf, bp, len);
|
|
|
|
buf[len] = 0;
|
2001-10-01 08:43:58 +00:00
|
|
|
history(hist, &he, H_ENTER, bp);
|
1999-08-19 03:29:15 +00:00
|
|
|
#undef MAXLINE
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (! fgets (buf, sizeof (buf), stdin)) {
|
|
|
|
*cmd = CMD_QUIT;
|
|
|
|
fprintf (stderr, "\r\n");
|
|
|
|
return (0);
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
p = parse (buf, cmd);
|
|
|
|
} while (! p);
|
|
|
|
return (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *parse (char *buf, int *cmd)
|
|
|
|
{
|
|
|
|
struct cmdtab *c;
|
|
|
|
char *p;
|
2001-12-09 18:40:56 +00:00
|
|
|
unsigned int len;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
for (p=buf; isspace (*p); p++)
|
|
|
|
continue;
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
if (isdigit (*p) || (p[0] == '#' && isdigit (p[1]))) {
|
|
|
|
*cmd = CMD_PLAY;
|
|
|
|
return (p);
|
2001-05-25 09:24:50 +00:00
|
|
|
} else if (*p == '+') {
|
|
|
|
*cmd = CMD_NEXT;
|
|
|
|
return (p + 1);
|
|
|
|
} else if (*p == '-') {
|
|
|
|
*cmd = CMD_PREVIOUS;
|
|
|
|
return (p + 1);
|
1996-02-09 00:22:17 +00:00
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
for (buf = p; *p && ! isspace (*p); p++)
|
|
|
|
continue;
|
2002-05-08 07:40:22 +00:00
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
len = p - buf;
|
1995-08-18 11:41:32 +00:00
|
|
|
if (! len)
|
|
|
|
return (0);
|
|
|
|
|
2001-12-09 19:34:11 +00:00
|
|
|
if (*p) { /* It must be a spacing character! */
|
1996-02-09 00:22:17 +00:00
|
|
|
char *q;
|
|
|
|
|
|
|
|
*p++ = 0;
|
|
|
|
for (q=p; *q && *q != '\n' && *q != '\r'; q++)
|
1995-08-18 11:41:32 +00:00
|
|
|
continue;
|
1996-02-09 00:22:17 +00:00
|
|
|
*q = 0;
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
|
1996-02-09 00:22:17 +00:00
|
|
|
*cmd = -1;
|
|
|
|
for (c=cmdtab; c->name; ++c) {
|
|
|
|
/* Is it an exact match? */
|
|
|
|
if (! strcasecmp (buf, c->name)) {
|
|
|
|
*cmd = c->command;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try short hand forms then... */
|
|
|
|
if (len >= c->min && ! strncasecmp (buf, c->name, len)) {
|
|
|
|
if (*cmd != -1 && *cmd != c->command) {
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("ambiguous command");
|
1996-02-09 00:22:17 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
*cmd = c->command;
|
|
|
|
}
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (*cmd == -1) {
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("invalid command, enter ``help'' for commands");
|
1995-08-18 11:41:32 +00:00
|
|
|
return (0);
|
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
|
|
|
|
while (isspace (*p))
|
|
|
|
p++;
|
1995-08-18 11:41:32 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
int open_cd ()
|
|
|
|
{
|
1999-12-05 20:05:45 +00:00
|
|
|
char devbuf[MAXPATHLEN];
|
1995-08-18 11:41:32 +00:00
|
|
|
|
|
|
|
if (fd > -1)
|
|
|
|
return (1);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1999-12-05 20:05:45 +00:00
|
|
|
if (*cdname == '/') {
|
|
|
|
snprintf (devbuf, MAXPATHLEN, "%s", cdname);
|
|
|
|
} else {
|
2000-12-09 09:35:55 +00:00
|
|
|
snprintf (devbuf, MAXPATHLEN, "%s%s", _PATH_DEV, cdname);
|
1999-12-05 20:05:45 +00:00
|
|
|
}
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
fd = open (devbuf, O_RDONLY);
|
1996-02-09 00:22:17 +00:00
|
|
|
|
1995-08-18 11:41:32 +00:00
|
|
|
if (fd < 0) {
|
1996-02-09 00:22:17 +00:00
|
|
|
if (errno == ENXIO) {
|
|
|
|
/* ENXIO has an overloaded meaning here.
|
|
|
|
* The original "Device not configured" should
|
|
|
|
* be interpreted as "No disc in drive %s". */
|
1997-09-04 11:52:28 +00:00
|
|
|
warnx("no disc in drive %s", devbuf);
|
1996-02-09 00:22:17 +00:00
|
|
|
return (0);
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
1997-09-04 11:52:28 +00:00
|
|
|
err(1, "%s", devbuf);
|
1995-08-18 11:41:32 +00:00
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|