Changeset 1c79996 in mainline
- Timestamp:
- 2012-08-18T23:20:48Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a42d7d8
- Parents:
- 1f9c9a4
- Location:
- uspace
- Files:
-
- 8 added
- 6 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/bithenge/fat.bh
r1f9c9a4 r1c79996 76 76 .size_shown <- if (.size > 32) { (32) } else { (.size) }; 77 77 78 if (.start != 0 && .start != self_start && .start != parent ) {78 if (.start != 0 && .start != self_start && .start != parent && .filename[0] != 229) { 79 79 .data 80 80 <- if (.attrs.subdirectory) { -
uspace/dist/src/bithenge/repeat.bh
r1f9c9a4 r1c79996 24 24 .without_count <- without_count <- known_length(9); 25 25 .do_while <- do_while; 26 .do_while_item <- (.do_while[1]); 26 27 }; -
uspace/dist/src/bithenge/repeat.out
r1f9c9a4 r1c79996 41 41 "val": 9 42 42 } 43 }, 44 "do_while_item": { 45 "valid": True, 46 "val": 4 43 47 } 44 48 } -
uspace/dist/src/bithenge/test.sh
r1f9c9a4 r1c79996 12 12 fi 13 13 14 test_file() { 15 echo "Testing $1 on $2..." 16 ${BITHENGE} $1 $2 2>&1|diff $3 - 17 } 18 14 19 for BH in *.bh 15 20 do … … 19 24 [ -e ${DAT} ] || continue 20 25 [ -e ${OUT} ] || continue 21 echo "Testing ${BH} on ${DAT}..." 22 ${BITHENGE} ${BH} ${DAT} 2>&1|diff ${OUT} - 26 test_file ${BH} ${DAT} ${OUT} 23 27 done 24 28 done 25 29 30 test_file trip.bh file:trip.dat trip.out 31 test_file repeat.bh hex:7f07020305070b0D11020004000800102040010101040009 repeat.out 32 26 33 echo "Done!" -
uspace/lib/bithenge/expression.c
r1f9c9a4 r1c79996 1066 1066 if (rc != EOK) 1067 1067 return rc; 1068 b_size = offset + *size - self->a_size; 1068 b_size = *size - a_size; 1069 assert(a_size % 8 == 0); /* TODO: don't require this */ 1069 1070 rc = bithenge_blob_read_bits(self->b, 1070 offset + a_size - self->a_size, buffer + a_size , &b_size,1071 little_endian);1071 offset + a_size - self->a_size, buffer + a_size / 8, 1072 &b_size, little_endian); 1072 1073 if (rc != EOK) 1073 1074 return rc; -
uspace/lib/bithenge/sequence.c
r1f9c9a4 r1c79996 915 915 typedef struct { 916 916 seq_node_t base; 917 bool prefix;918 917 bithenge_expression_t *expr; 919 918 bithenge_transform_t *xform; … … 995 994 } 996 995 997 if (!self->prefix) {998 bool complete;999 rc = seq_node_complete(do_while_as_seq(self), &complete);1000 if (rc != EOK)1001 return rc;1002 if (!complete)1003 return EINVAL;1004 }1005 1006 996 return rc; 1007 997 } … … 1035 1025 1036 1026 static int do_while_transform_make_node(do_while_transform_t *self, 1037 bithenge_node_t **out, bithenge_scope_t *scope, bithenge_blob_t *blob, 1038 bool prefix) 1027 bithenge_node_t **out, bithenge_scope_t *scope, bithenge_blob_t *blob) 1039 1028 { 1040 1029 do_while_node_t *node = malloc(sizeof(*node)); … … 1060 1049 bithenge_expression_inc_ref(self->expr); 1061 1050 node->expr = self->expr; 1062 node->prefix = prefix;1063 1051 node->count = -1; 1064 1052 *out = do_while_as_node(node); 1065 1053 return EOK; 1066 }1067 1068 static int do_while_transform_apply(bithenge_transform_t *base,1069 bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out)1070 {1071 do_while_transform_t *self = transform_as_do_while(base);1072 if (bithenge_node_type(in) != BITHENGE_NODE_BLOB)1073 return EINVAL;1074 return do_while_transform_make_node(self, out, scope,1075 bithenge_node_as_blob(in), false);1076 1054 } 1077 1055 … … 1089 1067 { 1090 1068 do_while_transform_t *self = transform_as_do_while(base); 1091 int rc = do_while_transform_make_node(self, out_node, scope, blob, 1092 true); 1069 int rc = do_while_transform_make_node(self, out_node, scope, blob); 1093 1070 if (rc != EOK) 1094 1071 return rc; … … 1121 1098 1122 1099 static const bithenge_transform_ops_t do_while_transform_ops = { 1123 .apply = do_while_transform_apply,1124 1100 .prefix_apply = do_while_transform_prefix_apply, 1125 1101 .destroy = do_while_transform_destroy, -
uspace/lib/bithenge/transform.c
r1f9c9a4 r1c79996 892 892 MAKE_UINT_TRANSFORM(uint32le, uint32_t, uint32_t_le2host, prefix_length_4); 893 893 MAKE_UINT_TRANSFORM(uint32be, uint32_t, uint32_t_be2host, prefix_length_4); 894 MAKE_UINT_TRANSFORM(uint64le, uint64_t, uint 32_t_le2host, prefix_length_8);895 MAKE_UINT_TRANSFORM(uint64be, uint64_t, uint 32_t_be2host, prefix_length_8);894 MAKE_UINT_TRANSFORM(uint64le, uint64_t, uint64_t_le2host, prefix_length_8); 895 MAKE_UINT_TRANSFORM(uint64be, uint64_t, uint64_t_be2host, prefix_length_8); 896 896 897 897 -
uspace/lib/bithenge/tree.c
r1f9c9a4 r1c79996 102 102 /** Get a child of a node. Takes ownership of the key. If the node does not 103 103 * provide this function, for_each will be used as an alternative, which may be 104 * very slow. 105 * @memberof bithenge_node_t 106 * @param self The internal node to find a child of. 104 * very slow. Also works for blob nodes to find the byte value at a given 105 * index. 106 * @memberof bithenge_node_t 107 * @param self The internal/blob node to find a child of. 107 108 * @param key The key to search for. 108 109 * @param[out] out Holds the found node. … … 112 113 bithenge_node_t **out) 113 114 { 115 if (self->type == BITHENGE_NODE_BLOB) { 116 if (bithenge_node_type(key) != BITHENGE_NODE_INTEGER) { 117 bithenge_node_dec_ref(key); 118 return ENOENT; 119 } 120 bithenge_int_t offset = bithenge_integer_node_value(key); 121 bithenge_node_dec_ref(key); 122 uint8_t byte; 123 aoff64_t size = 1; 124 int rc = bithenge_blob_read(bithenge_node_as_blob(self), 125 offset, (char *)&byte, &size); 126 if (rc != EOK) 127 return rc; 128 if (size != 1) 129 return ENOENT; 130 131 return bithenge_new_integer_node(out, byte); 132 } 133 114 134 assert(self->type == BITHENGE_NODE_INTERNAL); 115 135 if (self->internal_ops->get)
Note:
See TracChangeset
for help on using the changeset viewer.