-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompression.h
74 lines (65 loc) · 2.33 KB
/
compression.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "main.h"
/* Compression libraries */
#ifdef USE_GZ
#include <zlib.h>
#endif
#ifdef USE_BZ2
#include <bzlib.h>
#endif
#define CHUNK 16384
int ExtractFileFromTar(char * Prefix, int FileID);
int ExtractLoadedTar();
int LoadTarFromFile(char * FileName);
int LoadTarFromChar(char * FileName, int Size);
void FreeUpTar();
char * InfFile2Char(const char * FileName_In, char *dest, int * Size);
char * gzInfFromChar(char * Data, int zSize, int * Size);
int InfFile2File(const char * FileName_In, const char * FileName_Out);
/* Documention on tar format from: http://www.gnu.org/software/automake/manual/tar/Standard.html */
struct RawTarHeader
{ /* Byte offset - End */
char name[100]; /* 0 - 99 */
char mode[8]; /* 100 - 107 */
char uid[8]; /* 108 - 115 */
char gid[8]; /* 116 - 123 */
char size[12]; /* 124 - 135 */
char mtime[12]; /* 136 - 147 */
char chksum[8]; /* 148 - 155 */
char typeflag; /* 156 - 156 */
char linkname[100]; /* 157 - 256 */
char magic[6]; /* 257 - 262 */
char version[2]; /* 263 - 264 */
char uname[32]; /* 265 - 296 */
char gname[32]; /* 297 - 328 */
char devmajor[8]; /* 329 - 336 */
char devminor[8]; /* 337 - 344 */
char prefix[155]; /* 345 - 499 */
char padding[12]; /* 500 - 512 */
};
/* Values used in typeflag field. */
#define REGTYPE '0' /* regular file */
#define AREGTYPE '\0' /* regular file */
#define LNKTYPE '1' /* link */
#define SYMTYPE '2' /* reserved */
#define CHRTYPE '3' /* character special */
#define BLKTYPE '4' /* block special */
#define DIRTYPE '5' /* directory */
#define FIFOTYPE '6' /* FIFO special */
#define CONTTYPE '7' /* reserved */
/* We'll use this as an array of the files in the tar */
struct TarFile
{
char Name[255];
int Mode;
int DataLength;
char Type;
char * Data;
};
extern struct TarFile * tFile;
extern int TarFileCount; /* Keeps track of how many elements there are */