| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Message Packets... |
In a message to Eric Theriault
Kaleb Axon wrote:
> case 'P':
> if (buf[1] == 'K')
> type = zip;
> break;
;-)
Take this! (it seems to work :-))
----- ARCLIB.H follows ------
/*
ARCLIB.H; Archiver detection/handling library.
(c) copyright 1994 Andrew Clarke, Blizzard Software.
*/
#ifndef __ARCLIB_H__
#define __ARCLIB_H__
#ifdef __cplusplus
extern "C" {
#endif
enum TArcType {
ARC_ERROR,
ARC_UNKNOWN,
ARC_ZIP,
ARC_ZOO,
ARC_ARC,
ARC_LZH,
ARC_PAK,
ARC_ARJ
};
int GetArcType(char *path);
char *GetArcName(enum TArcType ArcType);
char *GetArcId(int iArc);
int StrToArcType(char *pArc);
extern int ArcLibError;
#ifdef __cplusplus
}
#endif
#endif
----- ARCLIB.H ends -----
And this!
----- ARCLIB.C follows -----
/*
ARCLIB.C; Archiver detection/handling library.
(c) copyright 1994 Andrew Clarke, Blizzard Software.
*/
#include
#include
#include
#include
#include
#include
#include "arclib.h"
static int ArcLibError = 0;
int GetArcType(char *path)
{
int fd;
unsigned char buf[5];
if( ((fd = sopen(path, O_RDONLY, SH_DENYWR, S_IREAD)) == -1) ||
read(fd, &buf, sizeof(buf)) != sizeof(buf) ) {
ArcLibError = errno;
return(ARC_ERROR);
}
close(fd);
if((buf[0] == 0x50) && (buf[1] == 0x4b))
return(ARC_ZIP);
if((buf[0] == 0x60) && (buf[1] == 0xea))
return(ARC_ARJ);
if((buf[3] == 0x6c) && (buf[4] == 0x68))
return(ARC_LZH);
if((buf[0] == 0x5a) && (buf[1] == 0x4f) && (buf[2] == 0x4f))
return(ARC_ZOO);
if((buf[0] == 0x1a) && (buf[1] == 0x08))
return(ARC_ARC);
if((buf[0] == 0x1a) && (buf[1] == 0x0b))
return(ARC_PAK);
return(ARC_UNKNOWN);
}
char *GetArcName(enum TArcType ArcType)
{
static char *szArcName[8] = {
"Error",
"Unknown",
"PKZIP",
"ZOO",
"PKARC",
"LHA",
"PAK",
"ARJ"
};
return(szArcName[ArcType]);
}
char *GetArcId(int iArc)
{
static char *szArcId[8] = {
"",
"",
"ZIP",
"ZOO",
"ARC",
"LHA",
"PAK",
"ARJ"
};
return(szArcId[iArc]);
}
int StrToArcType(char *pArc)
{
if(stricmp(pArc, "ZIP") == 0)
return(ARC_ZIP);
if(stricmp(pArc, "ZOO") == 0)
return(ARC_ZOO);
if(stricmp(pArc, "ARC") == 0)
return(ARC_ARC);
if(stricmp(pArc, "LZH") == 0)
return(ARC_LZH);
if(stricmp(pArc, "PAK") == 0)
return(ARC_PAK);
if(stricmp(pArc, "ARJ") == 0)
return(ARC_ARJ);
return(ARC_UNKNOWN);
}
----- ARCLIB.C ends -----
And don't come back until you're sorry.
:-)
ZeeYa...
Andrew.
---
* Origin: Blizzard of Ozz, Melbourne, Australia (3:635/727.4)SEEN-BY: 50/99 209/720 620/243 632/103 341 348 386 635/503 727 640/201 206 SEEN-BY: 640/217 297 305 820 822 823 690/660 711/409 410 413 430 431 807 808 SEEN-BY: 711/809 816 934 942 712/515 713/888 800/1 7877/2809 @PATH: 635/727 632/348 640/820 711/409 808 809 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™.