17 #ifndef DHT_BENCODE_H_ 18 #define DHT_BENCODE_H_ int bvalue_list_append(struct bvalue *list, struct bvalue *val)
Append value to a list.
struct bvalue * bvalue_new_integer(long long int i)
Allocate an integer value.
unsigned char * bytes
string pointer (zero-terminated)
Definition: bencode.h:54
long long int i
Integer value.
Definition: bencode.h:49
struct bvalue ** array
array of elements
Definition: bencode.h:61
struct bvalue::@1::@4 l
List value.
void bvalue_free(struct bvalue *val)
Free bencoding value.
enum bvalue::@0 type
Type of the value contained.
struct bvalue * bvalue_new_string(const unsigned char *s, size_t len)
Allocate a string value.
size_t len
length of the string
Definition: bencode.h:55
struct bvalue * bvalue_new_list(void)
Allocate a list value.
struct bvalue * bdecode_file(FILE *stream)
Parse bencoded file.
int bencode_buf_alloc(const struct bvalue *val, unsigned char **bufp)
Allocate and bencode value to a string buffer.
struct bvalue * bvalue_new_dict(void)
Allocate a dictionary value.
char ** key
array of keys (in lexicographical order)
Definition: bencode.h:68
bencoding value.
Definition: bencode.h:32
struct bvalue::@1::@5 d
Dictionary value.
const unsigned char * bvalue_string(const struct bvalue *val, size_t *len)
Get string value.
int bvalue_integer_ll(const struct bvalue *val, long long int *intval)
Get integer (long long int) value.
struct bvalue * bvalue_copy(const struct bvalue *val)
Deep copy bencoding value.
struct bvalue ** val
array of values
Definition: bencode.h:69
int bencode_buf(const struct bvalue *val, unsigned char *buf, size_t len)
bencode value to a string buffer.
int bvalue_integer_l(const struct bvalue *val, long int *intval)
Get integer (long int) value.
int bvalue_dict_set(struct bvalue *dict, const char *key, struct bvalue *val)
Add a key-value pair to a dictionary.
const struct bvalue * bvalue_dict_get(const struct bvalue *dict, const char *key)
Get dictionary value.
const struct bvalue * bvalue_list_get(const struct bvalue *list, size_t pos)
Get list value.
struct bvalue * bdecode_buf(const unsigned char *buf, size_t len)
Parse bencoded string buffer.
int bvalue_integer(const struct bvalue *val, int *intval)
Get integer (int) value.
int bencode_file(const struct bvalue *val, FILE *stream)
bencode value to file.
struct bvalue::@1::@3 s
String value.