forked from vonj/snippets.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
archive.hpp
60 lines (51 loc) · 1.53 KB
/
archive.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
** ARCHIVE.HPP
**
** Written by Jari Laaksonen (2:221/360.20), 2 Sep 1994
** Based on the code by Heinz Ozwirk and David Gersic.
**
** Free for all participants of the C_ECHO & other conferences where
** this code is posted. Released to SNIPPETS by the authors.
**
** See the file WhichArc.DOC about archive types and file offsets
** for self extracting archives.
*/
#include <stdio.h>
// add new type identifiers here if you need to separate e.g. different
// LHA files. Add your new types also in the Arctypes array in the TEST part
// and give them new descriptions.
typedef enum
{
ERROR = -1, UNKNOWN = 0,
ARC, ARC6, PAK, ZOO, HPK, RAR, UC2, SQZ,
ARJ, LARC, LHARC, LHA, ZIP, ZIP2,
SFXARC, SFXARC6, SFXPAK,
SFXARJ, SFXLHARC, SFXLHA, SFXZIP, SFXZIP2,
EXE,
COUNT_ARCTYPES
} ARCTYPE;
const int BUFFSIZE = 128;
class Archive
{
protected:
int type, sfxtype;
long offset;
char *fingerprint;
public:
Archive (long offs, char *fp, int t = UNKNOWN, int t2 = UNKNOWN) :
offset (offs), fingerprint (fp), type(t), sfxtype (t2) { };
int Scan (FILE *fp, char *szBuff, long flen);
virtual int Check (char *szBuff);
};
class LhaArchive : public Archive
{
public:
LhaArchive (long offs, char *fp) : Archive (offs, fp) { };
int Check (char *szBuff);
};
class PakArchive : public Archive
{
public:
PakArchive (long offs = 0) : Archive (offs, "") { };
int Check (char *szBuff);
};