summaryrefslogtreecommitdiffstats
path: root/usr.bin/unvis
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-21 06:52:43 +0000
committercharnier <charnier@FreeBSD.org>1997-08-21 06:52:43 +0000
commit9a7cf30825bb8f5c255d09ef4f040d428b54ec1b (patch)
tree3a730a65713fe237b3a1438a6ef62f8a5f4a72be /usr.bin/unvis
parent16f9b719d4b26646987292816e374ae6cc6da035 (diff)
downloadFreeBSD-src-9a7cf30825bb8f5c255d09ef4f040d428b54ec1b.zip
FreeBSD-src-9a7cf30825bb8f5c255d09ef4f040d428b54ec1b.tar.gz
Use err(3) instead of local redefinition. Add usage().
Diffstat (limited to 'usr.bin/unvis')
-rw-r--r--usr.bin/unvis/unvis.14
-rw-r--r--usr.bin/unvis/unvis.c65
2 files changed, 23 insertions, 46 deletions
diff --git a/usr.bin/unvis/unvis.1 b/usr.bin/unvis/unvis.1
index 4f6a832..81b8252 100644
--- a/usr.bin/unvis/unvis.1
+++ b/usr.bin/unvis/unvis.1
@@ -38,8 +38,8 @@
.Nm unvis
.Nd "revert a visual representation of data back to original form"
.Sh SYNOPSIS
-.Nm unvis
-.Op Ar file ...
+.Nm
+.Op Ar
.Sh DESCRIPTION
.Nm Unvis
is the inverse function of
diff --git a/usr.bin/unvis/unvis.c b/usr.bin/unvis/unvis.c
index 5ea689b..cdec94c 100644
--- a/usr.bin/unvis/unvis.c
+++ b/usr.bin/unvis/unvis.c
@@ -32,37 +32,39 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
+#include <err.h>
#include <stdio.h>
+#include <unistd.h>
#include <vis.h>
-char *Program;
-#define usage() fprintf(stderr, "usage: %s %s\n", Program, USAGE)
-#define USAGE "[file...]"
+void process __P((FILE *, char *));
+static void usage __P((void));
+void
main(argc, argv)
char *argv[];
{
FILE *fp;
- extern char *optarg;
- extern int optind;
int ch;
- Program = argv[0];
while ((ch = getopt(argc, argv, "")) != -1)
switch((char)ch) {
case '?':
default:
usage();
- exit(1);
}
argc -= optind;
argv += optind;
@@ -72,7 +74,7 @@ main(argc, argv)
if ((fp=fopen(*argv, "r")) != NULL)
process(fp, *argv);
else
- syserror("%s", *argv);
+ warn("%s", *argv);
argv++;
}
else
@@ -80,6 +82,14 @@ main(argc, argv)
exit(0);
}
+static void
+usage()
+{
+ fprintf(stderr, "usage: unvis [file ...]\n");
+ exit(1);
+}
+
+void
process(fp, filename)
FILE *fp;
char *filename;
@@ -99,49 +109,16 @@ process(fp, filename)
putchar(outc);
goto again;
case UNVIS_SYNBAD:
- error("%s: offset: %d: can't decode", filename, offset);
+ warnx("%s: offset: %d: can't decode", filename, offset);
state = 0;
break;
case 0:
case UNVIS_NOCHAR:
break;
default:
- error("bad return value (%d), can't happen", ret);
- exit(1);
+ errx(1, "bad return value (%d), can't happen", ret);
}
}
if (unvis(&outc, (char)0, &state, UNVIS_END) == UNVIS_VALID)
putchar(outc);
}
-
-#include <varargs.h>
-
-error(va_alist)
- va_dcl
-{
- char *fmt;
- va_list ap;
- extern errno;
-
- fprintf(stderr, "%s: ", Program);
- va_start(ap);
- fmt = va_arg(ap, char *);
- (void) vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, "\n");
-}
-
-syserror(va_alist)
- va_dcl
-{
- char *fmt;
- va_list ap;
- extern errno;
-
- fprintf(stderr, "%s: ", Program);
- va_start(ap);
- fmt = va_arg(ap, char *);
- (void) vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, ": %s\n", strerror(errno));
-}
OpenPOWER on IntegriCloud