Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pax/pax-xz.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 xz format
24
*/
25
26
#include "format.h"
27
28
static int
29
xz_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 foot[6];
33
34
if (size < 5 || buf[0] != 0xfd || buf[1] != '7' || buf[2] != 'z' || buf[3] != 'X' || buf[4] != 'Z')
35
return 0;
36
if ((pos = lseek(ap->io->fd, (off_t)0, SEEK_CUR)) < 0 || lseek(ap->io->fd, (off_t)-sizeof(foot), SEEK_END) <= 0 || read(ap->io->fd, foot, sizeof(foot)) != sizeof(foot) || foot[4] != 0x59 || foot[5] != 0x5A)
37
return 0;
38
else
39
ap->uncompressed = (foot[0]) |
40
(foot[1] << 8) |
41
(foot[2] << 16) |
42
(foot[3] << 24);
43
lseek(ap->io->fd, pos, SEEK_SET);
44
return 1;
45
}
46
47
static Compress_format_t pax_xz_data =
48
{
49
0,
50
{ "xz", "--decompress" },
51
{ 0 },
52
};
53
54
Format_t pax_xz_format =
55
{
56
"xz",
57
0,
58
"xz compression",
59
0,
60
COMPRESS|IN|OUT,
61
0,
62
0,
63
0,
64
PAXNEXT(xz),
65
&pax_xz_data,
66
0,
67
xz_getprologue,
68
};
69
70
PAXLIB(xz)
71
72