'Process an extended or global header as described in
POSIX.1-2001.'

def _proc_pax(self, tarfile):

    buf = tarfile.fileobj.read(self._block(self.size))
    if (self.type == XGLTYPE):
        pax_headers = tarfile.pax_headers
    else:
        pax_headers = tarfile.pax_headers.copy()
    regex = re.compile('(\\d+)    ([^=]+)=', re.U)
    pos = 0
    while True:
        match = regex.match(buf, pos)
        if (not match):
            break
        (length, keyword) = match.groups()
        length = int(length)
        value = buf[(match.end(2) + 1):((match.start(1) + length) - 1)]
        keyword = keyword.decode('utf8')
        value = value.decode('utf8')
        pax_headers[keyword] = value
        pos += length
    try:
        next = self.fromtarfile(tarfile)
    except HeaderError:
        raise SubsequentHeaderError('missing    or    bad    subsequent    header')
    if (self.type in (XHDTYPE, SOLARIS_XHDTYPE)):
        next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
        next.offset = self.offset
        if ('size' in pax_headers):
            offset = next.offset_data
            if (next.isreg() or (next.type not in SUPPORTED_TYPES)):
                offset += next._block(next.size)
            tarfile.offset = offset
    return next
