aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/cdcontrol
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-09-04 11:52:28 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-09-04 11:52:28 +0000
commitdd1f44fc099a4f4bd865e724ffa60b2ec3e38a51 (patch)
tree91f9f3521f1f191a72eaeb8eedda65030d1ecdbd /usr.sbin/cdcontrol
parent112eace26d9e5d2600a474a4d4f387ff0ca2e0b3 (diff)
downloadsrc-dd1f44fc099a4f4bd865e724ffa60b2ec3e38a51.tar.gz
src-dd1f44fc099a4f4bd865e724ffa60b2ec3e38a51.zip
Use err(3). Style in usage().
Notes
Notes: svn path=/head/; revision=29103
Diffstat (limited to 'usr.sbin/cdcontrol')
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.110
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.c48
2 files changed, 25 insertions, 33 deletions
diff --git a/usr.sbin/cdcontrol/cdcontrol.1 b/usr.sbin/cdcontrol/cdcontrol.1
index 29c63cbee5b7..fb52548a106f 100644
--- a/usr.sbin/cdcontrol/cdcontrol.1
+++ b/usr.sbin/cdcontrol/cdcontrol.1
@@ -1,4 +1,4 @@
-.\" $Id$
+.\" $Id: cdcontrol.1,v 1.10 1997/02/22 16:04:30 peter Exp $
.\"
.Dd July 3, 1995
.Dt CDCONTROL 1
@@ -11,9 +11,9 @@
.Op Fl s
.Op Fl v
.Op Fl f Ar discname
-.Op Ar command args...
+.Op Ar command args ...
.Sh DESCRIPTION
-.Nm cdcontrol
+.Nm Cdcontrol
is a program to control audio features of a CD drive. The device is a name such
as cd0 or mcd0.
.Pp
@@ -22,7 +22,7 @@ If the device not specified, the environment variable
will be used to find the cd device.
.Pp
If no command is given, then
-.Nm cdcontrol
+.Nm
enters an interactive mode, reading commands from the standard input.
.Pp
The following options are available:
@@ -157,6 +157,6 @@ Andrey A.\ Chernov,
Serge V.\ Vakulenko
.Sh HISTORY
The
-.Nm cdcontrol
+.Nm
command appeared in
.Fx 2.1 .
diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c
index 00eaecb630f5..092410d772c4 100644
--- a/usr.sbin/cdcontrol/cdcontrol.c
+++ b/usr.sbin/cdcontrol/cdcontrol.c
@@ -16,16 +16,20 @@
* 11-Oct-1995: Serge V.Vakulenko <vak@cronyx.ru>
* New eject algorithm.
* Some code style reformatting.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <ctype.h>
+#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <errno.h>
#include <sys/file.h>
#include <sys/cdio.h>
#include <sys/ioctl.h>
@@ -96,8 +100,6 @@ int fd = -1;
int verbose = 1;
int msf = 1;
-extern char *__progname;
-
int setvol __P((int, int));
int read_toc_entrys __P((int));
int play_msf __P((int, int, int, int, int, int));
@@ -144,14 +146,7 @@ void help ()
void usage ()
{
- printf ("Usage:\n\t%s [ -vs ] [ -f disc ] [ command args... ]\n", __progname);
- 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 ();
+ fprintf (stderr, "usage: cdcontrol [-vs] [-f disc] [command args ...]\n");
exit (1);
}
@@ -195,8 +190,7 @@ int main (int argc, char **argv)
if (! cdname) {
cdname = DEFAULT_CD_DRIVE;
- fprintf (stderr,
- "No CD device name specified. Defaulting to %s.\n", cdname);
+ warnx("no CD device name specified, defaulting to %s", cdname);
}
if (argc > 0) {
@@ -232,7 +226,7 @@ int main (int argc, char **argv)
arg = input (&cmd);
if (run (cmd, arg) < 0) {
if (verbose)
- perror (__progname);
+ warn(NULL);
close (fd);
fd = -1;
}
@@ -304,7 +298,7 @@ int run (int cmd, char *arg)
if (! strcasecmp (arg, "off"))
return ioctl (fd, CDIOCCLRDEBUG);
- printf ("%s: Invalid command arguments\n", __progname);
+ warnx("invalid command arguments");
return (0);
@@ -345,7 +339,7 @@ int run (int cmd, char *arg)
else if (! strcasecmp (arg, "lba"))
msf = 0;
else
- printf ("%s: Invalid command arguments\n", __progname);
+ warnx("invalid command arguments");
return (0);
case CMD_VOLUME:
@@ -368,7 +362,7 @@ int run (int cmd, char *arg)
return ioctl (fd, CDIOCSETMUTE);
if (2 != sscanf (arg, "%d %d", &l, &r)) {
- printf ("%s: Invalid command arguments\n", __progname);
+ warnx("invalid command arguments");
return (0);
}
@@ -660,7 +654,7 @@ Try_Absolute_Timed_Addresses:
return (play_track (start, istart, end, iend));
Clean_up:
- printf ("%s: Invalid command arguments\n", __progname);
+ warnx("invalid command arguments");
return (0);
}
@@ -737,7 +731,7 @@ int info (char *arg)
printf ("%d %d %d\n", h.starting_track,
h.ending_track, h.len);
} else {
- perror ("getting toc header");
+ warn("getting toc header");
return (rc);
}
@@ -911,7 +905,7 @@ char *input (int *cmd)
do {
if (verbose)
- fprintf (stderr, "%s> ", __progname);
+ fprintf (stderr, "cdcontrol> ");
if (! fgets (buf, sizeof (buf), stdin)) {
*cmd = CMD_QUIT;
fprintf (stderr, "\r\n");
@@ -963,7 +957,7 @@ char *parse (char *buf, int *cmd)
/* Try short hand forms then... */
if (len >= c->min && ! strncasecmp (buf, c->name, len)) {
if (*cmd != -1 && *cmd != c->command) {
- fprintf (stderr, "Ambiguous command\n");
+ warnx("ambiguous command");
return (0);
}
*cmd = c->command;
@@ -971,8 +965,7 @@ char *parse (char *buf, int *cmd)
}
if (*cmd == -1) {
- fprintf (stderr, "%s: Invalid command, enter ``help'' for commands.\n",
- __progname);
+ warnx("invalid command, enter ``help'' for commands");
return (0);
}
@@ -1007,11 +1000,10 @@ int open_cd ()
/* ENXIO has an overloaded meaning here.
* The original "Device not configured" should
* 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);
}
- perror (devbuf);
- exit (1);
+ err(1, "%s", devbuf);
}
return (1);
}