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


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.h

    rc3437d9 r0ce0103  
    5656        int (*read)(bithenge_blob_t *self, aoff64_t offset, char *buffer,
    5757            aoff64_t *size);
     58        /** @copydoc bithenge_blob_t::bithenge_blob_read_bits */
     59        int (*read_bits)(bithenge_blob_t *self, aoff64_t offset, char *buffer,
     60            aoff64_t *size, bool little_endian);
    5861        /** Destroy the blob.
    5962         * @param blob The blob. */
     
    146149        assert(self);
    147150        assert(self->base.blob_ops);
     151        if (!self->base.blob_ops->read)
     152                return EINVAL;
    148153        return self->base.blob_ops->read(self, offset, buffer, size);
     154}
     155
     156/** Read part of the bit blob. If the requested data extends beyond the end of
     157 * the blob, the data up until the end of the blob will be read. If the offset
     158 * is beyond the end of the blob, even if the size is zero, an error will be
     159 * returned.
     160 *
     161 * @memberof bithenge_blob_t
     162 * @param self The blob.
     163 * @param offset Byte offset within the blob.
     164 * @param[out] buffer Buffer to read into. If an error occurs, the contents are
     165 * undefined.
     166 * @param[in,out] size Number of bytes to read; may be 0. If the requested
     167 * range extends beyond the end of the blob, the actual number of bytes read
     168 * should be stored here. If an error occurs, the contents are undefined.
     169 * @param little_endian If true, bytes will be filled starting at the least
     170 * significant bit; otherwise, they will be filled starting at the most
     171 * significant bit.
     172 * @return EOK on success or an error code from errno.h.
     173 */
     174static inline int bithenge_blob_read_bits(bithenge_blob_t *self,
     175    aoff64_t offset, char *buffer, aoff64_t *size, bool little_endian)
     176{
     177        assert(self);
     178        assert(self->base.blob_ops);
     179        if (!self->base.blob_ops->read_bits)
     180                return EINVAL;
     181        return self->base.blob_ops->read_bits(self, offset, buffer, size,
     182            little_endian);
    149183}
    150184
Note: See TracChangeset for help on using the changeset viewer.