The bencode Reference Manual

This is the bencode Reference Manual, version 3.0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 03:44:29 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 bencode

Bencode

Author

Johan Andersson <>

License

MIT

Version

3.0.1

Dependency

flexi-streams (system).

Source

bencode.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 bencode/bencode.asd

Source

bencode.asd.

Parent Component

bencode (system).

ASDF Systems

bencode.

Packages

bencode-system.


3.1.2 bencode/package.lisp

Source

bencode.asd.

Parent Component

bencode (system).

Packages

bencode.


3.1.3 bencode/dictionary.lisp

Dependency

package.lisp (file).

Source

bencode.asd.

Parent Component

bencode (system).

Public Interface

*binary-key-p* (special variable).

Internals

3.1.4 bencode/encode.lisp

Dependencies
Source

bencode.asd.

Parent Component

bencode (system).

Public Interface

encode (generic function).

Internals

3.1.5 bencode/decode.lisp

Dependencies
Source

bencode.asd.

Parent Component

bencode (system).

Public Interface

decode (generic function).

Internals

4 Packages

Packages are listed by definition order.


4.1 bencode-system

Source

bencode.asd.

Use List
  • asdf/interface.
  • common-lisp.

4.2 bencode

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *binary-key-p*

When decoding dictionary values, this function is passed a list, where the first element is the key of the value. If the dictionary was in turn a dictionary value, that key is the second element of the list, and so on. Should a dictionary be a value in a bencoded list, the corresponding element in the list will be the symbol :list. When the function return a true value, the dictionary value will be binary. Otherwise it will be decoded as a string.

The default function in *binary-key-p* returns true for the "pieces" value in the "info" dictionary. All other values are decoded as strings.

Package

bencode.

Source

dictionary.lisp.


5.1.2 Generic functions

Generic Function: decode (input &key external-format &allow-other-keys)

Decode a bencode object from a stream or sequence.
If input is a flexi-stream, its external-format will be used when decoding strings. If input is a string, all characters must have char-codes that fit in an (unsigned-byte 8). Otherwise, the value of the external-format parameter is used to create a flexi-stream for decoding. The default is UTF-8.

Package

bencode.

Source

decode.lisp.

Methods
Method: decode ((stream flexi-stream) &key &allow-other-keys)
Method: decode ((sequence sequence) &key external-format)
Method: decode ((string string) &key external-format)
Method: decode ((stream stream) &key external-format)
Generic Function: encode (object stream &key external-format &allow-other-keys)

Encode object and write it to stream or, if stream
is nil, use an in-memory stream and return the resulting sequence. The external-format is used when encoding strings. UTF-8 is the default.

Package

bencode.

Source

encode.lisp.

Methods
Method: encode ((sequence array) (stream flexi-stream) &key &allow-other-keys)
Method: encode ((integer integer) (stream flexi-stream) &key &allow-other-keys)
Method: encode ((string string) (stream flexi-stream) &key &allow-other-keys)
Method: encode ((dictionary hash-table) (stream flexi-stream) &key &allow-other-keys)
Method: encode ((list list) (stream flexi-stream) &key &allow-other-keys)
Method: encode (object (stream (eql nil)) &key external-format)
Method: encode (object (stream stream) &key external-format)

5.2 Internals


5.2.1 Special variables

Special Variable: *ascii*
Package

bencode.

Source

encode.lisp.

Special Variable: *dictionary-keys*
Package

bencode.

Source

decode.lisp.


5.2.2 Macros

Macro: restart-case-loop (form &body clauses)
Package

bencode.

Source

decode.lisp.


5.2.3 Ordinary functions

Function: binary-dictionary-key-p (key)
Package

bencode.

Source

dictionary.lisp.

Function: decode-binary-string (stream)
Package

bencode.

Source

decode.lisp.

Function: decode-dictionary (stream)
Package

bencode.

Source

decode.lisp.

Function: decode-integer (stream)
Package

bencode.

Source

decode.lisp.

Function: decode-list (stream)
Package

bencode.

Source

decode.lisp.

Function: decode-string (stream)
Package

bencode.

Source

decode.lisp.

Function: dictionary->alist (dictionary)

Returns an alist representation of the dictionary.

Package

bencode.

Source

dictionary.lisp.

Function: get-dictionary (key dictionary)
Package

bencode.

Source

dictionary.lisp.

Function: make-dictionary (list)

Makes a dictionary from a plist or alist. Keys must be strings.

Package

bencode.

Source

dictionary.lisp.

Function: maybe-read-char (stream char)
Package

bencode.

Source

decode.lisp.

Function: must-read-char (stream char)
Package

bencode.

Source

decode.lisp.

Function: must-read-octets (stream length)
Package

bencode.

Source

decode.lisp.

Function: read-external-format ()
Package

bencode.

Source

decode.lisp.

Function: read-integers (stream)
Package

bencode.

Source

decode.lisp.

Function: render-integer (integer)
Package

bencode.

Source

encode.lisp.

Function: string-header (length)
Package

bencode.

Source

encode.lisp.


5.2.4 Generic functions

Generic Reader: actual-octet (condition)
Package

bencode.

Methods
Reader Method: actual-octet ((condition unexpected-octet))
Source

decode.lisp.

Target Slot

actual-octet.

Generic Reader: expected-octet (condition)
Package

bencode.

Methods
Reader Method: expected-octet ((condition unexpected-octet))
Source

decode.lisp.

Target Slot

expected-octet.

Generic Reader: key (condition)
Package

bencode.

Methods
Reader Method: key ((condition nonstring-dictionary-key))
Source

dictionary.lisp.

Target Slot

key.

Generic Reader: octet (condition)
Package

bencode.

Methods
Reader Method: octet ((condition invalid-value-type))
Source

decode.lisp.

Target Slot

octet.


5.2.5 Conditions

Condition: invalid-value-type
Package

bencode.

Source

decode.lisp.

Direct superclasses

error.

Direct methods

octet.

Direct slots
Slot: octet
Initargs

:octet

Readers

octet.

Writers

This slot is read-only.

Condition: nonstring-dictionary-key
Package

bencode.

Source

dictionary.lisp.

Direct superclasses

error.

Direct methods

key.

Direct slots
Slot: key
Initargs

:key

Readers

key.

Writers

This slot is read-only.

Condition: unexpected-octet
Package

bencode.

Source

decode.lisp.

Direct superclasses

error.

Direct methods
Direct slots
Slot: expected-octet
Initargs

:expected-octet

Readers

expected-octet.

Writers

This slot is read-only.

Slot: actual-octet
Initargs

:actual-octet

Readers

actual-octet.

Writers

This slot is read-only.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   B   D   E   F   G   K   M   O   R   S  
Index Entry  Section

A
actual-octet: Private generic functions
actual-octet: Private generic functions

B
binary-dictionary-key-p: Private ordinary functions

D
decode: Public generic functions
decode: Public generic functions
decode: Public generic functions
decode: Public generic functions
decode: Public generic functions
decode-binary-string: Private ordinary functions
decode-dictionary: Private ordinary functions
decode-integer: Private ordinary functions
decode-list: Private ordinary functions
decode-string: Private ordinary functions
dictionary->alist: Private ordinary functions

E
encode: Public generic functions
encode: Public generic functions
encode: Public generic functions
encode: Public generic functions
encode: Public generic functions
encode: Public generic functions
encode: Public generic functions
encode: Public generic functions
expected-octet: Private generic functions
expected-octet: Private generic functions

F
Function, binary-dictionary-key-p: Private ordinary functions
Function, decode-binary-string: Private ordinary functions
Function, decode-dictionary: Private ordinary functions
Function, decode-integer: Private ordinary functions
Function, decode-list: Private ordinary functions
Function, decode-string: Private ordinary functions
Function, dictionary->alist: Private ordinary functions
Function, get-dictionary: Private ordinary functions
Function, make-dictionary: Private ordinary functions
Function, maybe-read-char: Private ordinary functions
Function, must-read-char: Private ordinary functions
Function, must-read-octets: Private ordinary functions
Function, read-external-format: Private ordinary functions
Function, read-integers: Private ordinary functions
Function, render-integer: Private ordinary functions
Function, string-header: Private ordinary functions

G
Generic Function, actual-octet: Private generic functions
Generic Function, decode: Public generic functions
Generic Function, encode: Public generic functions
Generic Function, expected-octet: Private generic functions
Generic Function, key: Private generic functions
Generic Function, octet: Private generic functions
get-dictionary: Private ordinary functions

K
key: Private generic functions
key: Private generic functions

M
Macro, restart-case-loop: Private macros
make-dictionary: Private ordinary functions
maybe-read-char: Private ordinary functions
Method, actual-octet: Private generic functions
Method, decode: Public generic functions
Method, decode: Public generic functions
Method, decode: Public generic functions
Method, decode: Public generic functions
Method, encode: Public generic functions
Method, encode: Public generic functions
Method, encode: Public generic functions
Method, encode: Public generic functions
Method, encode: Public generic functions
Method, encode: Public generic functions
Method, encode: Public generic functions
Method, expected-octet: Private generic functions
Method, key: Private generic functions
Method, octet: Private generic functions
must-read-char: Private ordinary functions
must-read-octets: Private ordinary functions

O
octet: Private generic functions
octet: Private generic functions

R
read-external-format: Private ordinary functions
read-integers: Private ordinary functions
render-integer: Private ordinary functions
restart-case-loop: Private macros

S
string-header: Private ordinary functions