Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libzio for openSUSE:Factory checked in at 2026-09-22 15:48:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libzio (Old) and /work/SRC/openSUSE:Factory/.libzio.new.383539 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libzio" Tue Sep 22 15:48:43 2026 rev:54 rq:1378797 version:1.17 Changes: -------- --- /work/SRC/openSUSE:Factory/libzio/libzio.changes 2026-06-27 18:02:33.332839317 +0200 +++ /work/SRC/openSUSE:Factory/.libzio.new.383539/libzio.changes 2026-09-22 15:49:10.737141578 +0200 @@ -1,0 +2,16 @@ +Fri Sep 18 10:59:01 UTC 2026 - Dr. Werner Fink <[email protected]> + +- Update to version 1.17 + * Mention lzip in manual page as well + * Implement lzlib support as well + * Add Debian package build tree + +------------------------------------------------------------------- +Thu Sep 17 11:00:31 UTC 2026 - Dr. Werner Fink <[email protected]> + +- Update to version 1.16 + e2k arch support: makecontext() is unavailable on e2k arch since + makecontext_e2k() allocates additional stacks so freecontext_e2k() + is required where the given ucp.uc_stack gets either freed or reused. + +------------------------------------------------------------------- Old: ---- libzio-1.15.tar.bz2 New: ---- libzio-1.17.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libzio.spec ++++++ --- /var/tmp/diff_new_pack.0z1tdH/_old 2026-09-22 15:49:11.535174968 +0200 +++ /var/tmp/diff_new_pack.0z1tdH/_new 2026-09-22 15:49:11.537175052 +0200 @@ -18,7 +18,7 @@ Name: libzio %define lname libzio1 -Version: 1.15 +Version: 1.17 Release: 0 Summary: A Library for Accessing Compressed Text Files License: GPL-2.0-or-later @@ -30,6 +30,8 @@ BuildRequires: gzip BuildRequires: libbz2-devel BuildRequires: libzstd-devel +BuildRequires: lzip +BuildRequires: lzlib-devel BuildRequires: xz BuildRequires: xz-devel BuildRequires: zlib-devel @@ -69,7 +71,7 @@ %check make testt tests testx -for comp in gzip bzip2 lzma xz zstd +for comp in gzip bzip2 lzma xz zstd lzip do case $comp in gzip) x=g ;; @@ -77,6 +79,7 @@ lzma) x=l ;; xz) x=x ;; zstd) x=s ;; + lzip) x=L ;; esac $comp -c < fzopen.3.in > fzopen.test ./testt fzopen.test | cmp fzopen.3.in - ++++++ libzio-1.15.tar.bz2 -> libzio-1.17.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/Makefile new/libzio-1.17/Makefile --- old/libzio-1.15/Makefile 2026-06-25 10:24:46.000000000 +0200 +++ new/libzio-1.17/Makefile 2026-09-18 11:52:14.000000000 +0200 @@ -1,14 +1,14 @@ # # Makefile for compiling libzio # -# Author: Werner Fink, <[email protected]> +# Author: Werner Fink <[email protected]>, Werner Fink <[email protected]> # LARGE = $(shell getconf LFS_CFLAGS) CFLAGS = $(RPM_OPT_FLAGS) -pipe -Wall -D_GNU_SOURCE -D_REENTRANT -D_DEFAULT_SOURCE $(LARGE) CC = gcc MAJOR = 1 -MINOR = 15 +MINOR = 17 VERSION = $(MAJOR).$(MINOR) SONAME = libzio.so.$(MAJOR) LDMAP = -Wl,--version-script=zio.map @@ -49,6 +49,7 @@ CFLAGS += $(call cc-include,lzmadec.h,HAS_LZMADEC_H) CFLAGS += $(call cc-include,lzma.h,HAS_LZMA_H) CFLAGS += $(call cc-include,zstd.h,HAS_ZSTD_H) +CFLAGS += $(call cc-include,stdint.h -include lzlib.h,HAS_LZLIB_H) LIBS = -lz ifeq ($(call cc-library,libbz2),yes) @@ -64,6 +65,9 @@ ifeq ($(call cc-library,libzstd),yes) LIBS += -lzstd endif +ifeq ($(call cc-library,liblz),yes) + LIBS += -llz +endif all: shared static noweak: CFLAGS += -DNO_WEAK diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/fzopen.3.in new/libzio-1.17/fzopen.3.in --- old/libzio-1.15/fzopen.3.in 2026-06-25 10:24:46.000000000 +0200 +++ new/libzio-1.17/fzopen.3.in 2026-09-18 11:52:14.000000000 +0200 @@ -68,6 +68,9 @@ .BR l The file descriptor points to a lzma2ed file. .TP +.BR L +The file descriptor points to a lzip2ed file. +.TP .BR x The file descriptor points to a xz2ed file. .TP @@ -124,6 +127,7 @@ lzma yes yes yes .lzma pipe -llzma xz yes yes yes .xz pipe -llzma zstd yes yes no .zst pipe -lzstd +lzip yes yes no .lz pipe -llz .TE .PP .PP @@ -195,6 +199,15 @@ ]) done ]) + AC_CHECK_HEADER(lzlib.h, [ + for lib in lz; do + AC_CHECK_LIB($lib, LZ_decompress_read, [ + LIBS="$LIBS -Wl,--no-as-needed -l$lib" + am_cv_libzio="$am_cv_libzio lib$lib" + break + ]) + done + ], [], [#include <stdint.h>]) AC_MSG_NOTICE([libzio is used [$]am_cv_libzio]) fi .fi @@ -355,6 +368,8 @@ .br .BR zstd (1), .br +.BR lzip (1), +.br .BR /usr/include/zlib.h , .br .BR /usr/include/bzlib.h . @@ -362,6 +377,8 @@ .BR /usr/include/lzma.h . .br .BR /usr/include/zstd.h . +.br +.BR /usr/include/lzlib.h . .SH COPYRIGHT 2004 Werner Fink, 2004 SuSE LINUX AG Nuernberg, Germany. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/package/debian/changelog new/libzio-1.17/package/debian/changelog --- old/libzio-1.15/package/debian/changelog 1970-01-01 01:00:00.000000000 +0100 +++ new/libzio-1.17/package/debian/changelog 2026-09-18 11:52:14.000000000 +0200 @@ -0,0 +1,13 @@ +libzio (1.16) unstable; urgency=medium + + * Initial Debian packaging. + * Build shared and static library with the upstream Makefile + (\`make noweak' links the compression libraries explicitly + instead of relying on weak symbols). + * Ship libzio1 (shared library) and libzio-dev (header, static + library, manual page). + * Run the provided test programs (testt, tests, testx) against + all supported compression formats (gzip, bzip2, lzma, xz, zstd) + in the check stage. + + -- Dr. Werner Fink <[email protected]> Thu, 17 Sep 2026 13:30:00 +0200 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/package/debian/control new/libzio-1.17/package/debian/control --- old/libzio-1.15/package/debian/control 1970-01-01 01:00:00.000000000 +0100 +++ new/libzio-1.17/package/debian/control 2026-09-18 11:52:14.000000000 +0200 @@ -0,0 +1,43 @@ +Source: libzio +Section: libs +Priority: optional +Maintainer: Dr. Werner Fink <[email protected]> +Build-Depends: debhelper-compat (= 13), + gcc, + libc6-dev, + zlib1g-dev, + libbz2-dev, + liblzma-dev, + liblz-dev, + libzstd-dev, + gzip, + bzip2, + xz, + lzip, + zstd +Standards-Version: 4.6.2 +Homepage: https://libzio.sourceforge.net/ +Rules-Requires-Root: no + +Package: libzio1 +Architecture: any +Section: libs +Multi-Arch: same +Depends: ${shlibdeps:Depends}, ${misc:Depends} +Description: A library for accessing compressed text files + libzio provides a small wrapper around the glibc fopencookie(3) + interface together with zlib, libbzip2, liblzma, liblz, and libzstd to + obtain a streamable (FILE *) interface for reading and writing + gzip, bzip2, .Z/LZW, lzma/xz, lzip, and zstd compressed files using + fzopen(3) and fdzopen(3). + +Package: libzio-dev +Architecture: any +Section: libdevel +Multi-Arch: same +Depends: libzio1 (= ${binary:Version}), ${misc:Depends} +Provides: libzio1-dev +Description: A library for accessing compressed text files (development) + This package contains the development files for libzio: + the header file <zio.h>, the manual page fzopen(3), the static + library libzio.a and the symbolic link libzio.so. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/package/debian/copyright new/libzio-1.17/package/debian/copyright --- old/libzio-1.15/package/debian/copyright 1970-01-01 01:00:00.000000000 +0100 +++ new/libzio-1.17/package/debian/copyright 2026-09-18 11:52:14.000000000 +0200 @@ -0,0 +1,28 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: libzio +Source: https://libzio.sourceforge.net/ +Source: https://gitlab.com/bitstreamout/libzio + +Files: * +Copyright: 2004-2021 Werner Fink <[email protected]> +License: GPL-2.0-or-later + +Files: debian/* +Copyright: 2026 Dr. Werner Fink <[email protected]> +License: GPL-2.0-or-later + +License: GPL-2.0-or-later + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/> + or write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA 02110-1301, USA. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/package/debian/libzio-dev.docs new/libzio-1.17/package/debian/libzio-dev.docs --- old/libzio-1.15/package/debian/libzio-dev.docs 1970-01-01 01:00:00.000000000 +0100 +++ new/libzio-1.17/package/debian/libzio-dev.docs 2026-09-18 11:52:14.000000000 +0200 @@ -0,0 +1,2 @@ +README +COPYING diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/package/debian/libzio1.docs new/libzio-1.17/package/debian/libzio1.docs --- old/libzio-1.15/package/debian/libzio1.docs 1970-01-01 01:00:00.000000000 +0100 +++ new/libzio-1.17/package/debian/libzio1.docs 2026-09-18 11:52:14.000000000 +0200 @@ -0,0 +1 @@ +COPYING diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/package/debian/rules new/libzio-1.17/package/debian/rules --- old/libzio-1.15/package/debian/rules 1970-01-01 01:00:00.000000000 +0100 +++ new/libzio-1.17/package/debian/rules 2026-09-18 11:52:14.000000000 +0200 @@ -0,0 +1,145 @@ +#!/usr/bin/make -f +# +# libzio uses a plain GNU make Makefile, no configure script and +# no CMake, so debhelper only provides the packaging framework +# while the actual build is done by the upstream Makefile targets: +# +# make noweak build the shared and static library and link +# libz, libbz2, liblzma and libzstd explicitly +# instead of relying on weak symbols, so that +# dpkg-shlibdeps computes the runtime +# dependencies of the shared library correctly. +# make testt +# make tests +# make testx build the provided test programs. +# make install install the library, header and man page. +# +# The man page fzopen.3 and the header file zio.h are generated +# from fzopen.3.in resp. zio.h.in by the Makefile itself. +# +# The debian/ directory must be placed at the root of a pristine +# source tree, e.g.: +# +# make dest # libzio-X.Y.tar.bz2 +# tar xf libzio-X.Y.tar.bz2 -C build +# cp -a package/debian build/libzio-X.Y/debian +# dpkg-buildpackage -b -us -uc # in build/libzio-X.Y +# +# This builds two binary packages: +# +# libzio1 the runtime shared library +# libzio-dev the header file, static library, the +# libzio.so symlink and the manual page +# + +include /usr/share/dpkg/architecture.mk + +ifeq ($(DEB_TARGET_MULTIARCH),$(DEB_HOST_ARCH)) + DEB_LIBDIR = /usr/lib +else + DEB_LIBDIR = /usr/$(DEB_HOST_MULTIARCH) +endif + +MAJOR = $(shell sed -n 's/^MAJOR[[:space:]]*=[[:space:]]*//p' Makefile) +MINOR = $(shell sed -n 's/^MINOR[[:space:]]*=[[:space:]]*//p' Makefile) +VERSION = $(MAJOR).$(MINOR) + +# +# When building the package directly without root or +# fakeroot (for example in a test environment), relax +# the root requirement. In that case dpkg-deb adds +# --root-owner-group so that all files in the package +# are owned by root:root anyway. When dpkg-buildpackage +# runs, it provides the variable and this has no effect. +# +DEB_RULES_REQUIRES_ROOT ?= no +export DEB_RULES_REQUIRES_ROOT + +%: + dh $@ + +override_dh_auto_build: + # + # the Makefile already provides everything, no + # dh_auto_build wrapper is needed: + # + make noweak + +override_dh_auto_test: + make testt tests testx + # + # round-trip tests: compress zio.h with every supported + # format and verify that it can be read back unchanged + # through fzopen(3) resp. fdzopen(3): + # + @gzip -c < zio.h > /tmp/fzopen-test.gz + @./testt /tmp/fzopen-test.gz | cmp zio.h - + @cat /tmp/fzopen-test.gz | ./tests g | cmp zio.h - + @./testx g < zio.h | ./tests g | cmp zio.h - + @bzip2 -c < zio.h > /tmp/fzopen-test.bz2 + @./testt /tmp/fzopen-test.bz2 | cmp zio.h - + @cat /tmp/fzopen-test.bz2 | ./tests b | cmp zio.h - + @./testx b < zio.h | ./tests b | cmp zio.h - + @lzma -c < zio.h > /tmp/fzopen-test.lzma + @./testt /tmp/fzopen-test.lzma | cmp zio.h - + @cat /tmp/fzopen-test.lzma | ./tests l | cmp zio.h - + @./testx l < zio.h | ./tests l | cmp zio.h - + @xz -c < zio.h > /tmp/fzopen-test.xz + @./testt /tmp/fzopen-test.xz | cmp zio.h - + @cat /tmp/fzopen-test.xz | ./tests x | cmp zio.h - + @./testx x < zio.h | ./tests x | cmp zio.h - + @zstd -c < zio.h > /tmp/fzopen-test.zst + @./testt /tmp/fzopen-test.zst | cmp zio.h - + @cat /tmp/fzopen-test.zst | ./tests s | cmp zio.h - + @./testx s < zio.h | ./tests s | cmp zio.h - + @rm -f /tmp/fzopen-test.gz /tmp/fzopen-test.bz2 \ + /tmp/fzopen-test.lzma /tmp/fzopen-test.xz /tmp/fzopen-test.zst + +override_dh_auto_install: + make DESTDIR=$(CURDIR)/debian/tmp install libdir=$(DEB_LIBDIR) + # + # The Makefile installs the runtime and the development + # files into the same directory. Split the single + # install tree into the two packages here: + # + # libzio1 runtime shared library + # libzio-dev development header, static library, + # soname link, shared library symlink, + # manual page + # + mkdir -p debian/libzio1/$(DEB_LIBDIR) \ + debian/libzio-dev/$(DEB_LIBDIR) \ + debian/libzio-dev/usr/include \ + debian/libzio-dev/usr/share/man/man3 + mv debian/tmp/$(DEB_LIBDIR)/libzio.so.$(VERSION) \ + debian/tmp/$(DEB_LIBDIR)/libzio.so.$(MAJOR) \ + debian/libzio1/$(DEB_LIBDIR)/ + mv debian/tmp/$(DEB_LIBDIR)/libzio.so \ + debian/tmp/$(DEB_LIBDIR)/libzio.a \ + debian/libzio-dev/$(DEB_LIBDIR)/ + mv debian/tmp/usr/include/zio.h debian/libzio-dev/usr/include/ + mv debian/tmp/usr/share/man/man3/fzopen.3 \ + debian/libzio-dev/usr/share/man/man3/ + rm -rf debian/tmp + +override_dh_missing: + # + # all files are placed directly into the package + # directories by override_dh_auto_install, so there + # is nothing for dh_missing to check here: + # + + +ifeq ($(wildcard /var/lib/dpkg/status),) +# +# Fallback for environments without a dpkg database +# (e.g. this sandbox): state the runtime dependencies +# of the shared library explicitly. A complete system +# computes them automatically via dpkg-shlibdeps: +# +override_dh_shlibdeps: + printf 'shlibdeps:Depends=libc6, zlib1g, libbz2-1.0, liblzma5, libzstd1\n' >> debian/libzio1.substvars +else +override_dh_shlibdeps: + dh_shlibdeps +endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/package/debian/source/format new/libzio-1.17/package/debian/source/format --- old/libzio-1.15/package/debian/source/format 1970-01-01 01:00:00.000000000 +0100 +++ new/libzio-1.17/package/debian/source/format 2026-09-18 11:52:14.000000000 +0200 @@ -0,0 +1 @@ +3.0 (native) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/unlzw.c new/libzio-1.17/unlzw.c --- old/libzio-1.15/unlzw.c 2026-06-25 10:24:46.000000000 +0200 +++ new/libzio-1.17/unlzw.c 2026-09-18 11:52:14.000000000 +0200 @@ -210,7 +210,12 @@ #else in->uc[1].uc_sigmask = sigmask; #endif +#ifdef __e2k__ + if (!makecontext_e2k(&in->uc[1], (void(*)(void))unlzw, 1, in)) + goto err; +#else makecontext(&in->uc[1], (void(*)(void))unlzw, 1, in); +#endif sigucmask(SIG_SETMASK, &sigmask, &oldmask); magic[0] = get_byte(in); @@ -267,6 +272,9 @@ { if (in == (LZW_t*)0) return; +#ifdef __e2k__ + freecontext_e2k(&in->uc[1]); +#endif if (in->uc) free(in->uc); if (in->stack) free(in->stack); if (in->ifd >= 0) close(in->ifd); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/zio.c new/libzio-1.17/zio.c --- old/libzio-1.15/zio.c 2026-06-25 10:24:46.000000000 +0200 +++ new/libzio-1.17/zio.c 2026-09-18 11:52:14.000000000 +0200 @@ -29,6 +29,14 @@ #include "lzw.h" #include "zioP.h" +static void zio_fix_fileno(FILE *fp) +{ +# ifndef LIBIO_IS_FIXED + if (fp && fp->_fileno < 0) + fp->_fileno = 0; +# endif +} + #if defined(HAS_ZLIB_H) typedef struct gzfile_s { gzFile file; @@ -1028,6 +1036,252 @@ # warning No support for .zst(d) format #endif /* !HAS_ZSTD_H */ +#if defined(HAS_LZLIB_H) + +typedef struct lzipfile_s { + FILE *file; + int fd; + struct LZ_Encoder *encoder; + struct LZ_Decoder *decoder; + uint8_t buf[1 << 12]; + int encoding; + int eof; +} lzipfile_t; + +static ssize_t lzipread(void *cookie, char *buf, size_t count) +{ + lzipfile_t *lz = (lzipfile_t *)cookie; + if (!lz || lz->encoding) + return -1; + + int total_read = 0; + while (total_read < count) { + int ret = LZ_decompress_read(lz->decoder, (uint8_t *)buf + total_read, count - total_read); + if (ret < 0) { + errno = EINVAL; + return -1; + } + if (ret > 0) + total_read += ret; + + if (LZ_decompress_finished(lz->decoder)) + break; + + if (!lz->eof && LZ_decompress_write_size(lz->decoder) > 0) { + int n; + if (lz->file) { + n = fread(lz->buf, 1, sizeof(lz->buf), lz->file); + if (n == 0) { + if (ferror(lz->file)) + return -1; + lz->eof = 1; + LZ_decompress_finish(lz->decoder); + } else { + LZ_decompress_write(lz->decoder, lz->buf, n); + } + } else { + n = read(lz->fd, lz->buf, sizeof(lz->buf)); + if (n < 0) { + if (errno == EINTR || errno == EAGAIN) + continue; + return -1; + } else if (n == 0) { + lz->eof = 1; + LZ_decompress_finish(lz->decoder); + } else { + LZ_decompress_write(lz->decoder, lz->buf, n); + } + } + } else if (ret == 0) { + break; + } + } + return total_read; +} + +static ssize_t lzipwrite(void *cookie, const char *buf, size_t count) +{ + lzipfile_t *lz = (lzipfile_t *)cookie; + if (!lz || !lz->encoding) + return -1; + + int written = 0; + while (written < count) { + int to_write = LZ_compress_write_size(lz->encoder); + if (to_write > count - written) to_write = count - written; + + if (to_write > 0) { + int ret = LZ_compress_write(lz->encoder, (const uint8_t *)buf + written, to_write); + if (ret < 0) { + errno = EINVAL; + return -1; + } + written += ret; + } + + int n = LZ_compress_read(lz->encoder, lz->buf, sizeof(lz->buf)); + if (n < 0) { + errno = EINVAL; + return -1; + } + if (n > 0) { + if (lz->file) { + if (fwrite(lz->buf, 1, n, lz->file) != (size_t)n) + return -1; + } else { + if (write(lz->fd, lz->buf, n) != n) + return -1; + } + } + } + return count; +} + +static zio_int_t lzipseek(void *cookie __attribute__((__unused__)), zio_off_t *poffset __attribute__((__unused__)), int whence __attribute__((__unused__))) +{ + errno = ENOTSUP; + return -1; +} + +static int lzipclose(void *cookie) +{ + lzipfile_t *lz = (lzipfile_t *)cookie; + if (!lz) + return -1; + + if (lz->encoding && lz->encoder) { + LZ_compress_finish(lz->encoder); + while (LZ_compress_finished(lz->encoder) == 0) { + int n = LZ_compress_read(lz->encoder, lz->buf, sizeof(lz->buf)); + if (n > 0) { + if (lz->file) { + if (fwrite(lz->buf, 1, n, lz->file) != (size_t)n) + break; + } else { + if (write(lz->fd, lz->buf, n) != n) + break; + } + } else if (n < 0) { + break; + } + } + LZ_compress_close(lz->encoder); + } else if (lz->decoder) { + LZ_decompress_close(lz->decoder); + } + + if (lz->file) fclose(lz->file); + free(lz); + return 0; +} + +__extension__ static cookie_io_functions_t iolzip = { + .read = (cookie_read_function_t *)lzipread, + .write = (cookie_write_function_t *)lzipwrite, + .seek = (cookie_seek_function_t *)lzipseek, + .close = (cookie_close_function_t *)lzipclose, +}; + +static FILE *zio_open_lzip_file(int fd, const char *path, const char *mode, const char *check) +{ + lzipfile_t *cookie; + FILE *ret = NULL; + int level = 6; + size_t n = strlen(mode); + + for (size_t i = 1; i < n; i++) { + if (mode[i] >= '1' && mode[i] <= '9') { + level = (int)mode[i] - '0'; + break; + } + } + + if (posix_memalign((void *)&cookie, sizeof(void *), alignof(lzipfile_t)) != 0) + return NULL; + memset(cookie, 0, alignof(lzipfile_t)); + + cookie->fd = fd; + if (fd >= 0) { + if ((cookie->file = fdopen(fd, check)) == NULL) { + free(cookie); + return NULL; + } + } else { + if ((cookie->file = fopen(path, check)) == NULL) { + free(cookie); + return NULL; + } + } + + cookie->encoding = (check[0] == 'w') ? 1 : 0; + cookie->eof = 0; + + if (cookie->encoding) { + int dicts[] = { 1<<20, 1<<20, 1<<20, 1<<21, 1<<22, 1<<23, 1<<24, 1<<25, 1<<25 }; + int dict_size = dicts[level > 0 ? level - 1 : 5]; + cookie->encoder = LZ_compress_open(dict_size, 273, 0x7FFFFFFFFFFFFFFFLL); + if (!cookie->encoder) { + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; + } + } else { + cookie->decoder = LZ_decompress_open(); + if (!cookie->decoder) { + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; + } + } + + if (!(ret = fopencookie((void *)cookie, check, iolzip))) { + lzipclose(cookie); + errno = EINVAL; + return NULL; + } + zio_fix_fileno(ret); + return ret; +} + +static FILE *zio_open_lzip_pipe(int fd, const char *check, char *magic, size_t mlen) +{ + lzipfile_t *cookie; + FILE *fp = NULL; + + if (posix_memalign((void *)&cookie, sizeof(void *), alignof(lzipfile_t)) != 0) + return NULL; + memset(cookie, 0, alignof(lzipfile_t)); + + cookie->fd = fd; + cookie->file = NULL; + cookie->encoding = 0; + cookie->eof = 0; + + cookie->decoder = LZ_decompress_open(); + if (!cookie->decoder) { + free(cookie); + errno = EINVAL; + return NULL; + } + if (mlen > 0) { + LZ_decompress_write(cookie->decoder, (uint8_t *)magic, mlen); + } + + if (!(fp = fopencookie((void *)cookie, check, iolzip))) { + LZ_decompress_close(cookie->decoder); + free(cookie); + errno = EINVAL; + return NULL; + } + zio_fix_fileno(fp); + return fp; +} +#else /* !HAS_LZLIB_H */ +# warning No support for .lz format +#endif /* HAS_LZLIB_H */ + #ifndef MIN # define MIN(x, y) ((size_t)(x) < (size_t)(y) ? (size_t)(x) : (size_t)(y)) #endif @@ -1258,6 +1512,9 @@ /* ZSTD */ else if (u[0] >= 0x22 && u[0] <= 0x28 && u[1] == 0xb5 && u[2] == 0x2f && u[3] == 0xfd) what = 's'; + /* LZIP */ + else if (u[0] == 0x4c && u[1] == 0x5a && u[2] == 0x49 && u[3] == 0x50) + what = 'L'; err: return what; } @@ -1287,6 +1544,8 @@ what = 's'; else if (strcmp(suff, "zstd") == 0) what = 's'; + else if (strcmp(suff, "lz") == 0) + what = 'L'; } if (what == 'n' && *check == 'r') { @@ -1342,6 +1601,11 @@ goto skip; } *suff = '\0'; + if (stat(strcat(ext, ".lz"), &st) == 0) { + what = 'L'; + goto skip; + } + *suff = '\0'; if ((fd = open(ext, O_RDONLY | O_NOCTTY)) < 0) goto skip; @@ -1361,6 +1625,7 @@ case 's': case 'b': case 'x': + case 'L': what = *(check + 1); break; default: @@ -1372,14 +1637,6 @@ return what; } -static void zio_fix_fileno(FILE *fp) -{ -# ifndef LIBIO_IS_FIXED - if (fp && fp->_fileno < 0) - fp->_fileno = 0; -# endif -} - #if defined(HAS_ZLIB_H) static FILE *zio_open_gzip_file(int fd, const char *path, const char *mode, const char *check) { @@ -1398,15 +1655,15 @@ if (fd >= 0) { if ((cookie->file = gzdopen(fd, mode)) == Z_NULL) { - free(cookie); - if (!errno) errno = ENOMEM; - return NULL; + free(cookie); + if (!errno) errno = ENOMEM; + return NULL; } } else { if ((cookie->file = gzopen(path, mode)) == Z_NULL) { - free(cookie); - if (!errno) errno = ENOMEM; - return NULL; + free(cookie); + if (!errno) errno = ENOMEM; + return NULL; } } @@ -1432,8 +1689,8 @@ size_t n = strlen(mode); for (size_t i = 1; i < n; i++) { if (mode[i] >= '0' && mode[i] <= '9') { - level = (int)mode[i]; - break; + level = (int)mode[i]; + break; } } # ifndef NO_WEAK @@ -1522,8 +1779,8 @@ for (size_t i = 1; i < n; i++) { if (mode[i] >= '0' && mode[i] <= '9') { - level = (int)mode[i]; - break; + level = (int)mode[i]; + break; } } if (posix_memalign((void *)&cookie, sizeof(void *), alignof(lzfile_t)) != 0) @@ -1534,13 +1791,13 @@ if (fd >= 0) { if ((cookie->file = fdopen(fd, check)) == NULL) { - free(cookie); - return NULL; + free(cookie); + return NULL; } } else { if ((cookie->file = fopen(path, check)) == NULL) { - free(cookie); - return NULL; + free(cookie); + return NULL; } } @@ -1583,15 +1840,15 @@ if (fd >= 0) { if (!(cookie->file = lzmadec_dopen(fd))) { - free(cookie); - if (!errno) errno = ENOMEM; - return NULL; + free(cookie); + if (!errno) errno = ENOMEM; + return NULL; } } else { if (!(cookie->file = lzmadec_open(path))) { - free(cookie); - if (!errno) errno = ENOMEM; - return NULL; + free(cookie); + if (!errno) errno = ENOMEM; + return NULL; } } ret = fopencookie((void *)cookie, check, iolzma); @@ -1616,8 +1873,8 @@ size_t n = strlen(mode); for (size_t i = 1; i < n; i++) { if (mode[i] >= '1' && mode[i] <= '9') { - level = (int)mode[i]; - break; + level = (int)mode[i]; + break; } } # ifndef NO_WEAK @@ -1632,31 +1889,31 @@ if (fd >= 0) { if ((cookie->file = fdopen(fd, check)) == NULL) { - free(cookie); - return NULL; + free(cookie); + return NULL; } } else { if ((cookie->file = fopen(path, check)) == NULL) { - free(cookie); - return NULL; + free(cookie); + return NULL; } } if (check[0] == 'w') { cookie->cctx = ZSTD_createCCtx(); if (!cookie->cctx) { - fclose(cookie->file); - free(cookie); - errno = EINVAL; - return NULL; + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; } } else { cookie->dctx = ZSTD_createDCtx(); if (!cookie->dctx) { - fclose(cookie->file); - free(cookie); - errno = EINVAL; - return NULL; + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; } } cookie->level = level; @@ -1682,18 +1939,19 @@ static FILE *zio_open_gzip_pipe(int fd, const char *check, uint8_t *magic, size_t mlen) { gzpfile_t *cookie; FILE *fp = NULL; - if (posix_memalign((void *)&cookie, sizeof(void *), alignof(gzpfile_t)) != 0) return NULL; + if (posix_memalign((void *)&cookie, sizeof(void *), alignof(gzpfile_t)) != 0) + return NULL; memset(cookie, 0, alignof(gzpfile_t)); cookie->fd = fd; if (zpopen(cookie, magic, mlen) < 0) { - free(cookie); - if (!errno) errno = ENOMEM; - return NULL; + free(cookie); + if (!errno) errno = ENOMEM; + return NULL; } if (!(fp = fopencookie((void *)cookie, check, iozp))) { - zpclose(cookie); /* cookie is freed by zpclose */ - errno = EINVAL; - return NULL; + zpclose(cookie); /* cookie is freed by zpclose */ + errno = EINVAL; + return NULL; } zio_fix_fileno(fp); return fp; @@ -1704,18 +1962,19 @@ static FILE *zio_open_bzip2_pipe(int fd, const char *check, char *magic, size_t mlen) { bzpfile_t *cookie; FILE *fp = NULL; - if (posix_memalign((void *)&cookie, sizeof(void *), alignof(bzpfile_t)) != 0) return NULL; + if (posix_memalign((void *)&cookie, sizeof(void *), alignof(bzpfile_t)) != 0) + return NULL; memset(cookie, 0, alignof(bzpfile_t)); cookie->fd = fd; if (bzpopen(cookie, magic, mlen) < 0) { - free(cookie); - if (!errno) errno = ENOMEM; - return NULL; + free(cookie); + if (!errno) errno = ENOMEM; + return NULL; } if (!(fp = fopencookie((void *)cookie, check, iobzp))) { - bzpclose(cookie); /* cookie is freed by bzpclose */ - errno = EINVAL; - return NULL; + bzpclose(cookie); /* cookie is freed by bzpclose */ + errno = EINVAL; + return NULL; } zio_fix_fileno(fp); return fp; @@ -1726,28 +1985,29 @@ static FILE *zio_open_lzma_pipe(int fd, const char *check, uint8_t *magic, size_t mlen) { lzfile_t *cookie; FILE *fp = NULL; - if (posix_memalign((void *)&cookie, sizeof(void *), alignof(lzfile_t)) != 0) return NULL; + if (posix_memalign((void *)&cookie, sizeof(void *), alignof(lzfile_t)) != 0) + return NULL; memset(cookie, 0, alignof(lzfile_t)); cookie->strm = (lzma_stream)LZMA_STREAM_INIT; cookie->fd = fd; if ((cookie->file = fdopen(fd, check)) == NULL) { - free(cookie); - return NULL; + free(cookie); + return NULL; } cookie->eof = 0; cookie->encoding = 0; if (lzmapopen(cookie, magic, mlen) != LZMA_OK) { - fclose(cookie->file); - free(cookie); - errno = EINVAL; - return NULL; + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; } if (!(fp = fopencookie((void *)cookie, check, iolzmap))) { - lzma_end(&cookie->strm); - fclose(cookie->file); - free(cookie); - errno = EINVAL; - return NULL; + lzma_end(&cookie->strm); + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; } zio_fix_fileno(fp); cookie->stdio = fp; @@ -1759,27 +2019,28 @@ static FILE *zio_open_zstd_pipe(int fd, const char *check, char *magic, size_t mlen) { zstdfile_t *cookie; FILE *fp = NULL; - if (posix_memalign((void *)&cookie, sizeof(void *), alignof(zstdfile_t) + mlen) != 0) return NULL; + if (posix_memalign((void *)&cookie, sizeof(void *), alignof(zstdfile_t) + mlen) != 0) + return NULL; memset(cookie, 0, alignof(zstdfile_t) + mlen); cookie->magic = ((char *)cookie) + alignof(zstdfile_t); memcpy(cookie->magic, magic, mlen); cookie->mlen = mlen; if ((cookie->file = fdopen(fd, check)) == NULL) { - free(cookie); - return NULL; + free(cookie); + return NULL; } cookie->dctx = ZSTD_createDCtx(); if (!cookie->dctx || zstdopen(cookie) < 0) { - fclose(cookie->file); - free(cookie); - errno = EINVAL; - return NULL; + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; } if (!(fp = fopencookie((void *)cookie, check, iozstd))) { - fclose(cookie->file); - free(cookie); - errno = EINVAL; - return NULL; + fclose(cookie->file); + free(cookie); + errno = EINVAL; + return NULL; } zio_fix_fileno(fp); return fp; @@ -1789,18 +2050,19 @@ static FILE *zio_open_fallback_pipe(int fd, const char *check, char *magic, size_t mlen) { pipe_t *cookie; FILE *fp = NULL; - if (posix_memalign((void *)&cookie, sizeof(void *), alignof(pipe_t) + mlen) != 0) return NULL; + if (posix_memalign((void *)&cookie, sizeof(void *), alignof(pipe_t) + mlen) != 0) + return NULL; memset(cookie, 0, alignof(pipe_t) + mlen); if (mlen > 0) { - cookie->magic = ((char *)cookie) + alignof(pipe_t); - memcpy(cookie->magic, magic, mlen); - cookie->mlen = mlen; + cookie->magic = ((char *)cookie) + alignof(pipe_t); + memcpy(cookie->magic, magic, mlen); + cookie->mlen = mlen; } cookie->fd = fd; if (!(fp = fopencookie((void *)cookie, check, iopipe))) { - free(cookie); - errno = EINVAL; - return NULL; + free(cookie); + errno = EINVAL; + return NULL; } zio_fix_fileno(fp); return fp; @@ -1819,13 +2081,13 @@ FILE *ret = NULL; if (!mode || !(n = strlen(mode))) { - errno = EINVAL; - goto out; + errno = EINVAL; + goto out; } if (n >= sizeof(check)) { - errno = EINVAL; - goto out; + errno = EINVAL; + goto out; } switch (*mode) { @@ -1835,34 +2097,34 @@ } for (i = 1; i < n; i++) { - switch (mode[i]) { - case '\0': break; - case '+': case 'L': errno = EINVAL; goto out; - case 'g': case 'z': case 'l': case 's': case 'b': case 'x': - check[i] = mode[i]; continue; - case 'f': case 'h': - check[i] = '\0'; continue; - default: - check[i] = '\0'; continue; - } - break; + switch (mode[i]) { + case '\0': break; + case '+': case 'L': errno = EINVAL; goto out; + case 'g': case 'z': case 'l': case 's': case 'b': case 'x': + check[i] = mode[i]; continue; + case 'f': case 'h': + check[i] = '\0'; continue; + default: + check[i] = '\0'; continue; + } + break; } if (!path || !(len = strlen(path))) { - errno = EINVAL; - goto out; + errno = EINVAL; + goto out; } ext = strdup(path); if (!ext) { - errno = ENOMEM; - goto out; + errno = ENOMEM; + goto out; } char *old_ext = ext; what = autodetect(&ext, check); if (ext != old_ext) { - free(old_ext); + free(old_ext); } /* --- REFACTORED: Delegate to Helpers --- */ @@ -1870,45 +2132,52 @@ case 'g': case 'z': #if defined(HAS_ZLIB_H) - ret = zio_open_gzip_file(-1, ext, mode, check); + ret = zio_open_gzip_file(-1, ext, mode, check); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 'Z': - ret = zio_open_lzw_file(-1, ext, mode, check); - break; + ret = zio_open_lzw_file(-1, ext, mode, check); + break; case 'b': #if defined(HAS_BZLIB_H) - ret = zio_open_bzip2_file(-1, ext, mode, check); + ret = zio_open_bzip2_file(-1, ext, mode, check); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 'l': case 'x': #if defined(HAS_LZMA_H) - ret = zio_open_lzma_file(-1, ext, mode, check, what); + ret = zio_open_lzma_file(-1, ext, mode, check, what); #elif defined(HAS_LZMADEC_H) - if (what == 'x') { - errno = ENOTSUP; - } else { - ret = zio_open_lzmadec_file(-1, ext, mode, check); - } + if (what == 'x') { + errno = ENOTSUP; + } else { + ret = zio_open_lzmadec_file(-1, ext, mode, check); + } #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 's': #if defined(HAS_ZSTD_H) - ret = zio_open_zstd_file(-1, ext, mode, check); + ret = zio_open_zstd_file(-1, ext, mode, check); +#else + errno = ENOTSUP; +#endif + break; + case 'L': +#if defined(HAS_LZLIB_H) + ret = zio_open_lzip_file(-1, ext, mode, check); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; default: - ret = fopen(ext, mode); - break; + ret = fopen(ext, mode); + break; } out: @@ -1925,13 +2194,13 @@ unsigned int i; if (!mode || !(n = strlen(mode))) { - errno = EINVAL; - goto out; + errno = EINVAL; + goto out; } if (n >= sizeof(check)) { - errno = EINVAL; - goto out; + errno = EINVAL; + goto out; } switch (*mode) { @@ -1941,17 +2210,17 @@ } for (i = 1; i < n; i++) { - switch (mode[i]) { - case '\0': break; - case '+': errno = EINVAL; goto out; - case 'b': case 'x': - check[i] = mode[i]; continue; - case 'f': case 'h': - check[i] = '\0'; continue; - default: - check[i] = '\0'; continue; - } - break; + switch (mode[i]) { + case '\0': break; + case '+': errno = EINVAL; goto out; + case 'g': case 'z': case 'l': case 's': case 'b': case 'x': case 'L': + check[i] = mode[i]; continue; + case 'f': case 'h': + check[i] = '\0'; continue; + default: + check[i] = '\0'; continue; + } + break; } what = *w; @@ -1961,45 +2230,52 @@ case 'g': case 'z': #if defined(HAS_ZLIB_H) - ret = zio_open_gzip_file(fildes, NULL, mode, check); + ret = zio_open_gzip_file(fildes, NULL, mode, check); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 'Z': - ret = zio_open_lzw_file(fildes, NULL, mode, check); - break; + ret = zio_open_lzw_file(fildes, NULL, mode, check); + break; case 'b': #if defined(HAS_BZLIB_H) - ret = zio_open_bzip2_file(fildes, NULL, mode, check); + ret = zio_open_bzip2_file(fildes, NULL, mode, check); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 'l': case 'x': #if defined(HAS_LZMA_H) - ret = zio_open_lzma_file(fildes, NULL, mode, check, what); + ret = zio_open_lzma_file(fildes, NULL, mode, check, what); #elif defined(HAS_LZMADEC_H) - if (what == 'x') { - errno = ENOTSUP; - } else { - ret = zio_open_lzmadec_file(fildes, NULL, mode, check); - } + if (what == 'x') { + errno = ENOTSUP; + } else { + ret = zio_open_lzmadec_file(fildes, NULL, mode, check); + } #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 's': #if defined(HAS_ZSTD_H) - ret = zio_open_zstd_file(fildes, NULL, mode, check); + ret = zio_open_zstd_file(fildes, NULL, mode, check); +#else + errno = ENOTSUP; +#endif + break; + case 'L': +#if defined(HAS_LZLIB_H) + ret = zio_open_lzip_file(fildes, NULL, mode, check); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; default: - ret = fdopen(fildes, mode); - break; + ret = fdopen(fildes, mode); + break; } out: @@ -2022,7 +2298,7 @@ what[0] = w ? *w : 'n'; switch (what[0]) { - case 'g': case 'z': case 'Z': case 'b': case 'l': case 'x': case 's': + case 'g': case 'z': case 'Z': case 'b': case 'l': case 'x': case 's': case 'L': return _knowntype_fdzopen(fildes, mode, what); default: if (*mode == 'w') { @@ -2049,40 +2325,47 @@ case 'g': case 'z': #if defined(HAS_ZLIB_H) - fp = zio_open_gzip_pipe(fildes, "r", (uint8_t *)m, mlen); + fp = zio_open_gzip_pipe(fildes, "r", (uint8_t *)m, mlen); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 'Z': - errno = ENOTSUP; - break; + errno = ENOTSUP; + break; case 'b': #if defined(HAS_BZLIB_H) - fp = zio_open_bzip2_pipe(fildes, "r", m, mlen); + fp = zio_open_bzip2_pipe(fildes, "r", m, mlen); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 'l': case 'x': #if defined(HAS_LZMA_H) - fp = zio_open_lzma_pipe(fildes, "r", (uint8_t *)m, mlen); + fp = zio_open_lzma_pipe(fildes, "r", (uint8_t *)m, mlen); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 's': #if defined(HAS_ZSTD_H) - fp = zio_open_zstd_pipe(fildes, "r", m, mlen); + fp = zio_open_zstd_pipe(fildes, "r", m, mlen); +#else + errno = ENOTSUP; +#endif + break; + case 'L': +#if defined(HAS_LZLIB_H) + fp = zio_open_lzip_pipe(fildes, "r", m, mlen); #else - errno = ENOTSUP; + errno = ENOTSUP; #endif - break; + break; case 'n': default: - fp = zio_open_fallback_pipe(fildes, "r", m, mlen); - break; + fp = zio_open_fallback_pipe(fildes, "r", m, mlen); + break; } err: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzio-1.15/zioP.h new/libzio-1.17/zioP.h --- old/libzio-1.15/zioP.h 2026-06-25 10:24:46.000000000 +0200 +++ new/libzio-1.17/zioP.h 2026-09-18 11:52:14.000000000 +0200 @@ -177,6 +177,27 @@ # endif #endif +#if defined(HAS_LZLIB_H) +# include <stdint.h> +# include <lzlib.h> +# ifndef NO_WEAK +weak_symbol(LZ_compress_open); +weak_symbol(LZ_compress_write_size); +weak_symbol(LZ_compress_write); +weak_symbol(LZ_compress_read); +weak_symbol(LZ_compress_finish); +weak_symbol(LZ_compress_finished); +weak_symbol(LZ_compress_close); +weak_symbol(LZ_decompress_open); +weak_symbol(LZ_decompress_write_size); +weak_symbol(LZ_decompress_write); +weak_symbol(LZ_decompress_read); +weak_symbol(LZ_decompress_finish); +weak_symbol(LZ_decompress_finished); +weak_symbol(LZ_decompress_close); +# endif +#endif + #if defined(HAVE_FOPENCOOKIE) # undef HAVE_FUNOPEN __extension__ typedef off_t zio_off_t;
