Add a -p option to uudecode(1), which causes it to write decoded data to

stdout; based on PR bin/7183 from SUNAGAWA Keiki.
This commit is contained in:
kleink 1999-03-18 23:57:11 +00:00
parent 2d72cb3172
commit 5c39723cec
2 changed files with 22 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uudecode.c,v 1.10 1999/01/20 15:59:00 hubertf Exp $ */
/* $NetBSD: uudecode.c,v 1.11 1999/03/18 23:57:11 kleink Exp $ */
/*-
* Copyright (c) 1983, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "@(#)uudecode.c 8.2 (Berkeley) 4/2/94";
#endif
__RCSID("$NetBSD: uudecode.c,v 1.10 1999/01/20 15:59:00 hubertf Exp $");
__RCSID("$NetBSD: uudecode.c,v 1.11 1999/03/18 23:57:11 kleink Exp $");
#endif /* not lint */
/*
@ -69,6 +69,7 @@ static int decode __P((void));
static void usage __P((void));
int main __P((int, char **));
int pflag;
char *filename;
int
@ -76,12 +77,19 @@ main(argc, argv)
int argc;
char *argv[];
{
int rval;
int ch, rval;
setlocale(LC_ALL, "");
while (getopt(argc, argv, "") != -1)
usage();
pflag = 0;
while ((ch = getopt(argc, argv, "p")) != -1)
switch (ch) {
case 'p':
pflag = 1;
break;
default:
usage();
}
argc -= optind;
argv += optind;
@ -163,8 +171,8 @@ decode()
}
/* create output file, set mode */
if (!freopen(fn, "w", stdout) ||
fchmod(fileno(stdout), mode&0666)) {
if (!pflag && (!freopen(buf, "w", stdout) ||
fchmod(fileno(stdout), mode & 0666))) {
warnx("%s: %s", fn, filename);
return(1);
}
@ -216,6 +224,6 @@ decode()
static void
usage()
{
(void)fprintf(stderr, "usage: uudecode [file ...]\n");
(void)fprintf(stderr, "usage: uudecode [ -p ] [ file ... ]\n");
exit(1);
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: uuencode.1,v 1.7 1997/11/01 06:32:13 mycroft Exp $
.\" $NetBSD: uuencode.1,v 1.8 1999/03/18 23:57:12 kleink Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -33,7 +33,7 @@
.\"
.\" @(#)uuencode.1 8.1 (Berkeley) 6/6/93
.\"
.Dd June 6, 1993
.Dd March 19, 1999
.Dt UUENCODE 1
.Os BSD 4
.Sh NAME
@ -45,6 +45,7 @@
.Op Ar file
.Ar name
.Nm uudecode
.Op Fl p
.Op Ar file ...
.Sh DESCRIPTION
.Nm
@ -75,7 +76,9 @@ files (or by default, the standard input) into the original form.
The resulting file is named
.Ar name
and will have the mode of the original file except that setuid
and execute bits are not retained.
and execute bits are not retained; if the
.Fl p
option is specified, the data will be written to the standard output.
.Nm uudecode
ignores any leading and trailing lines.
.Sh EXAMPLES