Lines Matching +full:zlib +full:- +full:dev
2 * Copyright (c) Ian F. Darwin 1986-1995.
4 * maintained 1995-present by Christos Zoulas and others.
30 * zmagic() - returns 0 if not recognized, uncompresses and prints
32 * uncompress(method, old, n, newch) - uncompress old into new,
70 #include <zlib.h>
102 int tty = -1;
104 if (tty == -1) \
105 tty = open("/dev/tty", O_RDWR); \
106 if (tty == -1) \
117 * defined if we have a built-in zlib, and the built-in zlib handles that.
118 * That is not true for android where we have zlib.h and not -lz.
121 "import sys, zlib; sys.stdout.write(zlib.decompress(sys.stdin.read()))";
123 static const char *zlib_args[] = { "python", "-c", zlibcode, NULL };
153 #define gzip_flags "-cd"
160 "uncompress", "-c", NULL
163 "bzip2", "-cd", NULL
169 "xz", "-cd", NULL
172 "lrzip", "-qdf", "-", NULL
175 "lz4", "-cd", NULL
178 "zstd", "-cd", NULL
212 { { .magic = "BZh" }, 3, bzip2_args, do_bzlib },/* 7, bzip2-ed */
213 { { .magic = "LZIP" }, 4, lzip_args, NULL }, /* 8, lzip-ed */
218 { { .func = lzmacmp }, -13, xz_args, NULL }, /* 13, lzma */
220 { { .func = zlibcmp }, -2, zlib_args, NULL }, /* 14, zlib */
269 int mime = ms->flags & MAGIC_MIME; in format_decompression_error()
276 *p = '-'; in format_decompression_error()
278 return file_printf(ms, "application/x-decompression-error-%s-%s", in format_decompression_error()
290 int mime = ms->flags & MAGIC_MIME; in file_zmagic()
291 int fd = b->fd; in file_zmagic()
292 const unsigned char *buf = CAST(const unsigned char *, b->fbuf); in file_zmagic()
293 size_t nbytes = b->flen; in file_zmagic()
297 if ((ms->flags & MAGIC_COMPRESS) == 0) in file_zmagic()
320 sa_saved = sigaction(SIGPIPE, &new_act, &sig_act) != -1; in file_zmagic()
325 urv = uncompressbuf(fd, ms->bytes_max, i, in file_zmagic()
326 (ms->flags & MAGIC_NO_COMPRESS_FORK), buf, &newbuf, &nsz); in file_zmagic()
332 ms->flags &= ~MAGIC_COMPRESS; in file_zmagic()
336 prv = file_buffer(ms, -1, NULL, name, newbuf, in file_zmagic()
338 if (prv == -1) in file_zmagic()
341 if ((ms->flags & MAGIC_COMPRESS_TRANSP) != 0) in file_zmagic()
346 mime ? " compressed-encoding=" : " (")) == -1) in file_zmagic()
354 if (file_buffer(ms, -1, NULL, NULL, buf, nbytes) == -1) in file_zmagic()
361 if (file_printf(ms, "%s", rbuf) == -1) { in file_zmagic()
367 if (!mime && file_printf(ms, ")") == -1) in file_zmagic()
376 rv = -1; in file_zmagic()
387 ms->flags |= MAGIC_COMPRESS; in file_zmagic()
403 case -1: in swrite()
406 return -1; in swrite()
408 n -= rv; in swrite()
433 if (canbepipe && (ioctl(fd, FIONREAD, &t) == -1 || t == 0)) { in sread()
449 if (selrv == -1) { in sread()
470 case -1: in sread()
473 return -1; in sread()
475 return rn - n; in sread()
477 n -= rv; in sread()
527 if (tfd == -1) { in file_pipe2file()
530 return -1; in file_pipe2file()
542 case -1: in file_pipe2file()
544 return -1; in file_pipe2file()
549 return -1; in file_pipe2file()
557 if ((fd = dup2(tfd, fd)) == -1) { in file_pipe2file()
559 return -1; in file_pipe2file()
562 if (lseek(fd, CAST(off_t, 0), SEEK_SET) == CAST(off_t, -1)) { in file_pipe2file()
564 return -1; in file_pipe2file()
611 *n -= data_start; in uncompressgzipped()
620 size_t bytes_max, size_t *n, int zlib) in uncompresszlib() argument
625 DPRINTF("builtin zlib decompression\n"); in uncompresszlib()
635 rc = zlib ? inflateInit(&z) : inflateInit2(&z, -15); in uncompresszlib()
650 /* let's keep the nul-terminate tradition */ in uncompresszlib()
691 /* let's keep the nul-terminate tradition */ in uncompressbzlib()
729 /* let's keep the nul-terminate tradition */ in uncompressxzlib()
773 /* let's keep the nul-terminate tradition */ in uncompresszstd()
813 old_remaining -= wr; in uncompresslzlib()
819 new_remaining -= rd; in uncompresslzlib()
835 /* let's keep the nul-terminate tradition */ in uncompresslzlib()
926 if (fd[i] == -1) in closefd()
929 fd[i] = -1; in closefd()
950 if (dup2(fd, i) == -1) { in movedesc()
972 if (fd != -1) { in handledesc()
1007 if (pid == -1) { in writechild()
1009 return -1; in writechild()
1058 return "zlib"; in methodname()
1130 pid_t writepid = -1; in uncompressbuf()
1156 fdp[i][0] = fdp[i][1] = -1; in uncompressbuf()
1172 if ((fd == -1 && file_pipe_closexec(fdp[STDIN_FILENO]) == -1) || in uncompressbuf()
1173 file_pipe_closexec(fdp[STDOUT_FILENO]) == -1 || in uncompressbuf()
1174 file_pipe_closexec(fdp[STDERR_FILENO]) == -1) { in uncompressbuf()
1193 if (status == -1) { in uncompressbuf()
1199 * may be _much_ faster (10-100 times) than fork. in uncompressbuf()
1202 if (pid == -1) { in uncompressbuf()
1226 if (fd == -1) { in uncompressbuf()
1229 if (writepid == (pid_t)-1) { in uncompressbuf()
1279 if (w == -1) { in uncompressbuf()
1293 writepid = -1; in uncompressbuf()