Changeset 5c925ce in mainline for uspace/app/bithenge/print.c
- Timestamp:
- 2012-06-07T17:00:12Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8375d0eb
- Parents:
- 5f679702
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/print.c
r5f679702 r5c925ce 37 37 #include <errno.h> 38 38 #include <stdio.h> 39 #include "blob.h" 39 40 #include "print.h" 40 41 #include "tree.h" … … 120 121 } 121 122 123 static int print_blob(bithenge_print_type_t type, bithenge_node_t *node) 124 { 125 bithenge_blob_t *blob = bithenge_node_as_blob(node); 126 aoff64_t pos = 0; 127 char buffer[1024]; 128 aoff64_t size = sizeof(buffer); 129 int rc; 130 printf(type == BITHENGE_PRINT_PYTHON ? "b\"" : "\""); 131 do { 132 rc = bithenge_blob_read(blob, pos, buffer, &size); 133 if (rc != EOK) 134 return rc; 135 for (aoff64_t i = 0; i < size; i++) 136 printf("\\x%02x", buffer[i]); 137 pos += size; 138 } while (size == sizeof(buffer)); 139 printf("\""); 140 return EOK; 141 } 142 122 143 int bithenge_print_node(bithenge_print_type_t type, bithenge_node_t *tree) 123 144 { … … 133 154 case BITHENGE_NODE_STRING: 134 155 return print_string(type, tree); 156 case BITHENGE_NODE_BLOB: 157 return print_blob(type, tree); 135 158 } 136 159 return ENOTSUP;
Note:
See TracChangeset
for help on using the changeset viewer.