GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cwyang/bencode: Bittorrent bencode reader and writer module

BranchesTags
Open more actions menu

Latest commit

 

History

12 Commits
12 Commits

Folders and files

NameName
Last commit message
Last commit date
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
bencode.c
bencode.c
 
 
bencode.h
bencode.h
 
 
bencode.txt
bencode.txt
 
 
bencode_test.c
bencode_test.c
 
 
list.h
list.h
 
 

Repository files navigation

bencode Build Status Coverage Status

A robust C library for reading and writing Bittorrent bencode data.

License

Apache license v2.0.

APIs

extern be_node_t *be_decode(const char *inBuf, size_t inBufLen, size_t *readAmount);
extern ssize_t be_encode(const be_node_t *node, char *outBuf, size_t outBufLen);
extern void be_free(be_node_t *node);
extern void be_dump(be_node_t *node);
  • when be_decode() fails, it returns NULL and set errno to:
    • ENOMEM: memory allocation failed
    • EINVAL: invalid bencode data
    • ELOOP: max depth reached (default: 10)
  • be_encode(node, NULL, 0) returns the size of output buffer to be allocated. You can malloc and call be_encode() again with alloc'ed buffer.

Build and Test

$ make && make test
--(snip)--
{ "test": [ "test"]
, "announce": "udp://tracker.openbittorrent.com:80"
, "creation date": 1327049827
, "info": { "length": 20
          , "name": "sample.txt"
          , "piece length": 65536
          , "pieces": "..R....x...d.......1"
          , "private": 1}}
All tests passed!

Thank you for reading :-)

About

Bittorrent bencode reader and writer module

Topics

bittorrentbittorrent-protocol

Resources

Readme
Apache-2.0 license
Activity

Stars

8 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.