/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1987-2012 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped2021/*22* pax gzip format23*/2425#include "format.h"2627static int28gzip_getprologue(Pax_t* pax, Format_t* fp, Archive_t* ap, File_t* f, unsigned char* buf, size_t size)29{30off_t pos;31unsigned char num[4];3233if (size < 2 || buf[0] != 0x1f || buf[1] != 0x8b)34return 0;35if ((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))36ap->uncompressed = ap->io->size * 6;37else38ap->uncompressed = (num[0]) |39(num[1] << 8) |40(num[2] << 16) |41(num[3] << 24);42lseek(ap->io->fd, pos, SEEK_SET);43return 1;44}4546static Compress_format_t pax_gzip_data =47{48"-9",49{ "gunzip" },50{ "ratz", "-c" },51};5253Format_t pax_gzip_format =54{55"gzip",56"gz",57"gzip compression",580,59COMPRESS|IN|OUT,600,610,620,63PAXNEXT(gzip),64&pax_gzip_data,650,66gzip_getprologue,67};6869PAXLIB(gzip)707172