| 357 | } |
| 358 | |
| 359 | static int __bencode_str_dump(char *out, bencode_item_t *item) { |
| 360 | char *orig = out; |
| 361 | bencode_item_t *child; |
| 362 | |
| 363 | assert(item->iov[0].iov_base != NULL); |
| 364 | out += __bencode_str_cpy(out, &item->iov[0], 1); |
| 365 | |
| 366 | child = item->child; |
| 367 | while (child) { |
| 368 | out += __bencode_str_dump(out, child); |
| 369 | child = child->sibling; |
| 370 | } |
| 371 | |
| 372 | if (item->type == BENCODE_IOVEC) |
| 373 | out += __bencode_str_cpy(out, item->iov[1].iov_base, item->iov[1].iov_len); |
| 374 | else if (item->iov[1].iov_base) |
| 375 | out += __bencode_str_cpy(out, &item->iov[1], 1); |
| 376 | |
| 377 | assert((out - orig) == item->str_len); |
| 378 | *out = '\0'; |
| 379 | return item->str_len; |
| 380 | } |
| 381 | |
| 382 | struct iovec *bencode_iovec(bencode_item_t *root, int *cnt, unsigned int head, unsigned int tail) { |
| 383 | struct iovec *ret; |
no test coverage detected