home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
util
/
uuinout-1.03.lha
/
uuInOut
/
uuPrepare.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1993-12-08
|
4KB
|
107 lines
/*******************************************************************\
$VER: 1.03 (8.12.93) by Nicolas Dade. This is public domain
This arexx program prepares a binary file for posting by
uuencoding it, breaking it up into multiple parts, and giving
each part a nice header and tail.
Feel free to modify the headline and tailline to your taste.
Please note that the total number of parts is not available in
this program. To know it requires that uuIn have finished encoding,
and this program is pipe: driven, so uuIn is not finished when the
headline and tailline are created. This means that your head and
tail lines cannot say something like "part X of Y". If you really
want this, you'll have to change the program so that uuIn is run to
completion, leaving its output in "t:", then the number of output
files is counted, and finally the files in "t:" have the header,
headline and tailline added to them as they are copied to the final
destination.
This program requires the program uuIn to be somewhere in your
path, since it uses uuIn to uuencode and split the files.
use: (from a shell)
rx uuPrepare binaryfile headerfile
produces outputs called binaryfile.uu1, binaryfile.uu2, ... . Each file
consists of a copy of headerfile, the headline, about NOMINAL_LINES_PER-
_FILE or fewer lines of uuencoded data, and the tailline.
A headerfile is not required.
\*******************************************************************/
/* each file has slightly more than NOMINAL_LINES_PER_FILE lines */
NOMINAL_LINES_PER_FILE = 700
/* I do my IO in IO_SIZE chunks. IO_SIZE should be at least 25 bytes */
IO_SIZE=16000
parse arg binaryname headertextname .
/* create a few names */
dataname=right(binaryname,length(binaryname)-max(lastpos(':',binaryname),lastpos('/',binaryname)))
pipebasename = 'pipe:uuPrepare'||pragma('ID')||dataname'.uu'
/* start the file encoding process */
address command 'run uuIn INFILE="'binaryname'" OUTFILE="'pipebasename'" MAXLINES='NOMINAL_LINES_PER_FILE' NORENAME'
if rc>0 then do
say 'uuPrepare ABORTING: run uuIn failed'
exit 10
end
/* pull part-files out of the pipes, adding headers and tailers */
do partnum=1
inpartname = pipebasename||partnum
outpartname = binaryname||'.uu'||partnum
say 'uuPreparing part 'partnum' of "'binaryname'" into "'outpartname'" (from "'inpartname'")'
if ~open('inpart',inpartname,'R') then do
say 'uuPrepare ABORTING after 'partnum-1' parts: couldn''t open "'inpartname'"'
exit 10
end
if ~open('outpart',outpartname,'W') then do
say 'uuPrepare aborting after 'partnum-1' parts: couldn''t open "'outpartname'"'
exit 10
end
/* copy header text file to the top of this part's file */
if headertextname~='' then do
if ~open('header',headertextname,'R') then do
say 'uuPrepare WARNING: couldn''t open headertextfile "'headertextname'"'
say 'there will be no header text in "'outpartname'"'
end
else do
do while ~eof('header')
writech('outpart',readch('header',IO_SIZE)) /* copy the header file */
end
close('header')
end
end
headline='----BEGIN----begin----'dataname'----part 'partnum'----'
if length(headline)<75 then headline=left(headline,65,'-') /* add -'s as needed */
writeln('outpart',headline)
data=''
last25data=''
do while ~eof('inpart')
/* move some data */
data=readch('inpart',IO_SIZE)
writech('outpart',data)
/* keep the last 25 bytes of the file around so that we can check for the 'end' line */
if length(data)>=25 then last25data=right(data,25)
else last25data=right(last25data||data,25,' ')
end
tailline='-----END------end-----'dataname'----part 'partnum'----'
if length(tailline)<75 then tailline=left(tailline,65,'-')
writeln('outpart',tailline)
writeln('outpart','')
close('inpart')
close('outpart')
/* check to see if this was the last part by looking for an 'end' line in the data */
if pos('end',last25data)~=0 then leave
end
say 'uuPreparation of "'binaryname'" is finished'
exit 0