Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pax/pax-gzip.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1987-2012 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
22
/*
23
* pax gzip format
24
*/
25
26
#include "format.h"
27
28
static int
29
gzip_getprologue(Pax_t* pax, Format_t* fp, Archive_t* ap, File_t* f, unsigned char* buf, size_t size)
30
{
31
off_t pos;
32
unsigned char num[4];
33
34
if (size < 2 || buf[0] != 0x1f || buf[1] != 0x8b)
35
return 0;
36
if ((pos = lseek(ap->io->fd, (off_t)0, SEEK_CUR)) < 0 || lseek(ap->io->fd, (off_t)-4, SEEK_END) <= 0 || read(ap->io->fd, num, sizeof(num)) != sizeof(num))
37
ap->uncompressed = ap->io->size * 6;
38
else
39
ap->uncompressed = (num[0]) |
40
(num[1] << 8) |
41
(num[2] << 16) |
42
(num[3] << 24);
43
lseek(ap->io->fd, pos, SEEK_SET);
44
return 1;
45
}
46
47
static Compress_format_t pax_gzip_data =
48
{
49
"-9",
50
{ "gunzip" },
51
{ "ratz", "-c" },
52
};
53
54
Format_t pax_gzip_format =
55
{
56
"gzip",
57
"gz",
58
"gzip compression",
59
0,
60
COMPRESS|IN|OUT,
61
0,
62
0,
63
0,
64
PAXNEXT(gzip),
65
&pax_gzip_data,
66
0,
67
gzip_getprologue,
68
};
69
70
PAXLIB(gzip)
71
72