summaryrefslogtreecommitdiff
path: root/src/ejabberd.erl
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2017-10-31 11:04:32 +0100
committerChristophe Romain <christophe.romain@process-one.net>2017-10-31 11:04:32 +0100
commit675cc3e0ea5d3fe24952845859389896396d61a3 (patch)
tree7e0550c2413b4dfd860a855c29949996330f559c /src/ejabberd.erl
parentShow real jid in mucsub subscription change events (diff)
Allow auth and pubsub plugin to use Elixir module
Diffstat (limited to 'src/ejabberd.erl')
-rw-r--r--src/ejabberd.erl19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/ejabberd.erl b/src/ejabberd.erl
index 4edab98f..1d2d7790 100644
--- a/src/ejabberd.erl
+++ b/src/ejabberd.erl
@@ -37,7 +37,7 @@
-protocol({xep, 270, '1.0'}).
-export([start/0, stop/0, start_app/1, start_app/2,
- get_pid_file/0, check_app/1]).
+ get_pid_file/0, check_app/1, module_name/1]).
-include("logger.hrl").
@@ -148,3 +148,20 @@ get_module_file(App, Mod) ->
Dir ->
filename:join([Dir, BaseName ++ ".beam"])
end.
+
+module_name([Dir, _, <<H,T/binary>> | _] = Mod) when H >= 65, H =< 90 ->
+ Module = str:join([elixir_name(M) || M<-tl(Mod)], <<>>),
+ Prefix = case elixir_name(Dir) of
+ <<"Ejabberd">> -> <<"Elixir.Ejabberd.">>;
+ Lib -> <<"Elixir.Ejabberd.", Lib/binary, ".">>
+ end,
+ misc:binary_to_atom(<<Prefix/binary, Module/binary>>);
+module_name([<<"ejabberd">> | _] = Mod) ->
+ misc:binary_to_atom(str:join(Mod,$_));
+module_name(Mod) when is_list(Mod) ->
+ misc:binary_to_atom(str:join(tl(Mod),$_)).
+
+elixir_name(<<H,T/binary>>) when H >= 65, H =< 90 ->
+ <<H, T/binary>>;
+elixir_name(<<H,T/binary>>) ->
+ <<(H-32), T/binary>>.