66 #include <sys/types.h>
94 struct ind *me = (
struct ind *)in_desc;
101 if ((
unsigned)ret >
SIZE -
len)
110 }
while (ret != 0 &&
len <
SIZE);
134 struct outd *me = (
struct outd *)out_desc;
143 if ((
unsigned)ret >
len)
155 #define NEXT() (have ? 0 : (have = in(indp, &next)), \
156 last = have ? (have--, (int)(*next++)) : -1)
171 #define FLUSHCODE() \
175 if (chunk > have) { \
181 if (chunk > have) { \
230 strm->msg = (
char *)
"unknown lzw flags set";
234 if (max < 9 || max > 16) {
235 strm->msg = (
char *)
"lzw bits out of range";
255 strm->msg = (
char *)
"invalid lzw code";
261 outbuf[0] = (
unsigned char)
final;
322 strm->msg = (
char *)
"invalid lzw code";
331 while (
code >= 256) {
351 while (outcnt <
SIZE)
385 int ret, first, last;
406 if (last != 31 || (
NEXT() != 139 && last != 157)) {
407 strm->msg = (
char *)
"incorrect header check";
422 if (last == -1)
break;
423 strm->msg = (
char *)
"unknown compression method";
434 if (last == -1)
break;
436 strm->msg = (
char *)
"unknown header flags set";
443 if (last == -1)
break;
447 if (
NEXT() == -1)
break;
450 if (last == -1)
break;
455 while (
NEXT() != 0 && last != -1)
458 while (
NEXT() != 0 && last != -1)
464 if (last == -1)
break;
489 strm->msg = (
char *)
"incorrect data check";
500 strm->msg = (
char *)
"incorrect length check";
523 if (
stat(
from, &was) != 0 || (was.st_mode & S_IFMT) != S_IFREG)
527 (void)
chmod(
to, was.st_mode & 07777);
530 (void)
chown(
to, was.st_uid, was.st_gid);
533 when.actime = was.st_atime;
534 when.modtime = was.st_mtime;
554 if (inname ==
NULL || *inname == 0) {
561 fprintf(stderr,
"gun cannot open %s\n", inname);
567 else if (outname ==
NULL || *outname == 0) {
575 fprintf(stderr,
"gun cannot create %s\n", outname);
595 fprintf(stderr,
"gun warning: trailing garbage ignored in %s\n",
600 fprintf(stderr,
"gun data error on %s: %s\n", inname,
strm->msg);
604 fprintf(stderr,
"gun out of memory error--aborting\n");
609 fprintf(stderr,
"gun write error on %s: %s\n",
610 outname, strerror(errno));
613 fprintf(stderr,
"gun read error on %s: %s\n",
614 inname, strerror(errno));
617 fprintf(stderr,
"gun unexpected end of file on %s\n",
623 fprintf(stderr,
"gun internal error--aborting\n");
645 fprintf(stderr,
"gun out of memory error--aborting\n");
653 if (argc && strcmp(*
argv,
"-h") == 0) {
654 fprintf(stderr,
"gun 1.6 (17 Jan 2010)\n");
655 fprintf(stderr,
"Copyright (C) 2003-2010 Mark Adler\n");
656 fprintf(stderr,
"usage: gun [-t] [file1.gz [file2.Z ...]]\n");
659 if (argc && strcmp(*
argv,
"-t") == 0) {
670 if (strcmp(*
argv +
len - 3,
".gz") == 0 ||
671 strcmp(*
argv +
len - 3,
"-gz") == 0)
673 else if (strcmp(*
argv +
len - 2,
".z") == 0 ||
674 strcmp(*
argv +
len - 2,
"-z") == 0 ||
675 strcmp(*
argv +
len - 2,
"_z") == 0 ||
676 strcmp(*
argv +
len - 2,
".Z") == 0)
679 fprintf(stderr,
"gun error: no gz type on %s--skipping\n",
684 if (outname ==
NULL) {
685 fprintf(stderr,
"gun out of memory error--aborting\n");
695 }
while (
argv++, --argc);
int bits(struct state *s, int need)
static static fork const void static count close
static static fork const void static count static fd const char const char static newpath const char static path chmod
unsigned char suffix[65536]
int gunpipe(z_stream *strm, int infile, int outfile)
void copymeta(char *from, char *to)
unsigned char outbuf[SIZE]
int main(int argc, char **argv)
unsigned in(void *in_desc, z_const unsigned char **buf)
int out(void *out_desc, unsigned char *buf, unsigned len)
int gunzip(z_stream *strm, char *inname, char *outname, int test)
unsigned char match[65280+2]
int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp, int outfile, z_stream *strm)
unsigned short prefix[65536]
unsigned char inbuf[SIZE]
RZ_API void Ht_() free(HtName_(Ht) *ht)
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
int ZEXPORT inflateBackEnd(z_streamp strm)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds utime
static static fork const void static count static fd const char const char static newpath char char argv
static static fork const void static count static fd const char static mode unlink
static const char struct stat static buf struct stat static buf static vhangup int struct rusage static rusage struct sysinfo static info unsigned static __unused struct utsname static buf const char static size const char static name static pid unsigned static persona static fsgid const void static flags const struct iovec static count static fd const void static len static munlockall struct sched_param static p static sched_yield static policy const struct timespec struct timespec static rem uid_t uid_t uid_t static suid struct pollfd unsigned static timeout chown
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
static struct sockaddr static addrlen static backlog const void static flags void flags
static struct stack stack[MAX_INCLUDE]
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
#define inflateBackInit(strm, windowBits, window)
int read(izstream &zs, T *x, Items items)