Module pibfi_xlat

Description

Character translation server for pibfi.

This is not efficient. An efficient implementation would compile the candidates into a finite-state machine first. This doesn't do that.

Function Index

Exported Functions
flush/1Causes the xlat server to flush all its characters to the output, even ones in the process of matching candidate strings.
notify/2Notifies the other end of the connection.
send/2Sends a character or characters to an xlat server for translation.
server/2Spawned by start/2, should not be called directly by user code.
start/2Starts an xlat server.
test/0

Exported Functions

flush/1

flush(xlat()) -> ok

Causes the xlat server to flush all its characters to the output, even ones in the process of matching candidate strings. Typically this is called before the output is closed.

notify/2

notify(xlat(), term()) -> ok

Notifies the other end of the connection. They will receive a {Xlat::pid(), Notifier::pid(), message, term()} message.

send/2

send(xlat(), char() | string()) -> ok

Sends a character or characters to an xlat server for translation.

server/2

server(candidates(), Dest::pid()) -> never_returns()

Spawned by start/2, should not be called directly by user code.

start/2

start(candidates(), Dest::pid()) -> xlat()

Starts an xlat server. Candidates is a list of pairs of strings. Characters are sent to the xlat server with the send/2 function. When they match the left string of a candidate, the right string is sent to Dest instead. If they do not match any candidates, they are sent through unaltered. Characters are sent to Dest in the form {xlat(), xlat_char, char()}. Note that if two candidates have the same left string, the result of the translation is undefined. Also note that if one candidate has a left string that is a prefix of another candidate's left string, that second candidate will never match (the shorter one will always be matched first.)

test/0

test() -> term()