37
37
<p>This module contains the public interface to the flex scanner
38
38
linked in driver. The flex scanner performs the scanning phase
39
39
of text message decoding.</p>
40
41
<p>The flex scanner is written using a tool called <em>flex</em>.
41
42
In order to be able to compile the flex scanner driver, this
42
43
tool has to be available. </p>
43
45
<p>By default the flex scanner reports line-number of an error.
44
46
But it can be built without line-number reporting. Instead
45
47
token number is used. This will speed up the scanning some
46
48
5-10%. Use <c><![CDATA[--disable-megaco-flex-scanner-lineno]]></c> when
47
49
configuring the application.</p>
51
<p>The scanner will, by default, be built as a reentrant scanner <em>if</em> the
52
flex utility supports this (it depends on the version of flex).
53
It is possible to explicitly disable this even when flex support this.
54
Use <c><![CDATA[--disable-megaco-reentrant-flex-scanner]]></c> when
55
configuring the application.</p>
60
<title>DATA TYPES</title>
61
<code type="none"><![CDATA[
63
megaco_ports() = term()
64
megaco_version() = integer() >= 1
68
<marker id="start"></marker>
51
<name>start() -> {ok, Port} | {error, Reason}</name>
74
<name>start() -> {ok, PortOrPorts} | {error, Reason}</name>
52
75
<fsummary></fsummary>
77
<v>PortOrPorts = megaco_ports()</v>
55
78
<v>Reason = term()</v>
58
81
<p>This function is used to start the flex scanner.
59
82
It locates the library and loads the linked in driver.</p>
84
<p>On a single core system or if it's a non-reentrant scanner,
85
a single port is created. On a multi-core system with a reentrant
86
scanner, several ports will be created (one for each scheduler). </p>
60
88
<p>Note that the process that calls this function <em>must</em>
61
be permament. If it dies, the port will exit and the driver unload.</p>
89
be permament. If it dies, the port(s) will exit and the driver unload.</p>
91
<marker id="stop"></marker>
96
<name>stop(PortOrPorts) -> stopped</name>
99
<v>PortOrPorts = megaco_ports()</v>
102
<p>This function is used to stop the flex scanner. It also
103
unloads the driver.</p>
105
<marker id="is_reentrant_enabled"></marker>
110
<name>is_reentrant_enabled() -> Boolean</name>
111
<fsummary></fsummary>
113
<v>Boolean = boolean()</v>
116
<p>Is the flex scanner reentrant or not.</p>
118
<marker id="is_scanner_port"></marker>
123
<name>is_scanner_port(Port, PortOrPorts) -> Boolean</name>
124
<fsummary></fsummary>
127
<v>PortOrPorts = megaco_ports()</v>
128
<v>Boolean = boolean()</v>
131
<p>Checks if a port is a flex scanner port or not (usefull when
132
if a port exits). </p>
134
<marker id="scan"></marker>
139
<name>scan(Binary, PortOrPorts) -> {ok, Tokens, Version, LatestLine} | {error, Reason, LatestLine} </name>
140
<fsummary></fsummary>
142
<v>Binary = binary()</v>
143
<v>PortOrPorts = megaco_ports()</v>
144
<v>Tokens = list()</v>
145
<v>Version = megaco_version()</v>
146
<v>LatestLine = integer()</v>
147
<v>Reason = term()</v>
150
<p>Scans a megaco message and generates a token list to be passed on the parser. </p>