home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
TURBOPAS
/
SQZTURBO.LBR
/
USQZ.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
2000-06-30
|
10KB
|
240 lines
Program UnSqueeze; (* Written: 01/29/1986 15:59:57 *)
{
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[] Program UnSqueeze []
[] []
[] A file de-compression program. Compatible with CP/M or DOS, []
[] Turbo Pascal Version 2.0 and above. []
[] []
[] []
[] Bob Berry, CompuServe 76555,167 []
[] []
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
}
Const Version = 'Version 2.1 Last Update 01/29/1986';
PrinterToggle = '/P';
FormFeed = ^L;
Recognize = $FF76;
Recognize2 = $FFFA;
NumVals = 257; { max tree size + 1 }
SpEOF = 256; { special end of file marker }
DLE: char = #$90;
Space = ' ';
Type Tree = array [0..255,0..1] of integer;
HexStr = string[4];
FileName = string[30];
FlePtr = ^FileLst;
FileLst = Record
FNme: FileName;
NxtF: FlePtr;
end;
Var InFileName,
OutFileName,
FMask,
FileDateString,
AnotherString,
DrivePrefix,
OutDrive: FileName;
InFileSize,
OutFileSize: real;
DNode: Tree;
InChar, CurIn,
FileCkSum, Crc, BPos,
FileDate, FileTime,
i, RepCt, NumNodes: integer;
HeapTop: ^Integer;
FFirst, FLast, FCurrent: FlePtr;
LoggedDrive,
C, LastChar: char;
PrinterEcho, AllDone,
EoFile: boolean;
{
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[] Pick One: CP/M or DOS and comment out the one that doesn't apply []
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
}
(*
{$I cpm.inc }
*)
{$I dos.inc }
{$I usqzmain.inc }
Procedure Compress(Var TheString: FileName);
begin
While Pos(' ',TheString) > 0 do Delete(TheString,Pos(' ',TheString),1);
end; { Procedure Compress }
Procedure UnSqueeze;
begin
NumNodes:=ord(GetW);
If (NumNodes<0) or (NumNodes>=NumVals) then
begin
WriteLn('File has invalid decode tree size.');
CloseInFile;
end
else
begin
Assign(OutFile,OutFileName); ReWriteOutFile;
WriteLn;
WriteLn('The file ',InFileName,' (',InFileSize:6:0,
' bytes ) is being UnSqueezed to ',OutFilename);
DNode[0,0]:=-(succ(SpEOF));
DNode[0,1]:=-(succ(SpEOF));
NumNodes:=pred(NumNodes);
For i:=0 to NumNodes do begin DNode[i,0]:=GetW; DNode[i,1]:=GetW; end;
Crc:=0;
If FileDateString>'' then Write('[ File Date: ',FileDateString,' ] ');
Write('UnSqueezing,');
While not EOF(InFile) or (not EoFile) do
begin
C:=GetCr;
If not EoFile then begin WriteOutFile(C); Crc:=Crc+ord(C); end;
end;
CloseInFile; CloseOutFile;
WriteLn(' Done.');
If Crc<>FileCkSum then
begin
WriteLn('File CheckSum Was ',Hex(FileCkSum),', Is ',Hex(Crc));
end;
OutFileSize:=GetSizeOfOutFile;
WriteLn('The file ',OutFileName,' is',OutFileSize:6:0,
' bytes (',(100.0*OutFileSize/InFileSize):5:1,'%).');
end;
end; { Procedure UnSqueeze }
{
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[] UnSqueeze MainLine []
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
}
begin
ClrScr; GetLoggedDrive;
If CommandLine > '' then { Get InFileName from Command Line }
begin
WriteLn;
InFileName:=CommandLine;
For i:=1 to Length(InFileName) do
InFileName[i]:=UpCase(InFileName[i]);
PrinterEcho:= ( Pos(PrinterToggle,InFileName) > 0 );
If PrinterEcho then
begin
SetEchoToPrinter; Delete(InFileName,Pos(PrinterToggle,InFileName),2);
end;
Compress(InFileName);
end
else
begin
InFileName:=''; PrinterEcho:=False;
end;
Write('File UnSqueezer');
For i:=1 to 64-Length(Version) do Write(Space); WriteLn(Version);
Repeat
AllDone:=false;
If InFileName='' then
begin
WriteLn; Write('Enter file to UnSqueeze ( or <cr> to exit ) >');
ReadLn(InFileName);
For i:=1 to Length(InFileName) do InFileName[i]:=UpCase(InFileName[i]);
Compress(InFileName);
end;
If Pos('.',InFileName)=0 then InFileName:=InFileName+'.';
If Pos(':',InFileName)=0 then InFileName:=LoggedDrive+':'+InFileName;
DrivePrefix:=Copy(InFileName,1,2);
If Length(InFileName)<4 then AllDone:=true { <= Blank name, AllDone }
else
begin
Mark(HeapTop); FindFiles(InFileName);
If FFirst=Nil then
WriteLn('Input file(s) ',InFileName,' not found.')
else
begin
Write('Output Drive ( or <cr> for ',InFileName[1],': ) >');
ReadLn(OutDrive);
Repeat { Until InFileName='' }
InFileName:=NextFile;
If InFileName>'' then
begin
InFileName:=DrivePrefix+InFileName;
OutFileName:=Copy(InFileName,1,2);
If Length(OutDrive)>0 then
OutFileName[1]:=UpCase(OutDrive[1]);
Assign(InFile,InFileName); Reset(InFile);
InFileSize:=TheSizeOf(InFile);
If InFileSize=0 then
begin
WriteLn('Input file ',InFileName,' is empty.');
CloseInFile;
end
else
begin
CloseInFile; ResetInFile;
RepCt:=0; BPos:=99; EoFile:=false;
FileDateString:=''; AnotherString:='';
i:=GetW;
Case i of
Recognize: begin
FileCkSum:=GetW;
Repeat { Until InChar=0 }
InChar:=GetI;
If InChar<>0 then
OutFileName:=OutFileName+Chr(InChar);
Until InChar=0;
UnSqueeze;
end;
Recognize2: begin
Repeat { Until InChar=0 }
InChar:=GetI;
If InChar<>0 then
OutFileName:=OutFileName+Chr(InChar);
Until InChar=0;
Repeat { Until InChar=0 }
InChar:=GetI;
If InChar<>0 then
FileDateString:=FileDateString+
Chr(InChar);
Until InChar=0;
Repeat { Until InChar=0 }
InChar:=GetI;
If InChar<>0 then
AnotherString:=AnotherString+
Chr(InChar);
Until InChar=0;
InChar:=GetI; { ^Z (ASCII EOF) }
FileCkSum:=GetW;
FileDate:=GetW;
FileTime:=GetW;
UnSqueeze;
end;
Else begin
CloseInFile;
WriteLn('I don''t recognize ',InFileName,
' as a squeezed file.');
end;
end; { Case i }
end;
end;
Until InFileName='';
end;
end;
InFileName:='';
Until AllDone;
If PrinterEcho then Write(Lst,FormFeed);
end.