# Path: pyfive/core.py
# def _padded_size(size, padding_multipe=8):
#     """ Return the size of a field padded to be a multiple a give value. """
#     return int(ceil(size / padding_multipe) * padding_multipe)
# 
# def _structure_size(structure):
#     """ Return the size of a structure in bytes. """
#     fmt = '<' + ''.join(structure.values())
#     return struct.calcsize(fmt)
# 
# Path: pyfive/core.py
# def _unpack_struct_from(structure, buf, offset=0):
#     """ Unpack a structure into an OrderedDict from a buffer of bytes. """
#     fmt = '<' + ''.join(structure.values())
#     values = struct.unpack_from(fmt, buf, offset=offset)
#     return OrderedDict(zip(structure.keys(), values))
# 
# def _unpack_struct_from_file(structure, fh):
#     """ Unpack a structure into an OrderedDict from an open file. """
#     size = _structure_size(structure)
#     buf = fh.read(size)
#     return _unpack_struct_from(structure, buf)
# 
# Path: pyfive/core.py
# class InvalidHDF5File(Exception):
#     """ Exception raised when an invalid HDF5 file is detected. """
#     pass


import struct
from collections import OrderedDict
from .core import _padded_size, _structure_size
from .core import _unpack_struct_from, _unpack_struct_from_file
from .core import InvalidHDF5File
    ('reserved_0', 'B'),
    ('symbols', 'H'),
))

SYMBOL_TABLE_ENTRY = OrderedDict((
    ('link_name_offset', 'Q'),     # 8 byte address
    ('object_header_address', 'Q'),
    ('cache_type', 'I'),
    ('reserved', 'I'),
    ('scratch', '16s'),
))


# III.D Disk Format: Level 1D - Local Heaps
LOCAL_HEAP = OrderedDict((
    ('signature', '4s'),
    ('version', 'B'),
    ('reserved', '3s'),
    ('data_segment_size', 'Q'),         # 8 byte size of lengths
    ('offset_to_free_list', 'Q'),       # 8 bytes size of lengths
    ('address_of_data_segment', 'Q'),   # 8 byte addressing
))

# III.E Disk Format: Level 1E - Global Heap
GLOBAL_HEAP_HEADER = OrderedDict((
    ('signature', '4s'),
    ('version', 'B'),
    ('reserved', '3s'),
    ('collection_size', 'Q'),
))

# Path: pyfive/core.py
# def _padded_size(size, padding_multipe=8):
#     """ Return the size of a field padded to be a multiple a give value. """
#     return int(ceil(size / padding_multipe) * padding_multipe)
# 
# def _structure_size(structure):
#     """ Return the size of a structure in bytes. """
#     fmt = '<' + ''.join(structure.values())
#     return struct.calcsize(fmt)
# 
# Path: pyfive/core.py
# def _unpack_struct_from(structure, buf, offset=0):
#     """ Unpack a structure into an OrderedDict from a buffer of bytes. """
#     fmt = '<' + ''.join(structure.values())
#     values = struct.unpack_from(fmt, buf, offset=offset)
#     return OrderedDict(zip(structure.keys(), values))
# 
# def _unpack_struct_from_file(structure, fh):
#     """ Unpack a structure into an OrderedDict from an open file. """
#     size = _structure_size(structure)
#     buf = fh.read(size)
#     return _unpack_struct_from(structure, buf)
# 
# Path: pyfive/core.py
# class InvalidHDF5File(Exception):
#     """ Exception raised when an invalid HDF5 file is detected. """
#     pass


# Path: pyfive/misc_low_level.py
import struct
from collections import OrderedDict
from .core import _padded_size, _structure_size
from .core import _unpack_struct_from, _unpack_struct_from_file
from .core import InvalidHDF5File

    ('reserved_0', 'B'),
    ('symbols', 'H'),
))

SYMBOL_TABLE_ENTRY = OrderedDict((
    ('link_name_offset', 'Q'),     # 8 byte address
    ('object_header_address', 'Q'),
    ('cache_type', 'I'),
    ('reserved', 'I'),
    ('scratch', '16s'),
))


# III.D Disk Format: Level 1D - Local Heaps
LOCAL_HEAP = OrderedDict((
    ('signature', '4s'),
    ('version', 'B'),
    ('reserved', '3s'),
    ('data_segment_size', 'Q'),         # 8 byte size of lengths
    ('offset_to_free_list', 'Q'),       # 8 bytes size of lengths
    ('address_of_data_segment', 'Q'),   # 8 byte addressing
))

# III.E Disk Format: Level 1E - Global Heap
GLOBAL_HEAP_HEADER = OrderedDict((
    ('signature', '4s'),
    ('version', 'B'),
    ('reserved', '3s'),
    ('collection_size', 'Q'),
))

GLOBAL_HEAP_HEADER_SIZE = _structure_size(GLOBAL_HEAP_HEADER)