# Copyright © 2013, 2021 Nick Bowler
#
# 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 .
AT_BANNER([Image format tests])
m4_divert_push([PREPARE_TESTS])dnl
# Read the header from a PAM image (from standard input) and set declared
# parameters in shell variables. For example, if the PAM header specifies
# DEPTH 2, the shell variable pam_DEPTH will be set to 2.
#
# Returns a nonzero status if the header could not be parsed.
pam_read_header () {
pam_save_IFS=$IFS
pam_p7_seen=false pam_endhdr_seen=false
while IFS= read a; do
case $a in
P7)
$pam_p7_seen && break # duplicated header
pam_p7_seen=true
;;
ENDHDR)
pam_endhdr_seen=true
break
;;
*)
IFS=$pam_save_IFS read b c <