Changeset d5070ef in mainline
- Timestamp:
- 2012-06-22T05:32:30Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da0fef6
- Parents:
- 8b36bf2
- Location:
- uspace/app/bithenge
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/Makefile
r8b36bf2 rd5070ef 38 38 print.c \ 39 39 test.c \ 40 transform.c \ 40 41 tree.c 41 42 -
uspace/app/bithenge/blob.c
r8b36bf2 rd5070ef 297 297 } 298 298 299 /** Check whether the contents of two blobs are equal. 300 * @memberof bithenge_blob_t 301 * @param a, b Blobs to compare. 302 * @return Whether the blobs are equal. If an error occurs, returns false. 303 */ 304 bool bithenge_blob_equal(bithenge_blob_t *a, bithenge_blob_t *b) 305 { 306 assert(a); 307 assert(a->base.blob_ops); 308 assert(b); 309 assert(b->base.blob_ops); 310 int rc; 311 char buffer_a[4096], buffer_b[4096]; 312 aoff64_t offset = 0, size_a = sizeof(buffer_a), size_b = sizeof(buffer_b); 313 do { 314 rc = bithenge_blob_read(a, offset, buffer_a, &size_a); 315 if (rc != EOK) 316 return false; 317 rc = bithenge_blob_read(b, offset, buffer_b, &size_b); 318 if (rc != EOK) 319 return false; 320 if (size_a != size_b || bcmp(buffer_a, buffer_b, size_a)) 321 return false; 322 offset += size_a; 323 } while (size_a == sizeof(buffer_a)); 324 return true; 325 } 326 299 327 /** @} 300 328 */ -
uspace/app/bithenge/blob.h
r8b36bf2 rd5070ef 182 182 size_t len, bool needs_free); 183 183 184 bool bithenge_blob_equal(bithenge_blob_t *a, bithenge_blob_t *b); 185 184 186 #endif 185 187 -
uspace/app/bithenge/tree.c
r8b36bf2 rd5070ef 37 37 #include <errno.h> 38 38 #include <stdlib.h> 39 #include <str.h> 39 40 #include "blob.h" 40 41 #include "tree.h" … … 207 208 } 208 209 210 /** Check whether the contents of two nodes are equal. Does not yet work for 211 * internal nodes. 212 * @memberof bithenge_node_t 213 * @param a, b Nodes to compare. 214 * @return Whether the nodes are equal. If an error occurs, returns false. 215 * @todo Add support for internal nodes. 216 */ 217 bool bithenge_node_equal(bithenge_node_t *a, bithenge_node_t *b) 218 { 219 if (a->type != b->type) 220 return false; 221 switch (a->type) { 222 case BITHENGE_NODE_INTERNAL: 223 return false; 224 case BITHENGE_NODE_BOOLEAN: 225 return a->boolean_value == b->boolean_value; 226 case BITHENGE_NODE_INTEGER: 227 return a->integer_value == b->integer_value; 228 case BITHENGE_NODE_STRING: 229 return !str_cmp(a->string_value.ptr, b->string_value.ptr); 230 case BITHENGE_NODE_BLOB: 231 return bithenge_blob_equal(bithenge_node_as_blob(a), 232 bithenge_node_as_blob(b)); 233 } 234 return false; 235 } 236 209 237 /** @} 210 238 */ -
uspace/app/bithenge/tree.h
r8b36bf2 rd5070ef 153 153 int bithenge_new_string_node(bithenge_node_t **, const char *, bool); 154 154 int bithenge_node_destroy(bithenge_node_t *); 155 bool bithenge_node_equal(bithenge_node_t *, bithenge_node_t *); 155 156 156 157 #endif
Note:
See TracChangeset
for help on using the changeset viewer.