megaco_flex_scanner(3)
π megaco_flex_scanner π
okay bestie, this is the manual page for megaco_flex_scanner(3), which lives in the megaco application (we're on version 4.9.2, drop by Ericsson AB, iykyk). it's giving "public API to a C driver" energy and honestly? iconic.
β¨ NAME β¨
megaco_flex_scanner β it's the interface module to the flex scanner that's linked in driver. that's the whole vibe. periodt.
πΈ DESCRIPTION πΈ
so basically, this module holds the public interface to the flex scanner that's linked in driver. and what does that scanner do? it handles the scanning phase of text message decoding. so cute, so important, our little tokenizer π
the flex scanner is written using a tool called flex. and real talk: if you wanna be able to compile the flex scanner driver, that tool has to be available. no flex, no driver, no slay. π
by default, the flex scanner reports the line-number of an error. but plot twist β it can be built without line-number reporting. in that case, token number gets used instead. this speeds up the scanning some 5-10%. if that's your vibe, use --disable-megaco-flex-scanner-lineno when configuring the application. β¨
also, by default the scanner will be built as a reentrant scanner if the flex utility supports this (it literally depends on the version of flex, no cap). it is possible to explicitly disable this even when flex supports it. use --disable-megaco-reentrant-flex-scanner when configuring the application. π
π¦ DATA TYPES π¦
megaco_ports()
megaco_ports() :: port() | tuple().
the return value of a successful (flex) scanner start. that's it, that's the type. π
π FUNCTIONS π
is_reentrant_enabled()
is_reentrant_enabled() -> boolean().
is the flex scanner reentrant or not. simple question, simple answer, we love a yes/no. β¨
is_scanner_port(Port, PortOrPorts)
is_scanner_port(Port, PortOrPorts) -> boolean()
when
Port :: port(),
PortOrPorts :: megaco_ports().
checks if a port is a flex scanner port or not. and bestie, this is useful when if a port exits β like, that's the exact use case, we're not making this up. π«Ά
scan(Binary, PortOrPorts)
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. so you feed it a binary, it hands you tokens. icymi, this is the whole main character move of the module. π₯
start()
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. π«
here's the tea on ports: 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. one. for. each. scheduler. periodt. π
β οΈ no cap, this part matters: note that the process that calls this function must be permanent. if it dies, the port(s) will exit and the driver unload. like, sorry, but that's the rules. π
stop(PortOrPorts)
stop(PortOrPorts) -> stopped when PortOrPorts :: megaco_ports().
this function is used to stop the flex scanner. it also unloads the driver. clean exit, no loose ends, we love to see it. π
π SEE ALSO π
(no SEE ALSO section on this page, bestie β the original doesn't have one, so i'm not out here inventing references, that's not the vibe)
that's the whole page!! πβ¨π¦
signing off: this was megaco_flex_scanner(3) from Ericsson AB, megaco version 4.9.2. go forth and scan responsibly, bestie. π
ππ§π
π¦ where this page comes from
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms