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

Safe HaskellSafe
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 #

Ascii offset representation of a double quote.

singleQuote :: Word8 #

Ascii offset representation of a single quote.

backslash :: Word8 #

Ascii offset representation of a backslash.

equals :: Word8 #

Ascii offset representation of an equality sign.

quotedValue :: Parser ByteString #

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 #

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 #

Parses either a quoted value or an unquoted value

keyValue :: Parser Token #

Parses key and value

key :: Parser Token #

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 #

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

tokens :: Parser [Token] #

Parser that reads keys or key/values

line :: Parser Line #

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