Go to the documentation of this file.
66 #include <sys/types.h>
94 struct ind *me = (
struct ind *)in_desc;
134 struct outd *me = (
struct outd *)out_desc;
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";
251 final = prev = (unsigned)last;
255 strm->
msg = (
char *)
"invalid lzw code";
258 rem = (unsigned)last >> 1;
261 outbuf[0] = (
unsigned char)
final;
287 code += (unsigned)last << left;
293 code += (unsigned)last << left;
299 rem = (unsigned)last >> (8 - left);
322 strm->
msg = (
char *)
"invalid lzw code";
331 while (
code >= 256) {
351 while (outcnt <
SIZE)
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";
442 len += (unsigned)(
NEXT()) << 8;
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;
535 (void)utime(
to, &when);
554 if (inname == NULL || *inname == 0) {
559 infile =
open(inname, O_RDONLY, 0);
561 fprintf(
stderr,
"gun cannot open %s\n", inname);
567 else if (outname == NULL || *outname == 0) {
572 outfile =
open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0666);
575 fprintf(
stderr,
"gun cannot create %s\n", outname);
584 if (infile > 2)
close(infile);
590 if (infile > 2 &&
outfile > 2) {
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");
631 int main(
int argc,
char **argv)
635 unsigned char *window;
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",
683 outname = malloc(
len + 1);
684 if (outname == NULL) {
685 fprintf(
stderr,
"gun out of memory error--aborting\n");
693 if (outname != NULL) free(outname);
695 }
while (argv++, --argc);
unsigned char match[65280+2]
int out(void *out_desc, unsigned char *buf, unsigned len)
unsigned char outbuf[SIZE]
unsigned in(void *in_desc, z_const unsigned char **buf)
unsigned char inbuf[SIZE]
int main(int argc, char **argv)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp, int outfile, z_stream *strm)
#define inflateBackInit(strm, windowBits, window)
void copymeta(char *from, char *to)
OPENSSL_EXPORT ASN1_BIT_STRING * bits
unsigned short prefix[65536]
int read(izstream &zs, T *x, Items items)
unsigned char suffix[65536]
UniquePtr< SSL_SESSION > ret
int ZEXPORT inflateBackEnd(z_streamp strm)
int gunpipe(z_stream *strm, int infile, int outfile)
AllocList * next[kMaxLevel]
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
int gunzip(z_stream *strm, char *inname, char *outname, int test)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:59