+
+ p = header->buffer;
+ for (i = sizeof *header; i-- != 0;)
+ {
+ unsigned_sum += (unsigned char) *p;
+ signed_sum += (signed char) (*p++);
+ }
+
+ if (unsigned_sum == 0)
+ return HEADER_ZERO_BLOCK;
+
+ /* Adjust checksum to count the "chksum" field as blanks. */
+
+ for (i = sizeof header->header.chksum; i-- != 0;)
+ {
+ unsigned_sum -= (unsigned char) header->header.chksum[i];
+ signed_sum -= (signed char) (header->header.chksum[i]);
+ }
+ unsigned_sum += ' ' * sizeof header->header.chksum;
+ signed_sum += ' ' * sizeof header->header.chksum;
+
+ parsed_sum = from_header (header->header.chksum,
+ sizeof header->header.chksum, 0,
+ (uintmax_t) 0,
+ (uintmax_t) TYPE_MAXIMUM (int), true, silent);
+ if (parsed_sum == (uintmax_t) -1)
+ return HEADER_FAILURE;
+
+ recorded_sum = parsed_sum;
+
+ if (unsigned_sum != recorded_sum && signed_sum != recorded_sum)
+ return HEADER_FAILURE;
+
+ return HEADER_SUCCESS;
+}
+
+/* Read a block that's supposed to be a header block. Return its
+ address in *RETURN_BLOCK, and if it is good, the file's size
+ and names (file name, link name) in *INFO.
+
+ Return one of enum read_header describing the status of the
+ operation.
+
+ The MODE parameter instructs read_header what to do with special
+ header blocks, i.e.: extended POSIX, GNU long name or long link,
+ etc.:
+
+ read_header_auto process them automatically,
+ read_header_x_raw when a special header is read, return
+ HEADER_SUCCESS_EXTENDED without actually
+ processing the header,
+ read_header_x_global when a POSIX global header is read,
+ decode it and return HEADER_SUCCESS_EXTENDED.
+
+ You must always set_next_block_after(*return_block) to skip past
+ the header which this routine reads. */
+
+enum read_header
+read_header (union block **return_block, struct tar_stat_info *info,
+ enum read_header_mode mode)
+{