#!/bin/sh
# Test reading of PKZIP data descriptors.

# Copyright 2025 Free Software Foundation, Inc.

# This program 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 3 of the License, or
# (at your option) any later version.

# This program 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/>.
# limit so don't run it by default.

. "${srcdir=.}/init.sh"; path_prepend_ ..

printf '%s' \
'Alice has cat and cat has Alice.' > exp || framework_failure_
hex_printf_ \
'\x50\x4b\x03\x04\x2d\x00\x08\x00\x08\x00\x27\x3e\xd2\x5a\x00\x00'\
'\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x01\x00\x1d\x00\x2d\x01'\
'\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\
'\x00\x00\x00\x55\x54\x05\x00\x01\x00\x00\x00\x00\x73\xcc\xc9\x4c'\
'\x4e\x55\xc8\x48\x2c\x56\x48\x4e\x2c\x51\x48\xcc\x4b\x01\xd3\x20'\
'\xbe\x23\x48\x46\x0f\x00\x50\x4b\x07\x08\x8c\x2b\xd2\x45\x1a\x00'\
'\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x50\x4b'\
'\x01\x02\x2d\xff\x2d\x00\x08\x00\x08\x00\x27\x3e\xd2\x5a\x8c\x2b'\
'\xd2\x45\x1a\x00\x00\x00\x20\x00\x00\x00\x01\x00\x09\x00\x00\x00'\
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2d\x55\x54\x05'\
'\x00\x01\x00\x00\x00\x00\x50\x4b\x05\x06\x00\x00\x00\x00\x01\x00'\
'\x01\x00\x38\x00\x00\x00\x6e\x00\x00\x00\x00\x00'\
 > test.gz || framework_failure_

fail=0
gzip -dc test.gz > out 2> err || fail=1

compare exp out || fail=1
compare /dev/null err || fail=1

Exit $fail
