MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / __bencode_decode_dictionary

Function __bencode_decode_dictionary

modules/rtpengine/bencode.c:478–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478static bencode_item_t *__bencode_decode_dictionary(bencode_buffer_t *buf, const char *s, const char *end) {
479 bencode_item_t *ret, *key, *value;
480 struct __bencode_hash *hash;
481
482 if (*s != 'd')
483 return NULL;
484 s++;
485
486 ret = __bencode_item_alloc(buf, sizeof(*hash));
487 if (!ret)
488 return NULL;
489 __bencode_dictionary_init(ret);
490 ret->value = 1;
491 hash = (void *) ret->__buf;
492 memset(hash, 0, sizeof(*hash));
493
494 while (s < end) {
495 key = __bencode_decode(buf, s, end);
496 if (!key)
497 return NULL;
498 s += key->str_len;
499 if (key->type == BENCODE_END_MARKER)
500 break;
501 if (key->type != BENCODE_STRING)
502 return NULL;
503 __bencode_container_add(ret, key);
504
505 if (s >= end)
506 return NULL;
507 value = __bencode_decode(buf, s, end);
508 if (!value)
509 return NULL;
510 s += value->str_len;
511 if (value->type == BENCODE_END_MARKER)
512 return NULL;
513 __bencode_container_add(ret, value);
514
515 __bencode_hash_insert(key, hash);
516 }
517
518 return ret;
519}
520
521static bencode_item_t *__bencode_decode_list(bencode_buffer_t *buf, const char *s, const char *end) {
522 bencode_item_t *ret, *item;

Callers 1

__bencode_decodeFunction · 0.85

Calls 5

__bencode_item_allocFunction · 0.85
__bencode_decodeFunction · 0.85
__bencode_container_addFunction · 0.85
__bencode_hash_insertFunction · 0.85

Tested by

no test coverage detected