Changeset 978ccaf1 in mainline for uspace/app/bithenge/blob.h
- Timestamp:
- 2012-06-27T03:35:43Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 600f5d1
- Parents:
- 04a7435f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/blob.h
r04a7435f r978ccaf1 52 52 typedef struct bithenge_random_access_blob_ops_t { 53 53 /** @copydoc bithenge_blob_t::bithenge_blob_size */ 54 int (*size)(bithenge_blob_t * blob, aoff64_t *size);54 int (*size)(bithenge_blob_t *self, aoff64_t *size); 55 55 /** @copydoc bithenge_blob_t::bithenge_blob_read */ 56 int (*read)(bithenge_blob_t * blob, aoff64_t offset, char *buffer,56 int (*read)(bithenge_blob_t *self, aoff64_t offset, char *buffer, 57 57 aoff64_t *size); 58 58 /** Destroy the blob. 59 * @param blob The blob. 60 * @return EOK on success or an error code from errno.h. */ 61 int (*destroy)(bithenge_blob_t *blob); 59 * @param blob The blob. */ 60 void (*destroy)(bithenge_blob_t *self); 62 61 } bithenge_random_access_blob_ops_t; 63 62 … … 87 86 * 88 87 * @memberof bithenge_blob_t 89 * @param blobThe blob.88 * @param self The blob. 90 89 * @param[out] size Total size of the blob. 91 90 * @return EOK on success or an error code from errno.h. 92 91 */ 93 int (*size)(bithenge_sequential_blob_t * blob, aoff64_t *size);92 int (*size)(bithenge_sequential_blob_t *self, aoff64_t *size); 94 93 95 94 /** Read the next part of the blob. If the requested data extends … … 97 96 * will be read. 98 97 * 99 * @param blobThe blob.98 * @param self The blob. 100 99 * @param[out] buffer Buffer to read into. If an error occurs, the contents are 101 100 * undefined. … … 105 104 * @return EOK on success or an error code from errno.h. 106 105 */ 107 int (*read)(bithenge_sequential_blob_t * blob, char *buffer,106 int (*read)(bithenge_sequential_blob_t *self, char *buffer, 108 107 aoff64_t *size); 109 108 110 109 /** Destroy the blob. 111 * @param blob The blob. 112 * @return EOK on success or an error code from errno.h. */ 113 int (*destroy)(bithenge_sequential_blob_t *blob); 110 * @param self The blob. */ 111 void (*destroy)(bithenge_sequential_blob_t *self); 114 112 } bithenge_sequential_blob_ops_t; 115 113 … … 117 115 * 118 116 * @memberof bithenge_blob_t 119 * @param blobThe blob.117 * @param self The blob. 120 118 * @param[out] size Total size of the blob. 121 119 * @return EOK on success or an error code from errno.h. 122 120 */ 123 static inline int bithenge_blob_size(bithenge_blob_t * blob, aoff64_t *size)124 { 125 assert( blob);126 assert( blob->base.blob_ops);127 return blob->base.blob_ops->size(blob, size);121 static inline int bithenge_blob_size(bithenge_blob_t *self, aoff64_t *size) 122 { 123 assert(self); 124 assert(self->base.blob_ops); 125 return self->base.blob_ops->size(self, size); 128 126 } 129 127 … … 134 132 * 135 133 * @memberof bithenge_blob_t 136 * @param blobThe blob.134 * @param self The blob. 137 135 * @param offset Byte offset within the blob. 138 136 * @param[out] buffer Buffer to read into. If an error occurs, the contents are … … 143 141 * @return EOK on success or an error code from errno.h. 144 142 */ 145 static inline int bithenge_blob_read(bithenge_blob_t * blob, aoff64_t offset,143 static inline int bithenge_blob_read(bithenge_blob_t *self, aoff64_t offset, 146 144 char *buffer, aoff64_t *size) 147 145 { 148 assert( blob);149 assert( blob->base.blob_ops);150 return blob->base.blob_ops->read(blob, offset, buffer, size);146 assert(self); 147 assert(self->base.blob_ops); 148 return self->base.blob_ops->read(self, offset, buffer, size); 151 149 } 152 150 … … 170 168 } 171 169 172 static inline int bithenge_blob_inc_ref(bithenge_blob_t *blob) 173 { 174 return bithenge_node_inc_ref(bithenge_blob_as_node(blob)); 175 } 176 177 static inline int bithenge_blob_dec_ref(bithenge_blob_t *blob) 178 { 179 if (!blob) 180 return EOK; 181 return bithenge_node_dec_ref(bithenge_blob_as_node(blob)); 182 } 183 184 int bithenge_new_random_access_blob(bithenge_blob_t *blob, 185 const bithenge_random_access_blob_ops_t *ops); 186 187 int bithenge_new_sequential_blob(bithenge_sequential_blob_t *blob, 188 const bithenge_sequential_blob_ops_t *ops); 189 190 int bithenge_new_blob_from_data(bithenge_node_t **out, const void *data, 191 size_t len); 192 193 int bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer, 194 size_t len, bool needs_free); 195 196 int bithenge_new_offset_blob(bithenge_node_t **out, bithenge_blob_t *blob, 197 aoff64_t offset); 198 199 int bithenge_new_subblob(bithenge_node_t **out, bithenge_blob_t *blob, 200 aoff64_t offset, aoff64_t size); 201 202 bool bithenge_blob_equal(bithenge_blob_t *a, bithenge_blob_t *b); 170 /** Increment a blob's reference count. 171 * @param blob The blob to reference. */ 172 static inline void bithenge_blob_inc_ref(bithenge_blob_t *blob) 173 { 174 bithenge_node_inc_ref(bithenge_blob_as_node(blob)); 175 } 176 177 /** Decrement a blob's reference count. 178 * @param blob The blob to dereference, or NULL. */ 179 static inline void bithenge_blob_dec_ref(bithenge_blob_t *blob) 180 { 181 if (blob) 182 bithenge_node_dec_ref(bithenge_blob_as_node(blob)); 183 } 184 185 int bithenge_init_random_access_blob(bithenge_blob_t *, 186 const bithenge_random_access_blob_ops_t *); 187 int bithenge_init_sequential_blob(bithenge_sequential_blob_t *, 188 const bithenge_sequential_blob_ops_t *); 189 int bithenge_new_blob_from_data(bithenge_node_t **, const void *, size_t); 190 int bithenge_new_blob_from_buffer(bithenge_node_t **, const void *, size_t, 191 bool); 192 int bithenge_new_offset_blob(bithenge_node_t **, bithenge_blob_t *, aoff64_t); 193 int bithenge_new_subblob(bithenge_node_t **, bithenge_blob_t *, aoff64_t, 194 aoff64_t); 195 bool bithenge_blob_equal(bithenge_blob_t *, bithenge_blob_t *); 203 196 204 197 #endif
Note:
See TracChangeset
for help on using the changeset viewer.