summaryrefslogtreecommitdiff
path: root/src/stringprep/stringprep.erl
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2003-09-26 18:55:01 +0000
committerAlexey Shchepin <alexey@process-one.net>2003-09-26 18:55:01 +0000
commit8888e2528ca55a9c1c7461f850c6cad2e9c66f22 (patch)
tree0d9482dfab365b3831521b2fe054a68cce0b0347 /src/stringprep/stringprep.erl
parent* src/mod_muc/mod_muc_room.erl: Debug output switched off (diff)
* src/stringprep/: Support for stringprep (not completed yet)
* src/mod_muc/mod_muc.erl: Replaced io:format calls to ?DEBUG ones SVN Revision: 141
Diffstat (limited to 'src/stringprep/stringprep.erl')
-rw-r--r--src/stringprep/stringprep.erl74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/stringprep/stringprep.erl b/src/stringprep/stringprep.erl
new file mode 100644
index 00000000..919ae7a4
--- /dev/null
+++ b/src/stringprep/stringprep.erl
@@ -0,0 +1,74 @@
+%%%----------------------------------------------------------------------
+%%% File : stringprep.erl
+%%% Author : Alexey Shchepin <alexey@sevcom.net>
+%%% Purpose : Interface to stringprep_drv
+%%% Created : 16 Feb 2003 by Alexey Shchepin <alexey@sevcom.net>
+%%% Id : $Id$
+%%%----------------------------------------------------------------------
+
+-module(stringprep).
+-author('alexey@sevcom.net').
+-vsn('$Revision$ ').
+
+-behaviour(gen_server).
+
+-export([start/0, start_link/0, tolower/1]).
+
+%% Internal exports, call-back functions.
+-export([init/1,
+ handle_call/3,
+ handle_cast/2,
+ handle_info/2,
+ code_change/3,
+ terminate/2]).
+
+
+
+start() ->
+ gen_server:start({local, ?MODULE}, ?MODULE, [], []).
+
+start_link() ->
+ gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+init([]) ->
+ ok = erl_ddll:load_driver(".", stringprep_drv),
+ Port = open_port({spawn, stringprep_drv}, []),
+ ets:new(stringprep_table, [set, public, named_table]),
+ ets:insert(stringprep_table, {port, Port}),
+ {ok, Port}.
+
+
+%%% --------------------------------------------------------
+%%% The call-back functions.
+%%% --------------------------------------------------------
+
+handle_call(_, _, State) ->
+ {noreply, State}.
+
+handle_cast(_, State) ->
+ {noreply, State}.
+
+handle_info({'EXIT', Pid, Reason}, Port) ->
+ {noreply, Port};
+
+handle_info({'EXIT', Port, Reason}, Port) ->
+ {stop, {port_died, Reason}, Port};
+handle_info(_, State) ->
+ {noreply, State}.
+
+code_change(OldVsn, State, Extra) ->
+ {ok, State}.
+
+terminate(_Reason, Port) ->
+ Port ! {self, close},
+ ok.
+
+
+
+tolower(String) ->
+ [{port, Port} | _] = ets:lookup(stringprep_table, port),
+ Res = port_control(Port, 1, String),
+ binary_to_list(Res).
+
+
+