<HTML>
<HEAD>
<!-- refpage -->
<TITLE>bw_list</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFCC">
<CENTER>
<IMG BORDER=0 SRC="min_head.gif">
<H1>bw_list</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
bw_list</UL>
<H3>MODULE SUMMARY</H3>
<UL>
Provides a Black/White list checker for dialled numbers</UL>
<H3>DESCRIPTION</H3>
<UL>
<P><CODE>bw_list</CODE> provides functions to create lists of phone numbers which should be barred or allowed
and to check whether a dialled number matches. Numbers are checked on a digit by digit basis until either a
match is made, a match is definitely not made, or no more digits are left. Each new list which is created is
implemented using a single Mnesia table which may be replicated on a number of Erlang Nodes.
<P> Within each new table multiple lists of numbers may be built indexed by two further groupings called Ref and Name.
Functions are provided to create new tables, add lists within a table, add entries to lists within the table,
retrieve all lists contained in a table, retrieve all the phone numbers associated with a Ref/Name within a table,
as well as looking up and deleting entries.
</UL>
<H3>EXPORTS</H3>
<P><STRONG><CODE>new(Type [, node()]) -> {atomic, ok} | {aborted, Reason}</CODE></STRONG><BR>
<UL>
<P>This function creates a new table called Type where type must be an atom. e.g. Type could be black, to contain all black lists for an application.
If a list of node names are specified, the table is replicated on all those nodes, otherwise the table is created
on the local node only.
</UL>
<P><STRONG><CODE>add_list(Type, Ref, Name) -> ok | {error, Reason} </CODE></STRONG><BR>
<UL>
<P>This function adds a new list to the table Type which will be referenced by Ref and Name. This must be done before
any numbers can be added to the table for this Ref/Name.
</UL>
<P><STRONG><CODE>all_lists(Type, Ref) -> [{Name, Ref}] | {error, Reason} </CODE></STRONG><BR>
<UL>
<P>This function retrieves an erlang list of {Name, Ref} for all Lists in table Type with reference Ref.
</UL>
<P><STRONG><CODE>check(Type, Ref, Name, Numberlist) -> Result | no_match </CODE></STRONG><BR>
<UL>
<P>This function looks up a telephone number in the form <code>[0,1,8,1,2,1,4,2,4,1,3]</code> digit by digit.
If for example <code>[0,1,8,1]</code> is an entry in the referenced List, this function will return the
value stored against <code>[0,1,8,1]</code>. If no match is found returns <code>no_match</code>.
</UL>
<P><STRONG><CODE>delete(Type, Ref, Name, Numberlist) -> ok | {error, Reason} </CODE></STRONG><BR>
<UL>
<P>This function attempts to delete the entry referenced. If Numberlist is a prefix of a number already
in the table this command is rejected with Reason trying_to_delete_sublist.
</UL>
<P><STRONG><CODE>delete_list(Type, Ref, Name) -> ok | {error, Reason} </CODE></STRONG><BR>
<UL>
<P>This function attempts to delete all entries and then the existence of the List in table Type referenced
by Ref, Name. The table would need to be re-created using add_list/3 in order to be used again.
</UL>
<P><STRONG><CODE>insert(Type, Ref, Name, Numberlist, Value) -> ok | {error, Reason} </CODE></STRONG><BR>
<UL>
<P>This function attempts to insert the number Numberlist (given as list e.g [0,1,8,1]) into table Type, List Ref, Name.
The List Ref/Name must have been created using add_list/3 beforehand.
Future matches against this number by the check function will return the result Value.
</UL>
<P><STRONG><CODE>print_all(Type, Ref, Name) -> Result | exit() </CODE></STRONG><BR>
<UL>
<P>This function returns an erlang list of all the Numberlists in the bw_list referenced as printable ascii strings
e.g. <code>["0181","0171"]</code>.
</UL>
<P><STRONG><CODE>debug_print(Type, Ref, Name) -> Result | exit() </CODE></STRONG><BR>
<UL>
<P>This function returns an erlang list of all the Numberlists in the bw_list. The difference from the print_all/3 function is that this function prints all of the intermediate entries in the search tree and the results from the analysis. Entries are also returned as integer lists rather than strings.
</UL>
<P><STRONG><CODE>mnesia_table([nodes()]) -> {atomic, ok} | {aborted, Reason} </CODE></STRONG><BR>
<UL>
<P>This function is a one off requirement to set up the list management mnesia table. If a list of node
names is given as argument the table is replicated on the given nodes, otherwise mnesia_table/0 creates
the table on the local node.
</UL>
<H3>AUTHORS</H3>
<UL>
Sean Hinde<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>shlib 0.0.1
<BR>
</FONT>
</CENTER>
</BODY>
</HTML>