megaco_flex_scanner — megaco v4.7.2.1

Search documentation of megaco

# megaco_flex_scanner (megaco v4.7.2.1)

View Source

Interface module to the flex scanner linked in driver.

This module contains the public interface to the flex scanner linked in driver. The flex scanner performs the scanning phase of text message decoding.

The flex scanner is written using a tool called flex. In order to be able to compile the flex scanner driver, this tool has to be available.

By default the flex scanner reports line-number of an error. But it can be built without line-number reporting. Instead token number is used. This will speed up the scanning some 5-10%. Use `--disable-megaco-flex-scanner-lineno` when configuring the application.

The scanner will, by default, be built as a reentrant scanner if the flex utility supports this (it depends on the version of flex). It is possible to explicitly disable this even when flex support this. Use `--disable-megaco-reentrant-flex-scanner` when configuring the application.

# Summary

## Types

megaco_ports()

Return value of a successful (flex) scanner start.

## Functions

is_reentrant_enabled()

Is the flex scanner reentrant or not.

is_scanner_port(Port, PortOrPorts)

Checks if a port is a flex scanner port or not (useful when if a port exits).

scan(Binary, PortOrPorts)

Scans a megaco message and generates a token list to be passed on the parser.

start()

This function is used to start the flex scanner. It locates the library and loads the linked in driver.

stop(PortOrPorts)

This function is used to stop the flex scanner. It also unloads the driver.

# Types

# megaco_ports()

    -type megaco_ports() :: port() | tuple().

Return value of a successful (flex) scanner start.

# Functions

# is_reentrant_enabled()

    -spec is_reentrant_enabled() -> boolean().

Is the flex scanner reentrant or not.

# is_scanner_port(Port, PortOrPorts)

    -spec is_scanner_port(Port, PortOrPorts) -> boolean() when Port :: port(), PortOrPorts :: megaco_ports().

Checks if a port is a flex scanner port or not (useful when if a port exits).

# scan(Binary, PortOrPorts)

    -spec scan(Binary, PortOrPorts) -> {ok, Tokens, Version, LatestLine} | {error, Reason, LatestLine}
                  when
                      Binary :: binary(),
                      PortOrPorts :: megaco_ports(),
                      Tokens :: list(),
                      Version :: megaco_encoder:protocol_version(),
                      LatestLine :: non_neg_integer(),
                      Reason :: term().

Scans a megaco message and generates a token list to be passed on the parser.

# start()

    -spec start() -> {ok, PortOrPorts} | {error, Reason}
                   when PortOrPorts :: megaco_ports(), Reason :: term().

This function is used to start the flex scanner. It locates the library and loads the linked in driver.

On a single core system or if it's a non-reentrant scanner, a single port is created. On a multi-core system with a reentrant scanner, several ports will be created (one for each scheduler).

Note that the process that calls this function must be permanent. If it dies, the port(s) will exit and the driver unload.

# stop(PortOrPorts)

    -spec stop(PortOrPorts) -> stopped when PortOrPorts :: megaco_ports().

This function is used to stop the flex scanner. It also unloads the driver.