TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Ian Binnie
from: Frank Adam
date: 1996-06-11 07:27:00
subject: Archive Code

G'Day Ian,
 
-=> Quoting Ian Binnie to All <=-
 IB> Does anyone have any code (or information) to recognise which
 IB> archiver is used for compression (ZIP, ARC etc)?

I ripped this out of my archive scanner/converter, which i've never 
really finished for this reason, been using it for a long time though 
as is, and never missed or mistaken an archive it knows about.
If you come up with more info i'd appreciate if you could post them
so one day i could complete it.
 
int detectzip(char *curfilepath)
{
int i;
char fbytes[8]; /* 8 bytes is enough to read on these at least */

char zipid1[4] = {80,75,3,0};    /* this one i think is pkzip 1 */
char zipid2[4] = {80,75,4,0};    /* that would make this pkzip 2 */
char arjid [3] = {96,234,0};     /* ARJ */
char sqzid[] = "HLSQZ";          /* SQZ */
char lzhid1[]= "-lz";       /* this one is the old lzh format */
char lzhid2[]= "-lh";       /* this is the newer one needs LHA */
                            /* followed by "1-" or "5-"
AFAIK denotes */
                            /* version 1.13 and 2.54 respectively */

-- CUT ---
I did all the tests with if(strstr(fbytes,zipid1) == 0) etc..
If you want the whole source you're welcome to it, but be warned i did
this a long time ago, it's very inefficient, but it does the job.
It's about 12Ks so i don't think i'll post it here. 
                                                
Btw, i've got these by getting all the archivers off BBSs and since they
all put a signature in the header of archives they create, it's 
not too hard to work them out.Since then i've got a file off the net
the filename is ffmts002.zip, try ftpsearch i guess.
Didn't tell me much more about detecting archives, but it contains a lot 
of good info on other file formats, and the internals of archives etc...   
                      
But there is more.. :)
Sfx's should be easy, if the two first bytes are MZ, then search for   
"Lharc","LHA's","RJSX"  in the next 15 or so
bytes,the last one is ARJ.
Pkzip is a little more cunning with their exes, i found that i have to
seek to byte 18 decimal, it should be an 'R' then seek 4 bytes forward, 
it should be 14h followed by 11h, immidiately followed by "PKLITE". 
Scary isn't it ? Hmmm, perhaps the seek to 18 isn't really needed. 
Similar for pklited exes except the bytes before PKLITE are 0Fh,21h.    

Arc is long gone isnt it ? 
Anyway, PAK and PKPAK are using a similar format, but the only ID they 
all have is a single byte at offset 0 '1Ah', followed by another byte 
describimg the compression method,then the filename.
This i did find in ffmts002.txt.           

  L8r Frank (fadam{at}ozemail.com.au).
  
___ Blue Wave/DOS v2.21
                                                  

--- Maximus 3.01
* Origin: The Software Parlour (3:635/544)
SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/401 409 410 413
SEEN-BY: 711/430 808 809 932 934 712/515 713/888 714/906 800/1
@PATH: 635/544 50/99 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.