home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
comp
/
zipcmnt.lzh
/
CMNTREAD.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-11-16
|
4KB
|
151 lines
{ Zip file comment reader 1.0 }
{ Copyright (c) 1990 McBrine Computer Products }
{ See below for more info }
program commentread(zipfile,cmntfile,output);
type { Comment is stored on the heap }
ptr=^foo; { Note TP4.0 will not accept 0..65535 }
foo=record { as a range for an array! }
bar:array[0..65534] of byte
end;
var
zipfile,cmntfile:file of byte;
zipname,cmntname:string[80];
x,y,z:longint;
m,n,o,clength:word;
a,b,t:byte;
comment:ptr;
procedure sz;
begin { Too simple to be a procedure in its }
seek(zipfile,x) { own right, it seems; but it results in }
end; { a much shorter compiled program }
procedure rnp;
begin
read(zipfile,a,b)
end;
function rno:word;
begin
rnp;
rno:=a+256*b
end;
procedure gettype;
begin
x:=x+4;
t:=0;
rnp;
if (a=80) and (b=75) then
begin
rnp;
case a+b of
7:t:=1;
3:t:=2;
11:t:=3
end
end
end;
procedure error;
begin
writeln('I can''t read this ZIP file!');
halt
end;
procedure error1;
begin
writeln('Zip File Comment Reader 1.0');
writeln('by William J. McBrine III');
writeln('Copyright (c) 1990 McBrine Computer Products');
writeln;
writeln('Syntax is:');
writeln;
writeln('CMNTREAD zipfile[.zip] [cmntfile.ext]');
writeln;
writeln('"Zipfile" is the name of the file to read the comment from. The extension');
writeln('".ZIP" is assumed if none is given. "Cmntfile.ext" is the name of the file to');
writeln('write the comment to; "CON" (the screen) is used if no name is given.');
writeln;
writeln('This program is free software, distributed under the terms of the GNU General');
writeln('Public License as published by the Free Software Foundation, version 1. It is');
writeln('distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. See');
writeln('LICENSE.DOC for details. It should have come with this program; if not, write:');
writeln;
writeln('Free Software Foundation, Inc. / 675 Massachusetts Avenue / Cambridge, MA 02139');
writeln;
writeln('author: William J. McBrine III / 514 S. Jackson St. / Salisbury, NC 28144-5428');
writeln('email : WILLIAM MCBRINE on HomeBoy''s Digital Undergound, (704) 637-2342 3-24');
writeln(' & The Big Byte, (704) 279-2295 3-96 dual');
halt
end;
procedure skipfile;
begin
x:=x+14;
sz;
y:=rno;
z:=rno;
y:=y+65536*z;
x:=x+8;
sz;
m:=rno;
n:=rno;
x:=x+y+m+n+4;
sz
end;
procedure skipdir;
begin
x:=x+24;
sz;
m:=rno;
n:=rno;
o:=rno;
x:=x+m+n+o+18;
sz
end;
procedure writcmnt;
begin
writeln('Writing comment file: ',cmntname);
assign(cmntfile,cmntname);
rewrite(cmntfile);
if clength>0 then
with comment^ do for m:=0 to clength-1 do write(cmntfile,bar[m]);
close(cmntfile)
end;
begin
if (paramcount<>2) and (paramcount<>1) then error1;
zipname:=paramstr(1);
if paramcount=2 then cmntname:=paramstr(2)
else cmntname:='con';
if pos('.',zipname)=0 then zipname:=concat(zipname,'.zip');
writeln('Reading ZIP file: ',zipname);
assign(zipfile,zipname);
reset(zipfile);
x:=0;
repeat
gettype;
if t=0 then error;
case t of
1:skipfile;
2:skipdir
end
until t=3;
x:=x+16;
sz;
{ All the above got us to the length of the zipcomment }
clength:=rno;
mark(comment);
getmem(comment,clength);
if clength>0 then
with comment^ do for n:=0 to clength-1 do read(zipfile,bar[n]);
close(zipfile);
writcmnt
end.