Audit uudecode(1)
Style cleanup, Manpage refactoring.
This commit is contained in:
parent
4af8889396
commit
1b71559431
2
README
2
README
|
@ -84,7 +84,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
|
|||
#*| unexpand yes none
|
||||
=*| uniq yes none
|
||||
=*| unlink yes none
|
||||
=* uudecode yes none
|
||||
=*| uudecode yes none
|
||||
=* uuencode yes none
|
||||
#* wc yes none
|
||||
= xargs no -I, -L, -p, -s, -t, -x
|
||||
|
|
24
uudecode.1
24
uudecode.1
|
@ -1,4 +1,4 @@
|
|||
.Dd February 13, 2015
|
||||
.Dd March 18, 2015
|
||||
.Dt UUDECODE 1
|
||||
.Os sbase
|
||||
.Sh NAME
|
||||
|
@ -13,23 +13,27 @@
|
|||
.Nm
|
||||
reads
|
||||
.Ar file
|
||||
(or by default, the standard input) and writes a decoded
|
||||
version to the file specified in the uuencoded header. In case that
|
||||
the file already exists, it is truncated. Otherwise a new file is
|
||||
created. After the operation the permissions of the created/accessed
|
||||
are changed to reflect the mode in the header.
|
||||
and writes a decoded version to the file specified in the uuencoded header.
|
||||
In case the file already exists, it is truncated. Otherwise a new file is
|
||||
created. The permissions of the created/accessed file are changed to
|
||||
reflect the mode in the header.
|
||||
If no
|
||||
.Ar file
|
||||
is given
|
||||
.Nm
|
||||
reads from stdin.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl m
|
||||
Use Base64 for decoding.
|
||||
.It Fl o Ar output
|
||||
Use the file specified by
|
||||
Write to
|
||||
.Ar output
|
||||
instead of standard output.
|
||||
rather than the file specified in the header.
|
||||
.El
|
||||
.Sh IMPLEMENTATION NOTES
|
||||
For safety currently uudecode operates only on regular files and
|
||||
stdout. Trying to uudecode to a link, directory, or special file
|
||||
For safety uudecode operates on regular files and stdout only.
|
||||
Trying to uudecode to a link, directory, or special file
|
||||
yields an error.
|
||||
.Sh SEE ALSO
|
||||
.Xr uuencode 1
|
||||
|
|
13
uudecode.c
13
uudecode.c
|
@ -17,7 +17,7 @@ parsefile(const char *fname)
|
|||
struct stat st;
|
||||
int ret;
|
||||
|
||||
if (strcmp(fname, "/dev/stdout") == 0 || strcmp(fname, "-") == 0)
|
||||
if (!strcmp(fname, "/dev/stdout") || !strcmp(fname, "-"))
|
||||
return stdout;
|
||||
ret = lstat(fname, &st);
|
||||
/* if it is a new file, try to open it */
|
||||
|
@ -36,8 +36,7 @@ tropen:
|
|||
}
|
||||
|
||||
static void
|
||||
parseheader(FILE *fp, const char *s, char **header, mode_t *mode,
|
||||
char **fname)
|
||||
parseheader(FILE *fp, const char *s, char **header, mode_t *mode, char **fname)
|
||||
{
|
||||
char bufs[PATH_MAX + 18]; /* len header + mode + maxname */
|
||||
char *p, *q;
|
||||
|
@ -212,7 +211,7 @@ uudecode(FILE *fp, FILE *outfp)
|
|||
}
|
||||
/* check for end or fail */
|
||||
len = getline(&bufb, &n, fp);
|
||||
if (len < 3 || strncmp(bufb, "end", 3) != 0 || bufb[3] != '\n')
|
||||
if (len < 3 || strncmp(bufb, "end", 3) || bufb[3] != '\n')
|
||||
eprintf("invalid uudecode footer \"end\" not found\n");
|
||||
free(bufb);
|
||||
}
|
||||
|
@ -227,11 +226,9 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fp = NULL, *nfp = NULL;
|
||||
char *fname, *header;
|
||||
const char *ifname;
|
||||
mode_t mode = 0;
|
||||
char *fname, *header, *ifname, *ofname = NULL;
|
||||
void (*d) (FILE *, FILE *) = NULL;
|
||||
char *ofname = NULL;
|
||||
|
||||
ARGBEGIN {
|
||||
case 'm':
|
||||
|
@ -248,7 +245,7 @@ main(int argc, char *argv[])
|
|||
if (argc > 1)
|
||||
usage();
|
||||
|
||||
if (argc == 0) {
|
||||
if (!argc) {
|
||||
fp = stdin;
|
||||
ifname = "<stdin>";
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user