Import uudeview, from Mikolaj Kucharski.

ok zhuk@ on a previous version.

uudeview is program at which you can throw a mess of unordered files in
any of BinHex, uuencoded, xxencoded, Base64 or yEnc formats and expect
them all to be properly decoded. These formats are frequently
encountered when sending binary files via news or mail.
This commit is contained in:
jca 2014-11-20 21:14:54 +00:00
parent 7ac95f3a95
commit 8025c6e55e
14 changed files with 412 additions and 0 deletions

View File

@ -0,0 +1,27 @@
# $OpenBSD: Makefile,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
COMMENT = uu/xx/Base64/BinHex/yEnc decoder and encoder
DISTNAME = uudeview-0.5.20
CATEGORIES = converters
HOMEPAGE = http://www.fpx.de/fp/Software/UUDeview/
MAINTAINER = Mikolaj Kucharski <mikolaj@kucharski.name>
# GPLv2+, with BSD parts
PERMIT_PACKAGE_CDROM = Yes
WANTLIB = c m
MASTER_SITES = ${HOMEPAGE}download/
CONFIGURE_STYLE = autoconf dest
AUTOCONF_VERSION = 2.13
CONFIGURE_ARGS = --disable-tcl \
--enable-inews=inew
NO_TEST = Yes
.include <bsd.port.mk>

View File

@ -0,0 +1,2 @@
SHA256 (uudeview-0.5.20.tar.gz) = 5JpRDd8nICKvIE6WYFvUVLtT2gs/4L5DcRV2hxDa5DU=
SIZE (uudeview-0.5.20.tar.gz) = 261574

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-config_h_in,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- mkstemp(3) support
--- config.h.in.orig Mon Jun 4 18:29:33 2001
+++ config.h.in Mon Jan 27 21:44:49 2014
@@ -126,6 +126,9 @@
/* Define if you have the isatty function. */
#undef HAVE_ISATTY
+/* Define if you have the mkstemp function. */
+#undef HAVE_MKSTEMP
+
/* Define if you have the popen function. */
#undef HAVE_POPEN

View File

@ -0,0 +1,15 @@
$OpenBSD: patch-configure_in,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- mkstemp(3) support
--- configure.in.orig Tue Mar 2 00:06:18 2004
+++ configure.in Mon Jan 27 21:44:48 2014
@@ -507,7 +507,7 @@ AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(fcntl.h unistd.h memory.h malloc.h errno.h direct.h)
AC_CHECK_HEADERS(io.h sys/time.h)
-AC_CHECK_FUNCS(getcwd popen gettimeofday isatty)
+AC_CHECK_FUNCS(getcwd popen gettimeofday isatty mkstemp)
AC_CHECK_FUNC(tempnam,,AC_DEFINE(tempnam,_FP_tempnam))

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-man_uudeview_1,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- Debian patch
--- man/uudeview.1.orig Sun Apr 13 01:18:29 2003
+++ man/uudeview.1 Mon Jan 27 21:44:47 2014
@@ -164,6 +164,16 @@ delivered in have different subject lines.
verbosity. Normally, the program prints some status messages
while reading the input files, which can be very helpful if something
should go wrong. Use if these messages disturb you.
+Disables progress bars. See
+.B -n
+option.
+.TP
+.B -v
+(disables Verbosity) Disables verbose messages, i.e. notes are not
+displayed, but does not remove warnings and errors. Is not as quiet as
+the
+.B -q
+(Quiet) option.
.TP
.B -n
No progress bars. Normally, UUDeview prints ASCII bars crawling up

View File

@ -0,0 +1,84 @@
$OpenBSD: patch-unix_uudeview_c,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- mkstemp(3) support
- Debian patch
--- unix/uudeview.c.orig Sun Apr 13 01:33:55 2003
+++ unix/uudeview.c Mon Jan 27 21:44:47 2014
@@ -443,18 +443,45 @@ proc_stdin (void)
FILE *target;
size_t bytes;
int res;
+#ifdef HAVE_MKSTEMP
+ int tmpfd;
+ const char *tmpprefix = "uuXXXXXXXXXX";
+ char *tmpdir = NULL;
+#endif /* HAVE_MKSTEMP */
if (stdinput) {
fprintf (stderr, "proc_stdin: cannot process stdin twice\n");
return 0;
}
+#ifdef HAVE_MKSTEMP
+ if ((getuid()==geteuid()) && (getgid()==getegid())) {
+ tmpdir=getenv("TMPDIR");
+ }
+
+ if (!tmpdir) {
+ tmpdir = "/tmp";
+ }
+ stdfile = malloc(strlen(tmpdir)+strlen(tmpprefix)+2);
+
+ if (!stdfile) {
+#else
if ((stdfile = tempnam (NULL, "uu")) == NULL) {
+#endif
fprintf (stderr, "proc_stdin: cannot get temporary file\n");
return 0;
}
+#ifdef HAVE_MKSTEMP
+ strcpy(stdfile, tmpdir);
+ strcat(stdfile, "/");
+ strcat(stdfile, tmpprefix);
+
+ if ((tmpfd = mkstemp(stdfile)) == -1 ||
+ (target = fdopen(tmpfd, "wb")) == NULL) {
+#else
if ((target = fopen (stdfile, "wb")) == NULL) {
+#endif
fprintf (stderr, "proc_stdin: cannot open temp file %s for writing: %s\n",
stdfile, strerror (errno));
_FP_free (stdfile);
@@ -657,9 +684,6 @@ work_comline (int argc, char *argv[])
else switch (*(argv[number] + 1)) {
case '\0':
interact = 0;
- if (overwrite == 0) {
- overwrite = 1;
- }
proc_stdin ();
break;
case 'a':
@@ -699,10 +723,7 @@ work_comline (int argc, char *argv[])
fprintf (stderr, "WARNING: cannot interact when reading from stdin\n");
}
else {
- interact = (*argv[number] == '+') ? 1 : 0;
- if (overwrite == 0 && *argv[number] == '-') {
- overwrite = 1;
- }
+ interact = (*argv[number] == '+') ? 1 : 0;
}
break;
case 'm':
@@ -773,6 +794,8 @@ work_comline (int argc, char *argv[])
break;
}
}
+ if (overwrite == 0 && interact == 0 && autoren == 0)
+ overwrite = 1;
return 1;
}

View File

@ -0,0 +1,15 @@
$OpenBSD: patch-unix_uuenview_c,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- arbitrary string being passed as a format string to fprintf(3), patch from Debian
--- unix/uuenview.c.orig Wed Mar 6 13:52:46 2002
+++ unix/uuenview.c Tue Nov 18 23:24:07 2014
@@ -483,7 +483,7 @@ AttachFiles (char *towhom, char *subject,
if (_FP_stristr (input, "multipart") != NULL) {
/* it is already a multipart posting. grab the boundary */
if ((ptr = _FP_stristr (input, "boundary=")) != NULL) {
- fprintf(thepipe, input);
+ fprintf(thepipe, "%s", input);
strcpy (boundary, ParseValue (ptr));
hadmulti = 1;
}

View File

@ -0,0 +1,55 @@
$OpenBSD: patch-uulib_uulib_c,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- renaming file, if it's on the same filesystem, instead of copying
- fix problem with long headers, patch from Debian, but originally from
http://nget.sourceforge.net/Changelog.html and
http://nget.sf.net/patches/uulib-0.5.19-uuinfofile-long-headers.patch
--- uulib/uulib.c.orig Tue Sep 30 01:27:47 2003
+++ uulib/uulib.c Mon Jan 27 21:44:47 2014
@@ -872,7 +872,10 @@ UUDecodeToTemp (uulist *thefile)
}
/*
- * decode file first to temp file, then copy it to a final location
+ * Decode file first to temp file, then copy it to a final location.
+ * A move is preferable to a copy. If the file is on the same
+ * partition, no copy is performed. This is important for large
+ * files.
*/
int UUEXPORT
@@ -978,6 +981,12 @@ UUDecodeFile (uulist *thefile, char *destname)
return UURET_IOERR;
}
+ if (rename(thefile->binfile, uugen_fnbuffer) == 0) {
+ fclose(source);
+ close(fildes);
+ goto finish_ok;
+ }
+
if ((target = fdopen (fildes, "wb")) == NULL) {
progress.action = 0;
UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
@@ -1042,6 +1051,8 @@ UUDecodeFile (uulist *thefile, char *destname)
thefile->binfile,
strerror (uu_errno = errno));
}
+
+ finish_ok:
_FP_free (thefile->binfile);
thefile->binfile = NULL;
thefile->state &= ~UUFILE_TMPFILE;
@@ -1103,9 +1114,9 @@ UUInfoFile (uulist *thefile, void *opaque,
while (!feof (inpfile) &&
(uu_fast_scanning || ftell(inpfile) < maxpos)) {
- if (_FP_fgets (uugen_inbuffer, 511, inpfile) == NULL)
+ if (_FP_fgets (uugen_inbuffer, 1023, inpfile) == NULL)
break;
- uugen_inbuffer[511] = '\0';
+ uugen_inbuffer[1023] = '\0';
if (ferror (inpfile))
break;

View File

@ -0,0 +1,120 @@
$OpenBSD: patch-uulib_uunconc_c,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- mkstemp(3) support
- Debian patch
--- uulib/uunconc.c.orig Mon Mar 1 23:52:27 2004
+++ uulib/uunconc.c Mon Jan 27 21:44:47 2014
@@ -1311,6 +1311,11 @@ UUDecode (uulist *data)
char *mode, *ntmp;
uufile *iter;
size_t bytes;
+#ifdef HAVE_MKSTEMP
+ int tmpfd;
+ const char *tmpprefix = "uuXXXXXXXXXX";
+ char *tmpdir = NULL;
+#endif /* HAVE_MKSTEMP */
if (data == NULL || data->thisfile == NULL)
return UURET_ILLVAL;
@@ -1329,13 +1334,35 @@ UUDecode (uulist *data)
else
mode = "wb"; /* otherwise in binary */
+#ifdef HAVE_MKSTEMP
+ if ((getuid()==geteuid()) && (getgid()==getegid())) {
+ tmpdir=getenv("TMPDIR");
+ }
+
+ if (!tmpdir) {
+ tmpdir = "/tmp";
+ }
+ data->binfile = malloc(strlen(tmpdir)+strlen(tmpprefix)+2);
+
+ if (!data->binfile) {
+#else
if ((data->binfile = tempnam (NULL, "uu")) == NULL) {
+#endif /* HAVE_MKSTEMP */
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR,
uustring (S_NO_TEMP_NAME));
return UURET_NOMEM;
}
+#ifdef HAVE_MKSTEMP
+ strcpy(data->binfile, tmpdir);
+ strcat(data->binfile, "/");
+ strcat(data->binfile, tmpprefix);
+
+ if ((tmpfd = mkstemp(data->binfile)) == -1 ||
+ (dataout = fdopen(tmpfd, mode)) == NULL) {
+#else
if ((dataout = fopen (data->binfile, mode)) == NULL) {
+#endif /* HAVE_MKSTEMP */
/*
* we couldn't create a temporary file. Usually this means that TMP
* and TEMP aren't set
@@ -1343,6 +1370,12 @@ UUDecode (uulist *data)
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR,
uustring (S_WR_ERR_TARGET),
data->binfile, strerror (uu_errno = errno));
+#ifdef HAVE_MKSTEMP
+ if (tmpfd != -1) {
+ unlink(data->binfile);
+ close(tmpfd);
+ }
+#endif /* HAVE_MKSTEMP */
_FP_free (data->binfile);
data->binfile = NULL;
uu_errno = errno;
@@ -1437,6 +1470,9 @@ UUDecode (uulist *data)
res = UURET_IOERR;
break;
}
+ UUMessage (uunconc_id, __LINE__, UUMSG_MESSAGE,
+ uustring (S_OPEN_FILE),
+ iter->data->sfname);
_FP_strncpy (uugen_fnbuffer, iter->data->sfname, 1024);
}
@@ -1496,7 +1532,13 @@ UUDecode (uulist *data)
*/
if (data->uudet == BH_ENCODED && data->binfile) {
+#ifdef HAVE_MKSTEMP
+ ntmp = malloc(strlen(tmpdir)+strlen(tmpprefix)+2);
+
+ if (ntmp == NULL) {
+#else
if ((ntmp = tempnam (NULL, "uu")) == NULL) {
+#endif /* HAVE_MKSTEMP */
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR,
uustring (S_NO_TEMP_NAME));
progress.action = 0;
@@ -1510,12 +1552,27 @@ UUDecode (uulist *data)
free (ntmp);
return UURET_IOERR;
}
+
+#ifdef HAVE_MKSTEMP
+ strcpy(ntmp, tmpdir);
+ strcat(ntmp, "/");
+ strcat(ntmp, tmpprefix);
+ if ((tmpfd = mkstemp(ntmp)) == -1 ||
+ (dataout = fdopen(tmpfd, "wb")) == NULL) {
+#else
if ((dataout = fopen (ntmp, "wb")) == NULL) {
+#endif /* HAVE_MKSTEMP */
UUMessage (uunconc_id, __LINE__, UUMSG_ERROR,
uustring (S_NOT_OPEN_TARGET),
ntmp, strerror (uu_errno = errno));
progress.action = 0;
fclose (datain);
+#ifdef HAVE_MKSTEMP
+ if (tmpfd != -1) {
+ unlink(ntmp);
+ close(tmpfd);
+ }
+#endif /* HAVE_MKSTEMP */
free (ntmp);
return UURET_IOERR;
}

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-uulib_uuscan_c,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- Debian patch
--- uulib/uuscan.c.orig Mon Mar 1 23:52:27 2004
+++ uulib/uuscan.c Mon Jan 27 21:44:47 2014
@@ -387,10 +387,10 @@ ParseValue (char *attribute)
*attribute != '(' && *attribute != ')' &&
*attribute != '<' && *attribute != '>' &&
*attribute != '@' && *attribute != ',' &&
- /* *attribute != ';' && */ *attribute != ':' &&
- *attribute != '\\' &&*attribute != '"' &&
- *attribute != '/' && /* *attribute != '[' &&
- *attribute != ']' && */ *attribute != '?' &&
+ *attribute != ';' && *attribute != ':' &&
+ *attribute != '\\' && *attribute != '"' &&
+ *attribute != '/' && *attribute != '[' &&
+ *attribute != ']' && *attribute != '?' &&
*attribute != '=' && length < 255) {
*ptr++ = *attribute++;
length++;

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-uulib_uustring_c,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- Debian patch
--- uulib/uustring.c.orig Mon Mar 11 10:15:47 2002
+++ uulib/uustring.c Mon Jan 27 21:44:47 2014
@@ -107,6 +107,7 @@ static stringmap messages[] = {
{ S_MIME_B_NOT_FOUND, "Boundary expected on Multipart message but found EOF" },
{ S_MIME_MULTI_DEPTH, "Multipart message nested too deep" },
{ S_MIME_PART_MULTI, "Handling partial multipart message as plain text" },
+ { S_OPEN_FILE, "Opened file %s" },
{ 0, "" }
};

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-uulib_uustring_h,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
- Debian patch
--- uulib/uustring.h.orig Tue Apr 2 12:04:53 2002
+++ uulib/uustring.h Mon Jan 27 21:44:47 2014
@@ -36,3 +36,4 @@
#define S_MIME_B_NOT_FOUND 35
#define S_MIME_MULTI_DEPTH 36
#define S_MIME_PART_MULTI 37
+#define S_OPEN_FILE 38

View File

@ -0,0 +1,4 @@
uudeview is program at which you can throw a mess of unordered files in
any of BinHex, uuencoded, xxencoded, Base64 or yEnc formats and expect
them all to be properly decoded. These formats are frequently
encountered when sending binary files via news or mail.

View File

@ -0,0 +1,5 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $
@bin bin/uudeview
@bin bin/uuenview
@man man/man1/uudeview.1
@man man/man1/uuenview.1