• P
    block/dmg: extract mish block decoding functionality · 65a1c7c9
    Peter Wu 提交于
    Extract the mish block decoder such that this can be used for other
    formats in the future. A new DmgHeaderState struct is introduced to
    share state while decoding.
    
    The code is kept unchanged as much as possible, a "fail" label is added
    for example where a simple return would probably do. In dmg_open, the
    variable "tmp" is renamed to "rsrc_data_offset" for clarity and comments
    have been added explaining various data.
    
    Note that this patch has one subtle difference with the previous
    version which should not affect functionality. In the previous code,
    the end of a resource was inferred from the mish block (the offsets
    would be increased by the fields). In this patch, the resource length
    is used instead to avoid the need to rely on the previous offsets.
    Signed-off-by: NPeter Wu <peter@lekensteyn.nl>
    Reviewed-by: NJohn Snow <jsnow@redhat.com>
    Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
    Message-id: 1420566495-13284-3-git-send-email-peter@lekensteyn.nl
    Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: NKevin Wolf <kwolf@redhat.com>
    65a1c7c9
dmg.c 15.5 KB