Changeset 0ce0103 in mainline for uspace/app/bithenge/blob.c


Ignore:
Timestamp:
2012-08-06T04:15:33Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f9c314a5
Parents:
c3437d9
Message:

Bithenge: implement bitfields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/blob.c

    rc3437d9 r0ce0103  
    5555        assert(ops);
    5656        assert(ops->destroy);
    57         assert(ops->read);
     57        assert(ops->read || ops->read_bits);
    5858        assert(ops->size);
    5959
     
    339339}
    340340
     341static int subblob_read_bits(bithenge_blob_t *base, aoff64_t offset,
     342    char *buffer, aoff64_t *size, bool little_endian)
     343{
     344        subblob_t *blob = blob_as_subblob(base);
     345        if (blob->size_matters) {
     346                if (offset > blob->size)
     347                        return EINVAL;
     348                *size = min(*size, blob->size - offset);
     349        }
     350        offset += blob->offset;
     351        return bithenge_blob_read_bits(blob->source, offset, buffer, size,
     352            little_endian);
     353}
     354
    341355static void subblob_destroy(bithenge_blob_t *base)
    342356{
     
    349363        .size = subblob_size,
    350364        .read = subblob_read,
     365        .read_bits = subblob_read_bits,
    351366        .destroy = subblob_destroy,
    352367};
Note: See TracChangeset for help on using the changeset viewer.