aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/tapefs/zip.h
blob: 344498032b031a0a4c876ac7a11afb16f09f9bed (plain)
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
75
76
77
78
79
80
81
82
83
84
typedef struct ZipHead	ZipHead;

enum
{
	/*
	 * magic numbers
	 */
	ZHeader		= 0x04034b50,
	ZCHeader	= 0x02014b50,
	ZECHeader	= 0x06054b50,

	/*
	 * "general purpose flag" bits
	 */
	ZEncrypted	= 1 << 0,
	ZTrailInfo	= 1 << 3,	/* uncsize, csize, and crc are in trailer */
	ZCompPatch	= 1 << 5,	/* compression patched data */

/*	ZCrcPoly	= 0xedb88320, */
#define	ZCrcPoly	0xedb88320

	/*
	 * compression method
	 */
	ZDeflate	= 8,

	/*
	 * internal file attributes
	 */
	ZIsText		= 1 << 0,

	/*
	 * file attribute interpretation, from high byte of version
	 */
	ZDos		= 0,
	ZAmiga		= 1,
	ZVMS		= 2,
	ZUnix		= 3,
	ZVMCMS		= 4,
	ZAtariST	= 5,
	ZOS2HPFS	= 6,
	ZMac		= 7,
	ZZsys		= 8,
	ZCPM		= 9,
	ZNtfs		= 10,

	/*
	 * external attribute flags for ZDos
	 */
	ZDROnly		= 0x01,
	ZDHidden	= 0x02,
	ZDSystem	= 0x04,
	ZDVLable	= 0x08,
	ZDDir		= 0x10,
	ZDArch		= 0x20,

	ZHeadSize	= 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2,
	ZHeadCrc	= 4 + 2 + 2 + 2 + 2 + 2,
	ZTrailSize	= 4 + 4 + 4,
	ZCHeadSize	= 4 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4,
	ZECHeadSize	= 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2
};

/*
 * interesting info from a zip header
 */
struct ZipHead
{
	int	madeos;			/* version made by */
	int	madevers;
	int	extos;			/* version needed to extract */
	int	extvers;
	int	flags;			/* general purpose bit flag */
	int	meth;
	int	modtime;
	int	moddate;
	ulong	crc;
	ulong	csize;
	ulong	uncsize;
	int	iattr;
	ulong	eattr;
	ulong	off;
	char	*file;
};