File: bencode.h

package info (click to toggle)
ctorrent 1.3.4.dnh3.3.2-5
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,240 kB
  • sloc: cpp: 13,161; sh: 675; ansic: 383; makefile: 6
file content (37 lines) | stat: -rw-r--r-- 1,371 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef BENCODE_H
#define BENCODE_H

#include <inttypes.h>
#include <sys/types.h>
#include <stdio.h>

#define KEY_SP '|'	//the keyname list's delimiters
#define KEYNAME_SIZ 32
#define KEYNAME_LISTSIZ 256

#define MAX_INT_SIZ 64

#define QUERY_STR 0
#define QUERY_INT 1
#define QUERY_POS 2
#define QUERY_LONG 3

size_t buf_long(const char *b,size_t len,char beginchar,char endchar,int64_t *pi);
size_t buf_int(const char *b,size_t len,char beginchar,char endchar,size_t *pi);
size_t buf_str(const char *b,size_t len,const char **pstr,size_t* slen);
size_t decode_int(const char *b,size_t len);
size_t decode_str(const char *b,size_t len);
size_t decode_dict(const char *b,size_t len,const char *keylist);
size_t decode_list(const char *b,size_t len,const char *keylist);
size_t decode_rev(const char *b,size_t len,const char *keylist);
size_t decode_query(const char *b,size_t len,const char *keylist,const char **ps,size_t *pi,int64_t *pl,int method);
size_t decode_list2path(const char *b, size_t n, char *pathname, size_t maxlen);
size_t bencode_buf(const char *str,size_t len,FILE *fp);
size_t bencode_str(const char *str, FILE *fp);
size_t bencode_int(const uint64_t integer, FILE *fp);
size_t bencode_begin_dict(FILE *fp);
size_t bencode_begin_list(FILE *fp);
size_t bencode_end_dict_list(FILE *fp);
size_t bencode_path2list(const char *pathname, FILE *fp);

#endif