#!/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' \
'Ala ma kota a kot ma Alę.' > exp || framework_failure_
hex_printf_ \
'\x50\x4b\x03\x04\x2d\x00\x08\x00\x08\x00\x2c\x7f\xd1\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\x49\x54'\
'\xc8\x4d\x54\xc8\xce\x2f\x49\x54\x00\x53\x20\x9e\x63\xce\x91\x99'\
'\x7a\x00\x50\x4b\x07\x08\xa7\x87\xdf\x5f\x16\x00\x00\x00\x00\x00'\
'\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x50\x4b\x01\x02\x2d\xff'\
'\x2d\x00\x08\x00\x08\x00\x2c\x7f\xd1\x5a\xa7\x87\xdf\x5f\x16\x00'\
'\x00\x00\x1a\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\x6a\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
