aboutsummaryrefslogtreecommitdiff
path: root/sbin/comcontrol/comcontrol.c
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1998-06-30 06:09:37 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1998-06-30 06:09:37 +0000
commitd286dcb026a85d14ab64e1f3bfb0a507834e3be6 (patch)
tree0bbef118339de9a209ceb55e01359e9e89e8d2aa /sbin/comcontrol/comcontrol.c
parentdf394affa248f24fd597b349ef3e04ff0e5a9476 (diff)
downloadsrc-d286dcb026a85d14ab64e1f3bfb0a507834e3be6.tar.gz
src-d286dcb026a85d14ab64e1f3bfb0a507834e3be6.zip
Add rcsid. Remove unused #includes. Use err(3).
Notes
Notes: svn path=/head/; revision=37273
Diffstat (limited to 'sbin/comcontrol/comcontrol.c')
-rw-r--r--sbin/comcontrol/comcontrol.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/sbin/comcontrol/comcontrol.c b/sbin/comcontrol/comcontrol.c
index 17c288274f13..372f984409e4 100644
--- a/sbin/comcontrol/comcontrol.c
+++ b/sbin/comcontrol/comcontrol.c
@@ -26,79 +26,83 @@
* SUCH DAMAGE.
*/
-/* comcontrol.c */
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <ctype.h>
+#include <err.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
-
-void usage(char *progname)
+static void
+usage()
{
- fprintf(stderr, "usage: %s <filename> [dtrwait <n>] [drainwait <n>]\n", progname);
+ fprintf(stderr,
+ "usage: comcontrol <filename> [dtrwait <n>] [drainwait <n>]\n");
exit(1);
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
int fd;
int res = 0;
int dtrwait = -1, drainwait = -1;
if (argc < 2)
- usage(argv[0]);
+ usage();
fd = open(argv[1], O_RDONLY|O_NONBLOCK, 0);
if (fd < 0) {
- perror("open");
- fprintf(stderr, "%s: couldn't open file %s\n", argv[0], argv[1]);
+ warn("couldn't open file %s", argv[1]);
return 1;
}
if (argc == 2) {
if (ioctl(fd, TIOCMGDTRWAIT, &dtrwait) < 0) {
res = 1;
- perror("TIOCMGDTRWAIT");
+ warn("TIOCMGDTRWAIT");
}
if (ioctl(fd, TIOCGDRAINWAIT, &drainwait) < 0) {
res = 1;
- perror("TIOCGDRAINWAIT");
+ warn("TIOCGDRAINWAIT");
}
printf("dtrwait %d drainwait %d\n", dtrwait, drainwait);
} else {
- char *prg = argv[0];
-
while (argv[2] != NULL) {
if (!strcmp(argv[2],"dtrwait")) {
if (dtrwait >= 0)
- usage(prg);
+ usage();
if (argv[3] == NULL || !isdigit(argv[3][0]))
- usage(prg);
+ usage();
dtrwait = atoi(argv[3]);
argv += 2;
} else if (!strcmp(argv[2],"drainwait")) {
if (drainwait >= 0)
- usage(prg);
+ usage();
if (argv[3] == NULL || !isdigit(argv[3][0]))
- usage(prg);
+ usage();
drainwait = atoi(argv[3]);
argv += 2;
} else
- usage(prg);
+ usage();
}
if (dtrwait >= 0) {
if (ioctl(fd, TIOCMSDTRWAIT, &dtrwait) < 0) {
res = 1;
- perror("TIOCMSDTRWAIT");
+ warn("TIOCMSDTRWAIT");
}
}
if (drainwait >= 0) {
if (ioctl(fd, TIOCSDRAINWAIT, &drainwait) < 0) {
res = 1;
- perror("TIOCSDRAINWAIT");
+ warn("TIOCSDRAINWAIT");
}
}
}