xref: /plan9/sys/src/cmd/gzip/zip.h (revision 7dd7cddf99dd7472612f1413b4da293630e6b1bc)
1 typedef struct ZipHead	ZipHead;
2 
3 enum
4 {
5 	/*
6 	 * magic numbers
7 	 */
8 	ZHeader		= 0x04034b50,
9 	ZCHeader	= 0x02014b50,
10 	ZECHeader	= 0x06054b50,
11 
12 	/*
13 	 * "general purpose flag" bits
14 	 */
15 	ZEncrypted	= 1 << 0,
16 	ZTrailInfo	= 1 << 3,	/* uncsize, csize, and crc are in trailer */
17 	ZCompPatch	= 1 << 5,	/* compression patched data */
18 
19 	ZCrcPoly	= 0xedb88320,
20 
21 	/*
22 	 * compression method
23 	 */
24 	ZDeflate	= 8,
25 
26 	/*
27 	 * internal file attributes
28 	 */
29 	ZIsText		= 1 << 0,
30 
31 	/*
32 	 * file attribute interpretation, from high byte of version
33 	 */
34 	ZDos		= 0,
35 	ZAmiga		= 1,
36 	ZVMS		= 2,
37 	ZUnix		= 3,
38 	ZVMCMS		= 4,
39 	ZAtariST	= 5,
40 	ZOS2HPFS	= 6,
41 	ZMac		= 7,
42 	ZZsys		= 8,
43 	ZCPM		= 9,
44 	ZNtfs		= 10,
45 
46 	/*
47 	 * external attribute flags for ZDos
48 	 */
49 	ZDROnly		= 0x01,
50 	ZDHidden	= 0x02,
51 	ZDSystem	= 0x04,
52 	ZDVLable	= 0x08,
53 	ZDDir		= 0x10,
54 	ZDArch		= 0x20,
55 
56 	ZHeadSize	= 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2,
57 	ZHeadCrc	= 4 + 2 + 2 + 2 + 2 + 2,
58 	ZTrailSize	= 4 + 4 + 4,
59 	ZCHeadSize	= 4 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4,
60 	ZECHeadSize	= 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2,
61 };
62 
63 /*
64  * interesting info from a zip header
65  */
66 struct ZipHead
67 {
68 	int	madeos;			/* version made by */
69 	int	madevers;
70 	int	extos;			/* version needed to extract */
71 	int	extvers;
72 	int	flags;			/* general purpose bit flag */
73 	int	meth;
74 	int	modtime;
75 	int	moddate;
76 	ulong	crc;
77 	ulong	csize;
78 	ulong	uncsize;
79 	int	iattr;
80 	ulong	eattr;
81 	ulong	off;
82 	char	*file;
83 };
84