Article View: comp.sources.atari.st
Article #143v03i002: uurename -- Rename binary postings to work with uud
From: Steven Grimm
Date: Tue, 31 Oct 1989 23:49
Date: Tue, 31 Oct 1989 23:49
82 lines
3221 bytes
3221 bytes
Submitted-by: sun!pyramid!actisb!federico (Federico Heinz)
Posting-number: Volume 3, Issue 2
Archive-name: uurename
Here's a tiny utility I wrote to help unpacking files from an
archive server. You certainly know the problem: 'uud' expects all
files except the first one to have a certain name, and that name is
always different from the one you chose, no matter what you chose.
With this program it's over: just name the files as you choose, for
instance 'part01', 'part02',..., then type 'uurename part*', and you
are done. All files have now their correct names, except for the ones
that start a file (those not starting with 'begin part...' but just
'begin <permission> <name>'). All you have to do now is run uud on
these 'partNN' files. Of course, this works only for files encoded
with Dumas uuencode, and I have found some weirdly packed files that
cause trouble, but it works most of the time, and even when it fails
it does some useful work. After all, it's pretty trivial.
The executable is there also for people without Sozobon C or Dlibs.
The source compiled also on our BSD machine, but you must change the
directory delimiter from '\' to '/'.
#!/bin/sh
# shar: Shell Archiver (v1.22)
#
# Run the following text with /bin/sh to create:
# uurename.c
#
sed 's/^X//' << 'SHAR_EOF' > uurename.c &&
X#include <stdio.h>
X
Xstatic char buffer[200];
X
Xstatic void buildname(target, source, name)
Xchar *target, *source, *name;
X{
X char *nameTarget;
X
X nameTarget = target;
X while (*source)
X if ((*(target++) = *(source++)) == '\\')
X nameTarget = target;
X strcpy(nameTarget, name);
X}
X
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X int i;
X char newname[20];
X FILE *fp;
X char drive[4], path[128], file[10], ext[4];
X
X for (i=1; i < argc; i++)
X {
X if ((fp = fopen(argv[i], "r")) == NULL)
X fprintf(stderr, "Unable to open: %s.\n", argv[i]);
X else
X {
X while (fgets(buffer, 200, fp) != NULL)
X {
X if (!strncmp(buffer, "begin ", 6))
X {
X if (sscanf(buffer, "begin part %*s %s", newname) == 1)
X {
X buildname(buffer, argv[i], newname);
X if (rename(argv[i], buffer) != 0)
X fprintf(stderr, "Cannot move %s to %s.\n",
X argv[i], buffer);
X }
X break;
X }
X }
X fclose(fp);
X }
X }
X}
SHAR_EOF
chmod 0600 uurename.c || echo "restore of uurename.c fails"
exit 0
Technical Details
Message-ID:
<34656@grapevine.uucp>Path:
arc1-ca.pugleaf.net!wuarchive!brutus.cs.uiuc.edu!apple!sun-barr!newstop!sun!grapevine!koreth@panarthea.ebay.sun.comShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wuarchive!brutus.cs.uiuc.edu!apple!sun-barr!newstop!sun!grapevine!koreth@panarthea.ebay.sun.com From: koreth@panarthea.ebay.sun.com (Steven Grimm) Newsgroups: comp.sources.atari.st Subject: v03i002: uurename -- Rename binary postings to work with uud Keywords: shar, C Message-ID: <34656@grapevine.uucp> Date: 31 Oct 89 23:49:26 GMT Sender: news@grapevine.EBay Reply-To: sun!pyramid!actisb!federico (Federico Heinz) Lines: 82 Approved: koreth@panarthea.ebay.sun.com