network-anonymous-i2p-0.9.2: Haskell API for I2P anonymous networking

Safe HaskellNone
LanguageHaskell2010

Network.Anonymous.I2P.Protocol.Parser

Description

Parser defintions

Defines parsers used by the I2P SAM protocol

Warning: This function is used internally by I2P and using these functions directly is unsupported. The interface of these functions might change at any time without prior notice.

Synopsis

Documentation

doubleQuote :: Word8 Source

Ascii offset representation of a double quote.

singleQuote :: Word8 Source

Ascii offset representation of a single quote.

backslash :: Word8 Source

Ascii offset representation of a backslash.

equals :: Word8 Source

Ascii offset representation of an equality sign.

quotedValue :: Parser ByteString Source

Parses a single- or double-quoted value, and returns all bytes within the value; the unescaping is beyond the scope of this function (since different unescaping mechanisms might be desired).

Looking at the SAMv3 code on github, it appears as if the protocol is kind hacked together at the moment: no character escaping is performed at all, and no formal tokens / AST is used.

So this function already goes way beyond what is required, but it cannot hurt to do so.

unquotedValue :: Parser ByteString Source

An unquoted value is "everything until a whitespace or newline is reached". This is pretty broad, but the SAM implementation in I2P just uses a strtok, and is quite hackish.

value :: Parser ByteString Source

Parses either a quoted value or an unquoted value

keyValue :: Parser Token Source

Parses key and value

key :: Parser Token Source

Parses a key, which, after studying the SAMv3 code, is anything until either a space has been reached, or an '=' is reached.

token :: Parser Token Source

A Token is either a Key or a Key/Value combination.

tokens :: Parser [Token] Source

Parser that reads keys or key/values

line :: Parser Line Source

A generic parser that reads a whole line of key/values and ends in a newline