(* TURBO pascal version of MSBMKB *)
(* *)
(* Author: Gisbert W.Selke (RECK@DBNUAMA1.BITNET) *)
(* Wissenschaftliches Institut der Ortskrankenkassen *)
(* Kortrijker Strasse 1 *)
(* D-5300 Bonn 1 *)
(* West Germany *)
(* 10 February 1988 *)
(* RECK@DBNUAMA1.BITNET *)
(* *)
(* Produces boo-encoding of a binary file for transfer over *)
(* data links. Beware of EBCDIC <-> ASCII gremlins, however!*)
(* *)
(* Version 1.2: change for Turbo-Pascal 4.0 *)
(* *)
(*$S-*) (* stack checking off *)
(*$R-*) (* Range checking off *)
(*$B-*) (* Boolean complete evaluation off *)
(*$I+*) (* I/O checking on *)
(*$N-*) (* No numeric coprocessor *)
(*$M 65500,16384,16384*) (* Reduce maximum heap *)
program msbmkb;
uses crt;
const repchar : char = '~';
nullbyte : byte = $00;
b2 : byte = $03;
b4 : byte = $0F;
b6 : byte = $3F;
blocksize = 128;
offset = 48; (* ord('0') *)
maxrep = 78;
bufsize = 32000;
maxlinlength = 76;
defaultext = '.BOO';
type buftype = array (.1..bufsize.) of byte;
var a, b, c : byte;
bytect, buffct, restbytes, maxblocks, bbufsize, linlength, repct : integer;
fs, rin, rout : longint;
reff : real;
isend,preend : boolean;
infilename, outfilename, sname : string(.63.);
(* maximum path length in DOS *)
buffer, outbuffer : buftype;
infile : file;
outfile : text;
function getbyte : byte;
(* get one byte from input stream; mark eof and yield 0 afterwards *)
var ires : word;
begin (* getbyte *)
if isend then
begin (* end of file *)
getbyte := nullbyte;
exit;
end; (* end of file *)
if bytect >= bbufsize then
begin (* read next buffer *)
if preend then
begin (* end of file *)
getbyte := 0;
isend := true;
exit;
end; (* end of file *)
blockread(infile,buffer,maxblocks,ires);
if ires <> maxblocks then
begin (* last buffer! *)
preend := true;
bbufsize := restbytes;
end; (* last buffer! *)
bytect := 0;
inc(buffct);
write(chr(13),'Buffer ',buffct);
end; (* read next buffer *)
inc(bytect);
getbyte := buffer(.bytect.);
end; (* getbyte *)
procedure prepare;
(* get input and output file names; open files; get input file size *)
procedure getnames;
(* get input and output file names from command line *)
var i : integer;
begin (* getnames *)
if not (paramcount in (.1..2.)) then
Begin (* argument number error *)
writeln('Wrong number of parameters.');
writeln('Usage: MSBMKB (