Use err(3). Style in usage().
This commit is contained in:
parent
6440762ef4
commit
8f89c97f8a
@ -1,4 +1,4 @@
|
|||||||
.\" $Id$
|
.\" $Id: cdcontrol.1,v 1.10 1997/02/22 16:04:30 peter Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd July 3, 1995
|
.Dd July 3, 1995
|
||||||
.Dt CDCONTROL 1
|
.Dt CDCONTROL 1
|
||||||
@ -11,9 +11,9 @@
|
|||||||
.Op Fl s
|
.Op Fl s
|
||||||
.Op Fl v
|
.Op Fl v
|
||||||
.Op Fl f Ar discname
|
.Op Fl f Ar discname
|
||||||
.Op Ar command args...
|
.Op Ar command args ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm cdcontrol
|
.Nm Cdcontrol
|
||||||
is a program to control audio features of a CD drive. The device is a name such
|
is a program to control audio features of a CD drive. The device is a name such
|
||||||
as cd0 or mcd0.
|
as cd0 or mcd0.
|
||||||
.Pp
|
.Pp
|
||||||
@ -22,7 +22,7 @@ If the device not specified, the environment variable
|
|||||||
will be used to find the cd device.
|
will be used to find the cd device.
|
||||||
.Pp
|
.Pp
|
||||||
If no command is given, then
|
If no command is given, then
|
||||||
.Nm cdcontrol
|
.Nm
|
||||||
enters an interactive mode, reading commands from the standard input.
|
enters an interactive mode, reading commands from the standard input.
|
||||||
.Pp
|
.Pp
|
||||||
The following options are available:
|
The following options are available:
|
||||||
@ -157,6 +157,6 @@ Andrey A.\ Chernov,
|
|||||||
Serge V.\ Vakulenko
|
Serge V.\ Vakulenko
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The
|
The
|
||||||
.Nm cdcontrol
|
.Nm
|
||||||
command appeared in
|
command appeared in
|
||||||
.Fx 2.1 .
|
.Fx 2.1 .
|
||||||
|
@ -16,16 +16,20 @@
|
|||||||
* 11-Oct-1995: Serge V.Vakulenko <vak@cronyx.ru>
|
* 11-Oct-1995: Serge V.Vakulenko <vak@cronyx.ru>
|
||||||
* New eject algorithm.
|
* New eject algorithm.
|
||||||
* Some code style reformatting.
|
* Some code style reformatting.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/cdio.h>
|
#include <sys/cdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@ -96,8 +100,6 @@ int fd = -1;
|
|||||||
int verbose = 1;
|
int verbose = 1;
|
||||||
int msf = 1;
|
int msf = 1;
|
||||||
|
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
int setvol __P((int, int));
|
int setvol __P((int, int));
|
||||||
int read_toc_entrys __P((int));
|
int read_toc_entrys __P((int));
|
||||||
int play_msf __P((int, int, int, int, int, int));
|
int play_msf __P((int, int, int, int, int, int));
|
||||||
@ -144,14 +146,7 @@ void help ()
|
|||||||
|
|
||||||
void usage ()
|
void usage ()
|
||||||
{
|
{
|
||||||
printf ("Usage:\n\t%s [ -vs ] [ -f disc ] [ command args... ]\n", __progname);
|
fprintf (stderr, "usage: cdcontrol [-vs] [-f disc] [command args ...]\n");
|
||||||
printf ("Options:\n");
|
|
||||||
printf ("\t-v - verbose mode\n");
|
|
||||||
printf ("\t-s - silent mode\n");
|
|
||||||
printf ("\t-f disc - a block device name such as /dev/cd0c\n");
|
|
||||||
printf ("\tMUSIC_CD - shell variable with device name\n");
|
|
||||||
printf ("Commands:\n");
|
|
||||||
help ();
|
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +190,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
if (! cdname) {
|
if (! cdname) {
|
||||||
cdname = DEFAULT_CD_DRIVE;
|
cdname = DEFAULT_CD_DRIVE;
|
||||||
fprintf (stderr,
|
warnx("no CD device name specified, defaulting to %s", cdname);
|
||||||
"No CD device name specified. Defaulting to %s.\n", cdname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
@ -232,7 +226,7 @@ int main (int argc, char **argv)
|
|||||||
arg = input (&cmd);
|
arg = input (&cmd);
|
||||||
if (run (cmd, arg) < 0) {
|
if (run (cmd, arg) < 0) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
perror (__progname);
|
warn(NULL);
|
||||||
close (fd);
|
close (fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
@ -304,7 +298,7 @@ int run (int cmd, char *arg)
|
|||||||
if (! strcasecmp (arg, "off"))
|
if (! strcasecmp (arg, "off"))
|
||||||
return ioctl (fd, CDIOCCLRDEBUG);
|
return ioctl (fd, CDIOCCLRDEBUG);
|
||||||
|
|
||||||
printf ("%s: Invalid command arguments\n", __progname);
|
warnx("invalid command arguments");
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
@ -345,7 +339,7 @@ int run (int cmd, char *arg)
|
|||||||
else if (! strcasecmp (arg, "lba"))
|
else if (! strcasecmp (arg, "lba"))
|
||||||
msf = 0;
|
msf = 0;
|
||||||
else
|
else
|
||||||
printf ("%s: Invalid command arguments\n", __progname);
|
warnx("invalid command arguments");
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
case CMD_VOLUME:
|
case CMD_VOLUME:
|
||||||
@ -368,7 +362,7 @@ int run (int cmd, char *arg)
|
|||||||
return ioctl (fd, CDIOCSETMUTE);
|
return ioctl (fd, CDIOCSETMUTE);
|
||||||
|
|
||||||
if (2 != sscanf (arg, "%d %d", &l, &r)) {
|
if (2 != sscanf (arg, "%d %d", &l, &r)) {
|
||||||
printf ("%s: Invalid command arguments\n", __progname);
|
warnx("invalid command arguments");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +654,7 @@ int play (char *arg)
|
|||||||
return (play_track (start, istart, end, iend));
|
return (play_track (start, istart, end, iend));
|
||||||
|
|
||||||
Clean_up:
|
Clean_up:
|
||||||
printf ("%s: Invalid command arguments\n", __progname);
|
warnx("invalid command arguments");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,7 +731,7 @@ int info (char *arg)
|
|||||||
printf ("%d %d %d\n", h.starting_track,
|
printf ("%d %d %d\n", h.starting_track,
|
||||||
h.ending_track, h.len);
|
h.ending_track, h.len);
|
||||||
} else {
|
} else {
|
||||||
perror ("getting toc header");
|
warn("getting toc header");
|
||||||
return (rc);
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,7 +905,7 @@ char *input (int *cmd)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf (stderr, "%s> ", __progname);
|
fprintf (stderr, "cdcontrol> ");
|
||||||
if (! fgets (buf, sizeof (buf), stdin)) {
|
if (! fgets (buf, sizeof (buf), stdin)) {
|
||||||
*cmd = CMD_QUIT;
|
*cmd = CMD_QUIT;
|
||||||
fprintf (stderr, "\r\n");
|
fprintf (stderr, "\r\n");
|
||||||
@ -963,7 +957,7 @@ char *parse (char *buf, int *cmd)
|
|||||||
/* Try short hand forms then... */
|
/* Try short hand forms then... */
|
||||||
if (len >= c->min && ! strncasecmp (buf, c->name, len)) {
|
if (len >= c->min && ! strncasecmp (buf, c->name, len)) {
|
||||||
if (*cmd != -1 && *cmd != c->command) {
|
if (*cmd != -1 && *cmd != c->command) {
|
||||||
fprintf (stderr, "Ambiguous command\n");
|
warnx("ambiguous command");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
*cmd = c->command;
|
*cmd = c->command;
|
||||||
@ -971,8 +965,7 @@ char *parse (char *buf, int *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*cmd == -1) {
|
if (*cmd == -1) {
|
||||||
fprintf (stderr, "%s: Invalid command, enter ``help'' for commands.\n",
|
warnx("invalid command, enter ``help'' for commands");
|
||||||
__progname);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1007,11 +1000,10 @@ int open_cd ()
|
|||||||
/* ENXIO has an overloaded meaning here.
|
/* ENXIO has an overloaded meaning here.
|
||||||
* The original "Device not configured" should
|
* The original "Device not configured" should
|
||||||
* be interpreted as "No disc in drive %s". */
|
* be interpreted as "No disc in drive %s". */
|
||||||
fprintf (stderr, "%s: No disc in drive %s.\n", __progname, devbuf);
|
warnx("no disc in drive %s", devbuf);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
perror (devbuf);
|
err(1, "%s", devbuf);
|
||||||
exit (1);
|
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user