openTRI
0.1
triArchive.h
1
2
#ifndef __TRI_ARCHIVE_H__
3
#define __TRI_ARCHIVE_H__
4
5
#include "triTypes.h"
6
7
#define PACKED __attribute__((packed))
8
9
#define TRI_ARCHIVE_MAX_FS (0xFFFFFF)
//16MB max file entry
10
#define TRI_ARCHIVE_MAX_FNLEN (112)
//112byts max filename
11
#define TRI_ARCHIVE_MAGIC ("triA")
//magic id
12
#define TRI_ARCHIVE_KEYLEN (0x10)
//16 byte keylen
13
14
//archive flags
15
#define TRI_ARCHIVE_ENC (0x01)
16
#define TRI_ARCHIVE_COMP (0x02)
17
18
//compression types
19
#define TRI_ARCHIVE_ZLIB (0x00)
20
21
typedef
struct
triArchiveHeader
22
{
23
triU32 magic;
24
triU16 version;
25
triU16 numfiles;
26
triU32 off_entry_table;
27
triU32 off_file_table;
28
triUChar resevered[8];
29
}PACKED
triArchiveHeader
;
30
31
typedef
struct
triArchiveEntry
32
{
33
triChar filename[TRI_ARCHIVE_MAX_FNLEN];
34
triU32 filesize;
35
triU32 uncomp_filesize;
36
triU32 off_file_table;
37
triU32 crc;
38
}PACKED
triArchiveEntry
;
39
40
typedef
struct
triArchiveFile
41
{
42
triChar* data;
43
triU32 size;
44
}PACKED
triArchiveFile
;
45
46
typedef
struct
triArchive
47
{
48
triU16 numfiles;
49
triU16 version;
50
triUChar key[TRI_ARCHIVE_KEYLEN];
51
triChar archivename[TRI_ARCHIVE_MAX_FNLEN];
52
triArchiveEntry
* entries;
53
triU32 off_file_table;
54
}PACKED
triArchive
;
55
56
triArchive
* triArchiveOpen(triChar* archivename,triChar* key);
57
triArchiveFile
* triArchiveRead(triChar *file,
triArchive
* archive);
58
void
triArchiveFileFree(
triArchiveFile
* archivefile);
59
void
triArchiveClose(
triArchive
*archive);
60
triU32 triCRC32(triChar* data, triU32 len);
61
62
#endif
63
triArchiveEntry
Definition
triArchive.h:32
triArchiveFile
Definition
triArchive.h:41
triArchiveHeader
Definition
triArchive.h:22
triArchive
Definition
triArchive.h:47
Generated by
1.14.0